From ddf7a78d58fde8267b41fc96caa86a48a069e807 Mon Sep 17 00:00:00 2001 From: Josh Gavant Date: Wed, 30 Mar 2016 15:52:57 -0700 Subject: [PATCH] node: fix comments and strings Clarify comments re invoking bootstrap_node.js. Fix filename to bootstrap_node.js per #5103. Fix tests `node.js` -> `bootstrap_node.js` Fix comment on why we check the loop again before exiting. `context-inl.h` -> `env-inl.h` --- src/env.h | 4 +-- src/node.cc | 30 +++++++++---------- test/debugger/test-debugger-client.js | 2 +- test/message/core_line_numbers.out | 4 +-- test/message/error_exit.out | 4 +-- test/message/eval_messages.out | 8 ++--- test/message/nexttick_throw.out | 4 +-- test/message/stdin_messages.out | 8 ++--- .../undefined_reference_in_new_context.out | 2 +- test/message/vm_display_runtime_error.out | 4 +-- test/message/vm_display_syntax_error.out | 8 ++--- .../message/vm_dont_display_runtime_error.out | 4 +-- test/message/vm_dont_display_syntax_error.out | 4 +-- 13 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/env.h b/src/env.h index 0590a8a434b104..52432657d2f0c9 100644 --- a/src/env.h +++ b/src/env.h @@ -13,12 +13,12 @@ #include // Caveat emptor: we're going slightly crazy with macros here but the end -// hopefully justifies the means. We have a lot of per-context properties +// hopefully justifies the means. We have a lot of per-isolate properties // and adding and maintaining their getters and setters by hand would be // a nightmare so let's make the preprocessor generate them for us. // // Make sure that any macros defined here are undefined again at the bottom -// of context-inl.h. The exceptions are NODE_CONTEXT_EMBEDDER_DATA_INDEX +// of env-inl.h. The exceptions are NODE_CONTEXT_EMBEDDER_DATA_INDEX // and NODE_ISOLATE_SLOT, they may have been defined externally. namespace node { diff --git a/src/node.cc b/src/node.cc index fa9c3626aa95f3..4ea02572d0a125 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3265,13 +3265,17 @@ void LoadEnvironment(Environment* env) { env->isolate()->SetFatalErrorHandler(node::OnFatalError); env->isolate()->AddMessageListener(OnMessage); - // Compile, execute the src/node.js file. (Which was included as static C - // string in node_natives.h. 'native_node' is the string containing that - // source code.) - - // The node.js file returns a function 'f' atexit(AtExit); + // Compile ./lib/internal/bootstrap_node.js as `Local f`. + // We call `f` at the end of this block with the 'process' variable + // built up with all our bindings. Inside the script we take care of + // assigning things to their places. + + // We start the process this way in order to be more modular. Developers + // who do not like how bootrap_node.js sets up the module system but do like + // Node's I/O bindings may want to replace 'f' with their own function. + TryCatch try_catch(env->isolate()); // Disable verbose mode to stop FatalException() handler from trying @@ -3279,7 +3283,9 @@ void LoadEnvironment(Environment* env) { // are not safe to ignore. try_catch.SetVerbose(false); - Local script_name = FIXED_ONE_BYTE_STRING(env->isolate(), "node.js"); + Local script_name = FIXED_ONE_BYTE_STRING(env->isolate(), + "bootstrap_node.js"); + Local f_value = ExecuteString(env, MainSource(env), script_name); if (try_catch.HasCaught()) { ReportException(env, try_catch); @@ -3288,14 +3294,6 @@ void LoadEnvironment(Environment* env) { CHECK(f_value->IsFunction()); Local f = Local::Cast(f_value); - // Now we call 'f' with the 'process' variable that we've built up with - // all our bindings. Inside node.js we'll take care of assigning things to - // their places. - - // We start the process this way in order to be more modular. Developers - // who do not like how 'src/node.js' setups the module system but do like - // Node's I/O bindings may want to replace 'f' with their own function. - // Add a reference to the global object Local global = env->context()->Global(); @@ -4301,8 +4299,8 @@ static void StartNodeInstance(void* arg) { v8::platform::PumpMessageLoop(default_platform, isolate); EmitBeforeExit(env); - // Emit `beforeExit` if the loop became alive either after emitting - // event, or after running some callbacks. + // Check if the loop became alive either after emitting + // `beforeExit` event, or after running some callbacks. more = uv_loop_alive(env->event_loop()); if (uv_run(env->event_loop(), UV_RUN_NOWAIT) != 0) more = true; diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index fe65405c8583ce..f5d42ad497f3d7 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -105,7 +105,7 @@ addTest(function(client, done) { var foundMainScript = false; for (var k in client.scripts) { var script = client.scripts[k]; - if (script && script.name === 'node.js') { + if (script && script.name === 'bootstrap_node.js') { foundMainScript = true; break; } diff --git a/test/message/core_line_numbers.out b/test/message/core_line_numbers.out index c4909774a0e6ec..1fb6c32c6509b7 100644 --- a/test/message/core_line_numbers.out +++ b/test/message/core_line_numbers.out @@ -11,5 +11,5 @@ RangeError: Invalid input at Module.load (module.js:*:*) at Function.Module._load (module.js:*:*) at Function.Module.runMain (module.js:*:*) - at startup (node.js:*:*) - at node.js:*:* + at startup (bootstrap_node.js:*:*) + at bootstrap_node.js:*:* diff --git a/test/message/error_exit.out b/test/message/error_exit.out index 71690ba3d0dfb4..0e8735d0714811 100644 --- a/test/message/error_exit.out +++ b/test/message/error_exit.out @@ -10,5 +10,5 @@ AssertionError: 1 == 2 at Module.load (module.js:*:*) at Function.Module._load (module.js:*:*) at Function.Module.runMain (module.js:*:*) - at startup (node.js:*:*) - at node.js:*:* + at startup (bootstrap_node.js:*:*) + at bootstrap_node.js:*:* diff --git a/test/message/eval_messages.out b/test/message/eval_messages.out index 62f330725606b2..f1b9273342dbc2 100644 --- a/test/message/eval_messages.out +++ b/test/message/eval_messages.out @@ -6,7 +6,7 @@ SyntaxError: Strict mode code may not include a with statement at Object.exports.runInThisContext (vm.js:*) at Object. ([eval]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) 42 @@ -19,7 +19,7 @@ Error: hello at Object.exports.runInThisContext (vm.js:*) at Object. ([eval]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) [eval]:1 @@ -30,7 +30,7 @@ Error: hello at Object.exports.runInThisContext (vm.js:*) at Object. ([eval]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) 100 @@ -42,7 +42,7 @@ ReferenceError: y is not defined at Object.exports.runInThisContext (vm.js:*) at Object. ([eval]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) [eval]:1 diff --git a/test/message/nexttick_throw.out b/test/message/nexttick_throw.out index 6504bd315da900..1b72ea2d3cfb69 100644 --- a/test/message/nexttick_throw.out +++ b/test/message/nexttick_throw.out @@ -7,5 +7,5 @@ ReferenceError: undefined_reference_error_maker is not defined at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) at Function.Module.runMain (module.js:*:*) - at startup (node.js:*:*) - at node.js:*:* + at startup (bootstrap_node.js:*:*) + at bootstrap_node.js:*:* diff --git a/test/message/stdin_messages.out b/test/message/stdin_messages.out index a7c45a1fbb33fb..1d860918df2fcd 100644 --- a/test/message/stdin_messages.out +++ b/test/message/stdin_messages.out @@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement at Object.exports.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) 42 @@ -21,7 +21,7 @@ Error: hello at Object.exports.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) @@ -33,7 +33,7 @@ Error: hello at Object.exports.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) 100 @@ -46,7 +46,7 @@ ReferenceError: y is not defined at Object.exports.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) at Module._compile (module.js:*:*) - at node.js:*:* + at bootstrap_node.js:*:* at _combinedTickCallback (internal/process/next_tick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out index 3364c9bd34c08f..b453d420eeb201 100644 --- a/test/message/undefined_reference_in_new_context.out +++ b/test/message/undefined_reference_in_new_context.out @@ -13,4 +13,4 @@ ReferenceError: foo is not defined at Module.load (module.js:*) at Function.Module._load (module.js:*:*) at Function.Module.runMain (module.js:*:*) - at startup (node.js:*:*) + at startup (bootstrap_node.js:*:*) diff --git a/test/message/vm_display_runtime_error.out b/test/message/vm_display_runtime_error.out index f9d8354703bc67..146076bd0fdfc1 100644 --- a/test/message/vm_display_runtime_error.out +++ b/test/message/vm_display_runtime_error.out @@ -12,5 +12,5 @@ Error: boo! at Module.load (module.js:*) at Function.Module._load (module.js:*) at Function.Module.runMain (module.js:*) - at startup (node.js:*) - at node.js:* + at startup (bootstrap_node.js:*) + at bootstrap_node.js:* diff --git a/test/message/vm_display_syntax_error.out b/test/message/vm_display_syntax_error.out index 14df3a8284a64f..1bfa5c9c34db33 100644 --- a/test/message/vm_display_syntax_error.out +++ b/test/message/vm_display_syntax_error.out @@ -11,8 +11,8 @@ SyntaxError: Unexpected number at Module.load (module.js:*) at Function.Module._load (module.js:*) at Function.Module.runMain (module.js:*) - at startup (node.js:*) - at node.js:* + at startup (bootstrap_node.js:*) + at bootstrap_node.js:* test.vm:1 var 5; ^ @@ -24,5 +24,5 @@ SyntaxError: Unexpected number at Module.load (module.js:*) at Function.Module._load (module.js:*) at Function.Module.runMain (module.js:*) - at startup (node.js:*) - at node.js:* + at startup (bootstrap_node.js:*) + at bootstrap_node.js:* diff --git a/test/message/vm_dont_display_runtime_error.out b/test/message/vm_dont_display_runtime_error.out index ae8cf71142afae..0b94fa1045d00c 100644 --- a/test/message/vm_dont_display_runtime_error.out +++ b/test/message/vm_dont_display_runtime_error.out @@ -12,5 +12,5 @@ Error: boo! at Module.load (module.js:*) at Function.Module._load (module.js:*) at Function.Module.runMain (module.js:*) - at startup (node.js:*) - at node.js:* + at startup (bootstrap_node.js:*) + at bootstrap_node.js:* diff --git a/test/message/vm_dont_display_syntax_error.out b/test/message/vm_dont_display_syntax_error.out index f2e4a9495231e0..5c622ba551cba9 100644 --- a/test/message/vm_dont_display_syntax_error.out +++ b/test/message/vm_dont_display_syntax_error.out @@ -11,5 +11,5 @@ SyntaxError: Unexpected number at Module.load (module.js:*) at Function.Module._load (module.js:*) at Function.Module.runMain (module.js:*) - at startup (node.js:*) - at node.js:* + at startup (bootstrap_node.js:*) + at bootstrap_node.js:*