Skip to content

Commit b4239fa

Browse files
authored
feat: Update V8 to 9.2.230.18 (#121)
1 parent aa367d7 commit b4239fa

File tree

160 files changed

+2653
-2129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2653
-2129
lines changed

NativeScript/NativeScript-Prefix.pch

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define SIZEOF_OFF_T 8
88
#endif
99

10+
#define V8_ENABLE_WEBASSEMBLY 0
1011
#define V8_CONCURRENT_MARKING 1
1112
#define V8_ARRAY_BUFFER_EXTENSION 1
1213
#define V8_ENABLE_LAZY_SOURCE_POSITIONS 1

NativeScript/include/cppgc/common.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010

1111
namespace cppgc {
1212

13-
// Indicator for the stack state of the embedder.
13+
/**
14+
* Indicator for the stack state of the embedder.
15+
*/
1416
enum class EmbedderStackState {
17+
/**
18+
* Stack may contain interesting heap pointers.
19+
*/
1520
kMayContainHeapPointers,
21+
/**
22+
* Stack does not contain any interesting heap pointers.
23+
*/
1624
kNoHeapPointers,
17-
kUnknown V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") =
18-
kMayContainHeapPointers,
19-
kNonEmpty V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") =
20-
kMayContainHeapPointers,
21-
kEmpty V8_ENUM_DEPRECATE_SOON("Use kNoHeapPointers") = kNoHeapPointers,
2225
};
2326

2427
} // namespace cppgc

NativeScript/include/libplatform/v8-tracing.h

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class V8_PLATFORM_EXPORT TraceWriter {
125125
static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
126126
const std::string& tag);
127127

128+
static TraceWriter* CreateSystemInstrumentationTraceWriter();
129+
128130
private:
129131
// Disallow copy and assign
130132
TraceWriter(const TraceWriter&) = delete;

NativeScript/include/v8-inspector.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ class V8_EXPORT V8StackTrace {
105105
virtual StringView topSourceURL() const = 0;
106106
virtual int topLineNumber() const = 0;
107107
virtual int topColumnNumber() const = 0;
108-
virtual StringView topScriptId() const = 0;
108+
virtual int topScriptId() const = 0;
109+
V8_DEPRECATE_SOON("Use V8::StackTrace::topScriptId() instead.")
110+
int topScriptIdAsInteger() const { return topScriptId(); }
109111
virtual StringView topFunctionName() const = 0;
110112

111113
virtual ~V8StackTrace() = default;
@@ -129,6 +131,10 @@ class V8_EXPORT V8InspectorSession {
129131
virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
130132
virtual ~Inspectable() = default;
131133
};
134+
class V8_EXPORT CommandLineAPIScope {
135+
public:
136+
virtual ~CommandLineAPIScope() = default;
137+
};
132138
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
133139

134140
// Dispatching protocol messages.
@@ -138,6 +144,9 @@ class V8_EXPORT V8InspectorSession {
138144
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
139145
supportedDomains() = 0;
140146

147+
virtual std::unique_ptr<V8InspectorSession::CommandLineAPIScope>
148+
initializeCommandLineAPIScope(int executionContextId) = 0;
149+
141150
// Debugger actions.
142151
virtual void schedulePauseOnNextStatement(StringView breakReason,
143152
StringView breakDetails) = 0;
@@ -228,6 +237,10 @@ class V8_EXPORT V8InspectorClient {
228237
const StringView& resourceName) {
229238
return nullptr;
230239
}
240+
241+
// The caller would defer to generating a random 64 bit integer if
242+
// this method returns 0.
243+
virtual int64_t generateUniqueId() { return 0; }
231244
};
232245

233246
// These stack trace ids are intended to be passed between debuggers and be

NativeScript/include/v8-internal.h

+72-23
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,21 @@ const int kApiSystemPointerSize = sizeof(void*);
3333
const int kApiDoubleSize = sizeof(double);
3434
const int kApiInt32Size = sizeof(int32_t);
3535
const int kApiInt64Size = sizeof(int64_t);
36+
const int kApiSizetSize = sizeof(size_t);
3637

3738
// Tag information for HeapObject.
3839
const int kHeapObjectTag = 1;
3940
const int kWeakHeapObjectTag = 3;
4041
const int kHeapObjectTagSize = 2;
4142
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
4243

44+
// Tag information for fowarding pointers stored in object headers.
45+
// 0b00 at the lowest 2 bits in the header indicates that the map word is a
46+
// forwarding pointer.
47+
const int kForwardingTag = 0;
48+
const int kForwardingTagSize = 2;
49+
const intptr_t kForwardingTagMask = (1 << kForwardingTagSize) - 1;
50+
4351
// Tag information for Smi.
4452
const int kSmiTag = 0;
4553
const int kSmiTagSize = 1;
@@ -120,23 +128,28 @@ constexpr bool HeapSandboxIsEnabled() {
120128

121129
using ExternalPointer_t = Address;
122130

123-
// If the heap sandbox is enabled, these tag values will be XORed with the
131+
// If the heap sandbox is enabled, these tag values will be ORed with the
124132
// external pointers in the external pointer table to prevent use of pointers of
125-
// the wrong type.
126-
enum ExternalPointerTag : Address {
127-
kExternalPointerNullTag = static_cast<Address>(0ULL),
128-
kArrayBufferBackingStoreTag = static_cast<Address>(1ULL << 48),
129-
kTypedArrayExternalPointerTag = static_cast<Address>(2ULL << 48),
130-
kDataViewDataPointerTag = static_cast<Address>(3ULL << 48),
131-
kExternalStringResourceTag = static_cast<Address>(4ULL << 48),
132-
kExternalStringResourceDataTag = static_cast<Address>(5ULL << 48),
133-
kForeignForeignAddressTag = static_cast<Address>(6ULL << 48),
134-
kNativeContextMicrotaskQueueTag = static_cast<Address>(7ULL << 48),
135-
// TODO(v8:10391, saelo): Currently has to be zero so that raw zero values are
136-
// also nullptr
137-
kEmbedderDataSlotPayloadTag = static_cast<Address>(0ULL << 48),
133+
// the wrong type. When a pointer is loaded, it is ANDed with the inverse of the
134+
// expected type's tag. The tags are constructed in a way that guarantees that a
135+
// failed type check will result in one or more of the top bits of the pointer
136+
// to be set, rendering the pointer inacessible. This construction allows
137+
// performing the type check and removing GC marking bits from the pointer at
138+
// the same time.
139+
enum ExternalPointerTag : uint64_t {
140+
kExternalPointerNullTag = 0x0000000000000000,
141+
kArrayBufferBackingStoreTag = 0x00ff000000000000, // 0b000000011111111
142+
kTypedArrayExternalPointerTag = 0x017f000000000000, // 0b000000101111111
143+
kDataViewDataPointerTag = 0x01bf000000000000, // 0b000000110111111
144+
kExternalStringResourceTag = 0x01df000000000000, // 0b000000111011111
145+
kExternalStringResourceDataTag = 0x01ef000000000000, // 0b000000111101111
146+
kForeignForeignAddressTag = 0x01f7000000000000, // 0b000000111110111
147+
kNativeContextMicrotaskQueueTag = 0x01fb000000000000, // 0b000000111111011
148+
kEmbedderDataSlotPayloadTag = 0x01fd000000000000, // 0b000000111111101
138149
};
139150

151+
constexpr uint64_t kExternalPointerTagMask = 0xffff000000000000;
152+
140153
#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
141154
using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
142155
#else
@@ -177,6 +190,14 @@ V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate);
177190
* depend on functions and constants defined here.
178191
*/
179192
class Internals {
193+
#ifdef V8_MAP_PACKING
194+
V8_INLINE static constexpr internal::Address UnpackMapWord(
195+
internal::Address mapword) {
196+
// TODO(wenyuzhao): Clear header metadata.
197+
return mapword ^ kMapWordXorMask;
198+
}
199+
#endif
200+
180201
public:
181202
// These values match non-compiler-dependent values defined within
182203
// the implementation of v8.
@@ -207,8 +228,14 @@ class Internals {
207228
kNumIsolateDataSlots * kApiSystemPointerSize;
208229
static const int kIsolateFastCCallCallerPcOffset =
209230
kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize;
210-
static const int kIsolateStackGuardOffset =
231+
static const int kIsolateFastApiCallTargetOffset =
211232
kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize;
233+
static const int kIsolateCageBaseOffset =
234+
kIsolateFastApiCallTargetOffset + kApiSystemPointerSize;
235+
static const int kIsolateLongTaskStatsCounterOffset =
236+
kIsolateCageBaseOffset + kApiSystemPointerSize;
237+
static const int kIsolateStackGuardOffset =
238+
kIsolateLongTaskStatsCounterOffset + kApiSizetSize;
212239
static const int kIsolateRootsOffset =
213240
kIsolateStackGuardOffset + 7 * kApiSystemPointerSize;
214241

@@ -251,6 +278,17 @@ class Internals {
251278
// incremental GC once the external memory reaches this limit.
252279
static constexpr int kExternalAllocationSoftLimit = 64 * 1024 * 1024;
253280

281+
#ifdef V8_MAP_PACKING
282+
static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
283+
// The lowest two bits of mapwords are always `0b10`
284+
static const uintptr_t kMapWordSignature = 0b10;
285+
// XORing a (non-compressed) map with this mask ensures that the two
286+
// low-order bits are 0b10. The 0 at the end makes this look like a Smi,
287+
// although real Smis have all lower 32 bits unset. We only rely on these
288+
// values passing as Smis in very few places.
289+
static const int kMapWordXorMask = 0b11;
290+
#endif
291+
254292
V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
255293
V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
256294
#ifdef V8_ENABLE_CHECKS
@@ -277,6 +315,9 @@ class Internals {
277315
V8_INLINE static int GetInstanceType(const internal::Address obj) {
278316
typedef internal::Address A;
279317
A map = ReadTaggedPointerField(obj, kHeapObjectMapOffset);
318+
#ifdef V8_MAP_PACKING
319+
map = UnpackMapWord(map);
320+
#endif
280321
return ReadRawField<uint16_t>(map, kMapInstanceTypeOffset);
281322
}
282323

@@ -327,6 +368,12 @@ class Internals {
327368
return *reinterpret_cast<void* const*>(addr);
328369
}
329370

371+
V8_INLINE static void IncrementLongTasksStatsCounter(v8::Isolate* isolate) {
372+
internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
373+
kIsolateLongTaskStatsCounterOffset;
374+
++(*reinterpret_cast<size_t*>(addr));
375+
}
376+
330377
V8_INLINE static internal::Address* GetRoot(v8::Isolate* isolate, int index) {
331378
internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
332379
kIsolateRootsOffset +
@@ -356,8 +403,9 @@ class Internals {
356403
internal::Address heap_object_ptr, int offset) {
357404
#ifdef V8_COMPRESS_POINTERS
358405
uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
359-
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
360-
return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
406+
internal::Address base =
407+
GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
408+
return base + static_cast<internal::Address>(static_cast<uintptr_t>(value));
361409
#else
362410
return ReadRawField<internal::Address>(heap_object_ptr, offset);
363411
#endif
@@ -409,18 +457,19 @@ class Internals {
409457

410458
#ifdef V8_COMPRESS_POINTERS
411459
// See v8:7703 or src/ptr-compr.* for details about pointer compression.
412-
static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32;
413-
static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32;
460+
static constexpr size_t kPtrComprCageReservationSize = size_t{1} << 32;
461+
static constexpr size_t kPtrComprCageBaseAlignment = size_t{1} << 32;
414462

415-
V8_INLINE static internal::Address GetRootFromOnHeapAddress(
463+
V8_INLINE static internal::Address GetPtrComprCageBaseFromOnHeapAddress(
416464
internal::Address addr) {
417-
return addr & -static_cast<intptr_t>(kPtrComprIsolateRootAlignment);
465+
return addr & -static_cast<intptr_t>(kPtrComprCageBaseAlignment);
418466
}
419467

420468
V8_INLINE static internal::Address DecompressTaggedAnyField(
421469
internal::Address heap_object_ptr, uint32_t value) {
422-
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
423-
return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
470+
internal::Address base =
471+
GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
472+
return base + static_cast<internal::Address>(static_cast<uintptr_t>(value));
424473
}
425474

426475
#endif // V8_COMPRESS_POINTERS

NativeScript/include/v8-platform.h

+5-18
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ class JobDelegate {
181181
/**
182182
* Returns true if the current task is called from the thread currently
183183
* running JobHandle::Join().
184-
* TODO(etiennep): Make pure virtual once custom embedders implement it.
185184
*/
186-
virtual bool IsJoiningThread() const { return false; }
185+
virtual bool IsJoiningThread() const = 0;
187186
};
188187

189188
/**
@@ -220,27 +219,20 @@ class JobHandle {
220219
* Forces all existing workers to yield ASAP but doesn’t wait for them.
221220
* Warning, this is dangerous if the Job's callback is bound to or has access
222221
* to state which may be deleted after this call.
223-
* TODO(etiennep): Cleanup once implemented by all embedders.
224222
*/
225-
virtual void CancelAndDetach() { Cancel(); }
223+
virtual void CancelAndDetach() = 0;
226224

227225
/**
228-
* Returns true if there's currently no work pending and no worker running.
229-
* TODO(etiennep): Deprecate IsCompleted in favor of IsActive once implemented
230-
* by all embedders.
226+
* Returns true if there's any work pending or any worker running.
231227
*/
232-
virtual bool IsCompleted() = 0;
233-
virtual bool IsActive() { return !IsCompleted(); }
228+
virtual bool IsActive() = 0;
234229

235230
/**
236231
* Returns true if associated with a Job and other methods may be called.
237232
* Returns false after Join() or Cancel() was called. This may return true
238233
* even if no workers are running and IsCompleted() returns true
239-
* TODO(etiennep): Deprecate IsRunning in favor of IsValid once implemented by
240-
* all embedders.
241234
*/
242-
virtual bool IsRunning() = 0;
243-
virtual bool IsValid() { return IsRunning(); }
235+
virtual bool IsValid() = 0;
244236

245237
/**
246238
* Returns true if job priority can be changed.
@@ -270,10 +262,6 @@ class JobTask {
270262
* it must not call back any JobHandle methods.
271263
*/
272264
virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
273-
274-
// TODO(1114823): Clean up once all overrides are removed.
275-
V8_DEPRECATED("Use the version that takes |worker_count|.")
276-
virtual size_t GetMaxConcurrency() const { return 0; }
277265
};
278266

279267
/**
@@ -406,7 +394,6 @@ class PageAllocator {
406394
kNoAccess,
407395
kRead,
408396
kReadWrite,
409-
// TODO(hpayer): Remove this flag. Memory should never be rwx.
410397
kReadWriteExecute,
411398
kReadExecute,
412399
// Set this when reserving memory that will later require kReadWriteExecute

0 commit comments

Comments
 (0)