@@ -88,6 +88,44 @@ V8Runtime::V8Runtime(
8888 const V8Runtime *v8Runtime,
8989 std::unique_ptr<V8RuntimeConfig> config)
9090 : config_(std::move(config)) {
91+ arrayBufferAllocator_.reset (
92+ v8::ArrayBuffer::Allocator::NewDefaultAllocator ());
93+ v8::Isolate::CreateParams createParams;
94+ createParams.array_buffer_allocator = arrayBufferAllocator_.get ();
95+ if (v8Runtime->config_ ->snapshotBlob ) {
96+ snapshotBlob_ = std::make_unique<v8::StartupData>();
97+ snapshotBlob_->data = v8Runtime->config_ ->snapshotBlob ->c_str ();
98+ snapshotBlob_->raw_size =
99+ static_cast <int >(v8Runtime->config_ ->snapshotBlob ->size ());
100+ createParams.snapshot_blob = snapshotBlob_.get ();
101+ }
102+ config_->codecacheMode = V8RuntimeConfig::CodecacheMode::kNone ;
103+
104+ isolate_ = v8::Isolate::New (createParams);
105+ #if defined(__ANDROID__)
106+ if (!v8Runtime->config_ ->timezoneId .empty ()) {
107+ isolate_->DateTimeConfigurationChangeNotification (
108+ v8::Isolate::TimeZoneDetection::kCustom ,
109+ v8Runtime->config_ ->timezoneId .c_str ());
110+ }
111+ #endif
112+ v8::Locker locker (isolate_);
113+ v8::Isolate::Scope scopedIsolate (isolate_);
114+ v8::HandleScope scopedHandle (isolate_);
115+ context_.Reset (isolate_, CreateGlobalContext (isolate_));
116+ v8::Context::Scope scopedContext (context_.Get (isolate_));
117+ jsQueue_ = v8Runtime->jsQueue_ ;
118+
119+ if (config_->enableInspector ) {
120+ inspectorClient_ = std::make_shared<InspectorClient>(
121+ jsQueue_,
122+ context_.Get (isolate_),
123+ config_->appName ,
124+ config_->deviceName );
125+ inspectorClient_->ConnectToReactFrontend ();
126+ }
127+
128+ #if 0 // Experimental shared global context
91129 isSharedRuntime_ = true;
92130 isolate_ = v8Runtime->isolate_;
93131 jsQueue_ = v8Runtime->jsQueue_;
@@ -121,6 +159,7 @@ V8Runtime::V8Runtime(
121159 config_->deviceName);
122160 inspectorClient_->ConnectToReactFrontend();
123161 }
162+ #endif
124163}
125164
126165V8Runtime::~V8Runtime () {
@@ -414,11 +453,13 @@ jsi::Value V8Runtime::evaluatePreparedJavaScript(
414453 return evaluateJavaScript (sourceJs, sourceJs->sourceURL ());
415454}
416455
417- #if REACT_NATIVE_MINOR_VERSION >= 75 || (REACT_NATIVE_MINOR_VERSION >= 74 && REACT_NATIVE_PATCH_VERSION >= 3)
456+ #if REACT_NATIVE_MINOR_VERSION >= 75 || \
457+ (REACT_NATIVE_MINOR_VERSION >= 74 && REACT_NATIVE_PATCH_VERSION >= 3 )
418458void V8Runtime::queueMicrotask (const jsi::Function &callback) {
419459 // TODO: add this when we revisit new architecture support
420460}
421- #endif // REACT_NATIVE_MINOR_VERSION >= 75 || (REACT_NATIVE_MINOR_VERSION >= 74 && REACT_NATIVE_PATCH_VERSION >= 3
461+ #endif // REACT_NATIVE_MINOR_VERSION >= 75 || (REACT_NATIVE_MINOR_VERSION >= 74
462+ // && REACT_NATIVE_PATCH_VERSION >= 3
422463
423464bool V8Runtime::drainMicrotasks (int maxMicrotasksHint) {
424465 v8::Locker locker (isolate_);
@@ -1559,8 +1600,9 @@ bool V8Runtime::instanceOf(const jsi::Object &o, const jsi::Function &f) {
15591600}
15601601
15611602#if REACT_NATIVE_MINOR_VERSION >= 74
1562- void V8Runtime::setExternalMemoryPressure (const jsi::Object &obj, size_t amount) {
1563- }
1603+ void V8Runtime::setExternalMemoryPressure (
1604+ const jsi::Object &obj,
1605+ size_t amount) {}
15641606#endif
15651607
15661608//
0 commit comments