| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3cf65bd commit c81e114
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,6 +182,7 @@ const loaderId = 'internal/bootstrap/loaders'; | |||
| 182 | 182 | const { | |
| 183 | 183 | builtinIds, | |
| 184 | 184 | compileFunction, | |
| 185 | + setInternalLoaders, | ||
| 185 | 186 | } = internalBinding('builtins'); | |
| 186 | 187 | ||
| 187 | 188 | const getOwn = (target, property, receiver) => { | |
@@ -373,5 +374,5 @@ function requireWithFallbackInDeps(request) { | |||
| 373 | 374 | return requireBuiltin(request); | |
| 374 | 375 | } | |
| 375 | 376 | ||
| 376 | - // Pass the exports back to C++ land for C++ internals to use. | ||
| 377 | - return loaderExports; | ||
| 377 | + // Store the internal loaders in C++. | ||
| 378 | + setInternalLoaders(internalBinding, requireBuiltin); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -647,6 +647,16 @@ void BuiltinLoader::HasCachedBuiltins(const FunctionCallbackInfo<Value>& args) { | |||
| 647 | 647 | args.GetIsolate(), instance->code_cache_->has_code_cache)); | |
| 648 | 648 | } | |
| 649 | 649 | ||
| 650 | + void SetInternalLoaders(const FunctionCallbackInfo<Value>& args) { | ||
| 651 | + Realm* realm = Realm::GetCurrent(args); | ||
| 652 | + CHECK(args[0]->IsFunction()); | ||
| 653 | + CHECK(args[1]->IsFunction()); | ||
| 654 | + DCHECK(realm->internal_binding_loader().IsEmpty()); | ||
| 655 | + DCHECK(realm->builtin_module_require().IsEmpty()); | ||
| 656 | + realm->set_internal_binding_loader(args[0].As<Function>()); | ||
| 657 | + realm->set_builtin_module_require(args[1].As<Function>()); | ||
| 658 | + } | ||
| 659 | + | ||
| 650 | 660 | void BuiltinLoader::CopySourceAndCodeCacheReferenceFrom( | |
| 651 | 661 | const BuiltinLoader* other) { | |
| 652 | 662 | code_cache_ = other->code_cache_; | |
@@ -685,6 +695,7 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data, | |||
| 685 | 695 | SetMethod(isolate, proto, "getCacheUsage", BuiltinLoader::GetCacheUsage); | |
| 686 | 696 | SetMethod(isolate, proto, "compileFunction", BuiltinLoader::CompileFunction); | |
| 687 | 697 | SetMethod(isolate, proto, "hasCachedBuiltins", HasCachedBuiltins); | |
| 698 | + SetMethod(isolate, proto, "setInternalLoaders", SetInternalLoaders); | ||
| 688 | 699 | } | |
| 689 | 700 | ||
| 690 | 701 | void BuiltinLoader::CreatePerContextProperties(Local<Object> target, | |
@@ -703,6 +714,7 @@ void BuiltinLoader::RegisterExternalReferences( | |||
| 703 | 714 | registry->Register(GetCacheUsage); | |
| 704 | 715 | registry->Register(CompileFunction); | |
| 705 | 716 | registry->Register(HasCachedBuiltins); | |
| 717 | + registry->Register(SetInternalLoaders); | ||
| 706 | 718 | } | |
| 707 | 719 | ||
| 708 | 720 | } // namespace builtins | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,6 @@ namespace node { | |||
| 10 | 10 | ||
| 11 | 11 | using v8::Context; | |
| 12 | 12 | using v8::EscapableHandleScope; | |
| 13 | - using v8::Function; | ||
| 14 | 13 | using v8::HandleScope; | |
| 15 | 14 | using v8::Local; | |
| 16 | 15 | using v8::MaybeLocal; | |
@@ -174,42 +173,14 @@ MaybeLocal<Value> Realm::ExecuteBootstrapper(const char* id) { | |||
| 174 | 173 | return scope.EscapeMaybe(result); | |
| 175 | 174 | } | |
| 176 | 175 | ||
| 177 | - MaybeLocal<Value> Realm::BootstrapInternalLoaders() { | ||
| 178 | - EscapableHandleScope scope(isolate_); | ||
| 179 | - | ||
| 180 | - // Bootstrap internal loaders | ||
| 181 | - Local<Value> loader_exports; | ||
| 182 | - if (!ExecuteBootstrapper("internal/bootstrap/loaders") | ||
| 183 | - .ToLocal(&loader_exports)) { | ||
| 184 | - return MaybeLocal<Value>(); | ||
| 185 | - } | ||
| 186 | - CHECK(loader_exports->IsObject()); | ||
| 187 | - Local<Object> loader_exports_obj = loader_exports.As<Object>(); | ||
| 188 | - Local<Value> internal_binding_loader = | ||
| 189 | - loader_exports_obj->Get(context(), env_->internal_binding_string()) | ||
| 190 | - .ToLocalChecked(); | ||
| 191 | - CHECK(internal_binding_loader->IsFunction()); | ||
| 192 | - set_internal_binding_loader(internal_binding_loader.As<Function>()); | ||
| 193 | - Local<Value> require = | ||
| 194 | - loader_exports_obj->Get(context(), env_->require_string()) | ||
| 195 | - .ToLocalChecked(); | ||
| 196 | - CHECK(require->IsFunction()); | ||
| 197 | - set_builtin_module_require(require.As<Function>()); | ||
| 198 | - | ||
| 199 | - return scope.Escape(loader_exports); | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | 176 | MaybeLocal<Value> Realm::RunBootstrapping() { | |
| 203 | 177 | EscapableHandleScope scope(isolate_); | |
| 204 | 178 | ||
| 205 | 179 | CHECK(!has_run_bootstrapping_code()); | |
| 206 | 180 | ||
| 207 | - if (BootstrapInternalLoaders().IsEmpty()) { | ||
| 208 | - return MaybeLocal<Value>(); | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | 181 | Local<Value> result; | |
| 212 | - if (!BootstrapRealm().ToLocal(&result)) { | ||
| 182 | + if (!ExecuteBootstrapper("internal/bootstrap/loaders").ToLocal(&result) || | ||
| 183 | + !BootstrapRealm().ToLocal(&result)) { | ||
| 213 | 184 | return MaybeLocal<Value>(); | |
| 214 | 185 | } | |
| 215 | 186 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,6 @@ class Realm : public MemoryRetainer { | |||
| 129 | 129 | protected: | |
| 130 | 130 | ~Realm(); | |
| 131 | 131 | ||
| 132 | - v8::MaybeLocal<v8::Value> BootstrapInternalLoaders(); | ||
| 133 | 132 | virtual v8::MaybeLocal<v8::Value> BootstrapRealm() = 0; | |
| 134 | 133 | ||
| 135 | 134 | Environment* env_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments