Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-29 00:42:06 +0300
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2019-04-10 17:30:30 +0300
commitcdb0d8418c6ee97ac37c275610bd66abd2ab3d0d (patch)
treed0ccbfef0e8f1869826365b2eacedda4ab788454
parent4c7a2f187c40a5f4c5493395f054a781d5ab436d (diff)
module: inline try catch
Moving `try / catch` into separate functions is not necessary anymore due to V8 optimizations. PR-URL: https://github.com/nodejs/node/pull/26970 Refs: https://github.com/nodejs/node/pull/25362 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
-rw-r--r--lib/internal/modules/cjs/loader.js12
-rw-r--r--test/message/assert_throws_stack.out1
-rw-r--r--test/message/console.out1
-rw-r--r--test/message/core_line_numbers.out1
-rw-r--r--test/message/error_exit.out1
-rw-r--r--test/message/events_unhandled_error_common_trace.out1
-rw-r--r--test/message/events_unhandled_error_nexttick.out1
-rw-r--r--test/message/events_unhandled_error_sameline.out1
-rw-r--r--test/message/if-error-has-good-stack.out2
-rw-r--r--test/message/undefined_reference_in_new_context.out2
-rw-r--r--test/message/unhandled_promise_trace_warnings.out2
-rw-r--r--test/message/util_inspect_error.out5
-rw-r--r--test/message/vm_display_runtime_error.out4
-rw-r--r--test/message/vm_display_syntax_error.out4
-rw-r--r--test/message/vm_dont_display_runtime_error.out2
-rw-r--r--test/message/vm_dont_display_syntax_error.out2
16 files changed, 12 insertions, 30 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index dbe07f05127..5ea3f55c52f 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -595,13 +595,7 @@ Module._load = function(request, parent, isMain) {
Module._cache[filename] = module;
- tryModuleLoad(module, filename);
-
- return module.exports;
-};
-
-function tryModuleLoad(module, filename) {
- var threw = true;
+ let threw = true;
try {
module.load(filename);
threw = false;
@@ -610,7 +604,9 @@ function tryModuleLoad(module, filename) {
delete Module._cache[filename];
}
}
-}
+
+ return module.exports;
+};
Module._resolveFilename = function(request, parent, isMain, options) {
if (NativeModule.canBeRequiredByUsers(request)) {
diff --git a/test/message/assert_throws_stack.out b/test/message/assert_throws_stack.out
index 0457670d6a3..7d4a7aecbcd 100644
--- a/test/message/assert_throws_stack.out
+++ b/test/message/assert_throws_stack.out
@@ -16,4 +16,3 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
at *
at *
at *
- at *
diff --git a/test/message/console.out b/test/message/console.out
index 0ede283a54a..d55e59fa306 100644
--- a/test/message/console.out
+++ b/test/message/console.out
@@ -7,4 +7,3 @@ Trace: foo
at *
at *
at *
- at *
diff --git a/test/message/core_line_numbers.out b/test/message/core_line_numbers.out
index 0336e5b4516..53d3894825b 100644
--- a/test/message/core_line_numbers.out
+++ b/test/message/core_line_numbers.out
@@ -9,7 +9,6 @@ RangeError: Invalid input
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
at internal/main/run_main_module.js:*:*
diff --git a/test/message/error_exit.out b/test/message/error_exit.out
index 3364210099c..b975d41a55d 100644
--- a/test/message/error_exit.out
+++ b/test/message/error_exit.out
@@ -11,7 +11,6 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
at internal/main/run_main_module.js:*:*
diff --git a/test/message/events_unhandled_error_common_trace.out b/test/message/events_unhandled_error_common_trace.out
index 0d64143c67f..610ea6064dd 100644
--- a/test/message/events_unhandled_error_common_trace.out
+++ b/test/message/events_unhandled_error_common_trace.out
@@ -9,7 +9,6 @@ Error: foo:bar
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
at internal/main/run_main_module.js:*:*
diff --git a/test/message/events_unhandled_error_nexttick.out b/test/message/events_unhandled_error_nexttick.out
index fba05879fcc..3e7fa5055dc 100644
--- a/test/message/events_unhandled_error_nexttick.out
+++ b/test/message/events_unhandled_error_nexttick.out
@@ -7,7 +7,6 @@ Error
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
at internal/main/run_main_module.js:*:*
diff --git a/test/message/events_unhandled_error_sameline.out b/test/message/events_unhandled_error_sameline.out
index f877b254aaf..798061a39ba 100644
--- a/test/message/events_unhandled_error_sameline.out
+++ b/test/message/events_unhandled_error_sameline.out
@@ -7,7 +7,6 @@ Error
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
at internal/main/run_main_module.js:*:*
diff --git a/test/message/if-error-has-good-stack.out b/test/message/if-error-has-good-stack.out
index 2a4dfe8fb26..c762d74aedb 100644
--- a/test/message/if-error-has-good-stack.out
+++ b/test/message/if-error-has-good-stack.out
@@ -14,6 +14,6 @@ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
+ at internal/main/run_main_module.js:*:*
diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out
index 6b5fedfa993..9cc5eced7ce 100644
--- a/test/message/undefined_reference_in_new_context.out
+++ b/test/message/undefined_reference_in_new_context.out
@@ -12,5 +12,5 @@ ReferenceError: foo is not defined
at Module._compile (internal/modules/cjs/loader.js:*)
at *..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
+ at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out
index 60c08805f5c..901de1bd65d 100644
--- a/test/message/unhandled_promise_trace_warnings.out
+++ b/test/message/unhandled_promise_trace_warnings.out
@@ -12,7 +12,6 @@
at *
at *
at *
- at *
(node:*) Error: This was rejected
at * (*test*message*unhandled_promise_trace_warnings.js:*)
at *
@@ -21,7 +20,6 @@
at *
at *
at *
- at *
(node:*) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at *
at *
diff --git a/test/message/util_inspect_error.out b/test/message/util_inspect_error.out
index 31b65eb2e2b..644ccd58831 100644
--- a/test/message/util_inspect_error.out
+++ b/test/message/util_inspect_error.out
@@ -8,7 +8,6 @@
at *
at *
at *
- at *
nested:
{ err:
Error: foo
@@ -20,7 +19,6 @@
at *
at *
at *
- at *
{
err: Error: foo
bar
@@ -31,7 +29,6 @@
at *
at *
at *
- at *
nested: {
err: Error: foo
bar
@@ -42,7 +39,6 @@
at *
at *
at *
- at *
}
}
{ Error: foo
@@ -54,5 +50,4 @@ bar
at *
at *
at *
- at *
foo: 'bar' }
diff --git a/test/message/vm_display_runtime_error.out b/test/message/vm_display_runtime_error.out
index bc95b2a7b09..7927510c415 100644
--- a/test/message/vm_display_runtime_error.out
+++ b/test/message/vm_display_runtime_error.out
@@ -11,9 +11,9 @@ Error: boo!
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*
test.vm:1
throw new Error("spooky!")
^
@@ -26,6 +26,6 @@ Error: spooky!
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*
diff --git a/test/message/vm_display_syntax_error.out b/test/message/vm_display_syntax_error.out
index f0692723e81..71d4a0ea131 100644
--- a/test/message/vm_display_syntax_error.out
+++ b/test/message/vm_display_syntax_error.out
@@ -10,9 +10,9 @@ SyntaxError: Unexpected number
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*
test.vm:1
var 5;
^
@@ -24,6 +24,6 @@ SyntaxError: Unexpected number
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*
diff --git a/test/message/vm_dont_display_runtime_error.out b/test/message/vm_dont_display_runtime_error.out
index 532cfbf4dd8..831ec8b6be4 100644
--- a/test/message/vm_dont_display_runtime_error.out
+++ b/test/message/vm_dont_display_runtime_error.out
@@ -12,6 +12,6 @@ Error: boo!
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*
diff --git a/test/message/vm_dont_display_syntax_error.out b/test/message/vm_dont_display_syntax_error.out
index f27cb1a0859..22924e7a6e7 100644
--- a/test/message/vm_dont_display_syntax_error.out
+++ b/test/message/vm_dont_display_syntax_error.out
@@ -12,6 +12,6 @@ SyntaxError: Unexpected number
at Module._compile (internal/modules/cjs/loader.js:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*)
at Module.load (internal/modules/cjs/loader.js:*)
- at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*)
+ at internal/main/run_main_module.js:*:*