Skip to content

Commit ea60d2c

Browse files
committed
process: move moduleLoadList definition & usage to JS
1 parent b5fb9c1 commit ea60d2c

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

lib/internal/bootstrap_node.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,25 @@
243243
perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE);
244244
}
245245

246+
const moduleLoadList = [];
247+
Object.defineProperty(process, 'moduleLoadList', {
248+
value: moduleLoadList,
249+
configurable: true,
250+
enumerable: true,
251+
writable: false
252+
});
253+
246254
{
247255
const bindingObj = Object.create(null);
248256

249257
const getBinding = process.binding;
250258
process.binding = function binding(module) {
251259
module = String(module);
252260
let mod = bindingObj[module];
253-
if (typeof mod !== 'object')
261+
if (typeof mod !== 'object') {
254262
mod = bindingObj[module] = getBinding(module);
263+
moduleLoadList.push(`Binding ${module}`);
264+
}
255265
return mod;
256266
};
257267

@@ -273,8 +283,10 @@
273283

274284
internalBinding = function internalBinding(module) {
275285
let mod = bindingObj[module];
276-
if (typeof mod !== 'object')
286+
if (typeof mod !== 'object') {
277287
mod = bindingObj[module] = getInternalBinding(module);
288+
moduleLoadList.push(`Internal Binding ${module}`);
289+
}
278290
return mod;
279291
};
280292
}
@@ -583,7 +595,7 @@
583595
throw err;
584596
}
585597

586-
process.moduleLoadList.push(`NativeModule ${id}`);
598+
moduleLoadList.push(`NativeModule ${id}`);
587599

588600
const nativeModule = new NativeModule(id);
589601

src/env-inl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ inline Environment::Environment(IsolateData* isolate_data,
329329
v8::Context::Scope context_scope(context);
330330
set_as_external(v8::External::New(isolate(), this));
331331

332-
set_module_load_list_array(v8::Array::New(isolate()));
333-
334332
AssignToContext(context, ContextInfo(""));
335333

336334
destroy_async_id_list_.reserve(512);

src/env.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ class ModuleWrap;
285285
V(http2settings_constructor_template, v8::ObjectTemplate) \
286286
V(immediate_callback_function, v8::Function) \
287287
V(inspector_console_api_object, v8::Object) \
288-
V(module_load_list_array, v8::Array) \
289288
V(pbkdf2_constructor_template, v8::ObjectTemplate) \
290289
V(pipe_constructor_template, v8::FunctionTemplate) \
291290
V(performance_entry_callback, v8::Function) \

src/node.cc

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,15 +2556,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
25562556
CHECK(args[0]->IsString());
25572557

25582558
Local<String> module = args[0].As<String>();
2559-
2560-
// Append a string to process.moduleLoadList
2561-
char buf[1024];
25622559
node::Utf8Value module_v(env->isolate(), module);
2563-
snprintf(buf, sizeof(buf), "Binding %s", *module_v);
2564-
2565-
Local<Array> modules = env->module_load_list_array();
2566-
uint32_t l = modules->Length();
2567-
modules->Set(l, OneByteString(env->isolate(), buf));
25682560

25692561
node_module* mod = get_builtin_module(*module_v);
25702562
Local<Object> exports;
@@ -2591,15 +2583,7 @@ static void InternalBinding(const FunctionCallbackInfo<Value>& args) {
25912583
CHECK(args[0]->IsString());
25922584

25932585
Local<String> module = args[0].As<String>();
2594-
2595-
// Append a string to process.moduleLoadList
2596-
char buf[1024];
25972586
node::Utf8Value module_v(env->isolate(), module);
2598-
snprintf(buf, sizeof(buf), "Internal Binding %s", *module_v);
2599-
2600-
Local<Array> modules = env->module_load_list_array();
2601-
uint32_t l = modules->Length();
2602-
modules->Set(l, OneByteString(env->isolate(), buf));
26032587

26042588
node_module* mod = get_internal_module(*module_v);
26052589
if (mod == nullptr) return ThrowIfNoSuchModule(env, *module_v);
@@ -2971,11 +2955,6 @@ void SetupProcessObject(Environment* env,
29712955
"version",
29722956
FIXED_ONE_BYTE_STRING(env->isolate(), NODE_VERSION));
29732957

2974-
// process.moduleLoadList
2975-
READONLY_PROPERTY(process,
2976-
"moduleLoadList",
2977-
env->module_load_list_array());
2978-
29792958
// process.versions
29802959
Local<Object> versions = Object::New(env->isolate());
29812960
READONLY_PROPERTY(process, "versions", versions);

0 commit comments

Comments
 (0)