Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: Update strings node.js -> bootstrap_node.js #5962

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include <stdint.h>

// 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 {

Expand Down
30 changes: 14 additions & 16 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3265,21 +3265,27 @@ 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<Function> 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
// to handle the exception. Errors this early in the start-up phase
// are not safe to ignore.
try_catch.SetVerbose(false);

Local<String> script_name = FIXED_ONE_BYTE_STRING(env->isolate(), "node.js");
Local<String> script_name = FIXED_ONE_BYTE_STRING(env->isolate(),
"bootstrap_node.js");

Local<Value> f_value = ExecuteString(env, MainSource(env), script_name);
if (try_catch.HasCaught()) {
ReportException(env, try_catch);
Expand All @@ -3288,14 +3294,6 @@ void LoadEnvironment(Environment* env) {
CHECK(f_value->IsFunction());
Local<Function> f = Local<Function>::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<Object> global = env->context()->Global();

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know nothing about the debugger or it's tests but seems fine if it works

foundMainScript = true;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions test/message/core_line_numbers.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious that the message tests pass without this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing it was ExecuteString() setting the script name to node.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ExecuteString calls v8::Script::Compile which allows us to specify the ScriptOrigin, which comes from the FIXED_ONE_BYTE_STRING I changed. grep ExecuteString ./src/* -r says it isn't called anywhere else, perhaps ExecuteString should be merged into LoadEnvironment?

4 changes: 2 additions & 2 deletions test/message/error_exit.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*
8 changes: 4 additions & 4 deletions test/message/eval_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SyntaxError: Strict mode code may not include a with statement
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand All @@ -19,7 +19,7 @@ Error: hello
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand All @@ -30,7 +30,7 @@ Error: hello
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand All @@ -42,7 +42,7 @@ ReferenceError: y is not defined
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand Down
4 changes: 2 additions & 2 deletions test/message/nexttick_throw.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*
8 changes: 4 additions & 4 deletions test/message/stdin_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand All @@ -21,7 +21,7 @@ Error: hello
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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:*:*)

Expand All @@ -33,7 +33,7 @@ Error: hello
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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
Expand All @@ -46,7 +46,7 @@ ReferenceError: y is not defined
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([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:*:*)

Expand Down
2 changes: 1 addition & 1 deletion test/message/undefined_reference_in_new_context.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*)
4 changes: 2 additions & 2 deletions test/message/vm_display_runtime_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*
8 changes: 4 additions & 4 deletions test/message/vm_display_syntax_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -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;
^
Expand All @@ -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:*
4 changes: 2 additions & 2 deletions test/message/vm_dont_display_runtime_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*
4 changes: 2 additions & 2 deletions test/message/vm_dont_display_syntax_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*