@@ -88,6 +88,44 @@ V8Runtime::V8Runtime(
88
88
const V8Runtime *v8Runtime,
89
89
std::unique_ptr<V8RuntimeConfig> config)
90
90
: 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
91
129
isSharedRuntime_ = true;
92
130
isolate_ = v8Runtime->isolate_;
93
131
jsQueue_ = v8Runtime->jsQueue_;
@@ -121,6 +159,7 @@ V8Runtime::V8Runtime(
121
159
config_->deviceName);
122
160
inspectorClient_->ConnectToReactFrontend();
123
161
}
162
+ #endif
124
163
}
125
164
126
165
V8Runtime::~V8Runtime () {
@@ -414,11 +453,13 @@ jsi::Value V8Runtime::evaluatePreparedJavaScript(
414
453
return evaluateJavaScript (sourceJs, sourceJs->sourceURL ());
415
454
}
416
455
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 )
418
458
void V8Runtime::queueMicrotask (const jsi::Function &callback) {
419
459
// TODO: add this when we revisit new architecture support
420
460
}
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
422
463
423
464
bool V8Runtime::drainMicrotasks (int maxMicrotasksHint) {
424
465
v8::Locker locker (isolate_);
@@ -1559,8 +1600,9 @@ bool V8Runtime::instanceOf(const jsi::Object &o, const jsi::Function &f) {
1559
1600
}
1560
1601
1561
1602
#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) {}
1564
1606
#endif
1565
1607
1566
1608
//
0 commit comments