|
22 | 22 | #include "DisposerPHV.h" |
23 | 23 | #include "IsolateWrapper.h" |
24 | 24 |
|
| 25 | +#include <mutex> |
25 | 26 | #include <unordered_map> |
| 27 | +#include "DevFlags.h" |
| 28 | +#include "HMRSupport.h" |
26 | 29 | #include "ModuleBinding.hpp" |
27 | 30 | #include "ModuleInternalCallbacks.h" |
28 | 31 | #include "URLImpl.h" |
29 | 32 | #include "URLPatternImpl.h" |
30 | 33 | #include "URLSearchParamsImpl.h" |
31 | | -#include <mutex> |
32 | | -#include "HMRSupport.h" |
33 | | -#include "DevFlags.h" |
34 | 34 |
|
35 | 35 | #define STRINGIZE(x) #x |
36 | 36 | #define STRINGIZE_VALUE_OF(x) STRINGIZE(x) |
@@ -128,7 +128,7 @@ static void InitializeImportMetaObject(Local<Context> context, Local<Module> mod |
128 | 128 | std::atomic<int> Runtime::nextIsolateId{0}; |
129 | 129 | SimpleAllocator allocator_; |
130 | 130 | NSDictionary* AppPackageJson = nil; |
131 | | -static std::unordered_map<std::string, id> AppConfigCache; // generic cache for app config values |
| 131 | +static std::unordered_map<std::string, id> AppConfigCache; // generic cache for app config values |
132 | 132 | static std::mutex AppConfigCacheMutex; |
133 | 133 |
|
134 | 134 | // Global flag to track when JavaScript errors occur during execution |
@@ -301,8 +301,8 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { |
301 | 301 | DefineDrainMicrotaskMethod(isolate, globalTemplate); |
302 | 302 | // queueMicrotask(callback) per spec |
303 | 303 | { |
304 | | - Local<FunctionTemplate> qmtTemplate = FunctionTemplate::New( |
305 | | - isolate, [](const FunctionCallbackInfo<Value>& info) { |
| 304 | + Local<FunctionTemplate> qmtTemplate = |
| 305 | + FunctionTemplate::New(isolate, [](const FunctionCallbackInfo<Value>& info) { |
306 | 306 | auto* isolate = info.GetIsolate(); |
307 | 307 | if (info.Length() < 1 || !info[0]->IsFunction()) { |
308 | 308 | isolate->ThrowException(Exception::TypeError( |
@@ -434,6 +434,11 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { |
434 | 434 | v8::Locker locker(isolate); |
435 | 435 | Isolate::Scope isolate_scope(isolate); |
436 | 436 | HandleScope handle_scope(isolate); |
| 437 | + |
| 438 | + auto cache = Caches::Get(isolate); |
| 439 | + auto context = cache->GetContext(); |
| 440 | + Context::Scope context_scope(context); |
| 441 | + |
437 | 442 | this->moduleInternal_->RunModule(isolate, "./"); |
438 | 443 | } |
439 | 444 |
|
@@ -488,7 +493,8 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { |
488 | 493 | result = AppPackageJson[nsKey]; |
489 | 494 | } |
490 | 495 |
|
491 | | - // Store in cache (can cache nil as NSNull to differentiate presence if desired; for now, cache as-is) |
| 496 | + // Store in cache (can cache nil as NSNull to differentiate presence if desired; for now, cache |
| 497 | + // as-is) |
492 | 498 | { |
493 | 499 | std::lock_guard<std::mutex> lock(AppConfigCacheMutex); |
494 | 500 | AppConfigCache[key] = result; |
|
0 commit comments