libv8-node 20.2.0.0-aarch64-linux → 21.7.2.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/internal/api-constants.h +23 -4
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +16 -6
- data/vendor/v8/include/cppgc/internal/caged-heap.h +12 -5
- data/vendor/v8/include/cppgc/internal/gc-info.h +82 -91
- data/vendor/v8/include/cppgc/internal/member-storage.h +16 -8
- data/vendor/v8/include/cppgc/member.h +25 -0
- data/vendor/v8/include/cppgc/persistent.h +4 -0
- data/vendor/v8/include/cppgc/platform.h +6 -1
- data/vendor/v8/include/cppgc/sentinel-pointer.h +7 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -78
- data/vendor/v8/include/cppgc/trace-trait.h +8 -0
- data/vendor/v8/include/cppgc/visitor.h +82 -4
- data/vendor/v8/include/libplatform/libplatform.h +7 -1
- data/vendor/v8/include/v8-callbacks.h +52 -8
- data/vendor/v8/include/v8-context.h +10 -13
- data/vendor/v8/include/v8-cppgc.h +5 -0
- data/vendor/v8/include/v8-embedder-heap.h +12 -0
- data/vendor/v8/include/v8-fast-api-calls.h +23 -5
- data/vendor/v8/include/v8-function-callback.h +11 -15
- data/vendor/v8/include/v8-function.h +6 -0
- data/vendor/v8/include/v8-handle-base.h +185 -0
- data/vendor/v8/include/v8-inspector.h +31 -1
- data/vendor/v8/include/v8-internal.h +109 -77
- data/vendor/v8/include/v8-isolate.h +130 -89
- data/vendor/v8/include/v8-local-handle.h +134 -89
- data/vendor/v8/include/v8-object.h +71 -52
- data/vendor/v8/include/v8-persistent-handle.h +65 -89
- data/vendor/v8/include/v8-platform.h +140 -9
- data/vendor/v8/include/v8-primitive.h +12 -8
- data/vendor/v8/include/v8-profiler.h +26 -2
- data/vendor/v8/include/v8-script.h +30 -7
- data/vendor/v8/include/v8-snapshot.h +4 -1
- data/vendor/v8/include/v8-source-location.h +92 -0
- data/vendor/v8/include/v8-statistics.h +36 -1
- data/vendor/v8/include/v8-traced-handle.h +37 -54
- data/vendor/v8/include/v8-unwinder.h +1 -1
- data/vendor/v8/include/v8-util.h +15 -13
- data/vendor/v8/include/v8-value-serializer.h +14 -0
- data/vendor/v8/include/v8-value.h +14 -0
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8config.h +19 -10
- metadata +4 -2
@@ -11,6 +11,7 @@
|
|
11
11
|
#include <unordered_set>
|
12
12
|
#include <vector>
|
13
13
|
|
14
|
+
#include "cppgc/common.h" // NOLINT(build/include_directory)
|
14
15
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
15
16
|
#include "v8-message.h" // NOLINT(build/include_directory)
|
16
17
|
#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
|
@@ -24,7 +25,7 @@ enum class EmbedderStateTag : uint8_t;
|
|
24
25
|
class HeapGraphNode;
|
25
26
|
struct HeapStatsUpdate;
|
26
27
|
class Object;
|
27
|
-
enum StateTag :
|
28
|
+
enum StateTag : uint16_t;
|
28
29
|
|
29
30
|
using NativeObject = void*;
|
30
31
|
using SnapshotObjectId = uint32_t;
|
@@ -596,7 +597,6 @@ class V8_EXPORT HeapGraphNode {
|
|
596
597
|
kBigInt = 13, // BigInt.
|
597
598
|
kObjectShape = 14, // Internal data used for tracking the shapes (or
|
598
599
|
// "hidden classes") of JS objects.
|
599
|
-
kWasmObject = 15, // A WasmGC struct or array.
|
600
600
|
};
|
601
601
|
|
602
602
|
/** Returns node type (see HeapGraphNode::Type). */
|
@@ -883,6 +883,15 @@ class V8_EXPORT EmbedderGraph {
|
|
883
883
|
*/
|
884
884
|
virtual Detachedness GetDetachedness() { return Detachedness::kUnknown; }
|
885
885
|
|
886
|
+
/**
|
887
|
+
* Returns the address of the object in the embedder heap, or nullptr to not
|
888
|
+
* specify the address. If this address is provided, then V8 can generate
|
889
|
+
* consistent IDs for objects across subsequent heap snapshots, which allows
|
890
|
+
* devtools to determine which objects were retained from one snapshot to
|
891
|
+
* the next. This value is used only if GetNativeObject returns nullptr.
|
892
|
+
*/
|
893
|
+
virtual const void* GetAddress() { return nullptr; }
|
894
|
+
|
886
895
|
Node(const Node&) = delete;
|
887
896
|
Node& operator=(const Node&) = delete;
|
888
897
|
};
|
@@ -912,12 +921,22 @@ class V8_EXPORT EmbedderGraph {
|
|
912
921
|
virtual ~EmbedderGraph() = default;
|
913
922
|
};
|
914
923
|
|
924
|
+
class QueryObjectPredicate {
|
925
|
+
public:
|
926
|
+
virtual ~QueryObjectPredicate() = default;
|
927
|
+
virtual bool Filter(v8::Local<v8::Object> object) = 0;
|
928
|
+
};
|
929
|
+
|
915
930
|
/**
|
916
931
|
* Interface for controlling heap profiling. Instance of the
|
917
932
|
* profiler can be retrieved using v8::Isolate::GetHeapProfiler.
|
918
933
|
*/
|
919
934
|
class V8_EXPORT HeapProfiler {
|
920
935
|
public:
|
936
|
+
void QueryObjects(v8::Local<v8::Context> context,
|
937
|
+
QueryObjectPredicate* predicate,
|
938
|
+
std::vector<v8::Global<v8::Object>>* objects);
|
939
|
+
|
921
940
|
enum SamplingFlags {
|
922
941
|
kSamplingNoFlags = 0,
|
923
942
|
kSamplingForceGC = 1 << 0,
|
@@ -1045,6 +1064,11 @@ class V8_EXPORT HeapProfiler {
|
|
1045
1064
|
* Mode for dealing with numeric values, see `NumericsMode`.
|
1046
1065
|
*/
|
1047
1066
|
NumericsMode numerics_mode = NumericsMode::kHideNumericValues;
|
1067
|
+
/**
|
1068
|
+
* Whether stack is considered as a root set.
|
1069
|
+
*/
|
1070
|
+
cppgc::EmbedderStackState stack_state =
|
1071
|
+
cppgc::EmbedderStackState::kMayContainHeapPointers;
|
1048
1072
|
};
|
1049
1073
|
|
1050
1074
|
/**
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include <stdint.h>
|
10
10
|
|
11
11
|
#include <memory>
|
12
|
+
#include <tuple>
|
12
13
|
#include <vector>
|
13
14
|
|
14
15
|
#include "v8-callbacks.h" // NOLINT(build/include_directory)
|
@@ -55,7 +56,7 @@ class V8_EXPORT ScriptOrModule {
|
|
55
56
|
/**
|
56
57
|
* A compiled JavaScript script, not yet tied to a Context.
|
57
58
|
*/
|
58
|
-
class V8_EXPORT UnboundScript {
|
59
|
+
class V8_EXPORT UnboundScript : public Data {
|
59
60
|
public:
|
60
61
|
/**
|
61
62
|
* Binds the script to the currently entered context.
|
@@ -142,10 +143,9 @@ class V8_EXPORT ModuleRequest : public Data {
|
|
142
143
|
*
|
143
144
|
* All assertions present in the module request will be supplied in this
|
144
145
|
* list, regardless of whether they are supported by the host. Per
|
145
|
-
* https://tc39.es/proposal-import-
|
146
|
-
* hosts are expected to
|
147
|
-
* opposed to, for example,
|
148
|
-
* present).
|
146
|
+
* https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes,
|
147
|
+
* hosts are expected to throw for assertions that they do not support (as
|
148
|
+
* opposed to, for example, ignoring them).
|
149
149
|
*/
|
150
150
|
Local<FixedArray> GetImportAssertions() const;
|
151
151
|
|
@@ -320,7 +320,7 @@ class V8_EXPORT Module : public Data {
|
|
320
320
|
* A compiled JavaScript script, tied to a Context which was active when the
|
321
321
|
* script was compiled.
|
322
322
|
*/
|
323
|
-
class V8_EXPORT Script {
|
323
|
+
class V8_EXPORT Script : public Data {
|
324
324
|
public:
|
325
325
|
/**
|
326
326
|
* A shorthand for ScriptCompiler::Compile().
|
@@ -388,6 +388,27 @@ class V8_EXPORT ScriptCompiler {
|
|
388
388
|
CachedData(const uint8_t* data, int length,
|
389
389
|
BufferPolicy buffer_policy = BufferNotOwned);
|
390
390
|
~CachedData();
|
391
|
+
|
392
|
+
enum CompatibilityCheckResult {
|
393
|
+
// Don't change order/existing values of this enum since it keys into the
|
394
|
+
// `code_cache_reject_reason` histogram. Append-only!
|
395
|
+
kSuccess = 0,
|
396
|
+
kMagicNumberMismatch = 1,
|
397
|
+
kVersionMismatch = 2,
|
398
|
+
kSourceMismatch = 3,
|
399
|
+
kFlagsMismatch = 5,
|
400
|
+
kChecksumMismatch = 6,
|
401
|
+
kInvalidHeader = 7,
|
402
|
+
kLengthMismatch = 8,
|
403
|
+
kReadOnlySnapshotChecksumMismatch = 9,
|
404
|
+
|
405
|
+
// This should always point at the last real enum value.
|
406
|
+
kLast = kReadOnlySnapshotChecksumMismatch
|
407
|
+
};
|
408
|
+
|
409
|
+
// Check if the CachedData can be loaded in the given isolate.
|
410
|
+
CompatibilityCheckResult CompatibilityCheck(Isolate* isolate);
|
411
|
+
|
391
412
|
// TODO(marja): Async compilation; add constructors which take a callback
|
392
413
|
// which will be called when V8 no longer needs the data.
|
393
414
|
const uint8_t* data;
|
@@ -650,7 +671,9 @@ class V8_EXPORT ScriptCompiler {
|
|
650
671
|
static ScriptStreamingTask* StartStreaming(
|
651
672
|
Isolate* isolate, StreamedSource* source,
|
652
673
|
ScriptType type = ScriptType::kClassic,
|
653
|
-
CompileOptions options = kNoCompileOptions
|
674
|
+
CompileOptions options = kNoCompileOptions,
|
675
|
+
CompileHintCallback compile_hint_callback = nullptr,
|
676
|
+
void* compile_hint_callback_data = nullptr);
|
654
677
|
|
655
678
|
static ConsumeCodeCacheTask* StartConsumingCodeCache(
|
656
679
|
Isolate* isolate, std::unique_ptr<CachedData> source);
|
@@ -88,10 +88,13 @@ class V8_EXPORT SnapshotCreator {
|
|
88
88
|
* \param existing_blob existing snapshot from which to create this one.
|
89
89
|
* \param external_references a null-terminated array of external references
|
90
90
|
* that must be equivalent to CreateParams::external_references.
|
91
|
+
* \param owns_isolate whether this SnapshotCreator should call
|
92
|
+
* v8::Isolate::Dispose() during its destructor.
|
91
93
|
*/
|
92
94
|
SnapshotCreator(Isolate* isolate,
|
93
95
|
const intptr_t* external_references = nullptr,
|
94
|
-
const StartupData* existing_blob = nullptr
|
96
|
+
const StartupData* existing_blob = nullptr,
|
97
|
+
bool owns_isolate = true);
|
95
98
|
|
96
99
|
/**
|
97
100
|
* Create and enter an isolate, and set it up for serialization.
|
@@ -0,0 +1,92 @@
|
|
1
|
+
// Copyright 2020 the V8 project authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
#ifndef INCLUDE_SOURCE_LOCATION_H_
|
6
|
+
#define INCLUDE_SOURCE_LOCATION_H_
|
7
|
+
|
8
|
+
#include <cstddef>
|
9
|
+
#include <string>
|
10
|
+
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
#if defined(__has_builtin)
|
14
|
+
#define V8_SUPPORTS_SOURCE_LOCATION \
|
15
|
+
(__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
|
16
|
+
__has_builtin(__builtin_LINE)) // NOLINT
|
17
|
+
#elif defined(V8_CC_GNU) && __GNUC__ >= 7
|
18
|
+
#define V8_SUPPORTS_SOURCE_LOCATION 1
|
19
|
+
#elif defined(V8_CC_INTEL) && __ICC >= 1800
|
20
|
+
#define V8_SUPPORTS_SOURCE_LOCATION 1
|
21
|
+
#else
|
22
|
+
#define V8_SUPPORTS_SOURCE_LOCATION 0
|
23
|
+
#endif
|
24
|
+
|
25
|
+
namespace v8 {
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Encapsulates source location information. Mimics C++20's
|
29
|
+
* `std::source_location`.
|
30
|
+
*/
|
31
|
+
class V8_EXPORT SourceLocation final {
|
32
|
+
public:
|
33
|
+
/**
|
34
|
+
* Construct source location information corresponding to the location of the
|
35
|
+
* call site.
|
36
|
+
*/
|
37
|
+
#if V8_SUPPORTS_SOURCE_LOCATION
|
38
|
+
static constexpr SourceLocation Current(
|
39
|
+
const char* function = __builtin_FUNCTION(),
|
40
|
+
const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) {
|
41
|
+
return SourceLocation(function, file, line);
|
42
|
+
}
|
43
|
+
#else
|
44
|
+
static constexpr SourceLocation Current() { return SourceLocation(); }
|
45
|
+
#endif // V8_SUPPORTS_SOURCE_LOCATION
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Constructs unspecified source location information.
|
49
|
+
*/
|
50
|
+
constexpr SourceLocation() = default;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Returns the name of the function associated with the position represented
|
54
|
+
* by this object, if any.
|
55
|
+
*
|
56
|
+
* \returns the function name as cstring.
|
57
|
+
*/
|
58
|
+
constexpr const char* Function() const { return function_; }
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Returns the name of the current source file represented by this object.
|
62
|
+
*
|
63
|
+
* \returns the file name as cstring.
|
64
|
+
*/
|
65
|
+
constexpr const char* FileName() const { return file_; }
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Returns the line number represented by this object.
|
69
|
+
*
|
70
|
+
* \returns the line number.
|
71
|
+
*/
|
72
|
+
constexpr size_t Line() const { return line_; }
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Returns a human-readable string representing this object.
|
76
|
+
*
|
77
|
+
* \returns a human-readable string representing source location information.
|
78
|
+
*/
|
79
|
+
std::string ToString() const;
|
80
|
+
|
81
|
+
private:
|
82
|
+
constexpr SourceLocation(const char* function, const char* file, size_t line)
|
83
|
+
: function_(function), file_(file), line_(line) {}
|
84
|
+
|
85
|
+
const char* function_ = nullptr;
|
86
|
+
const char* file_ = nullptr;
|
87
|
+
size_t line_ = 0u;
|
88
|
+
};
|
89
|
+
|
90
|
+
} // namespace v8
|
91
|
+
|
92
|
+
#endif // INCLUDE_SOURCE_LOCATION_H_
|
@@ -46,6 +46,10 @@ enum class MeasureMemoryExecution { kDefault, kEager, kLazy };
|
|
46
46
|
*
|
47
47
|
* It specifies the contexts that need to be measured and gets called when
|
48
48
|
* the measurement is completed to report the results.
|
49
|
+
*
|
50
|
+
* Both MeasurementComplete() callbacks will be invoked on completion.
|
51
|
+
* Each implementation of this class should hence implement only one of them,
|
52
|
+
* and leave the other empty.
|
49
53
|
*/
|
50
54
|
class V8_EXPORT MeasureMemoryDelegate {
|
51
55
|
public:
|
@@ -66,10 +70,41 @@ class V8_EXPORT MeasureMemoryDelegate {
|
|
66
70
|
* \param unattributed_size_in_bytes total size of objects that were not
|
67
71
|
* attributed to any context (i.e. are likely shared objects).
|
68
72
|
*/
|
73
|
+
V8_DEPRECATE_SOON("Please use the version that takes a result struct")
|
69
74
|
virtual void MeasurementComplete(
|
70
75
|
const std::vector<std::pair<Local<Context>, size_t>>&
|
71
76
|
context_sizes_in_bytes,
|
72
|
-
size_t unattributed_size_in_bytes)
|
77
|
+
size_t unattributed_size_in_bytes) {}
|
78
|
+
|
79
|
+
/** Holds the result of a memory measurement request. */
|
80
|
+
struct Result {
|
81
|
+
/**
|
82
|
+
* a vector of (context, size) pairs that includes each context for
|
83
|
+
* which ShouldMeasure returned true and that was not garbage collected
|
84
|
+
* while the memory measurement was in progress.
|
85
|
+
*/
|
86
|
+
const std::vector<std::pair<Local<Context>, size_t>>&
|
87
|
+
context_sizes_in_bytes;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* total size of objects that were not attributed to any context (i.e. are
|
91
|
+
* likely shared objects).
|
92
|
+
*/
|
93
|
+
size_t unattributed_size_in_bytes;
|
94
|
+
|
95
|
+
/** total size of generated code for Wasm (shared across contexts). */
|
96
|
+
size_t wasm_code_size_in_bytes;
|
97
|
+
|
98
|
+
/** total size of Wasm metadata (except code; shared across contexts). */
|
99
|
+
size_t wasm_metadata_size_in_bytes;
|
100
|
+
};
|
101
|
+
|
102
|
+
/**
|
103
|
+
* This function is called when memory measurement finishes.
|
104
|
+
*
|
105
|
+
* \param result the result of the measurement.
|
106
|
+
*/
|
107
|
+
virtual void MeasurementComplete(Result result) {}
|
73
108
|
|
74
109
|
/**
|
75
110
|
* Returns a default delegate that resolves the given promise when
|
@@ -33,7 +33,7 @@ enum class GlobalHandleStoreMode {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
V8_EXPORT internal::Address* GlobalizeTracedReference(
|
36
|
-
internal::Isolate* isolate, internal::Address
|
36
|
+
internal::Isolate* isolate, internal::Address value,
|
37
37
|
internal::Address* slot, GlobalHandleStoreMode store_mode);
|
38
38
|
V8_EXPORT void MoveTracedReference(internal::Address** from,
|
39
39
|
internal::Address** to);
|
@@ -43,14 +43,12 @@ V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
|
|
43
43
|
|
44
44
|
} // namespace internal
|
45
45
|
|
46
|
-
|
46
|
+
/**
|
47
|
+
* An indirect handle, where the indirect pointer points to a GlobalHandles
|
48
|
+
* node.
|
49
|
+
*/
|
50
|
+
class TracedReferenceBase : public IndirectHandleBase {
|
47
51
|
public:
|
48
|
-
/**
|
49
|
-
* Returns true if the reference is empty, i.e., has not been assigned
|
50
|
-
* object.
|
51
|
-
*/
|
52
|
-
bool IsEmpty() const { return val_ == nullptr; }
|
53
|
-
|
54
52
|
/**
|
55
53
|
* If non-empty, destroy the underlying storage cell. |IsEmpty| will return
|
56
54
|
* true after this call.
|
@@ -60,10 +58,9 @@ class TracedReferenceBase {
|
|
60
58
|
/**
|
61
59
|
* Construct a Local<Value> from this handle.
|
62
60
|
*/
|
63
|
-
V8_INLINE
|
61
|
+
V8_INLINE Local<Value> Get(Isolate* isolate) const {
|
64
62
|
if (IsEmpty()) return Local<Value>();
|
65
|
-
return Local<Value>::New(isolate,
|
66
|
-
internal::ValueHelper::SlotAsValue<Value>(val_));
|
63
|
+
return Local<Value>::New(isolate, this->value<Value>());
|
67
64
|
}
|
68
65
|
|
69
66
|
/**
|
@@ -86,11 +83,13 @@ class TracedReferenceBase {
|
|
86
83
|
V8_INLINE uint16_t WrapperClassId() const;
|
87
84
|
|
88
85
|
protected:
|
86
|
+
V8_INLINE TracedReferenceBase() = default;
|
87
|
+
|
89
88
|
/**
|
90
89
|
* Update this reference in a thread-safe way.
|
91
90
|
*/
|
92
91
|
void SetSlotThreadSafe(void* new_val) {
|
93
|
-
reinterpret_cast<std::atomic<void*>*>(&
|
92
|
+
reinterpret_cast<std::atomic<void*>*>(&slot())->store(
|
94
93
|
new_val, std::memory_order_relaxed);
|
95
94
|
}
|
96
95
|
|
@@ -98,19 +97,13 @@ class TracedReferenceBase {
|
|
98
97
|
* Get this reference in a thread-safe way
|
99
98
|
*/
|
100
99
|
const void* GetSlotThreadSafe() const {
|
101
|
-
return reinterpret_cast<std::atomic<const void*> const*>(&
|
100
|
+
return reinterpret_cast<std::atomic<const void*> const*>(&slot())->load(
|
102
101
|
std::memory_order_relaxed);
|
103
102
|
}
|
104
103
|
|
105
104
|
V8_EXPORT void CheckValue() const;
|
106
105
|
|
107
|
-
V8_INLINE internal::Address address() const { return *val_; }
|
108
|
-
|
109
|
-
// val_ points to a GlobalHandles node.
|
110
|
-
internal::Address* val_ = nullptr;
|
111
|
-
|
112
106
|
friend class internal::BasicTracedReferenceExtractor;
|
113
|
-
friend class internal::HandleHelper;
|
114
107
|
template <typename F>
|
115
108
|
friend class Local;
|
116
109
|
template <typename U>
|
@@ -139,12 +132,7 @@ class BasicTracedReference : public TracedReferenceBase {
|
|
139
132
|
/**
|
140
133
|
* Construct a Local<T> from this handle.
|
141
134
|
*/
|
142
|
-
Local<T> Get(Isolate* isolate) const {
|
143
|
-
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
144
|
-
if (val_ == nullptr) return Local<T>();
|
145
|
-
#endif
|
146
|
-
return Local<T>::New(isolate, *this);
|
147
|
-
}
|
135
|
+
Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
|
148
136
|
|
149
137
|
template <class S>
|
150
138
|
V8_INLINE BasicTracedReference<S>& As() const {
|
@@ -152,19 +140,17 @@ class BasicTracedReference : public TracedReferenceBase {
|
|
152
140
|
const_cast<BasicTracedReference<T>&>(*this));
|
153
141
|
}
|
154
142
|
|
155
|
-
|
143
|
+
V8_DEPRECATE_SOON("Use Get to convert to Local instead")
|
144
|
+
V8_INLINE T* operator->() const {
|
156
145
|
#ifdef V8_ENABLE_CHECKS
|
157
146
|
CheckValue();
|
158
147
|
#endif // V8_ENABLE_CHECKS
|
159
|
-
return
|
160
|
-
}
|
161
|
-
T* operator*() const {
|
162
|
-
#ifdef V8_ENABLE_CHECKS
|
163
|
-
CheckValue();
|
164
|
-
#endif // V8_ENABLE_CHECKS
|
165
|
-
return reinterpret_cast<T*>(val_);
|
148
|
+
return this->template value<T>();
|
166
149
|
}
|
167
150
|
|
151
|
+
V8_DEPRECATE_SOON("Use Get to convert to Local instead")
|
152
|
+
V8_INLINE T* operator*() const { return this->operator->(); }
|
153
|
+
|
168
154
|
private:
|
169
155
|
/**
|
170
156
|
* An empty BasicTracedReference without storage cell.
|
@@ -172,7 +158,7 @@ class BasicTracedReference : public TracedReferenceBase {
|
|
172
158
|
BasicTracedReference() = default;
|
173
159
|
|
174
160
|
V8_INLINE static internal::Address* New(
|
175
|
-
Isolate* isolate, T* that,
|
161
|
+
Isolate* isolate, T* that, internal::Address** slot,
|
176
162
|
internal::GlobalHandleStoreMode store_mode);
|
177
163
|
|
178
164
|
template <typename F>
|
@@ -199,7 +185,7 @@ class TracedReference : public BasicTracedReference<T> {
|
|
199
185
|
/**
|
200
186
|
* An empty TracedReference without storage cell.
|
201
187
|
*/
|
202
|
-
TracedReference()
|
188
|
+
V8_INLINE TracedReference() = default;
|
203
189
|
|
204
190
|
/**
|
205
191
|
* Construct a TracedReference from a Local.
|
@@ -209,8 +195,9 @@ class TracedReference : public BasicTracedReference<T> {
|
|
209
195
|
*/
|
210
196
|
template <class S>
|
211
197
|
TracedReference(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
|
212
|
-
this->
|
213
|
-
|
198
|
+
this->slot() =
|
199
|
+
this->New(isolate, *that, &this->slot(),
|
200
|
+
internal::GlobalHandleStoreMode::kInitializingStore);
|
214
201
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
215
202
|
}
|
216
203
|
|
@@ -291,18 +278,18 @@ class TracedReference : public BasicTracedReference<T> {
|
|
291
278
|
// --- Implementation ---
|
292
279
|
template <class T>
|
293
280
|
internal::Address* BasicTracedReference<T>::New(
|
294
|
-
Isolate* isolate, T* that,
|
281
|
+
Isolate* isolate, T* that, internal::Address** slot,
|
295
282
|
internal::GlobalHandleStoreMode store_mode) {
|
296
|
-
if (
|
297
|
-
internal::Address* p = reinterpret_cast<internal::Address*>(that);
|
283
|
+
if (internal::ValueHelper::IsEmpty(that)) return nullptr;
|
298
284
|
return internal::GlobalizeTracedReference(
|
299
|
-
reinterpret_cast<internal::Isolate*>(isolate),
|
285
|
+
reinterpret_cast<internal::Isolate*>(isolate),
|
286
|
+
internal::ValueHelper::ValueAsAddress(that),
|
300
287
|
reinterpret_cast<internal::Address*>(slot), store_mode);
|
301
288
|
}
|
302
289
|
|
303
290
|
void TracedReferenceBase::Reset() {
|
304
291
|
if (IsEmpty()) return;
|
305
|
-
internal::DisposeTracedReference(
|
292
|
+
internal::DisposeTracedReference(slot());
|
306
293
|
SetSlotThreadSafe(nullptr);
|
307
294
|
}
|
308
295
|
|
@@ -347,7 +334,7 @@ void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
|
347
334
|
this->Reset();
|
348
335
|
if (other.IsEmpty()) return;
|
349
336
|
this->SetSlotThreadSafe(
|
350
|
-
this->New(isolate, *other, &this->
|
337
|
+
this->New(isolate, *other, &this->slot(),
|
351
338
|
internal::GlobalHandleStoreMode::kAssigningStore));
|
352
339
|
}
|
353
340
|
|
@@ -373,9 +360,7 @@ template <class T>
|
|
373
360
|
TracedReference<T>& TracedReference<T>::operator=(
|
374
361
|
TracedReference&& rhs) noexcept {
|
375
362
|
if (this != &rhs) {
|
376
|
-
internal::MoveTracedReference(
|
377
|
-
reinterpret_cast<internal::Address**>(&rhs.val_),
|
378
|
-
reinterpret_cast<internal::Address**>(&this->val_));
|
363
|
+
internal::MoveTracedReference(&rhs.slot(), &this->slot());
|
379
364
|
}
|
380
365
|
return *this;
|
381
366
|
}
|
@@ -384,10 +369,8 @@ template <class T>
|
|
384
369
|
TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
|
385
370
|
if (this != &rhs) {
|
386
371
|
this->Reset();
|
387
|
-
if (rhs.
|
388
|
-
internal::CopyTracedReference(
|
389
|
-
reinterpret_cast<const internal::Address* const*>(&rhs.val_),
|
390
|
-
reinterpret_cast<internal::Address**>(&this->val_));
|
372
|
+
if (!rhs.IsEmpty()) {
|
373
|
+
internal::CopyTracedReference(&rhs.slot(), &this->slot());
|
391
374
|
}
|
392
375
|
}
|
393
376
|
return *this;
|
@@ -396,16 +379,16 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
|
|
396
379
|
void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
|
397
380
|
using I = internal::Internals;
|
398
381
|
if (IsEmpty()) return;
|
399
|
-
|
400
|
-
|
382
|
+
uint8_t* addr =
|
383
|
+
reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
|
401
384
|
*reinterpret_cast<uint16_t*>(addr) = class_id;
|
402
385
|
}
|
403
386
|
|
404
387
|
uint16_t TracedReferenceBase::WrapperClassId() const {
|
405
388
|
using I = internal::Internals;
|
406
389
|
if (IsEmpty()) return 0;
|
407
|
-
|
408
|
-
|
390
|
+
uint8_t* addr =
|
391
|
+
reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
|
409
392
|
return *reinterpret_cast<uint16_t*>(addr);
|
410
393
|
}
|
411
394
|
|
data/vendor/v8/include/v8-util.h
CHANGED
@@ -182,7 +182,7 @@ class PersistentValueMapBase {
|
|
182
182
|
*/
|
183
183
|
Local<V> Get(const K& key) {
|
184
184
|
V* p = FromVal(Traits::Get(&impl_, key));
|
185
|
-
#ifdef
|
185
|
+
#ifdef V8_ENABLE_DIRECT_LOCAL
|
186
186
|
if (p == nullptr) return Local<V>();
|
187
187
|
#endif
|
188
188
|
return Local<V>::New(isolate_, p);
|
@@ -302,13 +302,13 @@ class PersistentValueMapBase {
|
|
302
302
|
}
|
303
303
|
|
304
304
|
static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
|
305
|
-
|
306
|
-
persistent->
|
307
|
-
return reinterpret_cast<PersistentContainerValue>(
|
305
|
+
internal::Address* address = persistent->slot();
|
306
|
+
persistent->Clear();
|
307
|
+
return reinterpret_cast<PersistentContainerValue>(address);
|
308
308
|
}
|
309
309
|
|
310
310
|
static PersistentContainerValue Leak(Global<V>* persistent) {
|
311
|
-
return reinterpret_cast<PersistentContainerValue>(persistent->
|
311
|
+
return reinterpret_cast<PersistentContainerValue>(persistent->slot());
|
312
312
|
}
|
313
313
|
|
314
314
|
/**
|
@@ -318,7 +318,7 @@ class PersistentValueMapBase {
|
|
318
318
|
*/
|
319
319
|
static Global<V> Release(PersistentContainerValue v) {
|
320
320
|
Global<V> p;
|
321
|
-
p.
|
321
|
+
p.slot() = reinterpret_cast<internal::Address*>(FromVal(v));
|
322
322
|
if (Traits::kCallbackType != kNotWeak && p.IsWeak()) {
|
323
323
|
Traits::DisposeCallbackData(
|
324
324
|
p.template ClearWeak<typename Traits::WeakCallbackDataType>());
|
@@ -328,7 +328,8 @@ class PersistentValueMapBase {
|
|
328
328
|
|
329
329
|
void RemoveWeak(const K& key) {
|
330
330
|
Global<V> p;
|
331
|
-
p.
|
331
|
+
p.slot() = reinterpret_cast<internal::Address*>(
|
332
|
+
FromVal(Traits::Remove(&impl_, key)));
|
332
333
|
p.Reset();
|
333
334
|
}
|
334
335
|
|
@@ -396,7 +397,7 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
396
397
|
Traits::kCallbackType == kWeakWithInternalFields
|
397
398
|
? WeakCallbackType::kInternalFields
|
398
399
|
: WeakCallbackType::kParameter;
|
399
|
-
|
400
|
+
auto value = Local<V>::New(this->isolate(), *persistent);
|
400
401
|
persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
|
401
402
|
Traits::WeakCallbackParameter(this, key, value), WeakCallback,
|
402
403
|
callback_type);
|
@@ -472,7 +473,7 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
472
473
|
Traits::kCallbackType == kWeakWithInternalFields
|
473
474
|
? WeakCallbackType::kInternalFields
|
474
475
|
: WeakCallbackType::kParameter;
|
475
|
-
|
476
|
+
auto value = Local<V>::New(this->isolate(), *persistent);
|
476
477
|
persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
|
477
478
|
Traits::WeakCallbackParameter(this, key, value), OnWeakCallback,
|
478
479
|
callback_type);
|
@@ -629,7 +630,8 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
|
|
629
630
|
size_t length = Traits::Size(&impl_);
|
630
631
|
for (size_t i = 0; i < length; i++) {
|
631
632
|
Global<V> p;
|
632
|
-
p.
|
633
|
+
p.slot() =
|
634
|
+
reinterpret_cast<internal::Address>(FromVal(Traits::Get(&impl_, i)));
|
633
635
|
}
|
634
636
|
Traits::Clear(&impl_);
|
635
637
|
}
|
@@ -644,9 +646,9 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
|
|
644
646
|
|
645
647
|
private:
|
646
648
|
static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
|
647
|
-
|
648
|
-
persistent->
|
649
|
-
return reinterpret_cast<PersistentContainerValue>(
|
649
|
+
auto slot = persistent->slot();
|
650
|
+
persistent->Clear();
|
651
|
+
return reinterpret_cast<PersistentContainerValue>(slot);
|
650
652
|
}
|
651
653
|
|
652
654
|
static V* FromVal(PersistentContainerValue v) {
|
@@ -75,6 +75,20 @@ class V8_EXPORT ValueSerializer {
|
|
75
75
|
*/
|
76
76
|
virtual void ThrowDataCloneError(Local<String> message) = 0;
|
77
77
|
|
78
|
+
/**
|
79
|
+
* The embedder overrides this method to enable custom host object filter
|
80
|
+
* with Delegate::IsHostObject.
|
81
|
+
*
|
82
|
+
* This method is called at most once per serializer.
|
83
|
+
*/
|
84
|
+
virtual bool HasCustomHostObject(Isolate* isolate);
|
85
|
+
|
86
|
+
/**
|
87
|
+
* The embedder overrides this method to determine if an JS object is a
|
88
|
+
* host object and needs to be serialized by the host.
|
89
|
+
*/
|
90
|
+
virtual Maybe<bool> IsHostObject(Isolate* isolate, Local<Object> object);
|
91
|
+
|
78
92
|
/**
|
79
93
|
* The embedder overrides this method to write some kind of host object, if
|
80
94
|
* possible. If not, a suitable exception should be thrown and
|
@@ -16,6 +16,8 @@
|
|
16
16
|
*/
|
17
17
|
namespace v8 {
|
18
18
|
|
19
|
+
class Primiitive;
|
20
|
+
class Numeric;
|
19
21
|
class BigInt;
|
20
22
|
class Int32;
|
21
23
|
class Integer;
|
@@ -354,6 +356,18 @@ class V8_EXPORT Value : public Data {
|
|
354
356
|
*/
|
355
357
|
bool IsModuleNamespaceObject() const;
|
356
358
|
|
359
|
+
/**
|
360
|
+
* Perform `ToPrimitive(value)` as specified in:
|
361
|
+
* https://tc39.es/ecma262/#sec-toprimitive.
|
362
|
+
*/
|
363
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Primitive> ToPrimitive(
|
364
|
+
Local<Context> context) const;
|
365
|
+
/**
|
366
|
+
* Perform `ToNumeric(value)` as specified in:
|
367
|
+
* https://tc39.es/ecma262/#sec-tonumeric.
|
368
|
+
*/
|
369
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Numeric> ToNumeric(
|
370
|
+
Local<Context> context) const;
|
357
371
|
/**
|
358
372
|
* Perform the equivalent of `BigInt(value)` in JS.
|
359
373
|
*/
|