libv8-node 18.13.0.1-aarch64-linux → 20.2.0.0-aarch64-linux
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/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/common.h +0 -1
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +11 -10
- data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
- data/vendor/v8/include/cppgc/heap-handle.h +48 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
- data/vendor/v8/include/cppgc/heap.h +3 -7
- data/vendor/v8/include/cppgc/internal/api-constants.h +14 -1
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
- data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +35 -34
- data/vendor/v8/include/cppgc/internal/member-storage.h +248 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
- data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +65 -8
- data/vendor/v8/include/cppgc/internal/write-barrier.h +153 -101
- data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
- data/vendor/v8/include/cppgc/macros.h +10 -1
- data/vendor/v8/include/cppgc/member.h +424 -111
- data/vendor/v8/include/cppgc/name-provider.h +4 -4
- data/vendor/v8/include/cppgc/persistent.h +27 -24
- data/vendor/v8/include/cppgc/platform.h +7 -5
- data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
- data/vendor/v8/include/cppgc/trace-trait.h +4 -0
- data/vendor/v8/include/cppgc/type-traits.h +13 -3
- data/vendor/v8/include/cppgc/visitor.h +104 -57
- 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 +32 -5
- data/vendor/v8/include/v8-context.h +63 -11
- data/vendor/v8/include/v8-cppgc.h +22 -0
- data/vendor/v8/include/v8-data.h +1 -1
- data/vendor/v8/include/v8-date.h +5 -0
- data/vendor/v8/include/v8-embedder-heap.h +0 -164
- data/vendor/v8/include/v8-exception.h +1 -1
- data/vendor/v8/include/v8-fast-api-calls.h +49 -31
- data/vendor/v8/include/v8-function-callback.h +69 -42
- data/vendor/v8/include/v8-function.h +9 -0
- data/vendor/v8/include/v8-initialization.h +23 -49
- data/vendor/v8/include/v8-inspector.h +32 -11
- data/vendor/v8/include/v8-internal.h +480 -183
- data/vendor/v8/include/v8-isolate.h +52 -77
- data/vendor/v8/include/v8-local-handle.h +86 -53
- data/vendor/v8/include/v8-locker.h +0 -11
- data/vendor/v8/include/v8-maybe.h +24 -1
- data/vendor/v8/include/v8-message.h +2 -4
- data/vendor/v8/include/v8-metrics.h +48 -40
- data/vendor/v8/include/v8-microtask-queue.h +6 -1
- data/vendor/v8/include/v8-object.h +29 -18
- data/vendor/v8/include/v8-persistent-handle.h +25 -18
- data/vendor/v8/include/v8-platform.h +133 -35
- data/vendor/v8/include/v8-primitive.h +27 -20
- data/vendor/v8/include/v8-profiler.h +133 -53
- data/vendor/v8/include/v8-regexp.h +2 -1
- data/vendor/v8/include/v8-script.h +91 -7
- data/vendor/v8/include/v8-snapshot.h +4 -8
- data/vendor/v8/include/v8-template.h +16 -77
- data/vendor/v8/include/v8-traced-handle.h +22 -28
- data/vendor/v8/include/v8-unwinder-state.h +4 -4
- data/vendor/v8/include/v8-util.h +11 -7
- data/vendor/v8/include/v8-value-serializer.h +46 -23
- 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 +7 -63
- data/vendor/v8/include/v8-weak-callback-info.h +0 -7
- data/vendor/v8/include/v8config.h +353 -15
- metadata +5 -1
@@ -194,6 +194,11 @@ enum RAILMode : unsigned {
|
|
194
194
|
*/
|
195
195
|
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
196
196
|
|
197
|
+
/**
|
198
|
+
* Indicator for the stack state.
|
199
|
+
*/
|
200
|
+
using StackState = cppgc::EmbedderStackState;
|
201
|
+
|
197
202
|
/**
|
198
203
|
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
|
199
204
|
* completely separate states. Objects from one isolate must not be used in
|
@@ -211,6 +216,8 @@ class V8_EXPORT Isolate {
|
|
211
216
|
CreateParams();
|
212
217
|
~CreateParams();
|
213
218
|
|
219
|
+
ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(CreateParams)
|
220
|
+
|
214
221
|
/**
|
215
222
|
* Allows the host application to provide the address of a function that is
|
216
223
|
* notified each time code is added, moved or removed.
|
@@ -226,7 +233,7 @@ class V8_EXPORT Isolate {
|
|
226
233
|
* Explicitly specify a startup snapshot blob. The embedder owns the blob.
|
227
234
|
* The embedder *must* ensure that the snapshot is from a trusted source.
|
228
235
|
*/
|
229
|
-
StartupData* snapshot_blob = nullptr;
|
236
|
+
const StartupData* snapshot_blob = nullptr;
|
230
237
|
|
231
238
|
/**
|
232
239
|
* Enables the host application to provide a mechanism for recording
|
@@ -287,12 +294,6 @@ class V8_EXPORT Isolate {
|
|
287
294
|
*/
|
288
295
|
FatalErrorCallback fatal_error_callback = nullptr;
|
289
296
|
OOMErrorCallback oom_error_callback = nullptr;
|
290
|
-
|
291
|
-
/**
|
292
|
-
* The following parameter is experimental and may change significantly.
|
293
|
-
* This is currently for internal testing.
|
294
|
-
*/
|
295
|
-
Isolate* experimental_attach_to_shared_isolate = nullptr;
|
296
297
|
};
|
297
298
|
|
298
299
|
/**
|
@@ -301,16 +302,18 @@ class V8_EXPORT Isolate {
|
|
301
302
|
*/
|
302
303
|
class V8_EXPORT V8_NODISCARD Scope {
|
303
304
|
public:
|
304
|
-
explicit Scope(Isolate* isolate) :
|
305
|
+
explicit Scope(Isolate* isolate) : v8_isolate_(isolate) {
|
306
|
+
v8_isolate_->Enter();
|
307
|
+
}
|
305
308
|
|
306
|
-
~Scope() {
|
309
|
+
~Scope() { v8_isolate_->Exit(); }
|
307
310
|
|
308
311
|
// Prevent copying of Scope objects.
|
309
312
|
Scope(const Scope&) = delete;
|
310
313
|
Scope& operator=(const Scope&) = delete;
|
311
314
|
|
312
315
|
private:
|
313
|
-
Isolate* const
|
316
|
+
Isolate* const v8_isolate_;
|
314
317
|
};
|
315
318
|
|
316
319
|
/**
|
@@ -330,12 +333,9 @@ class V8_EXPORT Isolate {
|
|
330
333
|
const DisallowJavascriptExecutionScope&) = delete;
|
331
334
|
|
332
335
|
private:
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
bool was_execution_allowed_assert_;
|
337
|
-
bool was_execution_allowed_throws_;
|
338
|
-
bool was_execution_allowed_dump_;
|
336
|
+
v8::Isolate* const v8_isolate_;
|
337
|
+
const OnFailure on_failure_;
|
338
|
+
bool was_execution_allowed_;
|
339
339
|
};
|
340
340
|
|
341
341
|
/**
|
@@ -353,7 +353,7 @@ class V8_EXPORT Isolate {
|
|
353
353
|
const AllowJavascriptExecutionScope&) = delete;
|
354
354
|
|
355
355
|
private:
|
356
|
-
Isolate*
|
356
|
+
Isolate* const v8_isolate_;
|
357
357
|
bool was_execution_allowed_assert_;
|
358
358
|
bool was_execution_allowed_throws_;
|
359
359
|
bool was_execution_allowed_dump_;
|
@@ -376,7 +376,7 @@ class V8_EXPORT Isolate {
|
|
376
376
|
const SuppressMicrotaskExecutionScope&) = delete;
|
377
377
|
|
378
378
|
private:
|
379
|
-
internal::Isolate* const
|
379
|
+
internal::Isolate* const i_isolate_;
|
380
380
|
internal::MicrotaskQueue* const microtask_queue_;
|
381
381
|
internal::Address previous_stack_height_;
|
382
382
|
|
@@ -389,7 +389,7 @@ class V8_EXPORT Isolate {
|
|
389
389
|
*/
|
390
390
|
class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
|
391
391
|
public:
|
392
|
-
explicit SafeForTerminationScope(v8::Isolate*
|
392
|
+
explicit SafeForTerminationScope(v8::Isolate* v8_isolate);
|
393
393
|
~SafeForTerminationScope();
|
394
394
|
|
395
395
|
// Prevent copying of Scope objects.
|
@@ -397,7 +397,7 @@ class V8_EXPORT Isolate {
|
|
397
397
|
SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete;
|
398
398
|
|
399
399
|
private:
|
400
|
-
internal::Isolate*
|
400
|
+
internal::Isolate* i_isolate_;
|
401
401
|
bool prev_value_;
|
402
402
|
};
|
403
403
|
|
@@ -531,6 +531,11 @@ class V8_EXPORT Isolate {
|
|
531
531
|
kInvalidatedMegaDOMProtector = 112,
|
532
532
|
kFunctionPrototypeArguments = 113,
|
533
533
|
kFunctionPrototypeCaller = 114,
|
534
|
+
kTurboFanOsrCompileStarted = 115,
|
535
|
+
kAsyncStackTaggingCreateTaskCall = 116,
|
536
|
+
kDurationFormat = 117,
|
537
|
+
kInvalidatedNumberStringPrototypeNoReplaceProtector = 118,
|
538
|
+
kRegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119, // Unused.
|
534
539
|
|
535
540
|
// If you add new values here, you'll also need to update Chromium's:
|
536
541
|
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
|
@@ -636,9 +641,6 @@ class V8_EXPORT Isolate {
|
|
636
641
|
* This specifies the callback called by the upcoming dynamic
|
637
642
|
* import() language feature to load modules.
|
638
643
|
*/
|
639
|
-
V8_DEPRECATED("Use HostImportModuleDynamicallyCallback")
|
640
|
-
void SetHostImportModuleDynamicallyCallback(
|
641
|
-
HostImportModuleDynamicallyWithImportAssertionsCallback callback);
|
642
644
|
void SetHostImportModuleDynamicallyCallback(
|
643
645
|
HostImportModuleDynamicallyCallback callback);
|
644
646
|
|
@@ -839,12 +841,6 @@ class V8_EXPORT Isolate {
|
|
839
841
|
*/
|
840
842
|
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
|
841
843
|
|
842
|
-
/**
|
843
|
-
* Returns the number of phantom handles without callbacks that were reset
|
844
|
-
* by the garbage collector since the last call to this function.
|
845
|
-
*/
|
846
|
-
size_t NumberOfPhantomHandleResetsSinceLastCall();
|
847
|
-
|
848
844
|
/**
|
849
845
|
* Returns heap profiler for this isolate. Will return NULL until the isolate
|
850
846
|
* is initialized.
|
@@ -927,25 +923,10 @@ class V8_EXPORT Isolate {
|
|
927
923
|
void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
|
928
924
|
void RemoveGCPrologueCallback(GCCallback callback);
|
929
925
|
|
930
|
-
/**
|
931
|
-
* Sets the embedder heap tracer for the isolate.
|
932
|
-
* SetEmbedderHeapTracer cannot be used simultaneously with AttachCppHeap.
|
933
|
-
*/
|
934
|
-
void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
|
935
|
-
|
936
|
-
/*
|
937
|
-
* Gets the currently active heap tracer for the isolate that was set with
|
938
|
-
* SetEmbedderHeapTracer.
|
939
|
-
*/
|
940
|
-
EmbedderHeapTracer* GetEmbedderHeapTracer();
|
941
|
-
|
942
926
|
/**
|
943
927
|
* Sets an embedder roots handle that V8 should consider when performing
|
944
|
-
* non-unified heap garbage collections.
|
945
|
-
*
|
946
|
-
* Using only EmbedderHeapTracer automatically sets up a default handler.
|
947
|
-
* The intended use case is for setting a custom handler after invoking
|
948
|
-
* `AttachCppHeap()`.
|
928
|
+
* non-unified heap garbage collections. The intended use case is for setting
|
929
|
+
* a custom handler after invoking `AttachCppHeap()`.
|
949
930
|
*
|
950
931
|
* V8 does not take ownership of the handler.
|
951
932
|
*/
|
@@ -955,22 +936,18 @@ class V8_EXPORT Isolate {
|
|
955
936
|
* Attaches a managed C++ heap as an extension to the JavaScript heap. The
|
956
937
|
* embedder maintains ownership of the CppHeap. At most one C++ heap can be
|
957
938
|
* attached to V8.
|
958
|
-
* AttachCppHeap cannot be used simultaneously with SetEmbedderHeapTracer.
|
959
939
|
*
|
960
|
-
*
|
940
|
+
* Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see
|
941
|
+
* CppHeap.
|
961
942
|
*/
|
962
943
|
void AttachCppHeap(CppHeap*);
|
963
944
|
|
964
945
|
/**
|
965
946
|
* Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
|
966
|
-
*
|
967
|
-
* This is an experimental feature and may still change significantly.
|
968
947
|
*/
|
969
948
|
void DetachCppHeap();
|
970
949
|
|
971
950
|
/**
|
972
|
-
* This is an experimental feature and may still change significantly.
|
973
|
-
|
974
951
|
* \returns the C++ heap managed by V8. Only available if such a heap has been
|
975
952
|
* attached using `AttachCppHeap()`.
|
976
953
|
*/
|
@@ -1146,9 +1123,8 @@ class V8_EXPORT Isolate {
|
|
1146
1123
|
*
|
1147
1124
|
* This should only be used for testing purposes and not to enforce a garbage
|
1148
1125
|
* collection schedule. It has strong negative impact on the garbage
|
1149
|
-
* collection performance. Use
|
1150
|
-
*
|
1151
|
-
* schedule.
|
1126
|
+
* collection performance. Use MemoryPressureNotification() instead to
|
1127
|
+
* influence the garbage collection schedule.
|
1152
1128
|
*/
|
1153
1129
|
void RequestGarbageCollectionForTesting(GarbageCollectionType type);
|
1154
1130
|
|
@@ -1159,13 +1135,11 @@ class V8_EXPORT Isolate {
|
|
1159
1135
|
*
|
1160
1136
|
* This should only be used for testing purposes and not to enforce a garbage
|
1161
1137
|
* collection schedule. It has strong negative impact on the garbage
|
1162
|
-
* collection performance. Use
|
1163
|
-
*
|
1164
|
-
* schedule.
|
1138
|
+
* collection performance. Use MemoryPressureNotification() instead to
|
1139
|
+
* influence the garbage collection schedule.
|
1165
1140
|
*/
|
1166
|
-
void RequestGarbageCollectionForTesting(
|
1167
|
-
|
1168
|
-
EmbedderHeapTracer::EmbedderStackState stack_state);
|
1141
|
+
void RequestGarbageCollectionForTesting(GarbageCollectionType type,
|
1142
|
+
StackState stack_state);
|
1169
1143
|
|
1170
1144
|
/**
|
1171
1145
|
* Set the callback to invoke for logging event.
|
@@ -1314,6 +1288,8 @@ class V8_EXPORT Isolate {
|
|
1314
1288
|
* that function. There is no guarantee that the actual work will be done
|
1315
1289
|
* within the time limit.
|
1316
1290
|
*/
|
1291
|
+
V8_DEPRECATE_SOON(
|
1292
|
+
"Use MemoryPressureNotification() to influence the GC schedule.")
|
1317
1293
|
bool IdleNotificationDeadline(double deadline_in_seconds);
|
1318
1294
|
|
1319
1295
|
/**
|
@@ -1350,11 +1326,13 @@ class V8_EXPORT Isolate {
|
|
1350
1326
|
* V8 uses this notification to guide heuristics which may result in a
|
1351
1327
|
* smaller memory footprint at the cost of reduced runtime performance.
|
1352
1328
|
*/
|
1329
|
+
V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
|
1353
1330
|
void EnableMemorySavingsMode();
|
1354
1331
|
|
1355
1332
|
/**
|
1356
1333
|
* Optional notification which will disable the memory savings mode.
|
1357
1334
|
*/
|
1335
|
+
V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
|
1358
1336
|
void DisableMemorySavingsMode();
|
1359
1337
|
|
1360
1338
|
/**
|
@@ -1523,14 +1501,23 @@ class V8_EXPORT Isolate {
|
|
1523
1501
|
|
1524
1502
|
void SetWasmStreamingCallback(WasmStreamingCallback callback);
|
1525
1503
|
|
1504
|
+
void SetWasmAsyncResolvePromiseCallback(
|
1505
|
+
WasmAsyncResolvePromiseCallback callback);
|
1506
|
+
|
1526
1507
|
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
|
1527
1508
|
|
1509
|
+
V8_DEPRECATED("Wasm SIMD is always enabled")
|
1528
1510
|
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
|
1529
1511
|
|
1512
|
+
V8_DEPRECATED("Wasm exceptions are always enabled")
|
1530
1513
|
void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
|
1531
1514
|
|
1532
|
-
|
1533
|
-
|
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);
|
1534
1521
|
|
1535
1522
|
void SetSharedArrayBufferConstructorEnabledCallback(
|
1536
1523
|
SharedArrayBufferConstructorEnabledCallback callback);
|
@@ -1598,19 +1585,6 @@ class V8_EXPORT Isolate {
|
|
1598
1585
|
*/
|
1599
1586
|
void VisitExternalResources(ExternalResourceVisitor* visitor);
|
1600
1587
|
|
1601
|
-
/**
|
1602
|
-
* Iterates through all the persistent handles in the current isolate's heap
|
1603
|
-
* that have class_ids.
|
1604
|
-
*/
|
1605
|
-
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
|
1606
|
-
|
1607
|
-
/**
|
1608
|
-
* Iterates through all the persistent handles in the current isolate's heap
|
1609
|
-
* that have class_ids and are weak to be marked as inactive if there is no
|
1610
|
-
* pending activity for the handle.
|
1611
|
-
*/
|
1612
|
-
void VisitWeakHandles(PersistentHandleVisitor* visitor);
|
1613
|
-
|
1614
1588
|
/**
|
1615
1589
|
* Check if this isolate is in use.
|
1616
1590
|
* True if at least one thread Enter'ed this isolate.
|
@@ -1699,7 +1673,8 @@ uint32_t Isolate::GetNumberOfDataSlots() {
|
|
1699
1673
|
|
1700
1674
|
template <class T>
|
1701
1675
|
MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
|
1702
|
-
T* data =
|
1676
|
+
T* data =
|
1677
|
+
internal::ValueHelper::SlotAsValue<T>(GetDataFromSnapshotOnce(index));
|
1703
1678
|
if (data) internal::PerformCastCheck(data);
|
1704
1679
|
return Local<T>(data);
|
1705
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 {
|
@@ -86,18 +91,21 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
86
91
|
static int NumberOfHandles(Isolate* isolate);
|
87
92
|
|
88
93
|
V8_INLINE Isolate* GetIsolate() const {
|
89
|
-
return reinterpret_cast<Isolate*>(
|
94
|
+
return reinterpret_cast<Isolate*>(i_isolate_);
|
90
95
|
}
|
91
96
|
|
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
|
|
98
106
|
void Initialize(Isolate* isolate);
|
99
107
|
|
100
|
-
static internal::Address* CreateHandle(internal::Isolate*
|
108
|
+
static internal::Address* CreateHandle(internal::Isolate* i_isolate,
|
101
109
|
internal::Address value);
|
102
110
|
|
103
111
|
private:
|
@@ -108,7 +116,7 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
108
116
|
void operator delete(void*, size_t);
|
109
117
|
void operator delete[](void*, size_t);
|
110
118
|
|
111
|
-
internal::Isolate*
|
119
|
+
internal::Isolate* i_isolate_;
|
112
120
|
internal::Address* prev_next_;
|
113
121
|
internal::Address* prev_limit_;
|
114
122
|
|
@@ -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,21 +371,23 @@ 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,
|
357
|
-
* |false| is returned and |out| is
|
386
|
+
* |false| is returned and |out| is assigned with nullptr.
|
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>
|
@@ -445,7 +478,7 @@ class V8_EXPORT V8_NODISCARD SealHandleScope {
|
|
445
478
|
void operator delete(void*, size_t);
|
446
479
|
void operator delete[](void*, size_t);
|
447
480
|
|
448
|
-
internal::Isolate* const
|
481
|
+
internal::Isolate* const i_isolate_;
|
449
482
|
internal::Address* prev_limit_;
|
450
483
|
int prev_sealed_level_;
|
451
484
|
};
|
@@ -121,17 +121,6 @@ class V8_EXPORT Locker {
|
|
121
121
|
*/
|
122
122
|
static bool IsLocked(Isolate* isolate);
|
123
123
|
|
124
|
-
/**
|
125
|
-
* Returns whether any v8::Locker has ever been used in this process.
|
126
|
-
* TODO(cbruni, chromium:1240851): Fix locking checks on a per-thread basis.
|
127
|
-
* The current implementation is quite confusing and leads to unexpected
|
128
|
-
* results if anybody uses v8::Locker in the current process.
|
129
|
-
*/
|
130
|
-
V8_DEPRECATE_SOON("This method will be removed.")
|
131
|
-
static bool WasEverUsed();
|
132
|
-
V8_DEPRECATED("Use WasEverUsed instead")
|
133
|
-
static bool IsActive();
|
134
|
-
|
135
124
|
// Disallow copying and assigning.
|
136
125
|
Locker(const Locker&) = delete;
|
137
126
|
void operator=(const Locker&) = delete;
|
@@ -5,6 +5,9 @@
|
|
5
5
|
#ifndef INCLUDE_V8_MAYBE_H_
|
6
6
|
#define INCLUDE_V8_MAYBE_H_
|
7
7
|
|
8
|
+
#include <type_traits>
|
9
|
+
#include <utility>
|
10
|
+
|
8
11
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
9
12
|
#include "v8config.h" // NOLINT(build/include_directory)
|
10
13
|
|
@@ -57,11 +60,20 @@ class Maybe {
|
|
57
60
|
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
58
61
|
* nothing (empty), V8 will crash the process.
|
59
62
|
*/
|
60
|
-
V8_INLINE T FromJust() const {
|
63
|
+
V8_INLINE T FromJust() const& {
|
61
64
|
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
62
65
|
return value_;
|
63
66
|
}
|
64
67
|
|
68
|
+
/**
|
69
|
+
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
70
|
+
* nothing (empty), V8 will crash the process.
|
71
|
+
*/
|
72
|
+
V8_INLINE T FromJust() && {
|
73
|
+
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
74
|
+
return std::move(value_);
|
75
|
+
}
|
76
|
+
|
65
77
|
/**
|
66
78
|
* Converts this Maybe<> to a value of type T, using a default value if this
|
67
79
|
* Maybe<> is nothing (empty).
|
@@ -82,6 +94,7 @@ class Maybe {
|
|
82
94
|
private:
|
83
95
|
Maybe() : has_value_(false) {}
|
84
96
|
explicit Maybe(const T& t) : has_value_(true), value_(t) {}
|
97
|
+
explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
|
85
98
|
|
86
99
|
bool has_value_;
|
87
100
|
T value_;
|
@@ -90,6 +103,8 @@ class Maybe {
|
|
90
103
|
friend Maybe<U> Nothing();
|
91
104
|
template <class U>
|
92
105
|
friend Maybe<U> Just(const U& u);
|
106
|
+
template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
|
107
|
+
friend Maybe<U> Just(U&& u);
|
93
108
|
};
|
94
109
|
|
95
110
|
template <class T>
|
@@ -102,6 +117,14 @@ inline Maybe<T> Just(const T& t) {
|
|
102
117
|
return Maybe<T>(t);
|
103
118
|
}
|
104
119
|
|
120
|
+
// Don't use forwarding references here but instead use two overloads.
|
121
|
+
// Forwarding references only work when type deduction takes place, which is not
|
122
|
+
// the case for callsites such as Just<Type>(t).
|
123
|
+
template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
|
124
|
+
inline Maybe<T> Just(T&& t) {
|
125
|
+
return Maybe<T>(std::move(t));
|
126
|
+
}
|
127
|
+
|
105
128
|
// A template specialization of Maybe<T> for the case of T = void.
|
106
129
|
template <>
|
107
130
|
class Maybe<void> {
|