libv8 6.7.288.46.1-universal-darwin-17 → 7.3.492.27.1-universal-darwin-17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/libplatform/libplatform.h +1 -6
- data/vendor/v8/include/libplatform/v8-tracing.h +7 -5
- data/vendor/v8/include/v8-inspector.h +14 -7
- data/vendor/v8/include/v8-internal.h +373 -0
- data/vendor/v8/include/v8-platform.h +66 -101
- data/vendor/v8/include/v8-profiler.h +157 -31
- data/vendor/v8/include/v8-util.h +27 -13
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +1192 -967
- data/vendor/v8/include/v8config.h +33 -72
- data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13a573497d87c7f9ef59f04ca1a0d091010e5800c1fa13617a4da06698c7df4e
|
4
|
+
data.tar.gz: ed6545476a3271d872e7af5ec688a9231e49484a01839de9568b523a413012dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1f4fe095a1a97fee0189bfa8fbf4c8d915ef5cb84e87289fe8deb5252f7d9413cd2b905f652adaa6844fe949426a7b6eb534448d90aa8377bcf5771dda63bb4
|
7
|
+
data.tar.gz: b3a022a082c9466175f6eb28fc079b589dbae9600e213eb0346c0c56d0043442d4ff034ccd2be64389be716e8de408f93e09a40c7134e63655c6a99b5e3ee218
|
data/lib/libv8/version.rb
CHANGED
@@ -41,7 +41,7 @@ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
|
|
41
41
|
InProcessStackDumping::kDisabled,
|
42
42
|
std::unique_ptr<v8::TracingController> tracing_controller = {});
|
43
43
|
|
44
|
-
V8_PLATFORM_EXPORT
|
44
|
+
V8_PLATFORM_EXPORT V8_DEPRECATED(
|
45
45
|
"Use NewDefaultPlatform instead",
|
46
46
|
v8::Platform* CreateDefaultPlatform(
|
47
47
|
int thread_pool_size = 0,
|
@@ -62,11 +62,6 @@ V8_PLATFORM_EXPORT bool PumpMessageLoop(
|
|
62
62
|
v8::Platform* platform, v8::Isolate* isolate,
|
63
63
|
MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
|
64
64
|
|
65
|
-
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
|
66
|
-
"This function has become obsolete and is essentially a nop",
|
67
|
-
void EnsureEventLoopInitialized(v8::Platform* platform,
|
68
|
-
v8::Isolate* isolate));
|
69
|
-
|
70
65
|
/**
|
71
66
|
* Runs pending idle tasks for at most |idle_time_in_seconds| seconds.
|
72
67
|
*
|
@@ -35,7 +35,7 @@ class V8_PLATFORM_EXPORT TraceObject {
|
|
35
35
|
const char* as_string;
|
36
36
|
};
|
37
37
|
|
38
|
-
TraceObject()
|
38
|
+
TraceObject() = default;
|
39
39
|
~TraceObject();
|
40
40
|
void Initialize(
|
41
41
|
char phase, const uint8_t* category_enabled_flag, const char* name,
|
@@ -106,12 +106,14 @@ class V8_PLATFORM_EXPORT TraceObject {
|
|
106
106
|
|
107
107
|
class V8_PLATFORM_EXPORT TraceWriter {
|
108
108
|
public:
|
109
|
-
TraceWriter()
|
110
|
-
virtual ~TraceWriter()
|
109
|
+
TraceWriter() = default;
|
110
|
+
virtual ~TraceWriter() = default;
|
111
111
|
virtual void AppendTraceEvent(TraceObject* trace_event) = 0;
|
112
112
|
virtual void Flush() = 0;
|
113
113
|
|
114
114
|
static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
|
115
|
+
static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
|
116
|
+
const std::string& tag);
|
115
117
|
|
116
118
|
private:
|
117
119
|
// Disallow copy and assign
|
@@ -145,8 +147,8 @@ class V8_PLATFORM_EXPORT TraceBufferChunk {
|
|
145
147
|
|
146
148
|
class V8_PLATFORM_EXPORT TraceBuffer {
|
147
149
|
public:
|
148
|
-
TraceBuffer()
|
149
|
-
virtual ~TraceBuffer()
|
150
|
+
TraceBuffer() = default;
|
151
|
+
virtual ~TraceBuffer() = default;
|
150
152
|
|
151
153
|
virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0;
|
152
154
|
virtual TraceObject* GetEventByHandle(uint64_t handle) = 0;
|
@@ -62,7 +62,7 @@ class V8_EXPORT StringView {
|
|
62
62
|
|
63
63
|
class V8_EXPORT StringBuffer {
|
64
64
|
public:
|
65
|
-
virtual ~StringBuffer()
|
65
|
+
virtual ~StringBuffer() = default;
|
66
66
|
virtual const StringView& string() = 0;
|
67
67
|
// This method copies contents.
|
68
68
|
static std::unique_ptr<StringBuffer> create(const StringView&);
|
@@ -99,6 +99,7 @@ class V8_EXPORT V8ContextInfo {
|
|
99
99
|
|
100
100
|
class V8_EXPORT V8StackTrace {
|
101
101
|
public:
|
102
|
+
virtual StringView firstNonEmptySourceURL() const = 0;
|
102
103
|
virtual bool isEmpty() const = 0;
|
103
104
|
virtual StringView topSourceURL() const = 0;
|
104
105
|
virtual int topLineNumber() const = 0;
|
@@ -106,7 +107,7 @@ class V8_EXPORT V8StackTrace {
|
|
106
107
|
virtual StringView topScriptId() const = 0;
|
107
108
|
virtual StringView topFunctionName() const = 0;
|
108
109
|
|
109
|
-
virtual ~V8StackTrace()
|
110
|
+
virtual ~V8StackTrace() = default;
|
110
111
|
virtual std::unique_ptr<protocol::Runtime::API::StackTrace>
|
111
112
|
buildInspectorObject() const = 0;
|
112
113
|
virtual std::unique_ptr<StringBuffer> toString() const = 0;
|
@@ -117,13 +118,13 @@ class V8_EXPORT V8StackTrace {
|
|
117
118
|
|
118
119
|
class V8_EXPORT V8InspectorSession {
|
119
120
|
public:
|
120
|
-
virtual ~V8InspectorSession()
|
121
|
+
virtual ~V8InspectorSession() = default;
|
121
122
|
|
122
123
|
// Cross-context inspectable values (DOM nodes in different worlds, etc.).
|
123
124
|
class V8_EXPORT Inspectable {
|
124
125
|
public:
|
125
126
|
virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
|
126
|
-
virtual ~Inspectable()
|
127
|
+
virtual ~Inspectable() = default;
|
127
128
|
};
|
128
129
|
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
|
129
130
|
|
@@ -161,7 +162,7 @@ class V8_EXPORT V8InspectorSession {
|
|
161
162
|
|
162
163
|
class V8_EXPORT V8InspectorClient {
|
163
164
|
public:
|
164
|
-
virtual ~V8InspectorClient()
|
165
|
+
virtual ~V8InspectorClient() = default;
|
165
166
|
|
166
167
|
virtual void runMessageLoopOnPause(int contextGroupId) {}
|
167
168
|
virtual void quitMessageLoopOnPause() {}
|
@@ -214,6 +215,11 @@ class V8_EXPORT V8InspectorClient {
|
|
214
215
|
virtual bool canExecuteScripts(int contextGroupId) { return true; }
|
215
216
|
|
216
217
|
virtual void maxAsyncCallStackDepthChanged(int depth) {}
|
218
|
+
|
219
|
+
virtual std::unique_ptr<StringBuffer> resourceNameToUrl(
|
220
|
+
const StringView& resourceName) {
|
221
|
+
return nullptr;
|
222
|
+
}
|
217
223
|
};
|
218
224
|
|
219
225
|
// These stack trace ids are intended to be passed between debuggers and be
|
@@ -233,12 +239,13 @@ struct V8_EXPORT V8StackTraceId {
|
|
233
239
|
class V8_EXPORT V8Inspector {
|
234
240
|
public:
|
235
241
|
static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
|
236
|
-
virtual ~V8Inspector()
|
242
|
+
virtual ~V8Inspector() = default;
|
237
243
|
|
238
244
|
// Contexts instrumentation.
|
239
245
|
virtual void contextCreated(const V8ContextInfo&) = 0;
|
240
246
|
virtual void contextDestroyed(v8::Local<v8::Context>) = 0;
|
241
247
|
virtual void resetContextGroup(int contextGroupId) = 0;
|
248
|
+
virtual v8::MaybeLocal<v8::Context> contextById(int contextId) = 0;
|
242
249
|
|
243
250
|
// Various instrumentation.
|
244
251
|
virtual void idleStarted() = 0;
|
@@ -269,7 +276,7 @@ class V8_EXPORT V8Inspector {
|
|
269
276
|
// Connection.
|
270
277
|
class V8_EXPORT Channel {
|
271
278
|
public:
|
272
|
-
virtual ~Channel()
|
279
|
+
virtual ~Channel() = default;
|
273
280
|
virtual void sendResponse(int callId,
|
274
281
|
std::unique_ptr<StringBuffer> message) = 0;
|
275
282
|
virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
|
@@ -0,0 +1,373 @@
|
|
1
|
+
// Copyright 2018 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_V8_INTERNAL_H_
|
6
|
+
#define INCLUDE_V8_INTERNAL_H_
|
7
|
+
|
8
|
+
#include <stddef.h>
|
9
|
+
#include <stdint.h>
|
10
|
+
#include <type_traits>
|
11
|
+
|
12
|
+
#include "v8-version.h" // NOLINT(build/include)
|
13
|
+
#include "v8config.h" // NOLINT(build/include)
|
14
|
+
|
15
|
+
namespace v8 {
|
16
|
+
|
17
|
+
class Context;
|
18
|
+
class Data;
|
19
|
+
class Isolate;
|
20
|
+
|
21
|
+
namespace internal {
|
22
|
+
|
23
|
+
class Isolate;
|
24
|
+
|
25
|
+
typedef uintptr_t Address;
|
26
|
+
static const Address kNullAddress = 0;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Configuration of tagging scheme.
|
30
|
+
*/
|
31
|
+
const int kApiSystemPointerSize = sizeof(void*);
|
32
|
+
const int kApiTaggedSize = kApiSystemPointerSize;
|
33
|
+
const int kApiDoubleSize = sizeof(double);
|
34
|
+
const int kApiIntSize = sizeof(int);
|
35
|
+
const int kApiInt64Size = sizeof(int64_t);
|
36
|
+
|
37
|
+
// Tag information for HeapObject.
|
38
|
+
const int kHeapObjectTag = 1;
|
39
|
+
const int kWeakHeapObjectTag = 3;
|
40
|
+
const int kHeapObjectTagSize = 2;
|
41
|
+
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
|
42
|
+
|
43
|
+
// Tag information for Smi.
|
44
|
+
const int kSmiTag = 0;
|
45
|
+
const int kSmiTagSize = 1;
|
46
|
+
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
|
47
|
+
|
48
|
+
template <size_t tagged_ptr_size>
|
49
|
+
struct SmiTagging;
|
50
|
+
|
51
|
+
// Smi constants for systems where tagged pointer is a 32-bit value.
|
52
|
+
template <>
|
53
|
+
struct SmiTagging<4> {
|
54
|
+
enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
|
55
|
+
V8_INLINE static int SmiToInt(const internal::Address value) {
|
56
|
+
int shift_bits = kSmiTagSize + kSmiShiftSize;
|
57
|
+
// Shift down (requires >> to be sign extending).
|
58
|
+
return static_cast<int>(static_cast<intptr_t>(value)) >> shift_bits;
|
59
|
+
}
|
60
|
+
V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
|
61
|
+
// To be representable as an tagged small integer, the two
|
62
|
+
// most-significant bits of 'value' must be either 00 or 11 due to
|
63
|
+
// sign-extension. To check this we add 01 to the two
|
64
|
+
// most-significant bits, and check if the most-significant bit is 0.
|
65
|
+
//
|
66
|
+
// CAUTION: The original code below:
|
67
|
+
// bool result = ((value + 0x40000000) & 0x80000000) == 0;
|
68
|
+
// may lead to incorrect results according to the C language spec, and
|
69
|
+
// in fact doesn't work correctly with gcc4.1.1 in some cases: The
|
70
|
+
// compiler may produce undefined results in case of signed integer
|
71
|
+
// overflow. The computation must be done w/ unsigned ints.
|
72
|
+
return static_cast<uintptr_t>(value) + 0x40000000U < 0x80000000U;
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
// Smi constants for systems where tagged pointer is a 64-bit value.
|
77
|
+
template <>
|
78
|
+
struct SmiTagging<8> {
|
79
|
+
enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
|
80
|
+
V8_INLINE static int SmiToInt(const internal::Address value) {
|
81
|
+
int shift_bits = kSmiTagSize + kSmiShiftSize;
|
82
|
+
// Shift down and throw away top 32 bits.
|
83
|
+
return static_cast<int>(static_cast<intptr_t>(value) >> shift_bits);
|
84
|
+
}
|
85
|
+
V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
|
86
|
+
// To be representable as a long smi, the value must be a 32-bit integer.
|
87
|
+
return (value == static_cast<int32_t>(value));
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
#if defined(V8_COMPRESS_POINTERS)
|
92
|
+
static_assert(
|
93
|
+
kApiSystemPointerSize == kApiInt64Size,
|
94
|
+
"Pointer compression can be enabled only for 64-bit architectures");
|
95
|
+
#endif
|
96
|
+
|
97
|
+
#if defined(V8_COMPRESS_POINTERS) || defined(V8_31BIT_SMIS_ON_64BIT_ARCH)
|
98
|
+
typedef SmiTagging<kApiIntSize> PlatformSmiTagging;
|
99
|
+
#else
|
100
|
+
typedef SmiTagging<kApiSystemPointerSize> PlatformSmiTagging;
|
101
|
+
#endif
|
102
|
+
|
103
|
+
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
|
104
|
+
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
|
105
|
+
const int kSmiMinValue = (static_cast<unsigned int>(-1)) << (kSmiValueSize - 1);
|
106
|
+
const int kSmiMaxValue = -(kSmiMinValue + 1);
|
107
|
+
constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
|
108
|
+
constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
|
109
|
+
|
110
|
+
V8_INLINE static constexpr internal::Address IntToSmi(int value) {
|
111
|
+
return (static_cast<Address>(value) << (kSmiTagSize + kSmiShiftSize)) |
|
112
|
+
kSmiTag;
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* This class exports constants and functionality from within v8 that
|
117
|
+
* is necessary to implement inline functions in the v8 api. Don't
|
118
|
+
* depend on functions and constants defined here.
|
119
|
+
*/
|
120
|
+
class Internals {
|
121
|
+
public:
|
122
|
+
// These values match non-compiler-dependent values defined within
|
123
|
+
// the implementation of v8.
|
124
|
+
static const int kHeapObjectMapOffset = 0;
|
125
|
+
static const int kMapInstanceTypeOffset = 1 * kApiTaggedSize + kApiIntSize;
|
126
|
+
static const int kStringResourceOffset = 1 * kApiTaggedSize + 2 * kApiIntSize;
|
127
|
+
|
128
|
+
static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize;
|
129
|
+
static const int kForeignAddressOffset = kApiTaggedSize;
|
130
|
+
static const int kJSObjectHeaderSize = 3 * kApiTaggedSize;
|
131
|
+
static const int kJSObjectHeaderSizeForEmbedderFields =
|
132
|
+
(kJSObjectHeaderSize + kApiSystemPointerSize - 1) &
|
133
|
+
-kApiSystemPointerSize;
|
134
|
+
static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize;
|
135
|
+
static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize;
|
136
|
+
static const int kEmbedderDataSlotSize =
|
137
|
+
#ifdef V8_COMPRESS_POINTERS
|
138
|
+
2 *
|
139
|
+
#endif
|
140
|
+
kApiSystemPointerSize;
|
141
|
+
static const int kNativeContextEmbedderDataOffset = 7 * kApiTaggedSize;
|
142
|
+
static const int kFullStringRepresentationMask = 0x0f;
|
143
|
+
static const int kStringEncodingMask = 0x8;
|
144
|
+
static const int kExternalTwoByteRepresentationTag = 0x02;
|
145
|
+
static const int kExternalOneByteRepresentationTag = 0x0a;
|
146
|
+
|
147
|
+
static const uint32_t kNumIsolateDataSlots = 4;
|
148
|
+
|
149
|
+
static const int kIsolateEmbedderDataOffset = 0;
|
150
|
+
static const int kExternalMemoryOffset =
|
151
|
+
kNumIsolateDataSlots * kApiTaggedSize;
|
152
|
+
static const int kExternalMemoryLimitOffset =
|
153
|
+
kExternalMemoryOffset + kApiInt64Size;
|
154
|
+
static const int kExternalMemoryAtLastMarkCompactOffset =
|
155
|
+
kExternalMemoryLimitOffset + kApiInt64Size;
|
156
|
+
static const int kIsolateRootsOffset =
|
157
|
+
kExternalMemoryAtLastMarkCompactOffset + kApiInt64Size;
|
158
|
+
|
159
|
+
static const int kUndefinedValueRootIndex = 4;
|
160
|
+
static const int kTheHoleValueRootIndex = 5;
|
161
|
+
static const int kNullValueRootIndex = 6;
|
162
|
+
static const int kTrueValueRootIndex = 7;
|
163
|
+
static const int kFalseValueRootIndex = 8;
|
164
|
+
static const int kEmptyStringRootIndex = 9;
|
165
|
+
|
166
|
+
static const int kNodeClassIdOffset = 1 * kApiTaggedSize;
|
167
|
+
static const int kNodeFlagsOffset = 1 * kApiTaggedSize + 3;
|
168
|
+
static const int kNodeStateMask = 0x7;
|
169
|
+
static const int kNodeStateIsWeakValue = 2;
|
170
|
+
static const int kNodeStateIsPendingValue = 3;
|
171
|
+
static const int kNodeStateIsNearDeathValue = 4;
|
172
|
+
static const int kNodeIsIndependentShift = 3;
|
173
|
+
static const int kNodeIsActiveShift = 4;
|
174
|
+
|
175
|
+
static const int kFirstNonstringType = 0x80;
|
176
|
+
static const int kOddballType = 0x83;
|
177
|
+
static const int kForeignType = 0x87;
|
178
|
+
static const int kJSSpecialApiObjectType = 0x410;
|
179
|
+
static const int kJSApiObjectType = 0x420;
|
180
|
+
static const int kJSObjectType = 0x421;
|
181
|
+
|
182
|
+
static const int kUndefinedOddballKind = 5;
|
183
|
+
static const int kNullOddballKind = 3;
|
184
|
+
|
185
|
+
// Soft limit for AdjustAmountofExternalAllocatedMemory. Trigger an
|
186
|
+
// incremental GC once the external memory reaches this limit.
|
187
|
+
static constexpr int kExternalAllocationSoftLimit = 64 * 1024 * 1024;
|
188
|
+
|
189
|
+
V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
|
190
|
+
V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
|
191
|
+
#ifdef V8_ENABLE_CHECKS
|
192
|
+
CheckInitializedImpl(isolate);
|
193
|
+
#endif
|
194
|
+
}
|
195
|
+
|
196
|
+
V8_INLINE static bool HasHeapObjectTag(const internal::Address value) {
|
197
|
+
return (value & kHeapObjectTagMask) == static_cast<Address>(kHeapObjectTag);
|
198
|
+
}
|
199
|
+
|
200
|
+
V8_INLINE static int SmiValue(const internal::Address value) {
|
201
|
+
return PlatformSmiTagging::SmiToInt(value);
|
202
|
+
}
|
203
|
+
|
204
|
+
V8_INLINE static constexpr internal::Address IntToSmi(int value) {
|
205
|
+
return internal::IntToSmi(value);
|
206
|
+
}
|
207
|
+
|
208
|
+
V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
|
209
|
+
return PlatformSmiTagging::IsValidSmi(value);
|
210
|
+
}
|
211
|
+
|
212
|
+
V8_INLINE static int GetInstanceType(const internal::Address obj) {
|
213
|
+
typedef internal::Address A;
|
214
|
+
A map = ReadTaggedPointerField(obj, kHeapObjectMapOffset);
|
215
|
+
return ReadRawField<uint16_t>(map, kMapInstanceTypeOffset);
|
216
|
+
}
|
217
|
+
|
218
|
+
V8_INLINE static int GetOddballKind(const internal::Address obj) {
|
219
|
+
return SmiValue(ReadTaggedSignedField(obj, kOddballKindOffset));
|
220
|
+
}
|
221
|
+
|
222
|
+
V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
|
223
|
+
int representation = (instance_type & kFullStringRepresentationMask);
|
224
|
+
return representation == kExternalTwoByteRepresentationTag;
|
225
|
+
}
|
226
|
+
|
227
|
+
V8_INLINE static uint8_t GetNodeFlag(internal::Address* obj, int shift) {
|
228
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
229
|
+
return *addr & static_cast<uint8_t>(1U << shift);
|
230
|
+
}
|
231
|
+
|
232
|
+
V8_INLINE static void UpdateNodeFlag(internal::Address* obj, bool value,
|
233
|
+
int shift) {
|
234
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
235
|
+
uint8_t mask = static_cast<uint8_t>(1U << shift);
|
236
|
+
*addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
|
237
|
+
}
|
238
|
+
|
239
|
+
V8_INLINE static uint8_t GetNodeState(internal::Address* obj) {
|
240
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
241
|
+
return *addr & kNodeStateMask;
|
242
|
+
}
|
243
|
+
|
244
|
+
V8_INLINE static void UpdateNodeState(internal::Address* obj, uint8_t value) {
|
245
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
246
|
+
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
|
247
|
+
}
|
248
|
+
|
249
|
+
V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, uint32_t slot,
|
250
|
+
void* data) {
|
251
|
+
internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
|
252
|
+
kIsolateEmbedderDataOffset +
|
253
|
+
slot * kApiSystemPointerSize;
|
254
|
+
*reinterpret_cast<void**>(addr) = data;
|
255
|
+
}
|
256
|
+
|
257
|
+
V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
|
258
|
+
uint32_t slot) {
|
259
|
+
internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
|
260
|
+
kIsolateEmbedderDataOffset +
|
261
|
+
slot * kApiSystemPointerSize;
|
262
|
+
return *reinterpret_cast<void* const*>(addr);
|
263
|
+
}
|
264
|
+
|
265
|
+
V8_INLINE static internal::Address* GetRoot(v8::Isolate* isolate, int index) {
|
266
|
+
internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
|
267
|
+
kIsolateRootsOffset +
|
268
|
+
index * kApiSystemPointerSize;
|
269
|
+
return reinterpret_cast<internal::Address*>(addr);
|
270
|
+
}
|
271
|
+
|
272
|
+
template <typename T>
|
273
|
+
V8_INLINE static T ReadRawField(internal::Address heap_object_ptr,
|
274
|
+
int offset) {
|
275
|
+
internal::Address addr = heap_object_ptr + offset - kHeapObjectTag;
|
276
|
+
return *reinterpret_cast<const T*>(addr);
|
277
|
+
}
|
278
|
+
|
279
|
+
V8_INLINE static internal::Address ReadTaggedPointerField(
|
280
|
+
internal::Address heap_object_ptr, int offset) {
|
281
|
+
#ifdef V8_COMPRESS_POINTERS
|
282
|
+
int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
|
283
|
+
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
|
284
|
+
return root + static_cast<internal::Address>(static_cast<intptr_t>(value));
|
285
|
+
#else
|
286
|
+
return ReadRawField<internal::Address>(heap_object_ptr, offset);
|
287
|
+
#endif
|
288
|
+
}
|
289
|
+
|
290
|
+
V8_INLINE static internal::Address ReadTaggedSignedField(
|
291
|
+
internal::Address heap_object_ptr, int offset) {
|
292
|
+
#ifdef V8_COMPRESS_POINTERS
|
293
|
+
int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
|
294
|
+
return static_cast<internal::Address>(static_cast<intptr_t>(value));
|
295
|
+
#else
|
296
|
+
return ReadRawField<internal::Address>(heap_object_ptr, offset);
|
297
|
+
#endif
|
298
|
+
}
|
299
|
+
|
300
|
+
V8_INLINE static internal::Address ReadTaggedAnyField(
|
301
|
+
internal::Address heap_object_ptr, int offset) {
|
302
|
+
#ifdef V8_COMPRESS_POINTERS
|
303
|
+
int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
|
304
|
+
internal::Address root_mask = static_cast<internal::Address>(
|
305
|
+
-static_cast<intptr_t>(value & kSmiTagMask));
|
306
|
+
internal::Address root_or_zero =
|
307
|
+
root_mask & GetRootFromOnHeapAddress(heap_object_ptr);
|
308
|
+
return root_or_zero +
|
309
|
+
static_cast<internal::Address>(static_cast<intptr_t>(value));
|
310
|
+
#else
|
311
|
+
return ReadRawField<internal::Address>(heap_object_ptr, offset);
|
312
|
+
#endif
|
313
|
+
}
|
314
|
+
|
315
|
+
#ifdef V8_COMPRESS_POINTERS
|
316
|
+
static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32;
|
317
|
+
static constexpr size_t kPtrComprIsolateRootBias =
|
318
|
+
kPtrComprHeapReservationSize / 2;
|
319
|
+
static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32;
|
320
|
+
|
321
|
+
V8_INLINE static internal::Address GetRootFromOnHeapAddress(
|
322
|
+
internal::Address addr) {
|
323
|
+
return (addr + kPtrComprIsolateRootBias) &
|
324
|
+
-static_cast<intptr_t>(kPtrComprIsolateRootAlignment);
|
325
|
+
}
|
326
|
+
|
327
|
+
#else
|
328
|
+
|
329
|
+
template <typename T>
|
330
|
+
V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
|
331
|
+
typedef internal::Address A;
|
332
|
+
typedef internal::Internals I;
|
333
|
+
A ctx = *reinterpret_cast<const A*>(context);
|
334
|
+
A embedder_data =
|
335
|
+
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
336
|
+
int value_offset =
|
337
|
+
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
338
|
+
return I::ReadRawField<T>(embedder_data, value_offset);
|
339
|
+
}
|
340
|
+
#endif // V8_COMPRESS_POINTERS
|
341
|
+
};
|
342
|
+
|
343
|
+
// Only perform cast check for types derived from v8::Data since
|
344
|
+
// other types do not implement the Cast method.
|
345
|
+
template <bool PerformCheck>
|
346
|
+
struct CastCheck {
|
347
|
+
template <class T>
|
348
|
+
static void Perform(T* data);
|
349
|
+
};
|
350
|
+
|
351
|
+
template <>
|
352
|
+
template <class T>
|
353
|
+
void CastCheck<true>::Perform(T* data) {
|
354
|
+
T::Cast(data);
|
355
|
+
}
|
356
|
+
|
357
|
+
template <>
|
358
|
+
template <class T>
|
359
|
+
void CastCheck<false>::Perform(T* data) {}
|
360
|
+
|
361
|
+
template <class T>
|
362
|
+
V8_INLINE void PerformCastCheck(T* data) {
|
363
|
+
CastCheck<std::is_base_of<Data, T>::value>::Perform(data);
|
364
|
+
}
|
365
|
+
|
366
|
+
// {obj} must be the raw tagged pointer representation of a HeapObject
|
367
|
+
// that's guaranteed to never be in ReadOnlySpace.
|
368
|
+
V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj);
|
369
|
+
|
370
|
+
} // namespace internal
|
371
|
+
} // namespace v8
|
372
|
+
|
373
|
+
#endif // INCLUDE_V8_INTERNAL_H_
|