Skip to content

Commit 3263264

Browse files
BridgeARBethGriggs
authored andcommitted
module: inline try catch
Moving `try / catch` into separate functions is not necessary anymore due to V8 optimizations. PR-URL: #26970 Refs: #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>
1 parent e9bffa8 commit 3263264

16 files changed

+12
-30
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,7 @@ Module._load = function(request, parent, isMain) {
595595

596596
Module._cache[filename] = module;
597597

598-
tryModuleLoad(module, filename);
599-
600-
return module.exports;
601-
};
602-
603-
function tryModuleLoad(module, filename) {
604-
var threw = true;
598+
let threw = true;
605599
try {
606600
module.load(filename);
607601
threw = false;
@@ -610,7 +604,9 @@ function tryModuleLoad(module, filename) {
610604
delete Module._cache[filename];
611605
}
612606
}
613-
}
607+
608+
return module.exports;
609+
};
614610

615611
Module._resolveFilename = function(request, parent, isMain, options) {
616612
if (NativeModule.canBeRequiredByUsers(request)) {

test/message/assert_throws_stack.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
1616
at *
1717
at *
1818
at *
19-
at *

test/message/console.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ Trace: foo
77
at *
88
at *
99
at *
10-
at *

test/message/core_line_numbers.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ RangeError: Invalid input
99
at Module._compile (internal/modules/cjs/loader.js:*:*)
1010
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
1111
at Module.load (internal/modules/cjs/loader.js:*:*)
12-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1312
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1413
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
1514
at internal/main/run_main_module.js:*:*

test/message/error_exit.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
1111
at Module._compile (internal/modules/cjs/loader.js:*:*)
1212
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
1313
at Module.load (internal/modules/cjs/loader.js:*:*)
14-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1514
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1615
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
1716
at internal/main/run_main_module.js:*:*

test/message/events_unhandled_error_common_trace.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Error: foo:bar
99
at Module._compile (internal/modules/cjs/loader.js:*:*)
1010
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
1111
at Module.load (internal/modules/cjs/loader.js:*:*)
12-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1312
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1413
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
1514
at internal/main/run_main_module.js:*:*

test/message/events_unhandled_error_nexttick.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Error
77
at Module._compile (internal/modules/cjs/loader.js:*:*)
88
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
99
at Module.load (internal/modules/cjs/loader.js:*:*)
10-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1110
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1211
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
1312
at internal/main/run_main_module.js:*:*

test/message/events_unhandled_error_sameline.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Error
77
at Module._compile (internal/modules/cjs/loader.js:*:*)
88
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
99
at Module.load (internal/modules/cjs/loader.js:*:*)
10-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1110
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1211
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
1312
at internal/main/run_main_module.js:*:*

test/message/if-error-has-good-stack.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
1414
at Module._compile (internal/modules/cjs/loader.js:*:*)
1515
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
1616
at Module.load (internal/modules/cjs/loader.js:*:*)
17-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1817
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1918
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
19+
at internal/main/run_main_module.js:*:*

test/message/undefined_reference_in_new_context.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ ReferenceError: foo is not defined
1212
at Module._compile (internal/modules/cjs/loader.js:*)
1313
at *..js (internal/modules/cjs/loader.js:*)
1414
at Module.load (internal/modules/cjs/loader.js:*)
15-
at tryModuleLoad (internal/modules/cjs/loader.js:*:*)
1615
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
16+
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)

0 commit comments

Comments
 (0)