Skip to content

Commit 383b0c0

Browse files
committed
src, test: fixup after v8 update
Because of behavior change of some V8 APIs (they mostly became more strict), following modules needed to be fixed: * crypto: duplicate prototype methods are not allowed anymore * contextify: some TryCatch trickery, the binding was using it incorrectly * util: maximum call stack error is now crashing in a different place Reviewed-By: Trevor Norris <trevnorris@gmail.com> PR-URL: nodejs/node-v0.x-archive#8476
1 parent 3821863 commit 383b0c0

9 files changed

Lines changed: 44 additions & 35 deletions

File tree

common.gypi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
}],
2727
['GENERATOR == "ninja" or OS== "mac"', {
2828
'OBJ_DIR': '<(PRODUCT_DIR)/obj',
29-
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.<(target_arch).a',
29+
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
3030
}, {
3131
'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
32-
'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.<(target_arch).a',
32+
'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.a',
3333
}],
3434
],
3535
},

src/node.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,7 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
26032603

26042604
#define READONLY_PROPERTY(obj, str, var) \
26052605
do { \
2606-
obj->Set(OneByteString(env->isolate(), str), var, v8::ReadOnly); \
2606+
obj->ForceSet(OneByteString(env->isolate(), str), var, v8::ReadOnly); \
26072607
} while (0)
26082608

26092609

@@ -3483,7 +3483,8 @@ void Init(int* argc,
34833483

34843484
// Fetch a reference to the main isolate, so we have a reference to it
34853485
// even when we need it to access it from another (debugger) thread.
3486-
node_isolate = Isolate::GetCurrent();
3486+
node_isolate = Isolate::New();
3487+
Isolate::Scope isolate_scope(node_isolate);
34873488

34883489
#ifdef __POSIX__
34893490
// Raise the open file descriptor limit.

src/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ NODE_EXTERN void RunAtExit(Environment* env);
219219
v8::Number::New(isolate, static_cast<double>(constant)); \
220220
v8::PropertyAttribute constant_attributes = \
221221
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
222-
(target)->Set(constant_name, constant_value, constant_attributes); \
222+
(target)->ForceSet(constant_name, constant_value, constant_attributes); \
223223
} \
224224
while (0)
225225

src/node_buffer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,9 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
624624
NODE_SET_METHOD(proto, "copy", Copy);
625625

626626
// for backwards compatibility
627-
proto->Set(env->offset_string(),
628-
Uint32::New(env->isolate(), 0),
629-
v8::ReadOnly);
627+
proto->ForceSet(env->offset_string(),
628+
Uint32::New(env->isolate(), 0),
629+
v8::ReadOnly);
630630

631631
assert(args[1]->IsObject());
632632

src/node_contextify.cc

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,24 @@ class ContextifyScript : public BaseObject {
537537
Environment* env = Environment::GetCurrent(args.GetIsolate());
538538
HandleScope scope(env->isolate());
539539

540+
int64_t timeout;
541+
bool display_errors;
542+
540543
// Assemble arguments
541-
TryCatch try_catch;
542544
if (!args[0]->IsObject()) {
543545
return env->ThrowTypeError(
544546
"contextifiedSandbox argument must be an object.");
545547
}
548+
546549
Local<Object> sandbox = args[0].As<Object>();
547-
int64_t timeout = GetTimeoutArg(args, 1);
548-
bool display_errors = GetDisplayErrorsArg(args, 1);
549-
if (try_catch.HasCaught()) {
550-
try_catch.ReThrow();
551-
return;
550+
{
551+
TryCatch try_catch;
552+
timeout = GetTimeoutArg(args, 1);
553+
display_errors = GetDisplayErrorsArg(args, 1);
554+
if (try_catch.HasCaught()) {
555+
try_catch.ReThrow();
556+
return;
557+
}
552558
}
553559

554560
// Get the context from the sandbox
@@ -563,14 +569,22 @@ class ContextifyScript : public BaseObject {
563569
if (contextify_context->context().IsEmpty())
564570
return;
565571

566-
// Do the eval within the context
567-
Context::Scope context_scope(contextify_context->context());
568-
if (EvalMachine(contextify_context->env(),
569-
timeout,
570-
display_errors,
571-
args,
572-
try_catch)) {
573-
contextify_context->CopyProperties();
572+
{
573+
TryCatch try_catch;
574+
// Do the eval within the context
575+
Context::Scope context_scope(contextify_context->context());
576+
if (EvalMachine(contextify_context->env(),
577+
timeout,
578+
display_errors,
579+
args,
580+
try_catch)) {
581+
contextify_context->CopyProperties();
582+
}
583+
584+
if (try_catch.HasCaught()) {
585+
try_catch.ReThrow();
586+
return;
587+
}
574588
}
575589
}
576590

src/node_crypto.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,12 @@ void SSLWrap<Base>::AddMethods(Environment* env, Handle<FunctionTemplate> t) {
10221022

10231023
#ifdef OPENSSL_NPN_NEGOTIATED
10241024
NODE_SET_PROTOTYPE_METHOD(t, "getNegotiatedProtocol", GetNegotiatedProto);
1025-
NODE_SET_PROTOTYPE_METHOD(t, "setNPNProtocols", SetNPNProtocols);
10261025
#endif // OPENSSL_NPN_NEGOTIATED
10271026

1027+
#ifdef OPENSSL_NPN_NEGOTIATED
1028+
NODE_SET_PROTOTYPE_METHOD(t, "setNPNProtocols", SetNPNProtocols);
1029+
#endif
1030+
10281031
NODE_SET_EXTERNAL(
10291032
t->PrototypeTemplate(),
10301033
"_external",
@@ -2057,15 +2060,6 @@ void Connection::Initialize(Environment* env, Handle<Object> target) {
20572060

20582061
SSLWrap<Connection>::AddMethods(env, t);
20592062

2060-
#ifdef OPENSSL_NPN_NEGOTIATED
2061-
NODE_SET_PROTOTYPE_METHOD(t,
2062-
"getNegotiatedProtocol",
2063-
Connection::GetNegotiatedProto);
2064-
NODE_SET_PROTOTYPE_METHOD(t,
2065-
"setNPNProtocols",
2066-
Connection::SetNPNProtocols);
2067-
#endif
2068-
20692063

20702064
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
20712065
NODE_SET_PROTOTYPE_METHOD(t, "getServername", Connection::GetServername);

src/util.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Utf8Value::Utf8Value(v8::Handle<v8::Value> value)
3131
return;
3232

3333
v8::Local<v8::String> val_ = value->ToString();
34+
if (val_.IsEmpty())
35+
return;
3436

3537
// Allocate enough space to include the null terminator
3638
size_t len = StringBytes::StorageSize(val_, UTF8) + 1;

test/simple/test-abort-fatal-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (process.platform === 'win32') {
3030
var exec = require('child_process').exec;
3131

3232
var cmdline = 'ulimit -c 0; ' + process.execPath;
33-
cmdline += ' --max-old-space-size=4 --max-new-space-size=1';
33+
cmdline += ' --max-old-space-size=4 --max-semi-space-size=1';
3434
cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"';
3535

3636
exec(cmdline, function(err, stdout, stderr) {

test/simple/test-vm-harmony-symbols.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
// Flags: --harmony_symbols
23-
2422
var common = require('../common');
2523
var assert = require('assert');
2624
var vm = require('vm');

0 commit comments

Comments
 (0)