| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 92311a0 commit 3551a19
14 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -489,7 +489,7 @@ MaybeLocal<Value> LoadEnvironment( | |||
| 489 | 489 | return LoadEnvironment( | |
| 490 | 490 | env, [&](const StartExecutionCallbackInfo& info) -> MaybeLocal<Value> { | |
| 491 | 491 | std::string name = "embedder_main_" + std::to_string(env->thread_id()); | |
| 492 | - builtins::BuiltinLoader::Add(name.c_str(), main_script_source_utf8); | ||
| 492 | + env->builtin_loader()->Add(name.c_str(), main_script_source_utf8); | ||
| 493 | 493 | Realm* realm = env->principal_realm(); | |
| 494 | 494 | ||
| 495 | 495 | return realm->ExecuteBootstrapper(name.c_str()); | |
@@ -729,10 +729,17 @@ Maybe<bool> InitializePrimordials(Local<Context> context) { | |||
| 729 | 729 | "internal/per_context/messageport", | |
| 730 | 730 | nullptr}; | |
| 731 | 731 | ||
| 732 | + // We do not have access to a per-Environment BuiltinLoader instance | ||
| 733 | + // at this point, because this code runs before an Environment exists | ||
| 734 | + // in the first place. However, creating BuiltinLoader instances is | ||
| 735 | + // relatively cheap and all the scripts that we may want to run at | ||
| 736 | + // startup are always present in it. | ||
| 737 | + thread_local builtins::BuiltinLoader builtin_loader; | ||
| 732 | 738 | for (const char** module = context_files; *module != nullptr; module++) { | |
| 733 | 739 | Local<Value> arguments[] = {exports, primordials}; | |
| 734 | - if (builtins::BuiltinLoader::CompileAndCall( | ||
| 735 | - context, *module, arraysize(arguments), arguments, nullptr) | ||
| 740 | + if (builtin_loader | ||
| 741 | + .CompileAndCall( | ||
| 742 | + context, *module, arraysize(arguments), arguments, nullptr) | ||
| 736 | 743 | .IsEmpty()) { | |
| 737 | 744 | // Execution failed during context creation. | |
| 738 | 745 | return Nothing<bool>(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -388,6 +388,10 @@ inline std::vector<double>* Environment::destroy_async_id_list() { | |||
| 388 | 388 | return &destroy_async_id_list_; | |
| 389 | 389 | } | |
| 390 | 390 | ||
| 391 | + inline builtins::BuiltinLoader* Environment::builtin_loader() { | ||
| 392 | + return &builtin_loader_; | ||
| 393 | + } | ||
| 394 | + | ||
| 391 | 395 | inline double Environment::new_async_id() { | |
| 392 | 396 | async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1; | |
| 393 | 397 | return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -676,6 +676,15 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 676 | 676 | thread_id_(thread_id.id == static_cast<uint64_t>(-1) | |
| 677 | 677 | ? AllocateEnvironmentThreadId().id | |
| 678 | 678 | : thread_id.id) { | |
| 679 | + #ifdef NODE_V8_SHARED_RO_HEAP | ||
| 680 | + if (!is_main_thread()) { | ||
| 681 | + CHECK_NOT_NULL(isolate_data->worker_context()); | ||
| 682 | + // TODO(addaleax): Adjust for the embedder API snapshot support changes | ||
| 683 | + builtin_loader()->CopySourceAndCodeCacheReferenceFrom( | ||
| 684 | + isolate_data->worker_context()->env()->builtin_loader()); | ||
| 685 | + } | ||
| 686 | + #endif | ||
| 687 | + | ||
| 679 | 688 | // We'll be creating new objects so make sure we've entered the context. | |
| 680 | 689 | HandleScope handle_scope(isolate); | |
| 681 | 690 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -695,6 +695,8 @@ class Environment : public MemoryRetainer { | |||
| 695 | 695 | // List of id's that have been destroyed and need the destroy() cb called. | |
| 696 | 696 | inline std::vector<double>* destroy_async_id_list(); | |
| 697 | 697 | ||
| 698 | + builtins::BuiltinLoader* builtin_loader(); | ||
| 699 | + | ||
| 698 | 700 | std::unordered_multimap<int, loader::ModuleWrap*> hash_to_module_map; | |
| 699 | 701 | std::unordered_map<uint32_t, loader::ModuleWrap*> id_to_module_map; | |
| 700 | 702 | std::unordered_map<uint32_t, contextify::ContextifyScript*> | |
@@ -1099,6 +1101,8 @@ class Environment : public MemoryRetainer { | |||
| 1099 | 1101 | ||
| 1100 | 1102 | std::unique_ptr<Realm> principal_realm_ = nullptr; | |
| 1101 | 1103 | ||
| 1104 | + builtins::BuiltinLoader builtin_loader_; | ||
| 1105 | + | ||
| 1102 | 1106 | // Used by allocate_managed_buffer() and release_managed_buffer() to keep | |
| 1103 | 1107 | // track of the BackingStore for a given pointer. | |
| 1104 | 1108 | std::unordered_map<char*, std::unique_ptr<v8::BackingStore>> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,8 +132,6 @@ | |||
| 132 | 132 | ||
| 133 | 133 | namespace node { | |
| 134 | 134 | ||
| 135 | - using builtins::BuiltinLoader; | ||
| 136 | - | ||
| 137 | 135 | using v8::EscapableHandleScope; | |
| 138 | 136 | using v8::Isolate; | |
| 139 | 137 | using v8::Local; | |
@@ -1214,9 +1212,6 @@ int LoadSnapshotDataAndRun(const SnapshotData** snapshot_data_ptr, | |||
| 1214 | 1212 | } | |
| 1215 | 1213 | } | |
| 1216 | 1214 | ||
| 1217 | - if ((*snapshot_data_ptr) != nullptr) { | ||
| 1218 | - BuiltinLoader::RefreshCodeCache((*snapshot_data_ptr)->code_cache); | ||
| 1219 | - } | ||
| 1220 | 1215 | NodeMainInstance main_instance(*snapshot_data_ptr, | |
| 1221 | 1216 | uv_default_loop(), | |
| 1222 | 1217 | per_process::v8_platform.Platform(), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -650,13 +650,13 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) { | |||
| 650 | 650 | CHECK(exports->SetPrototype(context, Null(isolate)).FromJust()); | |
| 651 | 651 | DefineConstants(isolate, exports); | |
| 652 | 652 | } else if (!strcmp(*module_v, "natives")) { | |
| 653 | - exports = builtins::BuiltinLoader::GetSourceObject(context); | ||
| 653 | + exports = realm->env()->builtin_loader()->GetSourceObject(context); | ||
| 654 | 654 | // Legacy feature: process.binding('natives').config contains stringified | |
| 655 | 655 | // config.gypi | |
| 656 | 656 | CHECK(exports | |
| 657 | 657 | ->Set(context, | |
| 658 | 658 | realm->isolate_data()->config_string(), | |
| 659 | - builtins::BuiltinLoader::GetConfigString(isolate)) | ||
| 659 | + realm->env()->builtin_loader()->GetConfigString(isolate)) | ||
| 660 | 660 | .FromJust()); | |
| 661 | 661 | } else { | |
| 662 | 662 | return THROW_ERR_INVALID_MODULE(isolate, "No such binding: %s", *module_v); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments