libv8-node 19.9.0.0-arm64-darwin → 20.2.0.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +4 -2
- data/vendor/v8/include/cppgc/heap-consistency.h +2 -2
- data/vendor/v8/include/cppgc/heap-handle.h +5 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +35 -33
- data/vendor/v8/include/cppgc/internal/member-storage.h +19 -7
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +38 -2
- data/vendor/v8/include/cppgc/internal/write-barrier.h +15 -5
- data/vendor/v8/include/cppgc/macros.h +10 -1
- data/vendor/v8/include/cppgc/member.h +167 -129
- data/vendor/v8/include/cppgc/persistent.h +22 -15
- data/vendor/v8/include/cppgc/platform.h +6 -4
- data/vendor/v8/include/cppgc/type-traits.h +4 -3
- data/vendor/v8/include/cppgc/visitor.h +16 -1
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
- data/vendor/v8/include/v8-array-buffer.h +59 -0
- data/vendor/v8/include/v8-callbacks.h +14 -1
- data/vendor/v8/include/v8-context.h +50 -3
- data/vendor/v8/include/v8-cppgc.h +10 -0
- data/vendor/v8/include/v8-data.h +1 -1
- data/vendor/v8/include/v8-embedder-heap.h +0 -169
- data/vendor/v8/include/v8-fast-api-calls.h +7 -3
- data/vendor/v8/include/v8-function-callback.h +69 -42
- data/vendor/v8/include/v8-function.h +1 -0
- data/vendor/v8/include/v8-inspector.h +20 -5
- data/vendor/v8/include/v8-internal.h +242 -150
- data/vendor/v8/include/v8-isolate.h +30 -40
- data/vendor/v8/include/v8-local-handle.h +81 -48
- data/vendor/v8/include/v8-metrics.h +28 -2
- data/vendor/v8/include/v8-microtask-queue.h +5 -0
- data/vendor/v8/include/v8-object.h +21 -3
- data/vendor/v8/include/v8-persistent-handle.h +25 -16
- data/vendor/v8/include/v8-platform.h +79 -10
- data/vendor/v8/include/v8-primitive.h +19 -12
- data/vendor/v8/include/v8-profiler.h +49 -31
- data/vendor/v8/include/v8-script.h +29 -1
- data/vendor/v8/include/v8-snapshot.h +4 -8
- data/vendor/v8/include/v8-template.h +3 -1
- data/vendor/v8/include/v8-traced-handle.h +22 -28
- data/vendor/v8/include/v8-util.h +9 -3
- data/vendor/v8/include/v8-value.h +31 -4
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +2 -1
- data/vendor/v8/include/v8config.h +73 -2
- metadata +1 -1
@@ -233,7 +233,7 @@ class V8_EXPORT Isolate {
|
|
233
233
|
* Explicitly specify a startup snapshot blob. The embedder owns the blob.
|
234
234
|
* The embedder *must* ensure that the snapshot is from a trusted source.
|
235
235
|
*/
|
236
|
-
StartupData* snapshot_blob = nullptr;
|
236
|
+
const StartupData* snapshot_blob = nullptr;
|
237
237
|
|
238
238
|
/**
|
239
239
|
* Enables the host application to provide a mechanism for recording
|
@@ -333,12 +333,9 @@ class V8_EXPORT Isolate {
|
|
333
333
|
const DisallowJavascriptExecutionScope&) = delete;
|
334
334
|
|
335
335
|
private:
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
bool was_execution_allowed_assert_;
|
340
|
-
bool was_execution_allowed_throws_;
|
341
|
-
bool was_execution_allowed_dump_;
|
336
|
+
v8::Isolate* const v8_isolate_;
|
337
|
+
const OnFailure on_failure_;
|
338
|
+
bool was_execution_allowed_;
|
342
339
|
};
|
343
340
|
|
344
341
|
/**
|
@@ -356,7 +353,7 @@ class V8_EXPORT Isolate {
|
|
356
353
|
const AllowJavascriptExecutionScope&) = delete;
|
357
354
|
|
358
355
|
private:
|
359
|
-
Isolate* v8_isolate_;
|
356
|
+
Isolate* const v8_isolate_;
|
360
357
|
bool was_execution_allowed_assert_;
|
361
358
|
bool was_execution_allowed_throws_;
|
362
359
|
bool was_execution_allowed_dump_;
|
@@ -537,6 +534,8 @@ class V8_EXPORT Isolate {
|
|
537
534
|
kTurboFanOsrCompileStarted = 115,
|
538
535
|
kAsyncStackTaggingCreateTaskCall = 116,
|
539
536
|
kDurationFormat = 117,
|
537
|
+
kInvalidatedNumberStringPrototypeNoReplaceProtector = 118,
|
538
|
+
kRegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119, // Unused.
|
540
539
|
|
541
540
|
// If you add new values here, you'll also need to update Chromium's:
|
542
541
|
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
|
@@ -924,27 +923,10 @@ class V8_EXPORT Isolate {
|
|
924
923
|
void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
|
925
924
|
void RemoveGCPrologueCallback(GCCallback callback);
|
926
925
|
|
927
|
-
START_ALLOW_USE_DEPRECATED()
|
928
|
-
/**
|
929
|
-
* Sets the embedder heap tracer for the isolate.
|
930
|
-
* SetEmbedderHeapTracer cannot be used simultaneously with AttachCppHeap.
|
931
|
-
*/
|
932
|
-
void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
|
933
|
-
|
934
|
-
/*
|
935
|
-
* Gets the currently active heap tracer for the isolate that was set with
|
936
|
-
* SetEmbedderHeapTracer.
|
937
|
-
*/
|
938
|
-
EmbedderHeapTracer* GetEmbedderHeapTracer();
|
939
|
-
END_ALLOW_USE_DEPRECATED()
|
940
|
-
|
941
926
|
/**
|
942
927
|
* Sets an embedder roots handle that V8 should consider when performing
|
943
|
-
* non-unified heap garbage collections.
|
944
|
-
*
|
945
|
-
* Using only EmbedderHeapTracer automatically sets up a default handler.
|
946
|
-
* The intended use case is for setting a custom handler after invoking
|
947
|
-
* `AttachCppHeap()`.
|
928
|
+
* non-unified heap garbage collections. The intended use case is for setting
|
929
|
+
* a custom handler after invoking `AttachCppHeap()`.
|
948
930
|
*
|
949
931
|
* V8 does not take ownership of the handler.
|
950
932
|
*/
|
@@ -954,22 +936,18 @@ class V8_EXPORT Isolate {
|
|
954
936
|
* Attaches a managed C++ heap as an extension to the JavaScript heap. The
|
955
937
|
* embedder maintains ownership of the CppHeap. At most one C++ heap can be
|
956
938
|
* attached to V8.
|
957
|
-
* AttachCppHeap cannot be used simultaneously with SetEmbedderHeapTracer.
|
958
939
|
*
|
959
|
-
*
|
940
|
+
* Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see
|
941
|
+
* CppHeap.
|
960
942
|
*/
|
961
943
|
void AttachCppHeap(CppHeap*);
|
962
944
|
|
963
945
|
/**
|
964
946
|
* Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
|
965
|
-
*
|
966
|
-
* This is an experimental feature and may still change significantly.
|
967
947
|
*/
|
968
948
|
void DetachCppHeap();
|
969
949
|
|
970
950
|
/**
|
971
|
-
* This is an experimental feature and may still change significantly.
|
972
|
-
|
973
951
|
* \returns the C++ heap managed by V8. Only available if such a heap has been
|
974
952
|
* attached using `AttachCppHeap()`.
|
975
953
|
*/
|
@@ -1145,9 +1123,8 @@ class V8_EXPORT Isolate {
|
|
1145
1123
|
*
|
1146
1124
|
* This should only be used for testing purposes and not to enforce a garbage
|
1147
1125
|
* collection schedule. It has strong negative impact on the garbage
|
1148
|
-
* collection performance. Use
|
1149
|
-
*
|
1150
|
-
* schedule.
|
1126
|
+
* collection performance. Use MemoryPressureNotification() instead to
|
1127
|
+
* influence the garbage collection schedule.
|
1151
1128
|
*/
|
1152
1129
|
void RequestGarbageCollectionForTesting(GarbageCollectionType type);
|
1153
1130
|
|
@@ -1158,9 +1135,8 @@ class V8_EXPORT Isolate {
|
|
1158
1135
|
*
|
1159
1136
|
* This should only be used for testing purposes and not to enforce a garbage
|
1160
1137
|
* collection schedule. It has strong negative impact on the garbage
|
1161
|
-
* collection performance. Use
|
1162
|
-
*
|
1163
|
-
* schedule.
|
1138
|
+
* collection performance. Use MemoryPressureNotification() instead to
|
1139
|
+
* influence the garbage collection schedule.
|
1164
1140
|
*/
|
1165
1141
|
void RequestGarbageCollectionForTesting(GarbageCollectionType type,
|
1166
1142
|
StackState stack_state);
|
@@ -1312,6 +1288,8 @@ class V8_EXPORT Isolate {
|
|
1312
1288
|
* that function. There is no guarantee that the actual work will be done
|
1313
1289
|
* within the time limit.
|
1314
1290
|
*/
|
1291
|
+
V8_DEPRECATE_SOON(
|
1292
|
+
"Use MemoryPressureNotification() to influence the GC schedule.")
|
1315
1293
|
bool IdleNotificationDeadline(double deadline_in_seconds);
|
1316
1294
|
|
1317
1295
|
/**
|
@@ -1348,11 +1326,13 @@ class V8_EXPORT Isolate {
|
|
1348
1326
|
* V8 uses this notification to guide heuristics which may result in a
|
1349
1327
|
* smaller memory footprint at the cost of reduced runtime performance.
|
1350
1328
|
*/
|
1329
|
+
V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
|
1351
1330
|
void EnableMemorySavingsMode();
|
1352
1331
|
|
1353
1332
|
/**
|
1354
1333
|
* Optional notification which will disable the memory savings mode.
|
1355
1334
|
*/
|
1335
|
+
V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
|
1356
1336
|
void DisableMemorySavingsMode();
|
1357
1337
|
|
1358
1338
|
/**
|
@@ -1526,10 +1506,19 @@ class V8_EXPORT Isolate {
|
|
1526
1506
|
|
1527
1507
|
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
|
1528
1508
|
|
1509
|
+
V8_DEPRECATED("Wasm SIMD is always enabled")
|
1529
1510
|
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
|
1530
1511
|
|
1512
|
+
V8_DEPRECATED("Wasm exceptions are always enabled")
|
1531
1513
|
void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
|
1532
1514
|
|
1515
|
+
/**
|
1516
|
+
* Register callback to control whehter Wasm GC is enabled.
|
1517
|
+
* The callback overwrites the value of the flag.
|
1518
|
+
* If the callback returns true, it will also enable Wasm stringrefs.
|
1519
|
+
*/
|
1520
|
+
void SetWasmGCEnabledCallback(WasmGCEnabledCallback callback);
|
1521
|
+
|
1533
1522
|
void SetSharedArrayBufferConstructorEnabledCallback(
|
1534
1523
|
SharedArrayBufferConstructorEnabledCallback callback);
|
1535
1524
|
|
@@ -1684,7 +1673,8 @@ uint32_t Isolate::GetNumberOfDataSlots() {
|
|
1684
1673
|
|
1685
1674
|
template <class T>
|
1686
1675
|
MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
|
1687
|
-
T* data =
|
1676
|
+
T* data =
|
1677
|
+
internal::ValueHelper::SlotAsValue<T>(GetDataFromSnapshotOnce(index));
|
1688
1678
|
if (data) internal::PerformCastCheck(data);
|
1689
1679
|
return Local<T>(data);
|
1690
1680
|
}
|
@@ -50,9 +50,14 @@ class TracedReference;
|
|
50
50
|
class TracedReferenceBase;
|
51
51
|
class Utils;
|
52
52
|
|
53
|
+
namespace debug {
|
54
|
+
class ConsoleCallArguments;
|
55
|
+
}
|
56
|
+
|
53
57
|
namespace internal {
|
54
58
|
template <typename T>
|
55
59
|
class CustomArguments;
|
60
|
+
class SamplingHeapProfiler;
|
56
61
|
} // namespace internal
|
57
62
|
|
58
63
|
namespace api_internal {
|
@@ -92,6 +97,9 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
92
97
|
HandleScope(const HandleScope&) = delete;
|
93
98
|
void operator=(const HandleScope&) = delete;
|
94
99
|
|
100
|
+
static internal::Address* CreateHandleForCurrentIsolate(
|
101
|
+
internal::Address value);
|
102
|
+
|
95
103
|
protected:
|
96
104
|
V8_INLINE HandleScope() = default;
|
97
105
|
|
@@ -122,6 +130,33 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
122
130
|
friend class Context;
|
123
131
|
};
|
124
132
|
|
133
|
+
namespace internal {
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Helper functions about handles.
|
137
|
+
*/
|
138
|
+
class HandleHelper final {
|
139
|
+
public:
|
140
|
+
/**
|
141
|
+
* Checks whether two handles are equal.
|
142
|
+
* They are equal iff they are both empty or they are both non-empty and the
|
143
|
+
* objects to which they refer are physically equal.
|
144
|
+
*
|
145
|
+
* If both handles refer to JS objects, this is the same as strict equality.
|
146
|
+
* For primitives, such as numbers or strings, a `false` return value does not
|
147
|
+
* indicate that the values aren't equal in the JavaScript sense.
|
148
|
+
* Use `Value::StrictEquals()` to check primitives for equality.
|
149
|
+
*/
|
150
|
+
template <typename T1, typename T2>
|
151
|
+
V8_INLINE static bool EqualHandles(const T1& lhs, const T2& rhs) {
|
152
|
+
if (lhs.IsEmpty()) return rhs.IsEmpty();
|
153
|
+
if (rhs.IsEmpty()) return false;
|
154
|
+
return lhs.address() == rhs.address();
|
155
|
+
}
|
156
|
+
};
|
157
|
+
|
158
|
+
} // namespace internal
|
159
|
+
|
125
160
|
/**
|
126
161
|
* An object reference managed by the v8 garbage collector.
|
127
162
|
*
|
@@ -154,7 +189,8 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
154
189
|
template <class T>
|
155
190
|
class Local {
|
156
191
|
public:
|
157
|
-
V8_INLINE Local() : val_(
|
192
|
+
V8_INLINE Local() : val_(internal::ValueHelper::EmptyValue<T>()) {}
|
193
|
+
|
158
194
|
template <class S>
|
159
195
|
V8_INLINE Local(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
|
160
196
|
/**
|
@@ -168,55 +204,40 @@ class Local {
|
|
168
204
|
/**
|
169
205
|
* Returns true if the handle is empty.
|
170
206
|
*/
|
171
|
-
V8_INLINE bool IsEmpty() const {
|
207
|
+
V8_INLINE bool IsEmpty() const {
|
208
|
+
return val_ == internal::ValueHelper::EmptyValue<T>();
|
209
|
+
}
|
172
210
|
|
173
211
|
/**
|
174
212
|
* Sets the handle to be empty. IsEmpty() will then return true.
|
175
213
|
*/
|
176
|
-
V8_INLINE void Clear() { val_ =
|
214
|
+
V8_INLINE void Clear() { val_ = internal::ValueHelper::EmptyValue<T>(); }
|
177
215
|
|
178
216
|
V8_INLINE T* operator->() const { return val_; }
|
179
217
|
|
180
218
|
V8_INLINE T* operator*() const { return val_; }
|
181
219
|
|
182
220
|
/**
|
183
|
-
* Checks whether two handles are
|
184
|
-
*
|
185
|
-
* are
|
221
|
+
* Checks whether two handles are equal or different.
|
222
|
+
* They are equal iff they are both empty or they are both non-empty and the
|
223
|
+
* objects to which they refer are physically equal.
|
186
224
|
*
|
187
|
-
* If both handles refer to JS objects, this is the same as strict
|
188
|
-
* For primitives, such as numbers or strings, a `
|
189
|
-
* indicate that the values aren't equal in the JavaScript
|
190
|
-
* Use `Value::StrictEquals()` to check primitives for equality.
|
225
|
+
* If both handles refer to JS objects, this is the same as strict
|
226
|
+
* non-equality. For primitives, such as numbers or strings, a `true` return
|
227
|
+
* value does not indicate that the values aren't equal in the JavaScript
|
228
|
+
* sense. Use `Value::StrictEquals()` to check primitives for equality.
|
191
229
|
*/
|
230
|
+
|
192
231
|
template <class S>
|
193
232
|
V8_INLINE bool operator==(const Local<S>& that) const {
|
194
|
-
|
195
|
-
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
196
|
-
if (a == nullptr) return b == nullptr;
|
197
|
-
if (b == nullptr) return false;
|
198
|
-
return *a == *b;
|
233
|
+
return internal::HandleHelper::EqualHandles(*this, that);
|
199
234
|
}
|
200
235
|
|
201
236
|
template <class S>
|
202
237
|
V8_INLINE bool operator==(const PersistentBase<S>& that) const {
|
203
|
-
|
204
|
-
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
205
|
-
if (a == nullptr) return b == nullptr;
|
206
|
-
if (b == nullptr) return false;
|
207
|
-
return *a == *b;
|
238
|
+
return internal::HandleHelper::EqualHandles(*this, that);
|
208
239
|
}
|
209
240
|
|
210
|
-
/**
|
211
|
-
* Checks whether two handles are different.
|
212
|
-
* Returns true if only one of the handles is empty, or if
|
213
|
-
* the objects to which they refer are different.
|
214
|
-
*
|
215
|
-
* If both handles refer to JS objects, this is the same as strict
|
216
|
-
* non-equality. For primitives, such as numbers or strings, a `true` return
|
217
|
-
* value does not indicate that the values aren't equal in the JavaScript
|
218
|
-
* sense. Use `Value::StrictEquals()` to check primitives for equality.
|
219
|
-
*/
|
220
241
|
template <class S>
|
221
242
|
V8_INLINE bool operator!=(const Local<S>& that) const {
|
222
243
|
return !operator==(that);
|
@@ -263,12 +284,12 @@ class Local {
|
|
263
284
|
|
264
285
|
V8_INLINE static Local<T> New(Isolate* isolate,
|
265
286
|
const PersistentBase<T>& that) {
|
266
|
-
return New(isolate, that.val_);
|
287
|
+
return New(isolate, internal::ValueHelper::SlotAsValue<T>(that.val_));
|
267
288
|
}
|
268
289
|
|
269
290
|
V8_INLINE static Local<T> New(Isolate* isolate,
|
270
291
|
const BasicTracedReference<T>& that) {
|
271
|
-
return New(isolate, *that);
|
292
|
+
return New(isolate, internal::ValueHelper::SlotAsValue<T>(*that));
|
272
293
|
}
|
273
294
|
|
274
295
|
private:
|
@@ -277,12 +298,6 @@ class Local {
|
|
277
298
|
template <class F>
|
278
299
|
friend class Eternal;
|
279
300
|
template <class F>
|
280
|
-
friend class PersistentBase;
|
281
|
-
template <class F, class M>
|
282
|
-
friend class Persistent;
|
283
|
-
template <class F>
|
284
|
-
friend class Local;
|
285
|
-
template <class F>
|
286
301
|
friend class MaybeLocal;
|
287
302
|
template <class F>
|
288
303
|
friend class FunctionCallbackInfo;
|
@@ -309,19 +324,31 @@ class Local {
|
|
309
324
|
friend class ReturnValue;
|
310
325
|
template <class F>
|
311
326
|
friend class Traced;
|
312
|
-
|
313
|
-
friend class
|
314
|
-
|
315
|
-
friend class TracedReference;
|
327
|
+
friend class internal::SamplingHeapProfiler;
|
328
|
+
friend class internal::HandleHelper;
|
329
|
+
friend class debug::ConsoleCallArguments;
|
316
330
|
|
317
331
|
explicit V8_INLINE Local(T* that) : val_(that) {}
|
332
|
+
|
333
|
+
V8_INLINE internal::Address address() const {
|
334
|
+
return internal::ValueHelper::ValueAsAddress(val_);
|
335
|
+
}
|
336
|
+
|
337
|
+
V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
|
338
|
+
return Local<T>(internal::ValueHelper::SlotAsValue<T>(slot));
|
339
|
+
}
|
340
|
+
|
318
341
|
V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
|
342
|
+
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
343
|
+
return Local<T>(that);
|
344
|
+
#else
|
319
345
|
if (that == nullptr) return Local<T>();
|
320
|
-
|
321
|
-
internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
|
346
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(that);
|
322
347
|
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
|
323
348
|
reinterpret_cast<internal::Isolate*>(isolate), *p)));
|
349
|
+
#endif
|
324
350
|
}
|
351
|
+
|
325
352
|
T* val_;
|
326
353
|
};
|
327
354
|
|
@@ -344,13 +371,15 @@ using Handle = Local<T>;
|
|
344
371
|
template <class T>
|
345
372
|
class MaybeLocal {
|
346
373
|
public:
|
347
|
-
V8_INLINE MaybeLocal() : val_(
|
374
|
+
V8_INLINE MaybeLocal() : val_(internal::ValueHelper::EmptyValue<T>()) {}
|
348
375
|
template <class S>
|
349
376
|
V8_INLINE MaybeLocal(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
|
350
377
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
351
378
|
}
|
352
379
|
|
353
|
-
V8_INLINE bool IsEmpty() const {
|
380
|
+
V8_INLINE bool IsEmpty() const {
|
381
|
+
return val_ == internal::ValueHelper::EmptyValue<T>();
|
382
|
+
}
|
354
383
|
|
355
384
|
/**
|
356
385
|
* Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
|
@@ -358,7 +387,7 @@ class MaybeLocal {
|
|
358
387
|
*/
|
359
388
|
template <class S>
|
360
389
|
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
|
361
|
-
out->val_ = IsEmpty() ?
|
390
|
+
out->val_ = IsEmpty() ? internal::ValueHelper::EmptyValue<T>() : this->val_;
|
362
391
|
return !IsEmpty();
|
363
392
|
}
|
364
393
|
|
@@ -367,7 +396,7 @@ class MaybeLocal {
|
|
367
396
|
* V8 will crash the process.
|
368
397
|
*/
|
369
398
|
V8_INLINE Local<T> ToLocalChecked() {
|
370
|
-
if (V8_UNLIKELY(
|
399
|
+
if (V8_UNLIKELY(IsEmpty())) api_internal::ToLocalEmpty();
|
371
400
|
return Local<T>(val_);
|
372
401
|
}
|
373
402
|
|
@@ -399,9 +428,13 @@ class V8_EXPORT V8_NODISCARD EscapableHandleScope : public HandleScope {
|
|
399
428
|
*/
|
400
429
|
template <class T>
|
401
430
|
V8_INLINE Local<T> Escape(Local<T> value) {
|
431
|
+
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
432
|
+
return value;
|
433
|
+
#else
|
402
434
|
internal::Address* slot =
|
403
435
|
Escape(reinterpret_cast<internal::Address*>(*value));
|
404
436
|
return Local<T>(reinterpret_cast<T*>(slot));
|
437
|
+
#endif
|
405
438
|
}
|
406
439
|
|
407
440
|
template <class T>
|
@@ -12,6 +12,7 @@
|
|
12
12
|
|
13
13
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
14
14
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
15
16
|
|
16
17
|
namespace v8 {
|
17
18
|
|
@@ -96,16 +97,42 @@ struct GarbageCollectionYoungCycle {
|
|
96
97
|
};
|
97
98
|
|
98
99
|
struct WasmModuleDecoded {
|
100
|
+
WasmModuleDecoded() = default;
|
101
|
+
WasmModuleDecoded(bool async, bool streamed, bool success,
|
102
|
+
size_t module_size_in_bytes, size_t function_count,
|
103
|
+
int64_t wall_clock_duration_in_us)
|
104
|
+
: async(async),
|
105
|
+
streamed(streamed),
|
106
|
+
success(success),
|
107
|
+
module_size_in_bytes(module_size_in_bytes),
|
108
|
+
function_count(function_count),
|
109
|
+
wall_clock_duration_in_us(wall_clock_duration_in_us) {}
|
110
|
+
|
99
111
|
bool async = false;
|
100
112
|
bool streamed = false;
|
101
113
|
bool success = false;
|
102
114
|
size_t module_size_in_bytes = 0;
|
103
115
|
size_t function_count = 0;
|
104
116
|
int64_t wall_clock_duration_in_us = -1;
|
105
|
-
int64_t cpu_duration_in_us = -1;
|
106
117
|
};
|
107
118
|
|
108
119
|
struct WasmModuleCompiled {
|
120
|
+
WasmModuleCompiled() = default;
|
121
|
+
|
122
|
+
WasmModuleCompiled(bool async, bool streamed, bool cached, bool deserialized,
|
123
|
+
bool lazy, bool success, size_t code_size_in_bytes,
|
124
|
+
size_t liftoff_bailout_count,
|
125
|
+
int64_t wall_clock_duration_in_us)
|
126
|
+
: async(async),
|
127
|
+
streamed(streamed),
|
128
|
+
cached(cached),
|
129
|
+
deserialized(deserialized),
|
130
|
+
lazy(lazy),
|
131
|
+
success(success),
|
132
|
+
code_size_in_bytes(code_size_in_bytes),
|
133
|
+
liftoff_bailout_count(liftoff_bailout_count),
|
134
|
+
wall_clock_duration_in_us(wall_clock_duration_in_us) {}
|
135
|
+
|
109
136
|
bool async = false;
|
110
137
|
bool streamed = false;
|
111
138
|
bool cached = false;
|
@@ -115,7 +142,6 @@ struct WasmModuleCompiled {
|
|
115
142
|
size_t code_size_in_bytes = 0;
|
116
143
|
size_t liftoff_bailout_count = 0;
|
117
144
|
int64_t wall_clock_duration_in_us = -1;
|
118
|
-
int64_t cpu_duration_in_us = -1;
|
119
145
|
};
|
120
146
|
|
121
147
|
struct WasmModuleInstantiated {
|
@@ -118,7 +118,12 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope {
|
|
118
118
|
public:
|
119
119
|
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
|
120
120
|
|
121
|
+
V8_DEPRECATE_SOON(
|
122
|
+
"May be incorrect if context was created with non-default microtask "
|
123
|
+
"queue")
|
121
124
|
MicrotasksScope(Isolate* isolate, Type type);
|
125
|
+
|
126
|
+
MicrotasksScope(Local<Context> context, Type type);
|
122
127
|
MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
|
123
128
|
~MicrotasksScope();
|
124
129
|
|
@@ -607,6 +607,19 @@ class V8_EXPORT Object : public Value {
|
|
607
607
|
return object.val_->GetCreationContext();
|
608
608
|
}
|
609
609
|
|
610
|
+
/**
|
611
|
+
* Gets the context in which the object was created (see GetCreationContext())
|
612
|
+
* and if it's available reads respective embedder field value.
|
613
|
+
* If the context can't be obtained nullptr is returned.
|
614
|
+
* Basically it's a shortcut for
|
615
|
+
* obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index)
|
616
|
+
* which doesn't create a handle for Context object on the way and doesn't
|
617
|
+
* try to expand the embedder data attached to the context.
|
618
|
+
* In case the Local<Context> is already available because of other reasons,
|
619
|
+
* it's fine to keep using Context::GetAlignedPointerFromEmbedderData().
|
620
|
+
*/
|
621
|
+
void* GetAlignedPointerFromEmbedderDataInCreationContext(int index);
|
622
|
+
|
610
623
|
/**
|
611
624
|
* Checks whether a callback is set by the
|
612
625
|
* ObjectTemplate::SetCallAsFunctionHandler method.
|
@@ -707,7 +720,7 @@ Local<Value> Object::GetInternalField(int index) {
|
|
707
720
|
#ifndef V8_ENABLE_CHECKS
|
708
721
|
using A = internal::Address;
|
709
722
|
using I = internal::Internals;
|
710
|
-
A obj =
|
723
|
+
A obj = internal::ValueHelper::ValueAsAddress(this);
|
711
724
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
712
725
|
// know where to find the internal fields and can return the value directly.
|
713
726
|
int instance_type = I::GetInstanceType(obj);
|
@@ -717,12 +730,17 @@ Local<Value> Object::GetInternalField(int index) {
|
|
717
730
|
#ifdef V8_COMPRESS_POINTERS
|
718
731
|
// We read the full pointer value and then decompress it in order to avoid
|
719
732
|
// dealing with potential endiannes issues.
|
720
|
-
value = I::
|
733
|
+
value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
|
721
734
|
#endif
|
735
|
+
|
736
|
+
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
737
|
+
return Local<Value>(reinterpret_cast<Value*>(value));
|
738
|
+
#else
|
722
739
|
internal::Isolate* isolate =
|
723
740
|
internal::IsolateFromNeverReadOnlySpaceObject(obj);
|
724
741
|
A* result = HandleScope::CreateHandle(isolate, value);
|
725
742
|
return Local<Value>(reinterpret_cast<Value*>(result));
|
743
|
+
#endif
|
726
744
|
}
|
727
745
|
#endif
|
728
746
|
return SlowGetInternalField(index);
|
@@ -732,7 +750,7 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
|
|
732
750
|
#if !defined(V8_ENABLE_CHECKS)
|
733
751
|
using A = internal::Address;
|
734
752
|
using I = internal::Internals;
|
735
|
-
A obj =
|
753
|
+
A obj = internal::ValueHelper::ValueAsAddress(this);
|
736
754
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
737
755
|
// know where to find the internal fields and can return the value directly.
|
738
756
|
auto instance_type = I::GetInstanceType(obj);
|
@@ -55,7 +55,7 @@ class Eternal {
|
|
55
55
|
V8_INLINE Local<T> Get(Isolate* isolate) const {
|
56
56
|
// The eternal handle will never go away, so as with the roots, we don't
|
57
57
|
// even need to open a handle.
|
58
|
-
return Local<T>(val_);
|
58
|
+
return Local<T>(internal::ValueHelper::SlotAsValue<T>(val_));
|
59
59
|
}
|
60
60
|
|
61
61
|
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
|
@@ -68,6 +68,10 @@ class Eternal {
|
|
68
68
|
}
|
69
69
|
|
70
70
|
private:
|
71
|
+
V8_INLINE internal::Address address() const {
|
72
|
+
return *reinterpret_cast<internal::Address*>(val_);
|
73
|
+
}
|
74
|
+
|
71
75
|
T* val_;
|
72
76
|
};
|
73
77
|
|
@@ -122,20 +126,12 @@ class PersistentBase {
|
|
122
126
|
|
123
127
|
template <class S>
|
124
128
|
V8_INLINE bool operator==(const PersistentBase<S>& that) const {
|
125
|
-
|
126
|
-
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
127
|
-
if (a == nullptr) return b == nullptr;
|
128
|
-
if (b == nullptr) return false;
|
129
|
-
return *a == *b;
|
129
|
+
return internal::HandleHelper::EqualHandles(*this, that);
|
130
130
|
}
|
131
131
|
|
132
132
|
template <class S>
|
133
133
|
V8_INLINE bool operator==(const Local<S>& that) const {
|
134
|
-
|
135
|
-
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
136
|
-
if (a == nullptr) return b == nullptr;
|
137
|
-
if (b == nullptr) return false;
|
138
|
-
return *a == *b;
|
134
|
+
return internal::HandleHelper::EqualHandles(*this, that);
|
139
135
|
}
|
140
136
|
|
141
137
|
template <class S>
|
@@ -221,8 +217,15 @@ class PersistentBase {
|
|
221
217
|
template <class F1, class F2>
|
222
218
|
friend class PersistentValueVector;
|
223
219
|
friend class Object;
|
220
|
+
friend class internal::HandleHelper;
|
224
221
|
|
225
222
|
explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
|
223
|
+
V8_INLINE T* operator*() const { return this->val_; }
|
224
|
+
V8_INLINE internal::Address address() const {
|
225
|
+
return *reinterpret_cast<internal::Address*>(val_);
|
226
|
+
}
|
227
|
+
|
228
|
+
V8_INLINE static T* New(Isolate* isolate, Local<T> that);
|
226
229
|
V8_INLINE static T* New(Isolate* isolate, T* that);
|
227
230
|
|
228
231
|
T* val_;
|
@@ -282,11 +285,13 @@ class Persistent : public PersistentBase<T> {
|
|
282
285
|
* When the Local is non-empty, a new storage cell is created
|
283
286
|
* pointing to the same object, and no flags are set.
|
284
287
|
*/
|
288
|
+
|
285
289
|
template <class S>
|
286
290
|
V8_INLINE Persistent(Isolate* isolate, Local<S> that)
|
287
|
-
: PersistentBase<T>(PersistentBase<T>::New(isolate,
|
291
|
+
: PersistentBase<T>(PersistentBase<T>::New(isolate, that)) {
|
288
292
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
289
293
|
}
|
294
|
+
|
290
295
|
/**
|
291
296
|
* Construct a Persistent from a Persistent.
|
292
297
|
* When the Persistent is non-empty, a new storage cell is created
|
@@ -356,7 +361,6 @@ class Persistent : public PersistentBase<T> {
|
|
356
361
|
friend class ReturnValue;
|
357
362
|
|
358
363
|
explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
|
359
|
-
V8_INLINE T* operator*() const { return this->val_; }
|
360
364
|
template <class S, class M2>
|
361
365
|
V8_INLINE void Copy(const Persistent<S, M2>& that);
|
362
366
|
};
|
@@ -381,7 +385,7 @@ class Global : public PersistentBase<T> {
|
|
381
385
|
*/
|
382
386
|
template <class S>
|
383
387
|
V8_INLINE Global(Isolate* isolate, Local<S> that)
|
384
|
-
: PersistentBase<T>(PersistentBase<T>::New(isolate,
|
388
|
+
: PersistentBase<T>(PersistentBase<T>::New(isolate, that)) {
|
385
389
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
386
390
|
}
|
387
391
|
|
@@ -425,7 +429,6 @@ class Global : public PersistentBase<T> {
|
|
425
429
|
private:
|
426
430
|
template <class F>
|
427
431
|
friend class ReturnValue;
|
428
|
-
V8_INLINE T* operator*() const { return this->val_; }
|
429
432
|
};
|
430
433
|
|
431
434
|
// UniquePersistent is an alias for Global for historical reason.
|
@@ -442,6 +445,12 @@ class V8_EXPORT PersistentHandleVisitor {
|
|
442
445
|
uint16_t class_id) {}
|
443
446
|
};
|
444
447
|
|
448
|
+
template <class T>
|
449
|
+
T* PersistentBase<T>::New(Isolate* isolate, Local<T> that) {
|
450
|
+
return PersistentBase<T>::New(isolate,
|
451
|
+
internal::ValueHelper::ValueAsSlot(*that));
|
452
|
+
}
|
453
|
+
|
445
454
|
template <class T>
|
446
455
|
T* PersistentBase<T>::New(Isolate* isolate, T* that) {
|
447
456
|
if (that == nullptr) return nullptr;
|
@@ -486,7 +495,7 @@ void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
|
486
495
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
487
496
|
Reset();
|
488
497
|
if (other.IsEmpty()) return;
|
489
|
-
this->val_ = New(isolate, other
|
498
|
+
this->val_ = New(isolate, internal::ValueHelper::ValueAsSlot(*other));
|
490
499
|
}
|
491
500
|
|
492
501
|
/**
|