From 07a9ff4dbb0fd5de21740f29616003bdf3822946 Mon Sep 17 00:00:00 2001 From: Francis McCabe Date: Mon, 5 Apr 2021 21:54:28 +0000 Subject: [PATCH] Revert "[ptr-cage] Rename IsolateRoot to PtrComprCageBase" This reverts commit e28dadc2070b202aab77b9e50a46e50be02f8f1c. Reason for revert: failed test262 tests;; see https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Win32/32275/steps?succeeded=true&debug=false Original change's description: > [ptr-cage] Rename IsolateRoot to PtrComprCageBase > > Currently, IsolateRoot is both the address of the Isolate root and the > base address of the pointer compression reservation. This CL teases the > two uses apart by renaming IsolateRoot to PtrComprCageBase. > > - In addition to V8_COMPRESS_POINTERS, add a > V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE (vs SHARED_CAGE). > > - Rename GetIsolate* helpers to GetPtrComprCageBase. When > V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE is true, the helpers remain as > aliases to GetPtrComprCageBase. > > - Rename kPtrComprIsolateRootAlignment to kPtrComprCageBaseAlignment. > > Bug: v8:11460 > Change-Id: I1d715f678ce9a0b5731895612ca14f56579b1c48 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2783672 > Commit-Queue: Shu-yu Guo > Auto-Submit: Shu-yu Guo > Reviewed-by: Igor Sheludko > Reviewed-by: Ross McIlroy > Cr-Commit-Position: refs/heads/master@{#73790} Bug: v8:11460 Change-Id: I19d0e28194fcdb28e89f129a7694ca3fe29fa17a No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2806168 Auto-Submit: Francis McCabe Commit-Queue: Rubber Stamper Bot-Commit: Rubber Stamper Cr-Commit-Position: refs/heads/master@{#73791} --- BUILD.gn | 7 - include/v8-internal.h | 18 +- src/ast/ast.cc | 2 +- src/builtins/builtins-typed-array-gen.cc | 4 +- src/common/external-pointer-inl.h | 12 +- src/common/external-pointer.h | 4 +- src/common/globals.h | 16 +- src/common/ptr-compr-inl.h | 64 ++---- src/common/ptr-compr.h | 4 +- src/deoptimizer/translated-state.cc | 3 +- src/diagnostics/objects-debug.cc | 6 +- src/diagnostics/objects-printer.cc | 19 +- src/execution/isolate-utils-inl.h | 32 +-- src/execution/isolate-utils.h | 11 +- src/execution/isolate.cc | 4 +- src/flags/flag-definitions.h | 12 -- src/handles/global-handles.cc | 4 +- src/heap/heap.cc | 2 +- src/heap/mark-compact.cc | 70 ++++--- src/heap/read-only-heap-inl.h | 6 +- src/heap/read-only-heap.cc | 6 +- src/heap/read-only-heap.h | 4 +- src/heap/read-only-spaces.cc | 4 +- src/heap/read-only-spaces.h | 9 +- src/init/isolate-allocator.cc | 10 +- src/objects/code-inl.h | 4 +- src/objects/compressed-slots-inl.h | 36 ++-- src/objects/compressed-slots.h | 16 +- src/objects/contexts-inl.h | 12 +- src/objects/contexts.h | 5 +- src/objects/descriptor-array-inl.h | 42 ++-- src/objects/descriptor-array.h | 10 +- src/objects/dictionary-inl.h | 45 ++--- src/objects/dictionary.h | 10 +- src/objects/elements.cc | 6 +- src/objects/embedder-data-slot-inl.h | 16 +- src/objects/embedder-data-slot.h | 5 +- src/objects/feedback-vector-inl.h | 5 +- src/objects/feedback-vector.h | 2 +- src/objects/field-index-inl.h | 8 +- src/objects/field-index.h | 2 +- src/objects/fixed-array-inl.h | 46 ++--- src/objects/fixed-array.h | 16 +- src/objects/foreign-inl.h | 2 +- src/objects/hash-table-inl.h | 20 +- src/objects/hash-table.h | 19 +- src/objects/heap-object.h | 8 +- src/objects/js-array-buffer-inl.h | 10 +- src/objects/js-array-buffer.h | 2 +- src/objects/js-array-inl.h | 6 +- src/objects/js-array.h | 2 +- src/objects/js-function-inl.h | 51 ++--- src/objects/js-objects-inl.h | 148 +++++++------- src/objects/js-objects.h | 8 +- src/objects/literal-objects-inl.h | 16 +- src/objects/literal-objects.h | 4 +- src/objects/map-inl.h | 41 ++-- src/objects/map.h | 5 +- src/objects/maybe-object-inl.h | 5 +- src/objects/maybe-object.h | 2 +- src/objects/name-inl.h | 10 +- src/objects/object-macros.h | 100 +++++----- src/objects/objects-inl.h | 211 ++++++++++---------- src/objects/objects.cc | 46 ++--- src/objects/objects.h | 11 +- src/objects/oddball-inl.h | 2 +- src/objects/property-array-inl.h | 8 +- src/objects/property-array.h | 2 +- src/objects/property.cc | 4 +- src/objects/scope-info.cc | 8 +- src/objects/scope-info.h | 2 +- src/objects/slots-inl.h | 13 +- src/objects/slots.h | 12 +- src/objects/string-inl.h | 32 ++- src/objects/string-table.cc | 35 ++-- src/objects/string-table.h | 4 +- src/objects/string.cc | 2 +- src/objects/string.h | 7 +- src/objects/swiss-name-dictionary-inl.h | 8 +- src/objects/swiss-name-dictionary.h | 3 +- src/objects/tagged-field-inl.h | 14 +- src/objects/tagged-field.h | 7 +- src/objects/templates-inl.h | 12 +- src/objects/templates.h | 2 +- src/profiler/heap-snapshot-generator.cc | 4 +- src/torque/cc-generator.cc | 6 +- src/torque/implementation-visitor.cc | 20 +- src/wasm/wasm-objects-inl.h | 20 +- tools/debug_helper/debug-helper-internal.cc | 2 +- tools/debug_helper/get-object-properties.cc | 2 +- 90 files changed, 730 insertions(+), 847 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 162d8cc1ca..357c7f493b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -404,10 +404,6 @@ if (v8_enable_shared_ro_heap && v8_enable_pointer_compression) { "Sharing read-only heap with pointer compression is only supported on Linux or Android") } -assert( - !v8_enable_pointer_compression_shared_cage || !v8_enable_shared_ro_heap, - "Sharing read-only heap is not yet supported when sharing a pointer compression cage") - assert(!v8_use_multi_snapshots || !v8_control_flow_integrity, "Control-flow integrity does not support multisnapshots") @@ -558,7 +554,6 @@ external_v8_defines = [ "V8_ENABLE_CHECKS", "V8_COMPRESS_POINTERS", "V8_COMPRESS_POINTERS_IN_SHARED_CAGE", - "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE", "V8_31BIT_SMIS_ON_64BIT_ARCH", "V8_COMPRESS_ZONES", "V8_HEAP_SANDBOX", @@ -578,8 +573,6 @@ if (v8_enable_pointer_compression) { } if (v8_enable_pointer_compression_shared_cage) { enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_SHARED_CAGE" ] -} else if (v8_enable_pointer_compression) { - enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE" ] } if (v8_enable_pointer_compression || v8_enable_31bit_smis_on_64bit_arch) { enabled_external_v8_defines += [ "V8_31BIT_SMIS_ON_64BIT_ARCH" ] diff --git a/include/v8-internal.h b/include/v8-internal.h index eb18f76504..8abbcfb416 100644 --- a/include/v8-internal.h +++ b/include/v8-internal.h @@ -358,9 +358,8 @@ class Internals { internal::Address heap_object_ptr, int offset) { #ifdef V8_COMPRESS_POINTERS uint32_t value = ReadRawField(heap_object_ptr, offset); - internal::Address base = - GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr); - return base + static_cast(static_cast(value)); + internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr); + return root + static_cast(static_cast(value)); #else return ReadRawField(heap_object_ptr, offset); #endif @@ -412,19 +411,18 @@ class Internals { #ifdef V8_COMPRESS_POINTERS // See v8:7703 or src/ptr-compr.* for details about pointer compression. - static constexpr size_t kPtrComprCageReservationSize = size_t{1} << 32; - static constexpr size_t kPtrComprCageBaseAlignment = size_t{1} << 32; + static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32; + static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32; - V8_INLINE static internal::Address GetPtrComprCageBaseFromOnHeapAddress( + V8_INLINE static internal::Address GetRootFromOnHeapAddress( internal::Address addr) { - return addr & -static_cast(kPtrComprCageBaseAlignment); + return addr & -static_cast(kPtrComprIsolateRootAlignment); } V8_INLINE static internal::Address DecompressTaggedAnyField( internal::Address heap_object_ptr, uint32_t value) { - internal::Address base = - GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr); - return base + static_cast(static_cast(value)); + internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr); + return root + static_cast(static_cast(value)); } #endif // V8_COMPRESS_POINTERS diff --git a/src/ast/ast.cc b/src/ast/ast.cc index 5515a4a3fc..64577de0a7 100644 --- a/src/ast/ast.cc +++ b/src/ast/ast.cc @@ -661,7 +661,7 @@ void ArrayLiteral::BuildBoilerplateDescription(LocalIsolate* isolate) { boilerplate_descriptor_kind(), GetMoreGeneralElementsKind(boilerplate_descriptor_kind(), boilerplate_value.OptimalElementsKind( - GetPtrComprCageBase(*elements)))); + GetIsolateForPtrCompr(*elements)))); FixedArray::cast(*elements).set(array_index, boilerplate_value); } diff --git a/src/builtins/builtins-typed-array-gen.cc b/src/builtins/builtins-typed-array-gen.cc index 65b1ab2f2b..a0ba890167 100644 --- a/src/builtins/builtins-typed-array-gen.cc +++ b/src/builtins/builtins-typed-array-gen.cc @@ -370,14 +370,14 @@ void TypedArrayBuiltinsAssembler::SetJSTypedArrayOnHeapDataPtr( TNode full_base = Signed(BitcastTaggedToWord(base)); TNode compressed_base = TruncateIntPtrToInt32(full_base); // TODO(v8:9706): Add a way to directly use kRootRegister value. - TNode ptr_compr_cage_base = + TNode isolate_root = IntPtrSub(full_base, Signed(ChangeUint32ToWord(compressed_base))); // Add JSTypedArray::ExternalPointerCompensationForOnHeapArray() to offset. DCHECK_EQ( isolate()->isolate_root(), JSTypedArray::ExternalPointerCompensationForOnHeapArray(isolate())); // See JSTypedArray::SetOnHeapDataPtr() for details. - offset = Unsigned(IntPtrAdd(offset, ptr_compr_cage_base)); + offset = Unsigned(IntPtrAdd(offset, isolate_root)); } StoreJSTypedArrayBasePointer(holder, base); diff --git a/src/common/external-pointer-inl.h b/src/common/external-pointer-inl.h index bc7aea3691..070d787b63 100644 --- a/src/common/external-pointer-inl.h +++ b/src/common/external-pointer-inl.h @@ -12,17 +12,11 @@ namespace v8 { namespace internal { -V8_INLINE Address DecodeExternalPointer(PtrComprCageBase isolate_root, +V8_INLINE Address DecodeExternalPointer(IsolateRoot isolate_root, ExternalPointer_t encoded_pointer, ExternalPointerTag tag) { STATIC_ASSERT(kExternalPointerSize == kSystemPointerSize); #ifdef V8_HEAP_SANDBOX - - // TODO(syg): V8_HEAP_SANDBOX doesn't work with pointer cage -#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE -#error "V8_HEAP_SANDBOX requires per-Isolate pointer compression cage" -#endif - uint32_t index = static_cast(encoded_pointer); const Isolate* isolate = Isolate::FromRootAddress(isolate_root.address()); return isolate->external_pointer_table().get(index) ^ tag; @@ -68,7 +62,7 @@ V8_INLINE void InitExternalPointerField(Address field_address, Isolate* isolate, } V8_INLINE Address ReadExternalPointerField(Address field_address, - PtrComprCageBase cage_base, + IsolateRoot isolate_root, ExternalPointerTag tag) { // Pointer compression causes types larger than kTaggedSize to be unaligned. constexpr bool v8_pointer_compression_unaligned = @@ -79,7 +73,7 @@ V8_INLINE Address ReadExternalPointerField(Address field_address, } else { encoded_value = base::Memory(field_address); } - return DecodeExternalPointer(cage_base, encoded_value, tag); + return DecodeExternalPointer(isolate_root, encoded_value, tag); } V8_INLINE void WriteExternalPointerField(Address field_address, diff --git a/src/common/external-pointer.h b/src/common/external-pointer.h index c0941f2978..5a380df762 100644 --- a/src/common/external-pointer.h +++ b/src/common/external-pointer.h @@ -12,7 +12,7 @@ namespace internal { // Convert external pointer from on-V8-heap representation to an actual external // pointer value. -V8_INLINE Address DecodeExternalPointer(PtrComprCageBase isolate, +V8_INLINE Address DecodeExternalPointer(IsolateRoot isolate, ExternalPointer_t encoded_pointer, ExternalPointerTag tag); @@ -34,7 +34,7 @@ V8_INLINE void InitExternalPointerField(Address field_address, Isolate* isolate, // Reads external pointer for the field, and decodes it if the sandbox is // enabled. V8_INLINE Address ReadExternalPointerField(Address field_address, - PtrComprCageBase isolate, + IsolateRoot isolate, ExternalPointerTag tag); // Encodes value if the sandbox is enabled and writes it into the field. diff --git a/src/common/globals.h b/src/common/globals.h index f51c3210f8..0891e6eddb 100644 --- a/src/common/globals.h +++ b/src/common/globals.h @@ -1748,13 +1748,13 @@ enum class DynamicCheckMapsStatus : uint8_t { }; #ifdef V8_COMPRESS_POINTERS -class PtrComprCageBase { +class IsolateRoot { public: - explicit constexpr PtrComprCageBase(Address address) : address_(address) {} + explicit constexpr IsolateRoot(Address address) : address_(address) {} // NOLINTNEXTLINE - inline PtrComprCageBase(const Isolate* isolate); + inline IsolateRoot(const Isolate* isolate); // NOLINTNEXTLINE - inline PtrComprCageBase(const LocalIsolate* isolate); + inline IsolateRoot(const LocalIsolate* isolate); inline Address address() const; @@ -1762,13 +1762,13 @@ class PtrComprCageBase { Address address_; }; #else -class PtrComprCageBase { +class IsolateRoot { public: - PtrComprCageBase() = default; + IsolateRoot() = default; // NOLINTNEXTLINE - PtrComprCageBase(const Isolate* isolate) {} + IsolateRoot(const Isolate* isolate) {} // NOLINTNEXTLINE - PtrComprCageBase(const LocalIsolate* isolate) {} + IsolateRoot(const LocalIsolate* isolate) {} }; #endif diff --git a/src/common/ptr-compr-inl.h b/src/common/ptr-compr-inl.h index 66c22311b0..f74c4d82c9 100644 --- a/src/common/ptr-compr-inl.h +++ b/src/common/ptr-compr-inl.h @@ -15,35 +15,15 @@ namespace internal { #ifdef V8_COMPRESS_POINTERS -#if defined V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE - -PtrComprCageBase::PtrComprCageBase(const Isolate* isolate) +IsolateRoot::IsolateRoot(const Isolate* isolate) : address_(isolate->isolate_root()) {} -PtrComprCageBase::PtrComprCageBase(const LocalIsolate* isolate) +IsolateRoot::IsolateRoot(const LocalIsolate* isolate) : address_(isolate->isolate_root()) {} -#elif defined V8_COMPRESS_POINTERS_IN_SHARED_CAGE - -PtrComprCageBase::PtrComprCageBase(const Isolate* isolate) - : address_(isolate->isolate_root()) { - UNIMPLEMENTED(); -} -PtrComprCageBase::PtrComprCageBase(const LocalIsolate* isolate) - : address_(isolate->isolate_root()) { - UNIMPLEMENTED(); -} - -#else - -#error "Pointer compression build configuration error" - -#endif // V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE, - // V8_COMPRESS_POINTERS_IN_SHARED_CAGE - -Address PtrComprCageBase::address() const { +Address IsolateRoot::address() const { Address ret = address_; ret = reinterpret_cast
(V8_ASSUME_ALIGNED( - reinterpret_cast(ret), kPtrComprCageBaseAlignment)); + reinterpret_cast(ret), kPtrComprIsolateRootAlignment)); return ret; } @@ -53,17 +33,12 @@ V8_INLINE Tagged_t CompressTagged(Address tagged) { return static_cast(static_cast(tagged)); } -V8_INLINE constexpr Address GetPtrComprCageBaseAddress(Address on_heap_addr) { - return RoundDown(on_heap_addr); +V8_INLINE constexpr Address GetIsolateRootAddress(Address on_heap_addr) { + return RoundDown(on_heap_addr); } -V8_INLINE Address GetPtrComprCageBaseAddress(PtrComprCageBase cage_base) { - return cage_base.address(); -} - -V8_INLINE constexpr PtrComprCageBase GetPtrComprCageBaseFromOnHeapAddress( - Address address) { - return PtrComprCageBase(GetPtrComprCageBaseAddress(address)); +V8_INLINE Address GetIsolateRootAddress(IsolateRoot isolate) { + return isolate.address(); } // Decompresses smi value. @@ -77,8 +52,7 @@ V8_INLINE Address DecompressTaggedSigned(Tagged_t raw_value) { template V8_INLINE Address DecompressTaggedPointer(TOnHeapAddress on_heap_addr, Tagged_t raw_value) { - return GetPtrComprCageBaseAddress(on_heap_addr) + - static_cast
(raw_value); + return GetIsolateRootAddress(on_heap_addr) + static_cast
(raw_value); } // Decompresses any tagged value, preserving both weak- and smi- tags. @@ -88,19 +62,18 @@ V8_INLINE Address DecompressTaggedAny(TOnHeapAddress on_heap_addr, return DecompressTaggedPointer(on_heap_addr, raw_value); } -STATIC_ASSERT(kPtrComprCageReservationSize == - Internals::kPtrComprCageReservationSize); -STATIC_ASSERT(kPtrComprCageBaseAlignment == - Internals::kPtrComprCageBaseAlignment); +STATIC_ASSERT(kPtrComprHeapReservationSize == + Internals::kPtrComprHeapReservationSize); +STATIC_ASSERT(kPtrComprIsolateRootAlignment == + Internals::kPtrComprIsolateRootAlignment); #else V8_INLINE Tagged_t CompressTagged(Address tagged) { UNREACHABLE(); } -V8_INLINE constexpr PtrComprCageBase GetPtrComprCageBaseFromOnHeapAddress( - Address address) { - return PtrComprCageBase(); -} +V8_INLINE Address GetIsolateRootAddress(Address on_heap_addr) { UNREACHABLE(); } + +V8_INLINE Address GetIsolateRootAddress(IsolateRoot isolate) { UNREACHABLE(); } V8_INLINE Address DecompressTaggedSigned(Tagged_t raw_value) { UNREACHABLE(); } @@ -117,11 +90,6 @@ V8_INLINE Address DecompressTaggedAny(TOnHeapAddress on_heap_addr, } #endif // V8_COMPRESS_POINTERS - -inline PtrComprCageBase GetPtrComprCageBase(HeapObject object) { - return GetPtrComprCageBaseFromOnHeapAddress(object.ptr()); -} - } // namespace internal } // namespace v8 diff --git a/src/common/ptr-compr.h b/src/common/ptr-compr.h index 1d5668208a..0c82c2328c 100644 --- a/src/common/ptr-compr.h +++ b/src/common/ptr-compr.h @@ -13,8 +13,8 @@ namespace v8 { namespace internal { // See v8:7703 for details about how pointer compression works. -constexpr size_t kPtrComprCageReservationSize = size_t{4} * GB; -constexpr size_t kPtrComprCageBaseAlignment = size_t{4} * GB; +constexpr size_t kPtrComprHeapReservationSize = size_t{4} * GB; +constexpr size_t kPtrComprIsolateRootAlignment = size_t{4} * GB; } // namespace internal } // namespace v8 diff --git a/src/deoptimizer/translated-state.cc b/src/deoptimizer/translated-state.cc index 02c473d22b..c6f88afdc4 100644 --- a/src/deoptimizer/translated-state.cc +++ b/src/deoptimizer/translated-state.cc @@ -1275,7 +1275,8 @@ int TranslatedState::CreateNextTranslatedValue( Address TranslatedState::DecompressIfNeeded(intptr_t value) { if (COMPRESS_POINTERS_BOOL) { - return DecompressTaggedAny(isolate(), static_cast(value)); + return DecompressTaggedAny(isolate()->isolate_root(), + static_cast(value)); } else { return value; } diff --git a/src/diagnostics/objects-debug.cc b/src/diagnostics/objects-debug.cc index b48df9385a..f197c7f21c 100644 --- a/src/diagnostics/objects-debug.cc +++ b/src/diagnostics/objects-debug.cc @@ -325,11 +325,11 @@ void BytecodeArray::BytecodeArrayVerify(Isolate* isolate) { USE_TORQUE_VERIFIER(JSReceiver) -bool JSObject::ElementsAreSafeToExamine(PtrComprCageBase cage_base) const { +bool JSObject::ElementsAreSafeToExamine(IsolateRoot isolate) const { // If a GC was caused while constructing this object, the elements // pointer may point to a one pointer filler map. - return elements(cage_base) != - GetReadOnlyRoots(cage_base).one_pointer_filler_map(); + return elements(isolate) != + GetReadOnlyRoots(isolate).one_pointer_filler_map(); } namespace { diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc index aa1713e3b3..4d5abb567a 100644 --- a/src/diagnostics/objects-printer.cc +++ b/src/diagnostics/objects-printer.cc @@ -468,13 +468,13 @@ void PrintSloppyArgumentElements(std::ostream& os, ElementsKind kind, } } -void PrintEmbedderData(PtrComprCageBase cage_base, std::ostream& os, +void PrintEmbedderData(IsolateRoot isolate, std::ostream& os, EmbedderDataSlot slot) { DisallowGarbageCollection no_gc; Object value = slot.load_tagged(); os << Brief(value); void* raw_pointer; - if (slot.ToAlignedPointer(cage_base, &raw_pointer)) { + if (slot.ToAlignedPointer(isolate, &raw_pointer)) { os << ", aligned pointer: " << raw_pointer; } } @@ -579,11 +579,11 @@ static void JSObjectPrintBody(std::ostream& os, } int embedder_fields = obj.GetEmbedderFieldCount(); if (embedder_fields > 0) { - PtrComprCageBase cage_base = GetPtrComprCageBase(obj); + IsolateRoot isolate = GetIsolateForPtrCompr(obj); os << " - embedder fields = {"; for (int i = 0; i < embedder_fields; i++) { os << "\n "; - PrintEmbedderData(cage_base, os, EmbedderDataSlot(obj, i)); + PrintEmbedderData(isolate, os, EmbedderDataSlot(obj, i)); } os << "\n }\n"; } @@ -762,14 +762,14 @@ void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionPrint( } void EmbedderDataArray::EmbedderDataArrayPrint(std::ostream& os) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); PrintHeader(os, "EmbedderDataArray"); os << "\n - length: " << length(); EmbedderDataSlot start(*this, 0); EmbedderDataSlot end(*this, length()); for (EmbedderDataSlot slot = start; slot < end; ++slot) { os << "\n "; - PrintEmbedderData(cage_base, os, slot); + PrintEmbedderData(isolate, os, slot); } os << "\n"; } @@ -2747,11 +2747,12 @@ namespace { inline i::Object GetObjectFromRaw(void* object) { i::Address object_ptr = reinterpret_cast(object); #ifdef V8_COMPRESS_POINTERS - if (RoundDown(object_ptr) == i::kNullAddress) { + if (RoundDown(object_ptr) == + i::kNullAddress) { // Try to decompress pointer. i::Isolate* isolate = i::Isolate::Current(); - object_ptr = - i::DecompressTaggedAny(isolate, static_cast(object_ptr)); + object_ptr = i::DecompressTaggedAny(isolate->isolate_root(), + static_cast(object_ptr)); } #endif return i::Object(object_ptr); diff --git a/src/execution/isolate-utils-inl.h b/src/execution/isolate-utils-inl.h index f199b525aa..2cc66a473c 100644 --- a/src/execution/isolate-utils-inl.h +++ b/src/execution/isolate-utils-inl.h @@ -13,28 +13,18 @@ namespace v8 { namespace internal { -#ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE - -// Aliases for GetPtrComprCageBase when -// V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE. Each Isolate has its own cage, whose -// base address is also the Isolate root. -V8_INLINE constexpr Address GetIsolateRootAddress(Address on_heap_addr) { - return GetPtrComprCageBaseAddress(on_heap_addr); -} - -V8_INLINE Address GetIsolateRootAddress(PtrComprCageBase cage_base) { - return cage_base.address(); -} - +inline constexpr IsolateRoot GetIsolateForPtrComprFromOnHeapAddress( + Address address) { +#ifdef V8_COMPRESS_POINTERS + return IsolateRoot(GetIsolateRootAddress(address)); #else - -V8_INLINE Address GetIsolateRootAddress(Address on_heap_addr) { UNREACHABLE(); } - -V8_INLINE Address GetIsolateRootAddress(PtrComprCageBase cage_base) { - UNREACHABLE(); + return IsolateRoot(); +#endif // V8_COMPRESS_POINTERS } -#endif // V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE +inline IsolateRoot GetIsolateForPtrCompr(HeapObject object) { + return GetIsolateForPtrComprFromOnHeapAddress(object.ptr()); +} V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object) { // Avoid using the below GetIsolateFromWritableObject because we want to be @@ -42,7 +32,7 @@ V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object) { #if defined V8_ENABLE_THIRD_PARTY_HEAP return Heap::GetIsolateFromWritableObject(object)->heap(); -#elif defined V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE +#elif defined V8_COMPRESS_POINTERS Isolate* isolate = Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr())); DCHECK_NOT_NULL(isolate); @@ -57,7 +47,7 @@ V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object) { V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object) { #ifdef V8_ENABLE_THIRD_PARTY_HEAP return Heap::GetIsolateFromWritableObject(object); -#elif defined V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE +#elif defined V8_COMPRESS_POINTERS Isolate* isolate = Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr())); DCHECK_NOT_NULL(isolate); diff --git a/src/execution/isolate-utils.h b/src/execution/isolate-utils.h index c41788d945..2204b2cd96 100644 --- a/src/execution/isolate-utils.h +++ b/src/execution/isolate-utils.h @@ -10,12 +10,11 @@ namespace v8 { namespace internal { -// Computes the pointer compression cage base from any read only or writable -// heap object. The resulting value is intended to be used only as a hoisted -// computation of cage base inside trivial accessors for optimizing value -// decompression. When pointer compression is disabled this function always -// returns nullptr. -V8_INLINE PtrComprCageBase GetPtrComprCageBase(HeapObject object); +// Computes isolate from any read only or writable heap object. The resulting +// value is intended to be used only as a hoisted computation of isolate root +// inside trivial accessors for optmizing value decompression. +// When pointer compression is disabled this function always returns nullptr. +V8_INLINE IsolateRoot GetIsolateForPtrCompr(HeapObject object); V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object); diff --git a/src/execution/isolate.cc b/src/execution/isolate.cc index 8f98ee443e..f3cb313187 100644 --- a/src/execution/isolate.cc +++ b/src/execution/isolate.cc @@ -2861,8 +2861,8 @@ Isolate* Isolate::New() { // Construct Isolate object in the allocated memory. void* isolate_ptr = isolate_allocator->isolate_memory(); Isolate* isolate = new (isolate_ptr) Isolate(std::move(isolate_allocator)); -#ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE - DCHECK(IsAligned(isolate->isolate_root(), kPtrComprCageBaseAlignment)); +#ifdef V8_COMPRESS_POINTERS + DCHECK(IsAligned(isolate->isolate_root(), kPtrComprIsolateRootAlignment)); #endif #ifdef DEBUG diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h index aa1e70ce77..379c02138e 100644 --- a/src/flags/flag-definitions.h +++ b/src/flags/flag-definitions.h @@ -151,18 +151,6 @@ struct MaybeBoolFlag { #define COMPRESS_POINTERS_BOOL false #endif -#ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE -#define COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL true -#else -#define COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL false -#endif - -#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE -#define COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL true -#else -#define COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL false -#endif - #ifdef V8_HEAP_SANDBOX #define V8_HEAP_SANDBOX_BOOL true #else diff --git a/src/handles/global-handles.cc b/src/handles/global-handles.cc index 6bc290eac7..8b24de2a05 100644 --- a/src/handles/global-handles.cc +++ b/src/handles/global-handles.cc @@ -382,11 +382,11 @@ namespace { void ExtractInternalFields(JSObject jsobject, void** embedder_fields, int len) { int field_count = jsobject.GetEmbedderFieldCount(); - PtrComprCageBase cage_base = GetPtrComprCageBase(jsobject); + IsolateRoot isolate = GetIsolateForPtrCompr(jsobject); for (int i = 0; i < len; ++i) { if (field_count == i) break; void* pointer; - if (EmbedderDataSlot(jsobject, i).ToAlignedPointer(cage_base, &pointer)) { + if (EmbedderDataSlot(jsobject, i).ToAlignedPointer(isolate, &pointer)) { embedder_fields[i] = pointer; } } diff --git a/src/heap/heap.cc b/src/heap/heap.cc index ff44912070..ab019c8e1b 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -289,7 +289,7 @@ size_t Heap::MinOldGenerationSize() { size_t Heap::AllocatorLimitOnMaxOldGenerationSize() { #ifdef V8_COMPRESS_POINTERS // Isolate and the young generation are also allocated on the heap. - return kPtrComprCageReservationSize - + return kPtrComprHeapReservationSize - YoungGenerationSizeFromSemiSpaceSize(kMaxSemiSpaceSize) - RoundUp(sizeof(Isolate), size_t{1} << kPageSizeBits); #endif diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index ab4c64dc08..258596c1c5 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -2704,9 +2704,8 @@ static inline SlotCallbackResult UpdateSlot(TSlot slot, } template -static inline SlotCallbackResult UpdateSlot(PtrComprCageBase cage_base, - TSlot slot) { - typename TSlot::TObject obj = slot.Relaxed_Load(cage_base); +static inline SlotCallbackResult UpdateSlot(IsolateRoot isolate, TSlot slot) { + typename TSlot::TObject obj = slot.Relaxed_Load(isolate); HeapObject heap_obj; if (TSlot::kCanBeWeak && obj->GetHeapObjectIfWeak(&heap_obj)) { UpdateSlot(slot, obj, heap_obj); @@ -2718,9 +2717,9 @@ static inline SlotCallbackResult UpdateSlot(PtrComprCageBase cage_base, } template -static inline SlotCallbackResult UpdateStrongSlot(PtrComprCageBase cage_base, +static inline SlotCallbackResult UpdateStrongSlot(IsolateRoot isolate, TSlot slot) { - typename TSlot::TObject obj = slot.Relaxed_Load(cage_base); + typename TSlot::TObject obj = slot.Relaxed_Load(isolate); DCHECK(!HAS_WEAK_HEAP_OBJECT_TAG(obj.ptr())); HeapObject heap_obj; if (obj.GetHeapObject(&heap_obj)) { @@ -2736,40 +2735,39 @@ static inline SlotCallbackResult UpdateStrongSlot(PtrComprCageBase cage_base, // It does not expect to encounter pointers to dead objects. class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { public: - explicit PointersUpdatingVisitor(PtrComprCageBase cage_base) - : cage_base_(cage_base) {} + explicit PointersUpdatingVisitor(IsolateRoot isolate) : isolate_(isolate) {} void VisitPointer(HeapObject host, ObjectSlot p) override { - UpdateStrongSlotInternal(cage_base_, p); + UpdateStrongSlotInternal(isolate_, p); } void VisitPointer(HeapObject host, MaybeObjectSlot p) override { - UpdateSlotInternal(cage_base_, p); + UpdateSlotInternal(isolate_, p); } void VisitPointers(HeapObject host, ObjectSlot start, ObjectSlot end) override { for (ObjectSlot p = start; p < end; ++p) { - UpdateStrongSlotInternal(cage_base_, p); + UpdateStrongSlotInternal(isolate_, p); } } void VisitPointers(HeapObject host, MaybeObjectSlot start, MaybeObjectSlot end) final { for (MaybeObjectSlot p = start; p < end; ++p) { - UpdateSlotInternal(cage_base_, p); + UpdateSlotInternal(isolate_, p); } } void VisitRootPointer(Root root, const char* description, FullObjectSlot p) override { - UpdateRootSlotInternal(cage_base_, p); + UpdateRootSlotInternal(isolate_, p); } void VisitRootPointers(Root root, const char* description, FullObjectSlot start, FullObjectSlot end) override { for (FullObjectSlot p = start; p < end; ++p) { - UpdateRootSlotInternal(cage_base_, p); + UpdateRootSlotInternal(isolate_, p); } } @@ -2777,7 +2775,7 @@ class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { OffHeapObjectSlot start, OffHeapObjectSlot end) override { for (OffHeapObjectSlot p = start; p < end; ++p) { - UpdateRootSlotInternal(cage_base_, p); + UpdateRootSlotInternal(isolate_, p); } } @@ -2792,32 +2790,32 @@ class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { } private: - static inline SlotCallbackResult UpdateRootSlotInternal( - PtrComprCageBase cage_base, FullObjectSlot slot) { - return UpdateStrongSlot(cage_base, slot); + static inline SlotCallbackResult UpdateRootSlotInternal(IsolateRoot isolate, + FullObjectSlot slot) { + return UpdateStrongSlot(isolate, slot); } static inline SlotCallbackResult UpdateRootSlotInternal( - PtrComprCageBase cage_base, OffHeapObjectSlot slot) { - return UpdateStrongSlot(cage_base, slot); + IsolateRoot isolate, OffHeapObjectSlot slot) { + return UpdateStrongSlot(isolate, slot); } static inline SlotCallbackResult UpdateStrongMaybeObjectSlotInternal( - PtrComprCageBase cage_base, MaybeObjectSlot slot) { - return UpdateStrongSlot(cage_base, slot); + IsolateRoot isolate, MaybeObjectSlot slot) { + return UpdateStrongSlot(isolate, slot); } - static inline SlotCallbackResult UpdateStrongSlotInternal( - PtrComprCageBase cage_base, ObjectSlot slot) { - return UpdateStrongSlot(cage_base, slot); + static inline SlotCallbackResult UpdateStrongSlotInternal(IsolateRoot isolate, + ObjectSlot slot) { + return UpdateStrongSlot(isolate, slot); } - static inline SlotCallbackResult UpdateSlotInternal( - PtrComprCageBase cage_base, MaybeObjectSlot slot) { - return UpdateSlot(cage_base, slot); + static inline SlotCallbackResult UpdateSlotInternal(IsolateRoot isolate, + MaybeObjectSlot slot) { + return UpdateSlot(isolate, slot); } - PtrComprCageBase cage_base_; + IsolateRoot isolate_; }; static String UpdateReferenceInExternalStringTableEntry(Heap* heap, @@ -3583,7 +3581,7 @@ class ToSpaceUpdatingItem : public UpdatingItem { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), "ToSpaceUpdatingItem::ProcessVisitAll"); PointersUpdatingVisitor visitor( - GetPtrComprCageBaseFromOnHeapAddress(start_)); + GetIsolateForPtrComprFromOnHeapAddress(start_)); for (Address cur = start_; cur < end_;) { HeapObject object = HeapObject::FromAddress(cur); Map map = object.map(); @@ -3599,7 +3597,7 @@ class ToSpaceUpdatingItem : public UpdatingItem { // For young generation evacuations we want to visit grey objects, for // full MC, we need to visit black objects. PointersUpdatingVisitor visitor( - GetPtrComprCageBaseFromOnHeapAddress(start_)); + GetIsolateForPtrComprFromOnHeapAddress(start_)); for (auto object_and_size : LiveObjectRange( chunk_, marking_state_->bitmap(chunk_))) { object_and_size.first.IterateBodyFast(&visitor); @@ -3745,12 +3743,12 @@ class RememberedSetUpdatingItem : public UpdatingItem { if ((updating_mode_ == RememberedSetUpdatingMode::ALL) && (chunk_->slot_set() != nullptr)) { InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(chunk_); - PtrComprCageBase cage_base = heap_->isolate(); + IsolateRoot isolate = heap_->isolate(); RememberedSet::Iterate( chunk_, - [&filter, cage_base](MaybeObjectSlot slot) { + [&filter, isolate](MaybeObjectSlot slot) { if (!filter.IsValid(slot.address())) return REMOVE_SLOT; - return UpdateSlot(cage_base, slot); + return UpdateSlot(isolate, slot); }, SlotSet::FREE_EMPTY_BUCKETS); chunk_->ReleaseSlotSet(); @@ -3785,10 +3783,10 @@ class RememberedSetUpdatingItem : public UpdatingItem { Address slot) { // Using UpdateStrongSlot is OK here, because there are no weak // typed slots. - PtrComprCageBase cage_base = heap_->isolate(); + IsolateRoot isolate = heap_->isolate(); return UpdateTypedSlotHelper::UpdateTypedSlot( - heap_, slot_type, slot, [cage_base](FullMaybeObjectSlot slot) { - return UpdateStrongSlot(cage_base, slot); + heap_, slot_type, slot, [isolate](FullMaybeObjectSlot slot) { + return UpdateStrongSlot(isolate, slot); }); }); } diff --git a/src/heap/read-only-heap-inl.h b/src/heap/read-only-heap-inl.h index 0c12828584..316f455013 100644 --- a/src/heap/read-only-heap-inl.h +++ b/src/heap/read-only-heap-inl.h @@ -14,9 +14,9 @@ namespace internal { // static ReadOnlyRoots ReadOnlyHeap::GetReadOnlyRoots(HeapObject object) { -#ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE - return ReadOnlyRoots( - Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr()))); +#ifdef V8_COMPRESS_POINTERS + IsolateRoot isolate = GetIsolateForPtrCompr(object); + return ReadOnlyRoots(Isolate::FromRootAddress(isolate.address())); #else #ifdef V8_SHARED_RO_HEAP // This fails if we are creating heap objects and the roots haven't yet been diff --git a/src/heap/read-only-heap.cc b/src/heap/read-only-heap.cc index d5f7e843ef..342ad1d031 100644 --- a/src/heap/read-only-heap.cc +++ b/src/heap/read-only-heap.cc @@ -37,7 +37,7 @@ base::LazyInstance>::type std::shared_ptr InitializeSharedReadOnlyArtifacts() { std::shared_ptr artifacts; - if (COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL) { + if (COMPRESS_POINTERS_BOOL) { artifacts = std::make_shared(); } else { artifacts = std::make_shared(); @@ -129,7 +129,7 @@ ReadOnlyHeap::ReadOnlyHeap(ReadOnlyHeap* ro_heap, ReadOnlySpace* ro_space) : read_only_space_(ro_space), read_only_object_cache_(ro_heap->read_only_object_cache_) { DCHECK(ReadOnlyHeap::IsReadOnlySpaceShared()); - DCHECK(COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL); + DCHECK(COMPRESS_POINTERS_BOOL); } // static @@ -139,7 +139,7 @@ ReadOnlyHeap* ReadOnlyHeap::CreateInitalHeapForBootstrapping( std::unique_ptr ro_heap; auto* ro_space = new ReadOnlySpace(isolate->heap()); - if (COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL) { + if (COMPRESS_POINTERS_BOOL) { ro_heap.reset(new ReadOnlyHeap(ro_space)); } else { std::unique_ptr sole_ro_heap( diff --git a/src/heap/read-only-heap.h b/src/heap/read-only-heap.h index f947832c5f..c78ea77452 100644 --- a/src/heap/read-only-heap.h +++ b/src/heap/read-only-heap.h @@ -87,8 +87,8 @@ class ReadOnlyHeap { // Returns whether the ReadOnlySpace will actually be shared taking into // account whether shared memory is available with pointer compression. static bool IsReadOnlySpaceShared() { - return V8_SHARED_RO_HEAP_BOOL && (!COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL || - IsSharedMemoryAvailable()); + return V8_SHARED_RO_HEAP_BOOL && + (!COMPRESS_POINTERS_BOOL || IsSharedMemoryAvailable()); } virtual void InitializeIsolateRoots(Isolate* isolate) {} diff --git a/src/heap/read-only-spaces.cc b/src/heap/read-only-spaces.cc index 5adac66afe..b54bfc0389 100644 --- a/src/heap/read-only-spaces.cc +++ b/src/heap/read-only-spaces.cc @@ -755,10 +755,9 @@ SharedReadOnlySpace::SharedReadOnlySpace( Heap* heap, PointerCompressedReadOnlyArtifacts* artifacts) : SharedReadOnlySpace(heap) { // This constructor should only be used when RO_SPACE is shared with pointer - // compression in a per-Isolate cage. + // compression. DCHECK(V8_SHARED_RO_HEAP_BOOL); DCHECK(COMPRESS_POINTERS_BOOL); - DCHECK(COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL); DCHECK(ReadOnlyHeap::IsReadOnlySpaceShared()); DCHECK(!artifacts->pages().empty()); @@ -777,7 +776,6 @@ SharedReadOnlySpace::SharedReadOnlySpace( : SharedReadOnlySpace(heap) { DCHECK(V8_SHARED_RO_HEAP_BOOL); DCHECK(COMPRESS_POINTERS_BOOL); - DCHECK(COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL); DCHECK(ReadOnlyHeap::IsReadOnlySpaceShared()); accounting_stats_ = std::move(new_stats); diff --git a/src/heap/read-only-spaces.h b/src/heap/read-only-spaces.h index ee4b2a8223..ffadcb55b3 100644 --- a/src/heap/read-only-spaces.h +++ b/src/heap/read-only-spaces.h @@ -35,11 +35,10 @@ class ReadOnlyPage : public BasicMemoryChunk { // Returns the address for a given offset in this page. Address OffsetToAddress(size_t offset) const { Address address_in_page = address() + offset; - if (V8_SHARED_RO_HEAP_BOOL && COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL) { - // Pointer compression with a per-Isolate cage and shared ReadOnlyPages - // means that the area_start and area_end cannot be defined since they are - // stored within the pages which can be mapped at multiple memory - // addresses. + if (V8_SHARED_RO_HEAP_BOOL && COMPRESS_POINTERS_BOOL) { + // Pointer compression with share ReadOnlyPages means that the area_start + // and area_end cannot be defined since they are stored within the pages + // which can be mapped at multiple memory addresses. DCHECK_LT(offset, size()); } else { DCHECK_GE(address_in_page, area_start()); diff --git a/src/init/isolate-allocator.cc b/src/init/isolate-allocator.cc index 5db27d288b..01ae416181 100644 --- a/src/init/isolate-allocator.cc +++ b/src/init/isolate-allocator.cc @@ -59,8 +59,8 @@ Address IsolateAllocator::InitReservation() { // Reserve a |4Gb + kIsolateRootBiasPageSize| region such as that the // resevation address plus |kIsolateRootBiasPageSize| is 4Gb aligned. const size_t reservation_size = - kPtrComprCageReservationSize + kIsolateRootBiasPageSize; - const size_t base_alignment = kPtrComprCageBaseAlignment; + kPtrComprHeapReservationSize + kIsolateRootBiasPageSize; + const size_t base_alignment = kPtrComprIsolateRootAlignment; const int kMaxAttempts = 4; for (int attempt = 0; attempt < kMaxAttempts; ++attempt) { @@ -137,11 +137,11 @@ void IsolateAllocator::CommitPagesForIsolate(Address heap_reservation_address) { GetIsolateRootBiasPageSize(platform_page_allocator); Address isolate_root = heap_reservation_address + kIsolateRootBiasPageSize; - CHECK(IsAligned(isolate_root, kPtrComprCageBaseAlignment)); + CHECK(IsAligned(isolate_root, kPtrComprIsolateRootAlignment)); CHECK(reservation_.InVM( heap_reservation_address, - kPtrComprCageReservationSize + kIsolateRootBiasPageSize)); + kPtrComprHeapReservationSize + kIsolateRootBiasPageSize)); // Simplify BoundedPageAllocator's life by configuring it to use same page // size as the Heap will use (MemoryChunk::kPageSize). @@ -149,7 +149,7 @@ void IsolateAllocator::CommitPagesForIsolate(Address heap_reservation_address) { platform_page_allocator->AllocatePageSize()); page_allocator_instance_ = std::make_unique( - platform_page_allocator, isolate_root, kPtrComprCageReservationSize, + platform_page_allocator, isolate_root, kPtrComprHeapReservationSize, page_size); page_allocator_ = page_allocator_instance_.get(); diff --git a/src/objects/code-inl.h b/src/objects/code-inl.h index d6203f0597..49eb3480fb 100644 --- a/src/objects/code-inl.h +++ b/src/objects/code-inl.h @@ -323,9 +323,9 @@ int Code::SizeIncludingMetadata() const { } ByteArray Code::unchecked_relocation_info() const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); return ByteArray::unchecked_cast( - TaggedField::load(cage_base, *this)); + TaggedField::load(isolate, *this)); } byte* Code::relocation_start() const { diff --git a/src/objects/compressed-slots-inl.h b/src/objects/compressed-slots-inl.h index 54c828d919..ecb276ce36 100644 --- a/src/objects/compressed-slots-inl.h +++ b/src/objects/compressed-slots-inl.h @@ -33,9 +33,9 @@ Object CompressedObjectSlot::operator*() const { return Object(DecompressTaggedAny(address(), value)); } -Object CompressedObjectSlot::load(PtrComprCageBase cage_base) const { +Object CompressedObjectSlot::load(IsolateRoot isolate) const { Tagged_t value = *location(); - return Object(DecompressTaggedAny(cage_base, value)); + return Object(DecompressTaggedAny(isolate, value)); } void CompressedObjectSlot::store(Object value) const { @@ -52,9 +52,9 @@ Object CompressedObjectSlot::Relaxed_Load() const { return Object(DecompressTaggedAny(address(), value)); } -Object CompressedObjectSlot::Relaxed_Load(PtrComprCageBase cage_base) const { +Object CompressedObjectSlot::Relaxed_Load(IsolateRoot isolate) const { AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location()); - return Object(DecompressTaggedAny(cage_base, value)); + return Object(DecompressTaggedAny(isolate, value)); } void CompressedObjectSlot::Relaxed_Store(Object value) const { @@ -85,9 +85,9 @@ MaybeObject CompressedMaybeObjectSlot::operator*() const { return MaybeObject(DecompressTaggedAny(address(), value)); } -MaybeObject CompressedMaybeObjectSlot::load(PtrComprCageBase cage_base) const { +MaybeObject CompressedMaybeObjectSlot::load(IsolateRoot isolate) const { Tagged_t value = *location(); - return MaybeObject(DecompressTaggedAny(cage_base, value)); + return MaybeObject(DecompressTaggedAny(isolate, value)); } void CompressedMaybeObjectSlot::store(MaybeObject value) const { @@ -99,10 +99,9 @@ MaybeObject CompressedMaybeObjectSlot::Relaxed_Load() const { return MaybeObject(DecompressTaggedAny(address(), value)); } -MaybeObject CompressedMaybeObjectSlot::Relaxed_Load( - PtrComprCageBase cage_base) const { +MaybeObject CompressedMaybeObjectSlot::Relaxed_Load(IsolateRoot isolate) const { AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location()); - return MaybeObject(DecompressTaggedAny(cage_base, value)); + return MaybeObject(DecompressTaggedAny(isolate, value)); } void CompressedMaybeObjectSlot::Relaxed_Store(MaybeObject value) const { @@ -126,10 +125,9 @@ HeapObjectReference CompressedHeapObjectSlot::operator*() const { return HeapObjectReference(DecompressTaggedPointer(address(), value)); } -HeapObjectReference CompressedHeapObjectSlot::load( - PtrComprCageBase cage_base) const { +HeapObjectReference CompressedHeapObjectSlot::load(IsolateRoot isolate) const { Tagged_t value = *location(); - return HeapObjectReference(DecompressTaggedPointer(cage_base, value)); + return HeapObjectReference(DecompressTaggedPointer(isolate, value)); } void CompressedHeapObjectSlot::store(HeapObjectReference value) const { @@ -150,25 +148,23 @@ void CompressedHeapObjectSlot::StoreHeapObject(HeapObject value) const { // OffHeapCompressedObjectSlot implementation. // -Object OffHeapCompressedObjectSlot::load(PtrComprCageBase cage_base) const { +Object OffHeapCompressedObjectSlot::load(IsolateRoot isolate) const { Tagged_t value = *location(); - return Object(DecompressTaggedAny(cage_base, value)); + return Object(DecompressTaggedAny(isolate, value)); } void OffHeapCompressedObjectSlot::store(Object value) const { *location() = CompressTagged(value.ptr()); } -Object OffHeapCompressedObjectSlot::Relaxed_Load( - PtrComprCageBase cage_base) const { +Object OffHeapCompressedObjectSlot::Relaxed_Load(IsolateRoot isolate) const { AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location()); - return Object(DecompressTaggedAny(cage_base, value)); + return Object(DecompressTaggedAny(isolate, value)); } -Object OffHeapCompressedObjectSlot::Acquire_Load( - PtrComprCageBase cage_base) const { +Object OffHeapCompressedObjectSlot::Acquire_Load(IsolateRoot isolate) const { AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location()); - return Object(DecompressTaggedAny(cage_base, value)); + return Object(DecompressTaggedAny(isolate, value)); } void OffHeapCompressedObjectSlot::Relaxed_Store(Object value) const { diff --git a/src/objects/compressed-slots.h b/src/objects/compressed-slots.h index 7737e685fe..6f74b723c8 100644 --- a/src/objects/compressed-slots.h +++ b/src/objects/compressed-slots.h @@ -41,12 +41,12 @@ class CompressedObjectSlot : public SlotBase { // TODO(leszeks): Consider deprecating the operator* load, and always pass the // Isolate. inline Object operator*() const; - inline Object load(PtrComprCageBase cage_base) const; + inline Object load(IsolateRoot isolate) const; inline void store(Object value) const; inline Object Acquire_Load() const; inline Object Relaxed_Load() const; - inline Object Relaxed_Load(PtrComprCageBase cage_base) const; + inline Object Relaxed_Load(IsolateRoot isolate) const; inline void Relaxed_Store(Object value) const; inline void Release_Store(Object value) const; inline Object Release_CompareAndSwap(Object old, Object target) const; @@ -77,11 +77,11 @@ class CompressedMaybeObjectSlot : SlotBase(slot.address()) {} inline MaybeObject operator*() const; - inline MaybeObject load(PtrComprCageBase cage_base) const; + inline MaybeObject load(IsolateRoot isolate) const; inline void store(MaybeObject value) const; inline MaybeObject Relaxed_Load() const; - inline MaybeObject Relaxed_Load(PtrComprCageBase cage_base) const; + inline MaybeObject Relaxed_Load(IsolateRoot isolate) const; inline void Relaxed_Store(MaybeObject value) const; inline void Release_CompareAndSwap(MaybeObject old, MaybeObject target) const; }; @@ -105,7 +105,7 @@ class CompressedHeapObjectSlot : SlotBase(slot.address()) {} inline HeapObjectReference operator*() const; - inline HeapObjectReference load(PtrComprCageBase cage_base) const; + inline HeapObjectReference load(IsolateRoot isolate) const; inline void store(HeapObjectReference value) const; inline HeapObject ToHeapObject() const; @@ -131,11 +131,11 @@ class OffHeapCompressedObjectSlot explicit OffHeapCompressedObjectSlot(const uint32_t* ptr) : SlotBase(reinterpret_cast
(ptr)) {} - inline Object load(PtrComprCageBase cage_base) const; + inline Object load(IsolateRoot isolate) const; inline void store(Object value) const; - inline Object Relaxed_Load(PtrComprCageBase cage_base) const; - inline Object Acquire_Load(PtrComprCageBase cage_base) const; + inline Object Relaxed_Load(IsolateRoot isolate) const; + inline Object Acquire_Load(IsolateRoot isolate) const; inline void Relaxed_Store(Object value) const; inline void Release_Store(Object value) const; inline void Release_CompareAndSwap(Object old, Object target) const; diff --git a/src/objects/contexts-inl.h b/src/objects/contexts-inl.h index 356df687de..b036b00686 100644 --- a/src/objects/contexts-inl.h +++ b/src/objects/contexts-inl.h @@ -56,8 +56,8 @@ NEVER_READ_ONLY_SPACE_IMPL(Context) CAST_ACCESSOR(NativeContext) V8_INLINE Object Context::get(int index) const { return elements(index); } -V8_INLINE Object Context::get(PtrComprCageBase cage_base, int index) const { - return elements(cage_base, index); +V8_INLINE Object Context::get(IsolateRoot isolate, int index) const { + return elements(isolate, index); } V8_INLINE void Context::set(int index, Object value) { set_elements(index, value); @@ -71,11 +71,11 @@ void Context::set_scope_info(ScopeInfo scope_info, WriteBarrierMode mode) { } Object Context::synchronized_get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return synchronized_get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return synchronized_get(isolate, index); } -Object Context::synchronized_get(PtrComprCageBase cage_base, int index) const { +Object Context::synchronized_get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(this->length())); return ACQUIRE_READ_FIELD(*this, OffsetOfElementAt(index)); @@ -243,7 +243,7 @@ Map Context::GetInitialJSArrayMap(ElementsKind kind) const { DEF_GETTER(NativeContext, microtask_queue, MicrotaskQueue*) { return reinterpret_cast(ReadExternalPointerField( - kMicrotaskQueueOffset, cage_base, kNativeContextMicrotaskQueueTag)); + kMicrotaskQueueOffset, isolate, kNativeContextMicrotaskQueueTag)); } void NativeContext::AllocateExternalPointerEntries(Isolate* isolate) { diff --git a/src/objects/contexts.h b/src/objects/contexts.h index 79aed5d40f..cae923ef8e 100644 --- a/src/objects/contexts.h +++ b/src/objects/contexts.h @@ -422,14 +422,13 @@ class Context : public TorqueGeneratedContext { // Setter and getter for elements. V8_INLINE Object get(int index) const; - V8_INLINE Object get(PtrComprCageBase cage_base, int index) const; + V8_INLINE Object get(IsolateRoot isolate, int index) const; V8_INLINE void set(int index, Object value); // Setter with explicit barrier mode. V8_INLINE void set(int index, Object value, WriteBarrierMode mode); // Setter and getter with synchronization semantics. V8_INLINE Object synchronized_get(int index) const; - V8_INLINE Object synchronized_get(PtrComprCageBase cage_base, - int index) const; + V8_INLINE Object synchronized_get(IsolateRoot isolate, int index) const; V8_INLINE void synchronized_set(int index, Object value); static const int kScopeInfoOffset = kElementsOffset; diff --git a/src/objects/descriptor-array-inl.h b/src/objects/descriptor-array-inl.h index 9bb01ffc4d..9a40298420 100644 --- a/src/objects/descriptor-array-inl.h +++ b/src/objects/descriptor-array-inl.h @@ -106,16 +106,15 @@ ObjectSlot DescriptorArray::GetDescriptorSlot(int descriptor) { } Name DescriptorArray::GetKey(InternalIndex descriptor_number) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return GetKey(cage_base, descriptor_number); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return GetKey(isolate, descriptor_number); } -Name DescriptorArray::GetKey(PtrComprCageBase cage_base, +Name DescriptorArray::GetKey(IsolateRoot isolate, InternalIndex descriptor_number) const { DCHECK_LT(descriptor_number.as_int(), number_of_descriptors()); int entry_offset = OffsetOfDescriptorAt(descriptor_number.as_int()); - return Name::cast( - EntryKeyField::Relaxed_Load(cage_base, *this, entry_offset)); + return Name::cast(EntryKeyField::Relaxed_Load(isolate, *this, entry_offset)); } void DescriptorArray::SetKey(InternalIndex descriptor_number, Name key) { @@ -130,13 +129,12 @@ int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { } Name DescriptorArray::GetSortedKey(int descriptor_number) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return GetSortedKey(cage_base, descriptor_number); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return GetSortedKey(isolate, descriptor_number); } -Name DescriptorArray::GetSortedKey(PtrComprCageBase cage_base, - int descriptor_number) { - return GetKey(cage_base, InternalIndex(GetSortedKeyIndex(descriptor_number))); +Name DescriptorArray::GetSortedKey(IsolateRoot isolate, int descriptor_number) { + return GetKey(isolate, InternalIndex(GetSortedKeyIndex(descriptor_number))); } void DescriptorArray::SetSortedKey(int descriptor_number, int pointer) { @@ -145,13 +143,13 @@ void DescriptorArray::SetSortedKey(int descriptor_number, int pointer) { } Object DescriptorArray::GetStrongValue(InternalIndex descriptor_number) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return GetStrongValue(cage_base, descriptor_number); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return GetStrongValue(isolate, descriptor_number); } -Object DescriptorArray::GetStrongValue(PtrComprCageBase cage_base, +Object DescriptorArray::GetStrongValue(IsolateRoot isolate, InternalIndex descriptor_number) { - return GetValue(cage_base, descriptor_number).cast(); + return GetValue(isolate, descriptor_number).cast(); } void DescriptorArray::SetValue(InternalIndex descriptor_number, @@ -163,15 +161,15 @@ void DescriptorArray::SetValue(InternalIndex descriptor_number, } MaybeObject DescriptorArray::GetValue(InternalIndex descriptor_number) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return GetValue(cage_base, descriptor_number); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return GetValue(isolate, descriptor_number); } -MaybeObject DescriptorArray::GetValue(PtrComprCageBase cage_base, +MaybeObject DescriptorArray::GetValue(IsolateRoot isolate, InternalIndex descriptor_number) { DCHECK_LT(descriptor_number.as_int(), number_of_descriptors()); int entry_offset = OffsetOfDescriptorAt(descriptor_number.as_int()); - return EntryValueField::Relaxed_Load(cage_base, *this, entry_offset); + return EntryValueField::Relaxed_Load(isolate, *this, entry_offset); } PropertyDetails DescriptorArray::GetDetails(InternalIndex descriptor_number) { @@ -194,14 +192,14 @@ int DescriptorArray::GetFieldIndex(InternalIndex descriptor_number) { } FieldType DescriptorArray::GetFieldType(InternalIndex descriptor_number) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return GetFieldType(cage_base, descriptor_number); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return GetFieldType(isolate, descriptor_number); } -FieldType DescriptorArray::GetFieldType(PtrComprCageBase cage_base, +FieldType DescriptorArray::GetFieldType(IsolateRoot isolate, InternalIndex descriptor_number) { DCHECK_EQ(GetDetails(descriptor_number).location(), kField); - MaybeObject wrapped_type = GetValue(cage_base, descriptor_number); + MaybeObject wrapped_type = GetValue(isolate, descriptor_number); return Map::UnwrapFieldType(wrapped_type); } diff --git a/src/objects/descriptor-array.h b/src/objects/descriptor-array.h index 327931a421..8120a0eaa0 100644 --- a/src/objects/descriptor-array.h +++ b/src/objects/descriptor-array.h @@ -69,22 +69,22 @@ class DescriptorArray // Accessors for fetching instance descriptor at descriptor number. inline Name GetKey(InternalIndex descriptor_number) const; - inline Name GetKey(PtrComprCageBase cage_base, + inline Name GetKey(IsolateRoot isolate, InternalIndex descriptor_number) const; inline Object GetStrongValue(InternalIndex descriptor_number); - inline Object GetStrongValue(PtrComprCageBase cage_base, + inline Object GetStrongValue(IsolateRoot isolate, InternalIndex descriptor_number); inline MaybeObject GetValue(InternalIndex descriptor_number); - inline MaybeObject GetValue(PtrComprCageBase cage_base, + inline MaybeObject GetValue(IsolateRoot isolate, InternalIndex descriptor_number); inline PropertyDetails GetDetails(InternalIndex descriptor_number); inline int GetFieldIndex(InternalIndex descriptor_number); inline FieldType GetFieldType(InternalIndex descriptor_number); - inline FieldType GetFieldType(PtrComprCageBase cage_base, + inline FieldType GetFieldType(IsolateRoot isolate, InternalIndex descriptor_number); inline Name GetSortedKey(int descriptor_number); - inline Name GetSortedKey(PtrComprCageBase cage_base, int descriptor_number); + inline Name GetSortedKey(IsolateRoot isolate, int descriptor_number); inline int GetSortedKeyIndex(int descriptor_number); // Accessor for complete descriptor. diff --git a/src/objects/dictionary-inl.h b/src/objects/dictionary-inl.h index bb3d8d5879..981f5aac93 100644 --- a/src/objects/dictionary-inl.h +++ b/src/objects/dictionary-inl.h @@ -30,15 +30,15 @@ Dictionary::Dictionary(Address ptr) template Object Dictionary::ValueAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return ValueAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return ValueAt(isolate, entry); } template -Object Dictionary::ValueAt(PtrComprCageBase cage_base, +Object Dictionary::ValueAt(IsolateRoot isolate, InternalIndex entry) { - return this->get(cage_base, DerivedHashTable::EntryToIndex(entry) + - Derived::kEntryValueIndex); + return this->get(isolate, DerivedHashTable::EntryToIndex(entry) + + Derived::kEntryValueIndex); } template @@ -181,12 +181,12 @@ Handle GlobalDictionary::GetMap(ReadOnlyRoots roots) { } Name NameDictionary::NameAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return NameAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return NameAt(isolate, entry); } -Name NameDictionary::NameAt(PtrComprCageBase cage_base, InternalIndex entry) { - return Name::cast(KeyAt(cage_base, entry)); +Name NameDictionary::NameAt(IsolateRoot isolate, InternalIndex entry) { + return Name::cast(KeyAt(isolate, entry)); } Handle NameDictionary::GetMap(ReadOnlyRoots roots) { @@ -194,33 +194,32 @@ Handle NameDictionary::GetMap(ReadOnlyRoots roots) { } PropertyCell GlobalDictionary::CellAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return CellAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return CellAt(isolate, entry); } -PropertyCell GlobalDictionary::CellAt(PtrComprCageBase cage_base, +PropertyCell GlobalDictionary::CellAt(IsolateRoot isolate, InternalIndex entry) { - DCHECK(KeyAt(cage_base, entry).IsPropertyCell(cage_base)); - return PropertyCell::cast(KeyAt(cage_base, entry)); + DCHECK(KeyAt(isolate, entry).IsPropertyCell(isolate)); + return PropertyCell::cast(KeyAt(isolate, entry)); } Name GlobalDictionary::NameAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return NameAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return NameAt(isolate, entry); } -Name GlobalDictionary::NameAt(PtrComprCageBase cage_base, InternalIndex entry) { - return CellAt(cage_base, entry).name(cage_base); +Name GlobalDictionary::NameAt(IsolateRoot isolate, InternalIndex entry) { + return CellAt(isolate, entry).name(isolate); } Object GlobalDictionary::ValueAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return ValueAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return ValueAt(isolate, entry); } -Object GlobalDictionary::ValueAt(PtrComprCageBase cage_base, - InternalIndex entry) { - return CellAt(cage_base, entry).value(cage_base); +Object GlobalDictionary::ValueAt(IsolateRoot isolate, InternalIndex entry) { + return CellAt(isolate, entry).value(isolate); } void GlobalDictionary::SetEntry(InternalIndex entry, Object key, Object value, diff --git a/src/objects/dictionary.h b/src/objects/dictionary.h index be255f8162..2a650f7019 100644 --- a/src/objects/dictionary.h +++ b/src/objects/dictionary.h @@ -39,7 +39,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary using Key = typename Shape::Key; // Returns the value at entry. inline Object ValueAt(InternalIndex entry); - inline Object ValueAt(PtrComprCageBase cage_base, InternalIndex entry); + inline Object ValueAt(IsolateRoot isolate, InternalIndex entry); // Set the value for entry. inline void ValueAtPut(InternalIndex entry, Object value); @@ -193,7 +193,7 @@ class V8_EXPORT_PRIVATE NameDictionary static const int kInitialCapacity = 2; inline Name NameAt(InternalIndex entry); - inline Name NameAt(PtrComprCageBase cage_base, InternalIndex entry); + inline Name NameAt(IsolateRoot isolate, InternalIndex entry); inline void set_hash(int hash); inline int hash() const; @@ -231,14 +231,14 @@ class V8_EXPORT_PRIVATE GlobalDictionary DECL_PRINTER(GlobalDictionary) inline Object ValueAt(InternalIndex entry); - inline Object ValueAt(PtrComprCageBase cage_base, InternalIndex entry); + inline Object ValueAt(IsolateRoot isolate, InternalIndex entry); inline PropertyCell CellAt(InternalIndex entry); - inline PropertyCell CellAt(PtrComprCageBase cage_base, InternalIndex entry); + inline PropertyCell CellAt(IsolateRoot isolate, InternalIndex entry); inline void SetEntry(InternalIndex entry, Object key, Object value, PropertyDetails details); inline void ClearEntry(InternalIndex entry); inline Name NameAt(InternalIndex entry); - inline Name NameAt(PtrComprCageBase cage_base, InternalIndex entry); + inline Name NameAt(IsolateRoot isolate, InternalIndex entry); inline void ValueAtPut(InternalIndex entry, Object value); OBJECT_CONSTRUCTORS( diff --git a/src/objects/elements.cc b/src/objects/elements.cc index 9b1c7936bb..1882024d4e 100644 --- a/src/objects/elements.cc +++ b/src/objects/elements.cc @@ -1421,10 +1421,10 @@ class DictionaryElementsAccessor DisallowGarbageCollection no_gc; NumberDictionary dict = NumberDictionary::cast(backing_store); if (!dict.requires_slow_elements()) return false; - PtrComprCageBase cage_base = GetPtrComprCageBase(holder); - ReadOnlyRoots roots = holder.GetReadOnlyRoots(cage_base); + IsolateRoot isolate = GetIsolateForPtrCompr(holder); + ReadOnlyRoots roots = holder.GetReadOnlyRoots(isolate); for (InternalIndex i : dict.IterateEntries()) { - Object key = dict.KeyAt(cage_base, i); + Object key = dict.KeyAt(isolate, i); if (!dict.IsKey(roots, key)) continue; PropertyDetails details = dict.DetailsAt(i); if (details.kind() == kAccessor) return true; diff --git a/src/objects/embedder-data-slot-inl.h b/src/objects/embedder-data-slot-inl.h index 3f8deb39f0..f9ef6e1e56 100644 --- a/src/objects/embedder-data-slot-inl.h +++ b/src/objects/embedder-data-slot-inl.h @@ -81,7 +81,7 @@ void EmbedderDataSlot::store_tagged(JSObject object, int embedder_field_index, #endif } -bool EmbedderDataSlot::ToAlignedPointer(PtrComprCageBase isolate_root, +bool EmbedderDataSlot::ToAlignedPointer(IsolateRoot isolate_root, void** out_pointer) const { // We don't care about atomicity of access here because embedder slots // are accessed this way only from the main thread via API during "mutator" @@ -89,12 +89,6 @@ bool EmbedderDataSlot::ToAlignedPointer(PtrComprCageBase isolate_root, // at the tagged part of the embedder slot but read-only access is ok). Address raw_value; #ifdef V8_HEAP_SANDBOX - - // TODO(syg): V8_HEAP_SANDBOX doesn't work with pointer cage -#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE -#error "V8_HEAP_SANDBOX requires per-Isolate pointer compression cage" -#endif - uint32_t index = base::Memory(address() + kRawPayloadOffset); const Isolate* isolate = Isolate::FromRootAddress(isolate_root.address()); raw_value = isolate->external_pointer_table().get(index) ^ @@ -114,15 +108,9 @@ bool EmbedderDataSlot::ToAlignedPointer(PtrComprCageBase isolate_root, return HAS_SMI_TAG(raw_value); } -bool EmbedderDataSlot::ToAlignedPointerSafe(PtrComprCageBase isolate_root, +bool EmbedderDataSlot::ToAlignedPointerSafe(IsolateRoot isolate_root, void** out_pointer) const { #ifdef V8_HEAP_SANDBOX - - // TODO(syg): V8_HEAP_SANDBOX doesn't work with pointer cage -#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE -#error "V8_HEAP_SANDBOX requires per-Isolate pointer compression cage" -#endif - uint32_t index = base::Memory(address() + kRawPayloadOffset); Address raw_value; const Isolate* isolate = Isolate::FromRootAddress(isolate_root.address()); diff --git a/src/objects/embedder-data-slot.h b/src/objects/embedder-data-slot.h index 65fe78403a..8f4fcc8af2 100644 --- a/src/objects/embedder-data-slot.h +++ b/src/objects/embedder-data-slot.h @@ -75,8 +75,7 @@ class EmbedderDataSlot // When V8 heap sandbox is enabled, calling this method when the raw part of // the slot does not contain valid external pointer table index is undefined // behaviour and most likely result in crashes. - V8_INLINE bool ToAlignedPointer(PtrComprCageBase isolate_root, - void** out_result) const; + V8_INLINE bool ToAlignedPointer(IsolateRoot isolate, void** out_result) const; // Same as ToAlignedPointer() but with a workaround for V8 heap sandbox. // When V8 heap sandbox is enabled, this method doesn't crash when the raw @@ -87,7 +86,7 @@ class EmbedderDataSlot // // Call this function if you are not sure whether the slot contains valid // external pointer or not. - V8_INLINE bool ToAlignedPointerSafe(PtrComprCageBase isolate_root, + V8_INLINE bool ToAlignedPointerSafe(IsolateRoot isolate, void** out_result) const; // Returns true if the pointer was successfully stored or false it the pointer diff --git a/src/objects/feedback-vector-inl.h b/src/objects/feedback-vector-inl.h index 8853dabdbd..a66ec312f6 100644 --- a/src/objects/feedback-vector-inl.h +++ b/src/objects/feedback-vector-inl.h @@ -187,9 +187,8 @@ MaybeObject FeedbackVector::Get(FeedbackSlot slot) const { return value; } -MaybeObject FeedbackVector::Get(PtrComprCageBase cage_base, - FeedbackSlot slot) const { - MaybeObject value = raw_feedback_slots(cage_base, GetIndex(slot)); +MaybeObject FeedbackVector::Get(IsolateRoot isolate, FeedbackSlot slot) const { + MaybeObject value = raw_feedback_slots(isolate, GetIndex(slot)); DCHECK(!IsOfLegacyType(value)); return value; } diff --git a/src/objects/feedback-vector.h b/src/objects/feedback-vector.h index cc5e867f72..e6a850fe52 100644 --- a/src/objects/feedback-vector.h +++ b/src/objects/feedback-vector.h @@ -259,7 +259,7 @@ class FeedbackVector WriteBarrierMode mode = UPDATE_WRITE_BARRIER); inline MaybeObject Get(FeedbackSlot slot) const; - inline MaybeObject Get(PtrComprCageBase cage_base, FeedbackSlot slot) const; + inline MaybeObject Get(IsolateRoot isolate, FeedbackSlot slot) const; // Returns the feedback cell at |index| that is used to create the // closure. diff --git a/src/objects/field-index-inl.h b/src/objects/field-index-inl.h index 64bb421301..09056cfd99 100644 --- a/src/objects/field-index-inl.h +++ b/src/objects/field-index-inl.h @@ -61,13 +61,13 @@ int FieldIndex::GetLoadByFieldIndex() const { } FieldIndex FieldIndex::ForDescriptor(Map map, InternalIndex descriptor_index) { - PtrComprCageBase cage_base = GetPtrComprCageBase(map); - return ForDescriptor(cage_base, map, descriptor_index); + IsolateRoot isolate = GetIsolateForPtrCompr(map); + return ForDescriptor(isolate, map, descriptor_index); } -FieldIndex FieldIndex::ForDescriptor(PtrComprCageBase cage_base, Map map, +FieldIndex FieldIndex::ForDescriptor(IsolateRoot isolate, Map map, InternalIndex descriptor_index) { - PropertyDetails details = map.instance_descriptors(cage_base, kRelaxedLoad) + PropertyDetails details = map.instance_descriptors(isolate, kRelaxedLoad) .GetDetails(descriptor_index); int field_index = details.field_index(); return ForPropertyIndex(map, field_index, details.representation()); diff --git a/src/objects/field-index.h b/src/objects/field-index.h index 7ccf049269..7819c8c06b 100644 --- a/src/objects/field-index.h +++ b/src/objects/field-index.h @@ -31,7 +31,7 @@ class FieldIndex final { static inline FieldIndex ForInObjectOffset(int offset, Encoding encoding); static inline FieldIndex ForDescriptor(Map map, InternalIndex descriptor_index); - static inline FieldIndex ForDescriptor(PtrComprCageBase cage_base, Map map, + static inline FieldIndex ForDescriptor(IsolateRoot isolate, Map map, InternalIndex descriptor_index); inline int GetLoadByFieldIndex() const; diff --git a/src/objects/fixed-array-inl.h b/src/objects/fixed-array-inl.h index 3a7c292fe5..a91f89784f 100644 --- a/src/objects/fixed-array-inl.h +++ b/src/objects/fixed-array-inl.h @@ -70,13 +70,13 @@ bool FixedArray::ContainsOnlySmisOrHoles() { } Object FixedArray::get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); } -Object FixedArray::get(PtrComprCageBase cage_base, int index) const { +Object FixedArray::get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(length())); - return TaggedField::Relaxed_Load(cage_base, *this, + return TaggedField::Relaxed_Load(isolate, *this, OffsetOfElementAt(index)); } @@ -124,12 +124,11 @@ void FixedArray::NoWriteBarrierSet(FixedArray array, int index, Object value) { } Object FixedArray::get(int index, RelaxedLoadTag) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); } -Object FixedArray::get(PtrComprCageBase cage_base, int index, - RelaxedLoadTag) const { +Object FixedArray::get(IsolateRoot isolate, int index, RelaxedLoadTag) const { DCHECK_LT(static_cast(index), static_cast(length())); return RELAXED_READ_FIELD(*this, OffsetOfElementAt(index)); } @@ -148,12 +147,11 @@ void FixedArray::set(int index, Smi value, RelaxedStoreTag tag) { } Object FixedArray::get(int index, AcquireLoadTag) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); } -Object FixedArray::get(PtrComprCageBase cage_base, int index, - AcquireLoadTag) const { +Object FixedArray::get(IsolateRoot isolate, int index, AcquireLoadTag) const { DCHECK_LT(static_cast(index), static_cast(length())); return ACQUIRE_READ_FIELD(*this, OffsetOfElementAt(index)); } @@ -437,13 +435,13 @@ void FixedDoubleArray::FillWithHoles(int from, int to) { } MaybeObject WeakFixedArray::Get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return Get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return Get(isolate, index); } -MaybeObject WeakFixedArray::Get(PtrComprCageBase cage_base, int index) const { +MaybeObject WeakFixedArray::Get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(length())); - return objects(cage_base, index); + return objects(isolate, index); } void WeakFixedArray::Set(int index, MaybeObject value, WriteBarrierMode mode) { @@ -472,13 +470,13 @@ void WeakFixedArray::CopyElements(Isolate* isolate, int dst_index, } MaybeObject WeakArrayList::Get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return Get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return Get(isolate, index); } -MaybeObject WeakArrayList::Get(PtrComprCageBase cage_base, int index) const { +MaybeObject WeakArrayList::Get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(capacity())); - return objects(cage_base, index); + return objects(isolate, index); } void WeakArrayList::Set(int index, MaybeObject value, WriteBarrierMode mode) { @@ -527,8 +525,8 @@ Object ArrayList::Get(int index) const { return FixedArray::cast(*this).get(kFirstIndex + index); } -Object ArrayList::Get(PtrComprCageBase cage_base, int index) const { - return FixedArray::cast(*this).get(cage_base, kFirstIndex + index); +Object ArrayList::Get(IsolateRoot isolate, int index) const { + return FixedArray::cast(*this).get(isolate, kFirstIndex + index); } ObjectSlot ArrayList::Slot(int index) { @@ -652,8 +650,8 @@ Object TemplateList::get(int index) const { return FixedArray::cast(*this).get(kFirstElementIndex + index); } -Object TemplateList::get(PtrComprCageBase cage_base, int index) const { - return FixedArray::cast(*this).get(cage_base, kFirstElementIndex + index); +Object TemplateList::get(IsolateRoot isolate, int index) const { + return FixedArray::cast(*this).get(isolate, kFirstElementIndex + index); } void TemplateList::set(int index, Object value) { diff --git a/src/objects/fixed-array.h b/src/objects/fixed-array.h index 98c5d8d5b5..53b4cbb22b 100644 --- a/src/objects/fixed-array.h +++ b/src/objects/fixed-array.h @@ -101,7 +101,7 @@ class FixedArray public: // Setter and getter for elements. inline Object get(int index) const; - inline Object get(PtrComprCageBase cage_base, int index) const; + inline Object get(IsolateRoot isolate, int index) const; static inline Handle get(FixedArray array, int index, Isolate* isolate); @@ -113,16 +113,14 @@ class FixedArray // Relaxed accessors. inline Object get(int index, RelaxedLoadTag) const; - inline Object get(PtrComprCageBase cage_base, int index, - RelaxedLoadTag) const; + inline Object get(IsolateRoot isolate, int index, RelaxedLoadTag) const; inline void set(int index, Object value, RelaxedStoreTag, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); inline void set(int index, Smi value, RelaxedStoreTag); // Acquire/release accessors. inline Object get(int index, AcquireLoadTag) const; - inline Object get(PtrComprCageBase cage_base, int index, - AcquireLoadTag) const; + inline Object get(IsolateRoot isolate, int index, AcquireLoadTag) const; inline void set(int index, Object value, ReleaseStoreTag, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); inline void set(int index, Smi value, ReleaseStoreTag); @@ -277,7 +275,7 @@ class WeakFixedArray : public TorqueGeneratedWeakFixedArray { public: inline MaybeObject Get(int index) const; - inline MaybeObject Get(PtrComprCageBase cage_base, int index) const; + inline MaybeObject Get(IsolateRoot isolate, int index) const; inline void Set( int index, MaybeObject value, @@ -352,7 +350,7 @@ class WeakArrayList V8_EXPORT_PRIVATE void Compact(Isolate* isolate); inline MaybeObject Get(int index) const; - inline MaybeObject Get(PtrComprCageBase cage_base, int index) const; + inline MaybeObject Get(IsolateRoot isolate, int index) const; // Set the element at index to obj. The underlying array must be large enough. // If you need to grow the WeakArrayList, use the static AddToEnd() method @@ -452,7 +450,7 @@ class ArrayList : public TorqueGeneratedArrayList { // storage capacity, i.e., length(). inline void SetLength(int length); inline Object Get(int index) const; - inline Object Get(PtrComprCageBase cage_base, int index) const; + inline Object Get(IsolateRoot isolate, int index) const; inline ObjectSlot Slot(int index); // Set the element at index to obj. The underlying array must be large enough. @@ -598,7 +596,7 @@ class TemplateList static Handle New(Isolate* isolate, int size); inline int length() const; inline Object get(int index) const; - inline Object get(PtrComprCageBase cage_base, int index) const; + inline Object get(IsolateRoot isolate, int index) const; inline void set(int index, Object value); static Handle Add(Isolate* isolate, Handle list, Handle value); diff --git a/src/objects/foreign-inl.h b/src/objects/foreign-inl.h index 150857f49a..cb3dac91eb 100644 --- a/src/objects/foreign-inl.h +++ b/src/objects/foreign-inl.h @@ -29,7 +29,7 @@ bool Foreign::IsNormalized(Object value) { } DEF_GETTER(Foreign, foreign_address, Address) { - return ReadExternalPointerField(kForeignAddressOffset, cage_base, + return ReadExternalPointerField(kForeignAddressOffset, isolate, kForeignForeignAddressTag); } diff --git a/src/objects/hash-table-inl.h b/src/objects/hash-table-inl.h index 27645058b3..08f30ad004 100644 --- a/src/objects/hash-table-inl.h +++ b/src/objects/hash-table-inl.h @@ -139,7 +139,7 @@ InternalIndex HashTable::FindEntry(LocalIsolate* isolate, // Find entry for key otherwise return kNotFound. template -InternalIndex HashTable::FindEntry(PtrComprCageBase cage_base, +InternalIndex HashTable::FindEntry(IsolateRoot isolate, ReadOnlyRoots roots, Key key, int32_t hash) { DisallowGarbageCollection no_gc; @@ -151,7 +151,7 @@ InternalIndex HashTable::FindEntry(PtrComprCageBase cage_base, // EnsureCapacity will guarantee the hash table is never full. for (InternalIndex entry = FirstProbe(hash, capacity);; entry = NextProbe(entry, count++, capacity)) { - Object element = KeyAt(cage_base, entry); + Object element = KeyAt(isolate, entry); // Empty entry. Uses raw unchecked accessors because it is called by the // string table during bootstrapping. if (element == undefined) return InternalIndex::NotFound(); @@ -177,24 +177,24 @@ bool HashTable::ToKey(ReadOnlyRoots roots, InternalIndex entry, } template -bool HashTable::ToKey(PtrComprCageBase cage_base, - InternalIndex entry, Object* out_k) { - Object k = KeyAt(cage_base, entry); - if (!IsKey(GetReadOnlyRoots(cage_base), k)) return false; +bool HashTable::ToKey(IsolateRoot isolate, InternalIndex entry, + Object* out_k) { + Object k = KeyAt(isolate, entry); + if (!IsKey(GetReadOnlyRoots(isolate), k)) return false; *out_k = Shape::Unwrap(k); return true; } template Object HashTable::KeyAt(InternalIndex entry) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return KeyAt(cage_base, entry); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return KeyAt(isolate, entry); } template -Object HashTable::KeyAt(PtrComprCageBase cage_base, +Object HashTable::KeyAt(IsolateRoot isolate, InternalIndex entry) { - return get(cage_base, EntryToIndex(entry) + kEntryKeyIndex); + return get(isolate, EntryToIndex(entry) + kEntryKeyIndex); } template diff --git a/src/objects/hash-table.h b/src/objects/hash-table.h index 12ac020fb7..39d8e326f6 100644 --- a/src/objects/hash-table.h +++ b/src/objects/hash-table.h @@ -138,25 +138,24 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable void IterateElements(ObjectVisitor* visitor); // Find entry for key otherwise return kNotFound. - inline InternalIndex FindEntry(PtrComprCageBase cage_base, - ReadOnlyRoots roots, Key key, int32_t hash); + inline InternalIndex FindEntry(IsolateRoot isolate, ReadOnlyRoots roots, + Key key, int32_t hash); template inline InternalIndex FindEntry(LocalIsolate* isolate, Key key); // Rehashes the table in-place. - void Rehash(PtrComprCageBase cage_base); + void Rehash(IsolateRoot isolate); // Returns whether k is a real key. The hole and undefined are not allowed as // keys and can be used to indicate missing or deleted elements. static inline bool IsKey(ReadOnlyRoots roots, Object k); inline bool ToKey(ReadOnlyRoots roots, InternalIndex entry, Object* out_k); - inline bool ToKey(PtrComprCageBase cage_base, InternalIndex entry, - Object* out_k); + inline bool ToKey(IsolateRoot isolate, InternalIndex entry, Object* out_k); // Returns the key at entry. inline Object KeyAt(InternalIndex entry); - inline Object KeyAt(PtrComprCageBase cage_base, InternalIndex entry); + inline Object KeyAt(IsolateRoot isolate, InternalIndex entry); static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; static const int kEntrySize = Shape::kEntrySize; @@ -218,8 +217,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable // Find the entry at which to insert element with the given key that // has the given hash value. - InternalIndex FindInsertionEntry(PtrComprCageBase cage_base, - ReadOnlyRoots roots, uint32_t hash); + InternalIndex FindInsertionEntry(IsolateRoot isolate, ReadOnlyRoots roots, + uint32_t hash); InternalIndex FindInsertionEntry(Isolate* isolate, uint32_t hash); // Computes the capacity a table with the given capacity would need to have @@ -232,7 +231,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable Isolate* isolate, Handle table, int additionalCapacity = 0); // Rehashes this hash-table into the new table. - void Rehash(PtrComprCageBase cage_base, Derived new_table); + void Rehash(IsolateRoot isolate, Derived new_table); inline void set_key(int index, Object value); inline void set_key(int index, Object value, WriteBarrierMode mode); @@ -323,7 +322,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) ObjectHashTableBase // returned in case the key is not present. Object Lookup(Handle key); Object Lookup(Handle key, int32_t hash); - Object Lookup(PtrComprCageBase cage_base, Handle key, int32_t hash); + Object Lookup(IsolateRoot isolate, Handle key, int32_t hash); // Returns the value at entry. Object ValueAt(InternalIndex entry); diff --git a/src/objects/heap-object.h b/src/objects/heap-object.h index e0aea97537..e62356218d 100644 --- a/src/objects/heap-object.h +++ b/src/objects/heap-object.h @@ -70,12 +70,12 @@ class HeapObject : public Object { // places where it might not be safe to access it. inline ReadOnlyRoots GetReadOnlyRoots() const; // This version is intended to be used for the isolate values produced by - // i::GetPtrComprCageBase(HeapObject) function which may return nullptr. - inline ReadOnlyRoots GetReadOnlyRoots(PtrComprCageBase cage_base) const; + // i::GetIsolateForPtrCompr(HeapObject) function which may return nullptr. + inline ReadOnlyRoots GetReadOnlyRoots(IsolateRoot isolate) const; #define IS_TYPE_FUNCTION_DECL(Type) \ V8_INLINE bool Is##Type() const; \ - V8_INLINE bool Is##Type(PtrComprCageBase cage_base) const; + V8_INLINE bool Is##Type(IsolateRoot isolate) const; HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) IS_TYPE_FUNCTION_DECL(HashTableBase) IS_TYPE_FUNCTION_DECL(SmallOrderedHashTable) @@ -96,7 +96,7 @@ class HeapObject : public Object { #define DECL_STRUCT_PREDICATE(NAME, Name, name) \ V8_INLINE bool Is##Name() const; \ - V8_INLINE bool Is##Name(PtrComprCageBase cage_base) const; + V8_INLINE bool Is##Name(IsolateRoot isolate) const; STRUCT_LIST(DECL_STRUCT_PREDICATE) #undef DECL_STRUCT_PREDICATE diff --git a/src/objects/js-array-buffer-inl.h b/src/objects/js-array-buffer-inl.h index b4aa5e33b9..66389ce431 100644 --- a/src/objects/js-array-buffer-inl.h +++ b/src/objects/js-array-buffer-inl.h @@ -43,7 +43,7 @@ void JSArrayBuffer::set_byte_length(size_t value) { } DEF_GETTER(JSArrayBuffer, backing_store, void*) { - Address value = ReadExternalPointerField(kBackingStoreOffset, cage_base, + Address value = ReadExternalPointerField(kBackingStoreOffset, isolate, kArrayBufferBackingStoreTag); return reinterpret_cast(value); } @@ -199,7 +199,7 @@ void JSTypedArray::set_length(size_t value) { } DEF_GETTER(JSTypedArray, external_pointer, Address) { - return ReadExternalPointerField(kExternalPointerOffset, cage_base, + return ReadExternalPointerField(kExternalPointerOffset, isolate, kTypedArrayExternalPointerTag); } @@ -213,9 +213,9 @@ void JSTypedArray::set_external_pointer(Isolate* isolate, Address value) { } Address JSTypedArray::ExternalPointerCompensationForOnHeapArray( - PtrComprCageBase cage_base) { + IsolateRoot isolate) { #ifdef V8_COMPRESS_POINTERS - return cage_base.address(); + return isolate.address(); #else return 0; #endif @@ -321,7 +321,7 @@ MaybeHandle JSTypedArray::Validate(Isolate* isolate, DEF_GETTER(JSDataView, data_pointer, void*) { return reinterpret_cast(ReadExternalPointerField( - kDataPointerOffset, cage_base, kDataViewDataPointerTag)); + kDataPointerOffset, isolate, kDataViewDataPointerTag)); } void JSDataView::AllocateExternalPointerEntries(Isolate* isolate) { diff --git a/src/objects/js-array-buffer.h b/src/objects/js-array-buffer.h index 3ec5e0d517..0c259ddece 100644 --- a/src/objects/js-array-buffer.h +++ b/src/objects/js-array-buffer.h @@ -300,7 +300,7 @@ class JSTypedArray // as Tagged_t value and an |external_pointer| value. // For full-pointer mode the compensation value is zero. static inline Address ExternalPointerCompensationForOnHeapArray( - PtrComprCageBase cage_base); + IsolateRoot isolate); // // Serializer/deserializer support. diff --git a/src/objects/js-array-inl.h b/src/objects/js-array-inl.h index ed7ab4e003..b53a8919a5 100644 --- a/src/objects/js-array-inl.h +++ b/src/objects/js-array-inl.h @@ -22,7 +22,7 @@ CAST_ACCESSOR(JSArray) CAST_ACCESSOR(JSArrayIterator) DEF_GETTER(JSArray, length, Object) { - return TaggedField::load(cage_base, *this); + return TaggedField::load(isolate, *this); } void JSArray::set_length(Object value, WriteBarrierMode mode) { @@ -31,8 +31,8 @@ void JSArray::set_length(Object value, WriteBarrierMode mode) { CONDITIONAL_WRITE_BARRIER(*this, kLengthOffset, value, mode); } -Object JSArray::length(PtrComprCageBase cage_base, RelaxedLoadTag tag) const { - return TaggedField::Relaxed_Load(cage_base, *this); +Object JSArray::length(IsolateRoot isolate, RelaxedLoadTag tag) const { + return TaggedField::Relaxed_Load(isolate, *this); } void JSArray::set_length(Smi length) { diff --git a/src/objects/js-array.h b/src/objects/js-array.h index a8b336d2be..b1bdad314c 100644 --- a/src/objects/js-array.h +++ b/src/objects/js-array.h @@ -32,7 +32,7 @@ class JSArray : public JSObject { // acquire/release semantics ever become necessary, the default setter should // be reverted to non-atomic behavior, and setters with explicit tags // introduced and used when required. - Object length(PtrComprCageBase cage_base, AcquireLoadTag tag) const = delete; + Object length(IsolateRoot isolate, AcquireLoadTag tag) const = delete; void set_length(Object value, ReleaseStoreTag tag, WriteBarrierMode mode = UPDATE_WRITE_BARRIER) = delete; diff --git a/src/objects/js-function-inl.h b/src/objects/js-function-inl.h index 5c8cb5b644..adf52a908d 100644 --- a/src/objects/js-function-inl.h +++ b/src/objects/js-function-inl.h @@ -210,62 +210,63 @@ ACCESSORS_CHECKED(JSFunction, prototype_or_initial_map, HeapObject, kPrototypeOrInitialMapOffset, map().has_prototype_slot()) DEF_GETTER(JSFunction, has_prototype_slot, bool) { - return map(cage_base).has_prototype_slot(); + return map(isolate).has_prototype_slot(); } DEF_GETTER(JSFunction, initial_map, Map) { - return Map::cast(prototype_or_initial_map(cage_base)); + return Map::cast(prototype_or_initial_map(isolate)); } DEF_GETTER(JSFunction, has_initial_map, bool) { - DCHECK(has_prototype_slot(cage_base)); - return prototype_or_initial_map(cage_base).IsMap(cage_base); + DCHECK(has_prototype_slot(isolate)); + return prototype_or_initial_map(isolate).IsMap(isolate); } DEF_GETTER(JSFunction, has_instance_prototype, bool) { - DCHECK(has_prototype_slot(cage_base)); - return has_initial_map(cage_base) || - !prototype_or_initial_map(cage_base).IsTheHole( - GetReadOnlyRoots(cage_base)); + DCHECK(has_prototype_slot(isolate)); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + return has_initial_map(isolate) || + !prototype_or_initial_map(isolate).IsTheHole( + GetReadOnlyRoots(isolate)); } DEF_GETTER(JSFunction, has_prototype, bool) { - DCHECK(has_prototype_slot(cage_base)); - return map(cage_base).has_non_instance_prototype() || - has_instance_prototype(cage_base); + DCHECK(has_prototype_slot(isolate)); + return map(isolate).has_non_instance_prototype() || + has_instance_prototype(isolate); } DEF_GETTER(JSFunction, has_prototype_property, bool) { - return (has_prototype_slot(cage_base) && IsConstructor(cage_base)) || - IsGeneratorFunction(shared(cage_base).kind()); + return (has_prototype_slot(isolate) && IsConstructor(isolate)) || + IsGeneratorFunction(shared(isolate).kind()); } DEF_GETTER(JSFunction, PrototypeRequiresRuntimeLookup, bool) { - return !has_prototype_property(cage_base) || - map(cage_base).has_non_instance_prototype(); + return !has_prototype_property(isolate) || + map(isolate).has_non_instance_prototype(); } DEF_GETTER(JSFunction, instance_prototype, HeapObject) { - DCHECK(has_instance_prototype(cage_base)); - if (has_initial_map(cage_base)) - return initial_map(cage_base).prototype(cage_base); + DCHECK(has_instance_prototype(isolate)); + if (has_initial_map(isolate)) return initial_map(isolate).prototype(isolate); // When there is no initial map and the prototype is a JSReceiver, the // initial map field is used for the prototype field. - return HeapObject::cast(prototype_or_initial_map(cage_base)); + return HeapObject::cast(prototype_or_initial_map(isolate)); } DEF_GETTER(JSFunction, prototype, Object) { - DCHECK(has_prototype(cage_base)); + DCHECK(has_prototype(isolate)); // If the function's prototype property has been set to a non-JSReceiver // value, that value is stored in the constructor field of the map. - if (map(cage_base).has_non_instance_prototype()) { - Object prototype = map(cage_base).GetConstructor(cage_base); + if (map(isolate).has_non_instance_prototype()) { + Object prototype = map(isolate).GetConstructor(isolate); // The map must have a prototype in that field, not a back pointer. - DCHECK(!prototype.IsMap(cage_base)); - DCHECK(!prototype.IsFunctionTemplateInfo(cage_base)); + DCHECK(!prototype.IsMap(isolate)); + DCHECK(!prototype.IsFunctionTemplateInfo(isolate)); return prototype; } - return instance_prototype(cage_base); + return instance_prototype(isolate); } bool JSFunction::is_compiled() const { diff --git a/src/objects/js-objects-inl.h b/src/objects/js-objects-inl.h index cbbbc9fc9e..4c577b45f8 100644 --- a/src/objects/js-objects-inl.h +++ b/src/objects/js-objects-inl.h @@ -52,12 +52,11 @@ CAST_ACCESSOR(JSMessageObject) CAST_ACCESSOR(JSReceiver) DEF_GETTER(JSObject, elements, FixedArrayBase) { - return TaggedField::load(cage_base, *this); + return TaggedField::load(isolate, *this); } -FixedArrayBase JSObject::elements(PtrComprCageBase cage_base, - RelaxedLoadTag) const { - return TaggedField::Relaxed_Load(cage_base, +FixedArrayBase JSObject::elements(IsolateRoot isolate, RelaxedLoadTag) const { + return TaggedField::Relaxed_Load(isolate, *this); } @@ -250,11 +249,11 @@ void JSObject::initialize_elements() { } DEF_GETTER(JSObject, GetIndexedInterceptor, InterceptorInfo) { - return map(cage_base).GetIndexedInterceptor(cage_base); + return map(isolate).GetIndexedInterceptor(isolate); } DEF_GETTER(JSObject, GetNamedInterceptor, InterceptorInfo) { - return map(cage_base).GetNamedInterceptor(cage_base); + return map(isolate).GetNamedInterceptor(isolate); } // static @@ -323,17 +322,16 @@ void JSObject::SetEmbedderField(int index, Smi value) { // is needed to correctly distinguish between properties stored in-object and // properties stored in the properties array. Object JSObject::RawFastPropertyAt(FieldIndex index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return RawFastPropertyAt(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return RawFastPropertyAt(isolate, index); } -Object JSObject::RawFastPropertyAt(PtrComprCageBase cage_base, +Object JSObject::RawFastPropertyAt(IsolateRoot isolate, FieldIndex index) const { if (index.is_inobject()) { - return TaggedField::load(cage_base, *this, index.offset()); + return TaggedField::load(isolate, *this, index.offset()); } else { - return property_array(cage_base).get(cage_base, - index.outobject_array_index()); + return property_array(isolate).get(isolate, index.outobject_array_index()); } } @@ -427,7 +425,7 @@ ACCESSORS(JSGlobalObject, native_context, NativeContext, kNativeContextOffset) ACCESSORS(JSGlobalObject, global_proxy, JSGlobalProxy, kGlobalProxyOffset) DEF_GETTER(JSGlobalObject, native_context_unchecked, Object) { - return TaggedField::load(cage_base, *this); + return TaggedField::load(isolate, *this); } bool JSMessageObject::DidEnsureSourcePositionsAvailable() const { @@ -463,119 +461,119 @@ SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset) SMI_ACCESSORS(JSMessageObject, raw_type, kMessageTypeOffset) DEF_GETTER(JSObject, GetElementsKind, ElementsKind) { - ElementsKind kind = map(cage_base).elements_kind(); + ElementsKind kind = map(isolate).elements_kind(); #if VERIFY_HEAP && DEBUG FixedArrayBase fixed_array = FixedArrayBase::unchecked_cast( - TaggedField::load(cage_base, *this)); + TaggedField::load(isolate, *this)); // If a GC was caused while constructing this object, the elements // pointer may point to a one pointer filler map. - if (ElementsAreSafeToExamine(cage_base)) { - Map map = fixed_array.map(cage_base); + if (ElementsAreSafeToExamine(isolate)) { + Map map = fixed_array.map(isolate); if (IsSmiOrObjectElementsKind(kind)) { - DCHECK(map == GetReadOnlyRoots(cage_base).fixed_array_map() || - map == GetReadOnlyRoots(cage_base).fixed_cow_array_map()); + DCHECK(map == GetReadOnlyRoots(isolate).fixed_array_map() || + map == GetReadOnlyRoots(isolate).fixed_cow_array_map()); } else if (IsDoubleElementsKind(kind)) { - DCHECK(fixed_array.IsFixedDoubleArray(cage_base) || - fixed_array == GetReadOnlyRoots(cage_base).empty_fixed_array()); + DCHECK(fixed_array.IsFixedDoubleArray(isolate) || + fixed_array == GetReadOnlyRoots(isolate).empty_fixed_array()); } else if (kind == DICTIONARY_ELEMENTS) { - DCHECK(fixed_array.IsFixedArray(cage_base)); - DCHECK(fixed_array.IsNumberDictionary(cage_base)); + DCHECK(fixed_array.IsFixedArray(isolate)); + DCHECK(fixed_array.IsNumberDictionary(isolate)); } else { DCHECK(kind > DICTIONARY_ELEMENTS || IsAnyNonextensibleElementsKind(kind)); } DCHECK(!IsSloppyArgumentsElementsKind(kind) || - elements(cage_base).IsSloppyArgumentsElements()); + elements(isolate).IsSloppyArgumentsElements()); } #endif return kind; } DEF_GETTER(JSObject, GetElementsAccessor, ElementsAccessor*) { - return ElementsAccessor::ForKind(GetElementsKind(cage_base)); + return ElementsAccessor::ForKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasObjectElements, bool) { - return IsObjectElementsKind(GetElementsKind(cage_base)); + return IsObjectElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasSmiElements, bool) { - return IsSmiElementsKind(GetElementsKind(cage_base)); + return IsSmiElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasSmiOrObjectElements, bool) { - return IsSmiOrObjectElementsKind(GetElementsKind(cage_base)); + return IsSmiOrObjectElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasDoubleElements, bool) { - return IsDoubleElementsKind(GetElementsKind(cage_base)); + return IsDoubleElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasHoleyElements, bool) { - return IsHoleyElementsKind(GetElementsKind(cage_base)); + return IsHoleyElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasFastElements, bool) { - return IsFastElementsKind(GetElementsKind(cage_base)); + return IsFastElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasFastPackedElements, bool) { - return IsFastPackedElementsKind(GetElementsKind(cage_base)); + return IsFastPackedElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasDictionaryElements, bool) { - return IsDictionaryElementsKind(GetElementsKind(cage_base)); + return IsDictionaryElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasPackedElements, bool) { - return GetElementsKind(cage_base) == PACKED_ELEMENTS; + return GetElementsKind(isolate) == PACKED_ELEMENTS; } DEF_GETTER(JSObject, HasAnyNonextensibleElements, bool) { - return IsAnyNonextensibleElementsKind(GetElementsKind(cage_base)); + return IsAnyNonextensibleElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasSealedElements, bool) { - return IsSealedElementsKind(GetElementsKind(cage_base)); + return IsSealedElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasNonextensibleElements, bool) { - return IsNonextensibleElementsKind(GetElementsKind(cage_base)); + return IsNonextensibleElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasFastArgumentsElements, bool) { - return IsFastArgumentsElementsKind(GetElementsKind(cage_base)); + return IsFastArgumentsElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasSlowArgumentsElements, bool) { - return IsSlowArgumentsElementsKind(GetElementsKind(cage_base)); + return IsSlowArgumentsElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasSloppyArgumentsElements, bool) { - return IsSloppyArgumentsElementsKind(GetElementsKind(cage_base)); + return IsSloppyArgumentsElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasStringWrapperElements, bool) { - return IsStringWrapperElementsKind(GetElementsKind(cage_base)); + return IsStringWrapperElementsKind(GetElementsKind(isolate)); } DEF_GETTER(JSObject, HasFastStringWrapperElements, bool) { - return GetElementsKind(cage_base) == FAST_STRING_WRAPPER_ELEMENTS; + return GetElementsKind(isolate) == FAST_STRING_WRAPPER_ELEMENTS; } DEF_GETTER(JSObject, HasSlowStringWrapperElements, bool) { - return GetElementsKind(cage_base) == SLOW_STRING_WRAPPER_ELEMENTS; + return GetElementsKind(isolate) == SLOW_STRING_WRAPPER_ELEMENTS; } DEF_GETTER(JSObject, HasTypedArrayElements, bool) { - DCHECK(!elements(cage_base).is_null()); - return map(cage_base).has_typed_array_elements(); + DCHECK(!elements(isolate).is_null()); + return map(isolate).has_typed_array_elements(); } -#define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype) \ - DEF_GETTER(JSObject, HasFixed##Type##Elements, bool) { \ - return map(cage_base).elements_kind() == TYPE##_ELEMENTS; \ +#define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype) \ + DEF_GETTER(JSObject, HasFixed##Type##Elements, bool) { \ + return map(isolate).elements_kind() == TYPE##_ELEMENTS; \ } TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK) @@ -583,21 +581,21 @@ TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK) #undef FIXED_TYPED_ELEMENTS_CHECK DEF_GETTER(JSObject, HasNamedInterceptor, bool) { - return map(cage_base).has_named_interceptor(); + return map(isolate).has_named_interceptor(); } DEF_GETTER(JSObject, HasIndexedInterceptor, bool) { - return map(cage_base).has_indexed_interceptor(); + return map(isolate).has_indexed_interceptor(); } RELEASE_ACQUIRE_ACCESSORS_CHECKED2(JSGlobalObject, global_dictionary, GlobalDictionary, kPropertiesOrHashOffset, - !HasFastProperties(cage_base), true) + !HasFastProperties(isolate), true) DEF_GETTER(JSObject, element_dictionary, NumberDictionary) { - DCHECK(HasDictionaryElements(cage_base) || - HasSlowStringWrapperElements(cage_base)); - return NumberDictionary::cast(elements(cage_base)); + DCHECK(HasDictionaryElements(isolate) || + HasSlowStringWrapperElements(isolate)); + return NumberDictionary::cast(elements(isolate)); } void JSReceiver::initialize_properties(Isolate* isolate) { @@ -619,34 +617,38 @@ void JSReceiver::initialize_properties(Isolate* isolate) { } DEF_GETTER(JSReceiver, HasFastProperties, bool) { - DCHECK(raw_properties_or_hash(cage_base).IsSmi() || - ((raw_properties_or_hash(cage_base).IsGlobalDictionary(cage_base) || - raw_properties_or_hash(cage_base).IsNameDictionary(cage_base) || - raw_properties_or_hash(cage_base).IsSwissNameDictionary( - cage_base)) == map(cage_base).is_dictionary_map())); - return !map(cage_base).is_dictionary_map(); + DCHECK(raw_properties_or_hash(isolate).IsSmi() || + ((raw_properties_or_hash(isolate).IsGlobalDictionary(isolate) || + raw_properties_or_hash(isolate).IsNameDictionary(isolate) || + raw_properties_or_hash(isolate).IsSwissNameDictionary(isolate)) == + map(isolate).is_dictionary_map())); + return !map(isolate).is_dictionary_map(); } DEF_GETTER(JSReceiver, property_dictionary, NameDictionary) { - DCHECK(!IsJSGlobalObject(cage_base)); - DCHECK(!HasFastProperties(cage_base)); + DCHECK(!IsJSGlobalObject(isolate)); + DCHECK(!HasFastProperties(isolate)); DCHECK(!V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL); - Object prop = raw_properties_or_hash(cage_base); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + Object prop = raw_properties_or_hash(isolate); if (prop.IsSmi()) { - return GetReadOnlyRoots(cage_base).empty_property_dictionary(); + return GetReadOnlyRoots(isolate).empty_property_dictionary(); } return NameDictionary::cast(prop); } DEF_GETTER(JSReceiver, property_dictionary_swiss, SwissNameDictionary) { - DCHECK(!IsJSGlobalObject(cage_base)); - DCHECK(!HasFastProperties(cage_base)); + DCHECK(!IsJSGlobalObject(isolate)); + DCHECK(!HasFastProperties(isolate)); DCHECK(V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL); - Object prop = raw_properties_or_hash(cage_base); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + Object prop = raw_properties_or_hash(isolate); if (prop.IsSmi()) { - return GetReadOnlyRoots(cage_base).empty_swiss_property_dictionary(); + return GetReadOnlyRoots(isolate).empty_swiss_property_dictionary(); } return SwissNameDictionary::cast(prop); } @@ -654,10 +656,12 @@ DEF_GETTER(JSReceiver, property_dictionary_swiss, SwissNameDictionary) { // TODO(gsathya): Pass isolate directly to this function and access // the heap from this. DEF_GETTER(JSReceiver, property_array, PropertyArray) { - DCHECK(HasFastProperties(cage_base)); - Object prop = raw_properties_or_hash(cage_base); - if (prop.IsSmi() || prop == GetReadOnlyRoots(cage_base).empty_fixed_array()) { - return GetReadOnlyRoots(cage_base).empty_property_array(); + DCHECK(HasFastProperties(isolate)); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + Object prop = raw_properties_or_hash(isolate); + if (prop.IsSmi() || prop == GetReadOnlyRoots(isolate).empty_fixed_array()) { + return GetReadOnlyRoots(isolate).empty_property_array(); } return PropertyArray::cast(prop); } diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h index b1f22ed8f6..aeb2504fc4 100644 --- a/src/objects/js-objects.h +++ b/src/objects/js-objects.h @@ -319,7 +319,7 @@ class JSObject : public TorqueGeneratedJSObject { // acquire/release semantics ever become necessary, the default setter should // be reverted to non-atomic behavior, and setters with explicit tags // introduced and used when required. - FixedArrayBase elements(PtrComprCageBase cage_base, + FixedArrayBase elements(IsolateRoot isolate, AcquireLoadTag tag) const = delete; void set_elements(FixedArrayBase value, ReleaseStoreTag tag, WriteBarrierMode mode = UPDATE_WRITE_BARRIER) = delete; @@ -652,8 +652,7 @@ class JSObject : public TorqueGeneratedJSObject { Representation representation, FieldIndex index); inline Object RawFastPropertyAt(FieldIndex index) const; - inline Object RawFastPropertyAt(PtrComprCageBase cage_base, - FieldIndex index) const; + inline Object RawFastPropertyAt(IsolateRoot isolate, FieldIndex index) const; inline void FastPropertyAtPut(FieldIndex index, Object value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); @@ -743,8 +742,7 @@ class JSObject : public TorqueGeneratedJSObject { // If a GC was caused while constructing this object, the elements pointer // may point to a one pointer filler map. The object won't be rooted, but // our heap verification code could stumble across it. - V8_EXPORT_PRIVATE bool ElementsAreSafeToExamine( - PtrComprCageBase cage_base) const; + V8_EXPORT_PRIVATE bool ElementsAreSafeToExamine(IsolateRoot isolate) const; #endif Object SlowReverseLookup(Object value); diff --git a/src/objects/literal-objects-inl.h b/src/objects/literal-objects-inl.h index 26c0829f3e..4a2329ee55 100644 --- a/src/objects/literal-objects-inl.h +++ b/src/objects/literal-objects-inl.h @@ -29,26 +29,26 @@ SMI_ACCESSORS(ObjectBoilerplateDescription, flags, FixedArray::OffsetOfElementAt(kLiteralTypeOffset)) Object ObjectBoilerplateDescription::name(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return name(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return name(isolate, index); } -Object ObjectBoilerplateDescription::name(PtrComprCageBase cage_base, +Object ObjectBoilerplateDescription::name(IsolateRoot isolate, int index) const { // get() already checks for out of bounds access, but we do not want to allow // access to the last element, if it is the number of properties. DCHECK_NE(size(), index); - return get(cage_base, 2 * index + kDescriptionStartIndex); + return get(isolate, 2 * index + kDescriptionStartIndex); } Object ObjectBoilerplateDescription::value(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return value(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return value(isolate, index); } -Object ObjectBoilerplateDescription::value(PtrComprCageBase cage_base, +Object ObjectBoilerplateDescription::value(IsolateRoot isolate, int index) const { - return get(cage_base, 2 * index + 1 + kDescriptionStartIndex); + return get(isolate, 2 * index + 1 + kDescriptionStartIndex); } void ObjectBoilerplateDescription::set_key_value(int index, Object key, diff --git a/src/objects/literal-objects.h b/src/objects/literal-objects.h index 3377bcd4c2..78fa53011b 100644 --- a/src/objects/literal-objects.h +++ b/src/objects/literal-objects.h @@ -28,10 +28,10 @@ class ClassLiteral; class ObjectBoilerplateDescription : public FixedArray { public: inline Object name(int index) const; - inline Object name(PtrComprCageBase cage_base, int index) const; + inline Object name(IsolateRoot isolate, int index) const; inline Object value(int index) const; - inline Object value(PtrComprCageBase cage_base, int index) const; + inline Object value(IsolateRoot isolate, int index) const; inline void set_key_value(int index, Object key, Object value); diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h index 3a1265d848..4bc32125b5 100644 --- a/src/objects/map-inl.h +++ b/src/objects/map-inl.h @@ -107,14 +107,14 @@ BIT_FIELD_ACCESSORS(Map, bit_field3, construction_counter, DEF_GETTER(Map, GetNamedInterceptor, InterceptorInfo) { DCHECK(has_named_interceptor()); - FunctionTemplateInfo info = GetFunctionTemplateInfo(cage_base); - return InterceptorInfo::cast(info.GetNamedPropertyHandler(cage_base)); + FunctionTemplateInfo info = GetFunctionTemplateInfo(isolate); + return InterceptorInfo::cast(info.GetNamedPropertyHandler(isolate)); } DEF_GETTER(Map, GetIndexedInterceptor, InterceptorInfo) { DCHECK(has_indexed_interceptor()); - FunctionTemplateInfo info = GetFunctionTemplateInfo(cage_base); - return InterceptorInfo::cast(info.GetIndexedPropertyHandler(cage_base)); + FunctionTemplateInfo info = GetFunctionTemplateInfo(isolate); + return InterceptorInfo::cast(info.GetIndexedPropertyHandler(isolate)); } bool Map::IsMostGeneralFieldType(Representation representation, @@ -657,18 +657,19 @@ void Map::AppendDescriptor(Isolate* isolate, Descriptor* desc) { #endif } -bool Map::ConcurrentIsMap(PtrComprCageBase cage_base, - const Object& object) const { - return object.IsHeapObject() && HeapObject::cast(object).map(cage_base) == - GetReadOnlyRoots(cage_base).meta_map(); +bool Map::ConcurrentIsMap(IsolateRoot isolate, const Object& object) const { + return object.IsHeapObject() && HeapObject::cast(object).map(isolate) == + GetReadOnlyRoots(isolate).meta_map(); } DEF_GETTER(Map, GetBackPointer, HeapObject) { - Object object = constructor_or_back_pointer(cage_base); - if (ConcurrentIsMap(cage_base, object)) { + Object object = constructor_or_back_pointer(isolate); + if (ConcurrentIsMap(isolate, object)) { return Map::cast(object); } - return GetReadOnlyRoots(cage_base).undefined_value(); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + return GetReadOnlyRoots(isolate).undefined_value(); } void Map::SetBackPointer(HeapObject value, WriteBarrierMode mode) { @@ -708,11 +709,11 @@ bool Map::IsPrototypeValidityCellValid() const { } DEF_GETTER(Map, GetConstructor, Object) { - Object maybe_constructor = constructor_or_back_pointer(cage_base); + Object maybe_constructor = constructor_or_back_pointer(isolate); // Follow any back pointers. - while (ConcurrentIsMap(cage_base, maybe_constructor)) { + while (ConcurrentIsMap(isolate, maybe_constructor)) { maybe_constructor = - Map::cast(maybe_constructor).constructor_or_back_pointer(cage_base); + Map::cast(maybe_constructor).constructor_or_back_pointer(isolate); } return maybe_constructor; } @@ -729,13 +730,13 @@ Object Map::TryGetConstructor(Isolate* isolate, int max_steps) { } DEF_GETTER(Map, GetFunctionTemplateInfo, FunctionTemplateInfo) { - Object constructor = GetConstructor(cage_base); - if (constructor.IsJSFunction(cage_base)) { + Object constructor = GetConstructor(isolate); + if (constructor.IsJSFunction(isolate)) { // TODO(ishell): IsApiFunction(isolate) and get_api_func_data(isolate) - DCHECK(JSFunction::cast(constructor).shared(cage_base).IsApiFunction()); - return JSFunction::cast(constructor).shared(cage_base).get_api_func_data(); + DCHECK(JSFunction::cast(constructor).shared(isolate).IsApiFunction()); + return JSFunction::cast(constructor).shared(isolate).get_api_func_data(); } - DCHECK(constructor.IsFunctionTemplateInfo(cage_base)); + DCHECK(constructor.IsFunctionTemplateInfo(isolate)); return FunctionTemplateInfo::cast(constructor); } @@ -790,7 +791,7 @@ int NormalizedMapCache::GetIndex(Handle map) { } DEF_GETTER(HeapObject, IsNormalizedMapCache, bool) { - if (!IsWeakFixedArray(cage_base)) return false; + if (!IsWeakFixedArray(isolate)) return false; if (WeakFixedArray::cast(*this).length() != NormalizedMapCache::kEntries) { return false; } diff --git a/src/objects/map.h b/src/objects/map.h index 6eeb68d2cc..68ba2d7fe9 100644 --- a/src/objects/map.h +++ b/src/objects/map.h @@ -943,7 +943,7 @@ class Map : public HeapObject { // This is the equivalent of IsMap() but avoids reading the instance type so // it can be used concurrently without acquire load. - V8_INLINE bool ConcurrentIsMap(PtrComprCageBase cage_base, + V8_INLINE bool ConcurrentIsMap(IsolateRoot isolate, const Object& object) const; // Use the high-level instance_descriptors/SetInstanceDescriptors instead. @@ -976,8 +976,7 @@ class NormalizedMapCache : public WeakFixedArray { DECL_VERIFIER(NormalizedMapCache) private: - friend bool HeapObject::IsNormalizedMapCache( - PtrComprCageBase cage_base) const; + friend bool HeapObject::IsNormalizedMapCache(IsolateRoot isolate) const; static const int kEntries = 64; diff --git a/src/objects/maybe-object-inl.h b/src/objects/maybe-object-inl.h index 4b06fec5cb..6cabc52312 100644 --- a/src/objects/maybe-object-inl.h +++ b/src/objects/maybe-object-inl.h @@ -78,14 +78,13 @@ HeapObjectReference HeapObjectReference::From(Object object, } // static -HeapObjectReference HeapObjectReference::ClearedValue( - PtrComprCageBase cage_base) { +HeapObjectReference HeapObjectReference::ClearedValue(IsolateRoot isolate) { // Construct cleared weak ref value. #ifdef V8_COMPRESS_POINTERS // This is necessary to make pointer decompression computation also // suitable for cleared weak references. Address raw_value = - DecompressTaggedPointer(cage_base, kClearedWeakHeapObjectLower32); + DecompressTaggedPointer(isolate, kClearedWeakHeapObjectLower32); #else Address raw_value = kClearedWeakHeapObjectLower32; #endif diff --git a/src/objects/maybe-object.h b/src/objects/maybe-object.h index 0393ef6497..3fe69ee5ec 100644 --- a/src/objects/maybe-object.h +++ b/src/objects/maybe-object.h @@ -54,7 +54,7 @@ class HeapObjectReference : public MaybeObject { V8_INLINE static HeapObjectReference From(Object object, HeapObjectReferenceType type); - V8_INLINE static HeapObjectReference ClearedValue(PtrComprCageBase cage_base); + V8_INLINE static HeapObjectReference ClearedValue(IsolateRoot isolate); template V8_INLINE static void Update(THeapObjectSlot slot, HeapObject value); diff --git a/src/objects/name-inl.h b/src/objects/name-inl.h index 93c0cd3fa9..f07e1bb9ce 100644 --- a/src/objects/name-inl.h +++ b/src/objects/name-inl.h @@ -56,7 +56,7 @@ void Symbol::set_is_private_name() { } DEF_GETTER(Name, IsUniqueName, bool) { - uint32_t type = map(cage_base).instance_type(); + uint32_t type = map(isolate).instance_type(); bool result = (type & (kIsNotStringMask | kIsNotInternalizedMask)) != (kStringTag | kNotInternalizedTag); SLOW_DCHECK(result == HeapObject::IsUniqueName()); @@ -104,23 +104,23 @@ uint32_t Name::hash() const { } DEF_GETTER(Name, IsInterestingSymbol, bool) { - return IsSymbol(cage_base) && Symbol::cast(*this).is_interesting_symbol(); + return IsSymbol(isolate) && Symbol::cast(*this).is_interesting_symbol(); } DEF_GETTER(Name, IsPrivate, bool) { - return this->IsSymbol(cage_base) && Symbol::cast(*this).is_private(); + return this->IsSymbol(isolate) && Symbol::cast(*this).is_private(); } DEF_GETTER(Name, IsPrivateName, bool) { bool is_private_name = - this->IsSymbol(cage_base) && Symbol::cast(*this).is_private_name(); + this->IsSymbol(isolate) && Symbol::cast(*this).is_private_name(); DCHECK_IMPLIES(is_private_name, IsPrivate()); return is_private_name; } DEF_GETTER(Name, IsPrivateBrand, bool) { bool is_private_brand = - this->IsSymbol(cage_base) && Symbol::cast(*this).is_private_brand(); + this->IsSymbol(isolate) && Symbol::cast(*this).is_private_brand(); DCHECK_IMPLIES(is_private_brand, IsPrivateName()); return is_private_brand; } diff --git a/src/objects/object-macros.h b/src/objects/object-macros.h index 2a742d5d77..2d0abc1bb2 100644 --- a/src/objects/object-macros.h +++ b/src/objects/object-macros.h @@ -86,14 +86,14 @@ // parameter. #define DECL_GETTER(name, type) \ inline type name() const; \ - inline type name(PtrComprCageBase cage_base) const; + inline type name(IsolateRoot isolate) const; -#define DEF_GETTER(holder, name, type) \ - type holder::name() const { \ - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \ - return holder::name(cage_base); \ - } \ - type holder::name(PtrComprCageBase cage_base) const +#define DEF_GETTER(holder, name, type) \ + type holder::name() const { \ + IsolateRoot isolate = GetIsolateForPtrCompr(*this); \ + return holder::name(isolate); \ + } \ + type holder::name(IsolateRoot isolate) const #define DECL_SETTER(name, type) \ inline void set_##name(type value, \ @@ -105,7 +105,7 @@ #define DECL_ACCESSORS_LOAD_TAG(name, type, tag_type) \ inline type name(tag_type tag) const; \ - inline type name(PtrComprCageBase cage_base, tag_type) const; + inline type name(IsolateRoot isolate, tag_type) const; #define DECL_ACCESSORS_STORE_TAG(name, type, tag_type) \ inline void set_##name(type value, tag_type, \ @@ -179,7 +179,7 @@ #define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \ set_condition) \ DEF_GETTER(holder, name, type) { \ - type value = TaggedField::load(cage_base, *this); \ + type value = TaggedField::load(isolate, *this); \ DCHECK(get_condition); \ return value; \ } \ @@ -215,11 +215,11 @@ #define RELAXED_ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \ set_condition) \ type holder::name(RelaxedLoadTag tag) const { \ - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \ - return holder::name(cage_base, tag); \ + IsolateRoot isolate = GetIsolateForPtrCompr(*this); \ + return holder::name(isolate, tag); \ } \ - type holder::name(PtrComprCageBase cage_base, RelaxedLoadTag) const { \ - type value = TaggedField::Relaxed_Load(cage_base, *this); \ + type holder::name(IsolateRoot isolate, RelaxedLoadTag) const { \ + type value = TaggedField::Relaxed_Load(isolate, *this); \ DCHECK(get_condition); \ return value; \ } \ @@ -236,22 +236,22 @@ #define RELAXED_ACCESSORS(holder, name, type, offset) \ RELAXED_ACCESSORS_CHECKED(holder, name, type, offset, true) -#define RELEASE_ACQUIRE_ACCESSORS_CHECKED2(holder, name, type, offset, \ - get_condition, set_condition) \ - type holder::name(AcquireLoadTag tag) const { \ - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \ - return holder::name(cage_base, tag); \ - } \ - type holder::name(PtrComprCageBase cage_base, AcquireLoadTag) const { \ - type value = TaggedField::Acquire_Load(cage_base, *this); \ - DCHECK(get_condition); \ - return value; \ - } \ - void holder::set_##name(type value, ReleaseStoreTag, \ - WriteBarrierMode mode) { \ - DCHECK(set_condition); \ - TaggedField::Release_Store(*this, value); \ - CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \ +#define RELEASE_ACQUIRE_ACCESSORS_CHECKED2(holder, name, type, offset, \ + get_condition, set_condition) \ + type holder::name(AcquireLoadTag tag) const { \ + IsolateRoot isolate = GetIsolateForPtrCompr(*this); \ + return holder::name(isolate, tag); \ + } \ + type holder::name(IsolateRoot isolate, AcquireLoadTag) const { \ + type value = TaggedField::Acquire_Load(isolate, *this); \ + DCHECK(get_condition); \ + return value; \ + } \ + void holder::set_##name(type value, ReleaseStoreTag, \ + WriteBarrierMode mode) { \ + DCHECK(set_condition); \ + TaggedField::Release_Store(*this, value); \ + CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \ } #define RELEASE_ACQUIRE_ACCESSORS_CHECKED(holder, name, type, offset, \ @@ -266,7 +266,7 @@ set_condition) \ DEF_GETTER(holder, name, MaybeObject) { \ MaybeObject value = \ - TaggedField::load(cage_base, *this); \ + TaggedField::load(isolate, *this); \ DCHECK(get_condition); \ return value; \ } \ @@ -282,23 +282,23 @@ #define WEAK_ACCESSORS(holder, name, offset) \ WEAK_ACCESSORS_CHECKED(holder, name, offset, true) -#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED2(holder, name, offset, \ - get_condition, set_condition) \ - MaybeObject holder::name(AcquireLoadTag tag) const { \ - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \ - return holder::name(cage_base, tag); \ - } \ - MaybeObject holder::name(PtrComprCageBase cage_base, AcquireLoadTag) const { \ - MaybeObject value = \ - TaggedField::Acquire_Load(cage_base, *this); \ - DCHECK(get_condition); \ - return value; \ - } \ - void holder::set_##name(MaybeObject value, ReleaseStoreTag, \ - WriteBarrierMode mode) { \ - DCHECK(set_condition); \ - TaggedField::Release_Store(*this, value); \ - CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \ +#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED2(holder, name, offset, \ + get_condition, set_condition) \ + MaybeObject holder::name(AcquireLoadTag tag) const { \ + IsolateRoot isolate = GetIsolateForPtrCompr(*this); \ + return holder::name(isolate, tag); \ + } \ + MaybeObject holder::name(IsolateRoot isolate, AcquireLoadTag) const { \ + MaybeObject value = \ + TaggedField::Acquire_Load(isolate, *this); \ + DCHECK(get_condition); \ + return value; \ + } \ + void holder::set_##name(MaybeObject value, ReleaseStoreTag, \ + WriteBarrierMode mode) { \ + DCHECK(set_condition); \ + TaggedField::Release_Store(*this, value); \ + CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \ } #define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED(holder, name, offset, \ @@ -380,9 +380,9 @@ return instance_type == forinstancetype; \ } -#define TYPE_CHECKER(type, ...) \ - DEF_GETTER(HeapObject, Is##type, bool) { \ - return InstanceTypeChecker::Is##type(map(cage_base).instance_type()); \ +#define TYPE_CHECKER(type, ...) \ + DEF_GETTER(HeapObject, Is##type, bool) { \ + return InstanceTypeChecker::Is##type(map(isolate).instance_type()); \ } #define RELAXED_INT16_ACCESSORS(holder, name, offset) \ diff --git a/src/objects/objects-inl.h b/src/objects/objects-inl.h index c94feca250..df2f0c64ab 100644 --- a/src/objects/objects-inl.h +++ b/src/objects/objects-inl.h @@ -65,19 +65,19 @@ int PropertyDetails::field_width_in_words() const { } DEF_GETTER(HeapObject, IsClassBoilerplate, bool) { - return IsFixedArrayExact(cage_base); + return IsFixedArrayExact(isolate); } bool Object::IsTaggedIndex() const { return IsSmi() && TaggedIndex::IsValid(TaggedIndex(ptr()).value()); } -#define IS_TYPE_FUNCTION_DEF(type_) \ - bool Object::Is##type_() const { \ - return IsHeapObject() && HeapObject::cast(*this).Is##type_(); \ - } \ - bool Object::Is##type_(PtrComprCageBase cage_base) const { \ - return IsHeapObject() && HeapObject::cast(*this).Is##type_(cage_base); \ +#define IS_TYPE_FUNCTION_DEF(type_) \ + bool Object::Is##type_() const { \ + return IsHeapObject() && HeapObject::cast(*this).Is##type_(); \ + } \ + bool Object::Is##type_(IsolateRoot isolate) const { \ + return IsHeapObject() && HeapObject::cast(*this).Is##type_(isolate); \ } HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) IS_TYPE_FUNCTION_DEF(HashTableBase) @@ -148,125 +148,127 @@ bool HeapObject::IsNullOrUndefined() const { } DEF_GETTER(HeapObject, IsUniqueName, bool) { - return IsInternalizedString(cage_base) || IsSymbol(cage_base); + return IsInternalizedString(isolate) || IsSymbol(isolate); } DEF_GETTER(HeapObject, IsFunction, bool) { return IsJSFunctionOrBoundFunction(); } -DEF_GETTER(HeapObject, IsCallable, bool) { - return map(cage_base).is_callable(); -} +DEF_GETTER(HeapObject, IsCallable, bool) { return map(isolate).is_callable(); } DEF_GETTER(HeapObject, IsCallableJSProxy, bool) { - return IsCallable(cage_base) && IsJSProxy(cage_base); + return IsCallable(isolate) && IsJSProxy(isolate); } DEF_GETTER(HeapObject, IsCallableApiObject, bool) { - InstanceType type = map(cage_base).instance_type(); - return IsCallable(cage_base) && + InstanceType type = map(isolate).instance_type(); + return IsCallable(isolate) && (type == JS_API_OBJECT_TYPE || type == JS_SPECIAL_API_OBJECT_TYPE); } DEF_GETTER(HeapObject, IsNonNullForeign, bool) { - return IsForeign(cage_base) && + return IsForeign(isolate) && Foreign::cast(*this).foreign_address() != kNullAddress; } DEF_GETTER(HeapObject, IsConstructor, bool) { - return map(cage_base).is_constructor(); + return map(isolate).is_constructor(); } DEF_GETTER(HeapObject, IsSourceTextModuleInfo, bool) { - return map(cage_base) == GetReadOnlyRoots(cage_base).module_info_map(); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + return map(isolate) == GetReadOnlyRoots(isolate).module_info_map(); } DEF_GETTER(HeapObject, IsConsString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsCons(); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsCons(); } DEF_GETTER(HeapObject, IsThinString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsThin(); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsThin(); } DEF_GETTER(HeapObject, IsSlicedString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsSliced(); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsSliced(); } DEF_GETTER(HeapObject, IsSeqString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsSequential(); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsSequential(); } DEF_GETTER(HeapObject, IsSeqOneByteString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsSequential() && - String::cast(*this).IsOneByteRepresentation(cage_base); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsSequential() && + String::cast(*this).IsOneByteRepresentation(isolate); } DEF_GETTER(HeapObject, IsSeqTwoByteString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsSequential() && - String::cast(*this).IsTwoByteRepresentation(cage_base); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsSequential() && + String::cast(*this).IsTwoByteRepresentation(isolate); } DEF_GETTER(HeapObject, IsExternalOneByteString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsExternal() && - String::cast(*this).IsOneByteRepresentation(cage_base); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsExternal() && + String::cast(*this).IsOneByteRepresentation(isolate); } DEF_GETTER(HeapObject, IsExternalTwoByteString, bool) { - if (!IsString(cage_base)) return false; - return StringShape(String::cast(*this).map(cage_base)).IsExternal() && - String::cast(*this).IsTwoByteRepresentation(cage_base); + if (!IsString(isolate)) return false; + return StringShape(String::cast(*this).map(isolate)).IsExternal() && + String::cast(*this).IsTwoByteRepresentation(isolate); } bool Object::IsNumber() const { if (IsSmi()) return true; HeapObject this_heap_object = HeapObject::cast(*this); - PtrComprCageBase cage_base = GetPtrComprCageBase(this_heap_object); - return this_heap_object.IsHeapNumber(cage_base); + IsolateRoot isolate = GetIsolateForPtrCompr(this_heap_object); + return this_heap_object.IsHeapNumber(isolate); } -bool Object::IsNumber(PtrComprCageBase cage_base) const { - return IsSmi() || IsHeapNumber(cage_base); +bool Object::IsNumber(IsolateRoot isolate) const { + return IsSmi() || IsHeapNumber(isolate); } bool Object::IsNumeric() const { if (IsSmi()) return true; HeapObject this_heap_object = HeapObject::cast(*this); - PtrComprCageBase cage_base = GetPtrComprCageBase(this_heap_object); - return this_heap_object.IsHeapNumber(cage_base) || - this_heap_object.IsBigInt(cage_base); + IsolateRoot isolate = GetIsolateForPtrCompr(this_heap_object); + return this_heap_object.IsHeapNumber(isolate) || + this_heap_object.IsBigInt(isolate); } -bool Object::IsNumeric(PtrComprCageBase cage_base) const { - return IsNumber(cage_base) || IsBigInt(cage_base); +bool Object::IsNumeric(IsolateRoot isolate) const { + return IsNumber(isolate) || IsBigInt(isolate); } DEF_GETTER(HeapObject, IsFreeSpaceOrFiller, bool) { - InstanceType instance_type = map(cage_base).instance_type(); + InstanceType instance_type = map(isolate).instance_type(); return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; } DEF_GETTER(HeapObject, IsArrayList, bool) { - ReadOnlyRoots roots = GetReadOnlyRoots(cage_base); + // Can't use ReadOnlyRoots(isolate) as this isolate could be produced by + // i::GetIsolateForPtrCompr(HeapObject). + ReadOnlyRoots roots = GetReadOnlyRoots(isolate); return *this == roots.empty_fixed_array() || - map(cage_base) == roots.array_list_map(); + map(isolate) == roots.array_list_map(); } DEF_GETTER(HeapObject, IsRegExpMatchInfo, bool) { - return IsFixedArrayExact(cage_base); + return IsFixedArrayExact(isolate); } DEF_GETTER(HeapObject, IsDeoptimizationData, bool) { // Must be a fixed array. - if (!IsFixedArrayExact(cage_base)) return false; + if (!IsFixedArrayExact(isolate)) return false; // There's no sure way to detect the difference between a fixed array and // a deoptimization data array. Since this is used for asserts we can @@ -280,14 +282,14 @@ DEF_GETTER(HeapObject, IsDeoptimizationData, bool) { } DEF_GETTER(HeapObject, IsHandlerTable, bool) { - if (!IsFixedArrayExact(cage_base)) return false; + if (!IsFixedArrayExact(isolate)) return false; // There's actually no way to see the difference between a fixed array and // a handler table array. return true; } DEF_GETTER(HeapObject, IsTemplateList, bool) { - if (!IsFixedArrayExact(cage_base)) return false; + if (!IsFixedArrayExact(isolate)) return false; // There's actually no way to see the difference between a fixed array and // a template list. if (FixedArray::cast(*this).length() < 1) return false; @@ -295,86 +297,84 @@ DEF_GETTER(HeapObject, IsTemplateList, bool) { } DEF_GETTER(HeapObject, IsDependentCode, bool) { - if (!IsWeakFixedArray(cage_base)) return false; + if (!IsWeakFixedArray(isolate)) return false; // There's actually no way to see the difference between a weak fixed array // and a dependent codes array. return true; } DEF_GETTER(HeapObject, IsOSROptimizedCodeCache, bool) { - if (!IsWeakFixedArray(cage_base)) return false; + if (!IsWeakFixedArray(isolate)) return false; // There's actually no way to see the difference between a weak fixed array // and a osr optimized code cache. return true; } DEF_GETTER(HeapObject, IsAbstractCode, bool) { - return IsBytecodeArray(cage_base) || IsCode(cage_base); + return IsBytecodeArray(isolate) || IsCode(isolate); } DEF_GETTER(HeapObject, IsStringWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsString(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsString(isolate); } DEF_GETTER(HeapObject, IsBooleanWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsBoolean(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsBoolean(isolate); } DEF_GETTER(HeapObject, IsScriptWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsScript(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsScript(isolate); } DEF_GETTER(HeapObject, IsNumberWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsNumber(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsNumber(isolate); } DEF_GETTER(HeapObject, IsBigIntWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsBigInt(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsBigInt(isolate); } DEF_GETTER(HeapObject, IsSymbolWrapper, bool) { - return IsJSPrimitiveWrapper(cage_base) && - JSPrimitiveWrapper::cast(*this).value().IsSymbol(cage_base); + return IsJSPrimitiveWrapper(isolate) && + JSPrimitiveWrapper::cast(*this).value().IsSymbol(isolate); } -DEF_GETTER(HeapObject, IsStringSet, bool) { return IsHashTable(cage_base); } +DEF_GETTER(HeapObject, IsStringSet, bool) { return IsHashTable(isolate); } -DEF_GETTER(HeapObject, IsObjectHashSet, bool) { return IsHashTable(cage_base); } +DEF_GETTER(HeapObject, IsObjectHashSet, bool) { return IsHashTable(isolate); } DEF_GETTER(HeapObject, IsCompilationCacheTable, bool) { - return IsHashTable(cage_base); + return IsHashTable(isolate); } -DEF_GETTER(HeapObject, IsMapCache, bool) { return IsHashTable(cage_base); } +DEF_GETTER(HeapObject, IsMapCache, bool) { return IsHashTable(isolate); } -DEF_GETTER(HeapObject, IsObjectHashTable, bool) { - return IsHashTable(cage_base); -} +DEF_GETTER(HeapObject, IsObjectHashTable, bool) { return IsHashTable(isolate); } -DEF_GETTER(HeapObject, IsHashTableBase, bool) { return IsHashTable(cage_base); } +DEF_GETTER(HeapObject, IsHashTableBase, bool) { return IsHashTable(isolate); } #if V8_ENABLE_WEBASSEMBLY DEF_GETTER(HeapObject, IsWasmExceptionPackage, bool) { // It is not possible to check for the existence of certain properties on the // underlying {JSReceiver} here because that requires calling handlified code. - return IsJSReceiver(cage_base); + return IsJSReceiver(isolate); } #endif // V8_ENABLE_WEBASSEMBLY bool Object::IsPrimitive() const { if (IsSmi()) return true; HeapObject this_heap_object = HeapObject::cast(*this); - PtrComprCageBase cage_base = GetPtrComprCageBase(this_heap_object); - return this_heap_object.map(cage_base).IsPrimitiveMap(); + IsolateRoot isolate = GetIsolateForPtrCompr(this_heap_object); + return this_heap_object.map(isolate).IsPrimitiveMap(); } -bool Object::IsPrimitive(PtrComprCageBase cage_base) const { - return IsSmi() || HeapObject::cast(*this).map(cage_base).IsPrimitiveMap(); +bool Object::IsPrimitive(IsolateRoot isolate) const { + return IsSmi() || HeapObject::cast(*this).map(isolate).IsPrimitiveMap(); } // static @@ -387,24 +387,24 @@ Maybe Object::IsArray(Handle object) { } DEF_GETTER(HeapObject, IsUndetectable, bool) { - return map(cage_base).is_undetectable(); + return map(isolate).is_undetectable(); } DEF_GETTER(HeapObject, IsAccessCheckNeeded, bool) { - if (IsJSGlobalProxy(cage_base)) { + if (IsJSGlobalProxy(isolate)) { const JSGlobalProxy proxy = JSGlobalProxy::cast(*this); JSGlobalObject global = proxy.GetIsolate()->context().global_object(); return proxy.IsDetachedFrom(global); } - return map(cage_base).is_access_check_needed(); + return map(isolate).is_access_check_needed(); } -#define MAKE_STRUCT_PREDICATE(NAME, Name, name) \ - bool Object::Is##Name() const { \ - return IsHeapObject() && HeapObject::cast(*this).Is##Name(); \ - } \ - bool Object::Is##Name(PtrComprCageBase cage_base) const { \ - return IsHeapObject() && HeapObject::cast(*this).Is##Name(cage_base); \ +#define MAKE_STRUCT_PREDICATE(NAME, Name, name) \ + bool Object::Is##Name() const { \ + return IsHeapObject() && HeapObject::cast(*this).Is##Name(); \ + } \ + bool Object::Is##Name(IsolateRoot isolate) const { \ + return IsHeapObject() && HeapObject::cast(*this).Is##Name(isolate); \ } STRUCT_LIST(MAKE_STRUCT_PREDICATE) #undef MAKE_STRUCT_PREDICATE @@ -467,17 +467,17 @@ bool Object::FilterKey(PropertyFilter filter) { return false; } -Representation Object::OptimalRepresentation(PtrComprCageBase cage_base) const { +Representation Object::OptimalRepresentation(IsolateRoot isolate) const { if (!FLAG_track_fields) return Representation::Tagged(); if (IsSmi()) { return Representation::Smi(); } HeapObject heap_object = HeapObject::cast(*this); - if (FLAG_track_double_fields && heap_object.IsHeapNumber(cage_base)) { + if (FLAG_track_double_fields && heap_object.IsHeapNumber(isolate)) { return Representation::Double(); } else if (FLAG_track_computed_fields && heap_object.IsUninitialized( - heap_object.GetReadOnlyRoots(cage_base))) { + heap_object.GetReadOnlyRoots(isolate))) { return Representation::None(); } else if (FLAG_track_heap_object_fields) { return Representation::HeapObject(); @@ -486,9 +486,9 @@ Representation Object::OptimalRepresentation(PtrComprCageBase cage_base) const { } } -ElementsKind Object::OptimalElementsKind(PtrComprCageBase cage_base) const { +ElementsKind Object::OptimalElementsKind(IsolateRoot isolate) const { if (IsSmi()) return PACKED_SMI_ELEMENTS; - if (IsNumber(cage_base)) return PACKED_DOUBLE_ELEMENTS; + if (IsNumber(isolate)) return PACKED_DOUBLE_ELEMENTS; return PACKED_ELEMENTS; } @@ -631,10 +631,9 @@ void Object::InitExternalPointerField(size_t offset, Isolate* isolate, i::InitExternalPointerField(field_address(offset), isolate, value, tag); } -Address Object::ReadExternalPointerField(size_t offset, - PtrComprCageBase isolate_root, +Address Object::ReadExternalPointerField(size_t offset, IsolateRoot isolate, ExternalPointerTag tag) const { - return i::ReadExternalPointerField(field_address(offset), isolate_root, tag); + return i::ReadExternalPointerField(field_address(offset), isolate, tag); } void Object::WriteExternalPointerField(size_t offset, Isolate* isolate, @@ -688,16 +687,16 @@ ReadOnlyRoots HeapObject::GetReadOnlyRoots() const { return ReadOnlyHeap::GetReadOnlyRoots(*this); } -ReadOnlyRoots HeapObject::GetReadOnlyRoots(PtrComprCageBase cage_base) const { -#ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE - DCHECK_NE(cage_base.address(), 0); - return ReadOnlyRoots(Isolate::FromRootAddress(cage_base.address())); +ReadOnlyRoots HeapObject::GetReadOnlyRoots(IsolateRoot isolate) const { +#ifdef V8_COMPRESS_POINTERS + DCHECK_NE(isolate.address(), 0); + return ReadOnlyRoots(Isolate::FromRootAddress(isolate.address())); #else return GetReadOnlyRoots(); #endif } -DEF_GETTER(HeapObject, map, Map) { return map_word(cage_base).ToMap(); } +DEF_GETTER(HeapObject, map, Map) { return map_word(isolate).ToMap(); } void HeapObject::set_map(Map value) { #ifdef VERIFY_HEAP @@ -716,7 +715,7 @@ void HeapObject::set_map(Map value) { } DEF_GETTER(HeapObject, synchronized_map, Map) { - return synchronized_map_word(cage_base).ToMap(); + return synchronized_map_word(isolate).ToMap(); } void HeapObject::synchronized_set_map(Map value) { @@ -762,7 +761,7 @@ ObjectSlot HeapObject::map_slot() const { } DEF_GETTER(HeapObject, map_word, MapWord) { - return MapField::Relaxed_Load(cage_base, *this); + return MapField::Relaxed_Load(isolate, *this); } void HeapObject::set_map_word(MapWord map_word) { @@ -770,7 +769,7 @@ void HeapObject::set_map_word(MapWord map_word) { } DEF_GETTER(HeapObject, synchronized_map_word, MapWord) { - return MapField::Acquire_Load(cage_base, *this); + return MapField::Acquire_Load(isolate, *this); } void HeapObject::synchronized_set_map_word(MapWord map_word) { diff --git a/src/objects/objects.cc b/src/objects/objects.cc index 122bc8718b..276157563e 100644 --- a/src/objects/objects.cc +++ b/src/objects/objects.cc @@ -5567,8 +5567,7 @@ Handle HashTable::NewInternal( } template -void HashTable::Rehash(PtrComprCageBase cage_base, - Derived new_table) { +void HashTable::Rehash(IsolateRoot isolate, Derived new_table) { DisallowGarbageCollection no_gc; WriteBarrierMode mode = new_table.GetWriteBarrierMode(no_gc); @@ -5576,21 +5575,21 @@ void HashTable::Rehash(PtrComprCageBase cage_base, // Copy prefix to new array. for (int i = kPrefixStartIndex; i < kElementsStartIndex; i++) { - new_table.set(i, get(cage_base, i), mode); + new_table.set(i, get(isolate, i), mode); } // Rehash the elements. - ReadOnlyRoots roots = GetReadOnlyRoots(cage_base); + ReadOnlyRoots roots = GetReadOnlyRoots(isolate); for (InternalIndex i : this->IterateEntries()) { uint32_t from_index = EntryToIndex(i); - Object k = this->get(cage_base, from_index); + Object k = this->get(isolate, from_index); if (!IsKey(roots, k)) continue; uint32_t hash = Shape::HashForObject(roots, k); uint32_t insertion_index = - EntryToIndex(new_table.FindInsertionEntry(cage_base, roots, hash)); - new_table.set_key(insertion_index, get(cage_base, from_index), mode); + EntryToIndex(new_table.FindInsertionEntry(isolate, roots, hash)); + new_table.set_key(insertion_index, get(isolate, from_index), mode); for (int j = 1; j < Shape::kEntrySize; j++) { - new_table.set(insertion_index + j, get(cage_base, from_index + j), mode); + new_table.set(insertion_index + j, get(isolate, from_index + j), mode); } } new_table.SetNumberOfElements(NumberOfElements()); @@ -5632,10 +5631,10 @@ void HashTable::Swap(InternalIndex entry1, InternalIndex entry2, } template -void HashTable::Rehash(PtrComprCageBase cage_base) { +void HashTable::Rehash(IsolateRoot isolate) { DisallowGarbageCollection no_gc; WriteBarrierMode mode = GetWriteBarrierMode(no_gc); - ReadOnlyRoots roots = GetReadOnlyRoots(cage_base); + ReadOnlyRoots roots = GetReadOnlyRoots(isolate); uint32_t capacity = Capacity(); bool done = false; for (int probe = 1; !done; probe++) { @@ -5644,7 +5643,7 @@ void HashTable::Rehash(PtrComprCageBase cage_base) { done = true; for (InternalIndex current(0); current.raw_value() < capacity; /* {current} is advanced manually below, when appropriate.*/) { - Object current_key = KeyAt(cage_base, current); + Object current_key = KeyAt(isolate, current); if (!IsKey(roots, current_key)) { ++current; // Advance to next entry. continue; @@ -5654,7 +5653,7 @@ void HashTable::Rehash(PtrComprCageBase cage_base) { ++current; // Advance to next entry. continue; } - Object target_key = KeyAt(cage_base, target); + Object target_key = KeyAt(isolate, target); if (!IsKey(roots, target_key) || EntryForProbe(roots, target_key, probe, target) != target) { // Put the current element into the correct position. @@ -5674,7 +5673,7 @@ void HashTable::Rehash(PtrComprCageBase cage_base) { HeapObject undefined = roots.undefined_value(); Derived* self = static_cast(this); for (InternalIndex current : InternalIndex::Range(capacity)) { - if (KeyAt(cage_base, current) == the_hole) { + if (KeyAt(isolate, current) == the_hole) { self->set_key(EntryToIndex(current) + kEntryKeyIndex, undefined, SKIP_WRITE_BARRIER); } @@ -5765,14 +5764,15 @@ Handle HashTable::Shrink(Isolate* isolate, } template -InternalIndex HashTable::FindInsertionEntry( - PtrComprCageBase cage_base, ReadOnlyRoots roots, uint32_t hash) { +InternalIndex HashTable::FindInsertionEntry(IsolateRoot isolate, + ReadOnlyRoots roots, + uint32_t hash) { uint32_t capacity = Capacity(); uint32_t count = 1; // EnsureCapacity will guarantee the hash table is never full. for (InternalIndex entry = FirstProbe(hash, capacity);; entry = NextProbe(entry, count++, capacity)) { - if (!IsKey(roots, KeyAt(cage_base, entry))) return entry; + if (!IsKey(roots, KeyAt(isolate, entry))) return entry; } } @@ -6080,14 +6080,14 @@ void ObjectHashTableBase::FillEntriesWithHoles( } template -Object ObjectHashTableBase::Lookup(PtrComprCageBase cage_base, +Object ObjectHashTableBase::Lookup(IsolateRoot isolate, Handle key, int32_t hash) { DisallowGarbageCollection no_gc; - ReadOnlyRoots roots = this->GetReadOnlyRoots(cage_base); + ReadOnlyRoots roots = this->GetReadOnlyRoots(isolate); DCHECK(this->IsKey(roots, *key)); - InternalIndex entry = this->FindEntry(cage_base, roots, key, hash); + InternalIndex entry = this->FindEntry(isolate, roots, key, hash); if (entry.is_not_found()) return roots.the_hole_value(); return this->get(Derived::EntryToIndex(entry) + 1); } @@ -6096,8 +6096,8 @@ template Object ObjectHashTableBase::Lookup(Handle key) { DisallowGarbageCollection no_gc; - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - ReadOnlyRoots roots = this->GetReadOnlyRoots(cage_base); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + ReadOnlyRoots roots = this->GetReadOnlyRoots(isolate); DCHECK(this->IsKey(roots, *key)); // If the object does not have an identity hash, it was never used as a key. @@ -6105,13 +6105,13 @@ Object ObjectHashTableBase::Lookup(Handle key) { if (hash.IsUndefined(roots)) { return roots.the_hole_value(); } - return Lookup(cage_base, key, Smi::ToInt(hash)); + return Lookup(isolate, key, Smi::ToInt(hash)); } template Object ObjectHashTableBase::Lookup(Handle key, int32_t hash) { - return Lookup(GetPtrComprCageBase(*this), key, hash); + return Lookup(GetIsolateForPtrCompr(*this), key, hash); } template diff --git a/src/objects/objects.h b/src/objects/objects.h index e4532bb0e5..c68445597f 100644 --- a/src/objects/objects.h +++ b/src/objects/objects.h @@ -279,7 +279,7 @@ class Object : public TaggedImpl { #define IS_TYPE_FUNCTION_DECL(Type) \ V8_INLINE bool Is##Type() const; \ - V8_INLINE bool Is##Type(PtrComprCageBase cage_base) const; + V8_INLINE bool Is##Type(IsolateRoot isolate) const; OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) IS_TYPE_FUNCTION_DECL(HashTableBase) @@ -307,7 +307,7 @@ class Object : public TaggedImpl { #define DECL_STRUCT_PREDICATE(NAME, Name, name) \ V8_INLINE bool Is##Name() const; \ - V8_INLINE bool Is##Name(PtrComprCageBase cage_base) const; + V8_INLINE bool Is##Name(IsolateRoot isolate) const; STRUCT_LIST(DECL_STRUCT_PREDICATE) #undef DECL_STRUCT_PREDICATE @@ -322,9 +322,9 @@ class Object : public TaggedImpl { V8_EXPORT_PRIVATE bool ToInt32(int32_t* value); inline bool ToUint32(uint32_t* value) const; - inline Representation OptimalRepresentation(PtrComprCageBase cage_base) const; + inline Representation OptimalRepresentation(IsolateRoot isolate) const; - inline ElementsKind OptimalElementsKind(PtrComprCageBase cage_base) const; + inline ElementsKind OptimalElementsKind(IsolateRoot isolate) const; inline bool FitsRepresentation(Representation representation); @@ -673,8 +673,7 @@ class Object : public TaggedImpl { inline void InitExternalPointerField(size_t offset, Isolate* isolate); inline void InitExternalPointerField(size_t offset, Isolate* isolate, Address value, ExternalPointerTag tag); - inline Address ReadExternalPointerField(size_t offset, - PtrComprCageBase isolate_root, + inline Address ReadExternalPointerField(size_t offset, IsolateRoot isolate, ExternalPointerTag tag) const; inline void WriteExternalPointerField(size_t offset, Isolate* isolate, Address value, ExternalPointerTag tag); diff --git a/src/objects/oddball-inl.h b/src/objects/oddball-inl.h index df7829e2b4..4a022831be 100644 --- a/src/objects/oddball-inl.h +++ b/src/objects/oddball-inl.h @@ -37,7 +37,7 @@ Handle Oddball::ToNumber(Isolate* isolate, Handle input) { } DEF_GETTER(HeapObject, IsBoolean, bool) { - return IsOddball(cage_base) && + return IsOddball(isolate) && ((Oddball::cast(*this).kind() & Oddball::kNotBooleanMask) == 0); } diff --git a/src/objects/property-array-inl.h b/src/objects/property-array-inl.h index fe884b043f..e2e905fbb3 100644 --- a/src/objects/property-array-inl.h +++ b/src/objects/property-array-inl.h @@ -25,14 +25,14 @@ SMI_ACCESSORS(PropertyArray, length_and_hash, kLengthAndHashOffset) SYNCHRONIZED_SMI_ACCESSORS(PropertyArray, length_and_hash, kLengthAndHashOffset) Object PropertyArray::get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); } -Object PropertyArray::get(PtrComprCageBase cage_base, int index) const { +Object PropertyArray::get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(this->length())); - return TaggedField::Relaxed_Load(cage_base, *this, + return TaggedField::Relaxed_Load(isolate, *this, OffsetOfElementAt(index)); } diff --git a/src/objects/property-array.h b/src/objects/property-array.h index f4cc5c9fb1..da15e8d732 100644 --- a/src/objects/property-array.h +++ b/src/objects/property-array.h @@ -30,7 +30,7 @@ class PropertyArray : public HeapObject { inline int Hash() const; inline Object get(int index) const; - inline Object get(PtrComprCageBase cage_base, int index) const; + inline Object get(IsolateRoot isolate, int index) const; inline void set(int index, Object value); // Setter with explicit barrier mode. diff --git a/src/objects/property.cc b/src/objects/property.cc index c21a618cb1..b0bb79c601 100644 --- a/src/objects/property.cc +++ b/src/objects/property.cc @@ -75,10 +75,10 @@ Descriptor Descriptor::DataField(Handle key, int field_index, Descriptor Descriptor::DataConstant(Handle key, Handle value, PropertyAttributes attributes) { - PtrComprCageBase cage_base = GetPtrComprCageBase(*key); + IsolateRoot isolate = GetIsolateForPtrCompr(*key); return Descriptor(key, MaybeObjectHandle(value), kData, attributes, kDescriptor, PropertyConstness::kConst, - value->OptimalRepresentation(cage_base), 0); + value->OptimalRepresentation(isolate), 0); } Descriptor Descriptor::DataConstant(Isolate* isolate, Handle key, diff --git a/src/objects/scope-info.cc b/src/objects/scope-info.cc index 308b57a309..9e37b0ef11 100644 --- a/src/objects/scope-info.cc +++ b/src/objects/scope-info.cc @@ -575,13 +575,13 @@ Handle ScopeInfo::CreateForBootstrapping(Isolate* isolate, } Object ScopeInfo::get(int index) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return get(cage_base, index); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); } -Object ScopeInfo::get(PtrComprCageBase cage_base, int index) const { +Object ScopeInfo::get(IsolateRoot isolate, int index) const { DCHECK_LT(static_cast(index), static_cast(length())); - return TaggedField::Relaxed_Load(cage_base, *this, + return TaggedField::Relaxed_Load(isolate, *this, OffsetOfElementAt(index)); } diff --git a/src/objects/scope-info.h b/src/objects/scope-info.h index 57e5d2e308..d773115bbd 100644 --- a/src/objects/scope-info.h +++ b/src/objects/scope-info.h @@ -293,7 +293,7 @@ class ScopeInfo : public TorqueGeneratedScopeInfo { // 'flags', the first field defined by ScopeInfo after the standard-size // HeapObject header. V8_EXPORT_PRIVATE Object get(int index) const; - Object get(PtrComprCageBase cage_base, int index) const; + Object get(IsolateRoot isolate, int index) const; // Setter that doesn't need write barrier. void set(int index, Smi value); // Setter with explicit barrier mode. diff --git a/src/objects/slots-inl.h b/src/objects/slots-inl.h index c0d35c525f..2943c117c7 100644 --- a/src/objects/slots-inl.h +++ b/src/objects/slots-inl.h @@ -31,7 +31,7 @@ bool FullObjectSlot::contains_value(Address raw_value) const { Object FullObjectSlot::operator*() const { return Object(*location()); } -Object FullObjectSlot::load(PtrComprCageBase cage_base) const { return **this; } +Object FullObjectSlot::load(IsolateRoot isolate) const { return **this; } void FullObjectSlot::store(Object value) const { *location() = value.ptr(); } @@ -39,7 +39,7 @@ Object FullObjectSlot::Acquire_Load() const { return Object(base::AsAtomicPointer::Acquire_Load(location())); } -Object FullObjectSlot::Acquire_Load(PtrComprCageBase cage_base) const { +Object FullObjectSlot::Acquire_Load(IsolateRoot isolate) const { return Acquire_Load(); } @@ -47,7 +47,7 @@ Object FullObjectSlot::Relaxed_Load() const { return Object(base::AsAtomicPointer::Relaxed_Load(location())); } -Object FullObjectSlot::Relaxed_Load(PtrComprCageBase cage_base) const { +Object FullObjectSlot::Relaxed_Load(IsolateRoot isolate) const { return Relaxed_Load(); } @@ -79,7 +79,7 @@ MaybeObject FullMaybeObjectSlot::operator*() const { return MaybeObject(*location()); } -MaybeObject FullMaybeObjectSlot::load(PtrComprCageBase cage_base) const { +MaybeObject FullMaybeObjectSlot::load(IsolateRoot isolate) const { return **this; } @@ -91,8 +91,7 @@ MaybeObject FullMaybeObjectSlot::Relaxed_Load() const { return MaybeObject(base::AsAtomicPointer::Relaxed_Load(location())); } -MaybeObject FullMaybeObjectSlot::Relaxed_Load( - PtrComprCageBase cage_base) const { +MaybeObject FullMaybeObjectSlot::Relaxed_Load(IsolateRoot isolate) const { return Relaxed_Load(); } @@ -114,7 +113,7 @@ HeapObjectReference FullHeapObjectSlot::operator*() const { return HeapObjectReference(*location()); } -HeapObjectReference FullHeapObjectSlot::load(PtrComprCageBase cage_base) const { +HeapObjectReference FullHeapObjectSlot::load(IsolateRoot isolate) const { return **this; } diff --git a/src/objects/slots.h b/src/objects/slots.h index 69c6a8a80b..2221fb41c8 100644 --- a/src/objects/slots.h +++ b/src/objects/slots.h @@ -110,13 +110,13 @@ class FullObjectSlot : public SlotBase { inline bool contains_value(Address raw_value) const; inline Object operator*() const; - inline Object load(PtrComprCageBase cage_base) const; + inline Object load(IsolateRoot isolate) const; inline void store(Object value) const; inline Object Acquire_Load() const; - inline Object Acquire_Load(PtrComprCageBase cage_base) const; + inline Object Acquire_Load(IsolateRoot isolate) const; inline Object Relaxed_Load() const; - inline Object Relaxed_Load(PtrComprCageBase cage_base) const; + inline Object Relaxed_Load(IsolateRoot isolate) const; inline void Relaxed_Store(Object value) const; inline void Release_Store(Object value) const; inline Object Relaxed_CompareAndSwap(Object old, Object target) const; @@ -147,11 +147,11 @@ class FullMaybeObjectSlot : SlotBase(slot.address()) {} inline MaybeObject operator*() const; - inline MaybeObject load(PtrComprCageBase cage_base) const; + inline MaybeObject load(IsolateRoot isolate) const; inline void store(MaybeObject value) const; inline MaybeObject Relaxed_Load() const; - inline MaybeObject Relaxed_Load(PtrComprCageBase cage_base) const; + inline MaybeObject Relaxed_Load(IsolateRoot isolate) const; inline void Relaxed_Store(MaybeObject value) const; inline void Release_CompareAndSwap(MaybeObject old, MaybeObject target) const; }; @@ -174,7 +174,7 @@ class FullHeapObjectSlot : public SlotBase { : SlotBase(slot.address()) {} inline HeapObjectReference operator*() const; - inline HeapObjectReference load(PtrComprCageBase cage_base) const; + inline HeapObjectReference load(IsolateRoot isolate) const; inline void store(HeapObjectReference value) const; inline HeapObject ToHeapObject() const; diff --git a/src/objects/string-inl.h b/src/objects/string-inl.h index 912109b2e0..c610e7b2f4 100644 --- a/src/objects/string-inl.h +++ b/src/objects/string-inl.h @@ -274,12 +274,12 @@ inline TResult StringShape::DispatchToSpecificType(String str, } DEF_GETTER(String, IsOneByteRepresentation, bool) { - uint32_t type = map(cage_base).instance_type(); + uint32_t type = map(isolate).instance_type(); return (type & kStringEncodingMask) == kOneByteStringTag; } DEF_GETTER(String, IsTwoByteRepresentation, bool) { - uint32_t type = map(cage_base).instance_type(); + uint32_t type = map(isolate).instance_type(); return (type & kStringEncodingMask) == kTwoByteStringTag; } @@ -463,7 +463,7 @@ bool String::IsEqualTo(Vector str, Isolate* isolate) const { template bool String::IsEqualTo(Vector str) const { DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this)); - return IsEqualToImpl(str, GetPtrComprCageBase(*this), + return IsEqualToImpl(str, GetIsolateForPtrCompr(*this), SharedStringAccessGuardIfNeeded::NotNeeded()); } @@ -475,7 +475,7 @@ bool String::IsEqualTo(Vector str, LocalIsolate* isolate) const { template bool String::IsEqualToImpl( - Vector str, PtrComprCageBase cage_base, + Vector str, IsolateRoot isolate, const SharedStringAccessGuardIfNeeded& access_guard) const { size_t len = str.size(); switch (kEqType) { @@ -496,7 +496,7 @@ bool String::IsEqualToImpl( String string = *this; const Char* data = str.data(); while (true) { - int32_t type = string.map(cage_base).instance_type(); + int32_t type = string.map(isolate).instance_type(); switch (type & (kStringRepresentationMask | kStringEncodingMask)) { case kSeqStringTag | kOneByteStringTag: return CompareCharsEqual( @@ -521,7 +521,7 @@ bool String::IsEqualToImpl( case kSlicedStringTag | kTwoByteStringTag: { SlicedString slicedString = SlicedString::cast(string); slice_offset += slicedString.offset(); - string = slicedString.parent(cage_base); + string = slicedString.parent(isolate); continue; } @@ -529,14 +529,13 @@ bool String::IsEqualToImpl( case kConsStringTag | kTwoByteStringTag: { // The ConsString path is more complex and rare, so call out to an // out-of-line handler. - return IsConsStringEqualToImpl(ConsString::cast(string), - slice_offset, str, cage_base, - access_guard); + return IsConsStringEqualToImpl( + ConsString::cast(string), slice_offset, str, isolate, access_guard); } case kThinStringTag | kOneByteStringTag: case kThinStringTag | kTwoByteStringTag: - string = ThinString::cast(string).actual(cage_base); + string = ThinString::cast(string).actual(isolate); continue; default: @@ -549,8 +548,7 @@ bool String::IsEqualToImpl( template bool String::IsConsStringEqualToImpl( ConsString string, int slice_offset, Vector str, - PtrComprCageBase cage_base, - const SharedStringAccessGuardIfNeeded& access_guard) { + IsolateRoot isolate, const SharedStringAccessGuardIfNeeded& access_guard) { // Already checked the len in IsEqualToImpl. Check GE rather than EQ in case // this is a prefix check. DCHECK_GE(string.length(), str.size()); @@ -563,7 +561,7 @@ bool String::IsConsStringEqualToImpl( // remaining string. size_t len = std::min(segment.length(), remaining_str.size()); Vector sub_str = remaining_str.SubVector(0, len); - if (!segment.IsEqualToImpl(sub_str, cage_base, + if (!segment.IsEqualToImpl(sub_str, isolate, access_guard)) { return false; } @@ -847,7 +845,7 @@ Object ConsString::unchecked_second() { } DEF_GETTER(ThinString, unchecked_actual, HeapObject) { - return TaggedField::load(cage_base, *this); + return TaggedField::load(isolate, *this); } bool ExternalString::is_uncached() const { @@ -862,7 +860,7 @@ void ExternalString::AllocateExternalPointerEntries(Isolate* isolate) { } DEF_GETTER(ExternalString, resource_as_address, Address) { - return ReadExternalPointerField(kResourceOffset, cage_base, + return ReadExternalPointerField(kResourceOffset, isolate, kExternalStringResourceTag); } @@ -910,7 +908,7 @@ DEF_GETTER(ExternalOneByteString, resource, DEF_GETTER(ExternalOneByteString, mutable_resource, ExternalOneByteString::Resource*) { - return reinterpret_cast(resource_as_address(cage_base)); + return reinterpret_cast(resource_as_address(isolate)); } void ExternalOneByteString::update_data_cache(Isolate* isolate) { @@ -975,7 +973,7 @@ DEF_GETTER(ExternalTwoByteString, resource, DEF_GETTER(ExternalTwoByteString, mutable_resource, ExternalTwoByteString::Resource*) { - return reinterpret_cast(resource_as_address(cage_base)); + return reinterpret_cast(resource_as_address(isolate)); } void ExternalTwoByteString::update_data_cache(Isolate* isolate) { diff --git a/src/objects/string-table.cc b/src/objects/string-table.cc index a549376116..8d5b44c6c5 100644 --- a/src/objects/string-table.cc +++ b/src/objects/string-table.cc @@ -91,15 +91,15 @@ bool KeyIsMatch(LocalIsolate* isolate, StringTableKey* key, String string) { class StringTable::Data { public: static std::unique_ptr New(int capacity); - static std::unique_ptr Resize(PtrComprCageBase cage_base, + static std::unique_ptr Resize(IsolateRoot isolate, std::unique_ptr data, int capacity); OffHeapObjectSlot slot(InternalIndex index) const { return OffHeapObjectSlot(&elements_[index.as_uint32()]); } - Object Get(PtrComprCageBase cage_base, InternalIndex index) const { - return slot(index).Acquire_Load(cage_base); + Object Get(IsolateRoot isolate, InternalIndex index) const { + return slot(index).Acquire_Load(isolate); } void Set(InternalIndex index, String entry) { @@ -139,8 +139,7 @@ class StringTable::Data { InternalIndex FindEntry(LocalIsolate* isolate, StringTableKey* key, uint32_t hash) const; - InternalIndex FindInsertionEntry(PtrComprCageBase cage_base, - uint32_t hash) const; + InternalIndex FindInsertionEntry(IsolateRoot isolate, uint32_t hash) const; template InternalIndex FindEntryOrInsertionEntry(LocalIsolate* isolate, @@ -158,7 +157,7 @@ class StringTable::Data { Data* PreviousData() { return previous_data_.get(); } void DropPreviousData() { previous_data_.reset(); } - void Print(PtrComprCageBase cage_base) const; + void Print(IsolateRoot isolate) const; size_t GetCurrentMemoryUsage() const; private: @@ -225,7 +224,7 @@ std::unique_ptr StringTable::Data::New(int capacity) { } std::unique_ptr StringTable::Data::Resize( - PtrComprCageBase cage_base, std::unique_ptr data, int capacity) { + IsolateRoot isolate, std::unique_ptr data, int capacity) { std::unique_ptr new_data(new (capacity) Data(capacity)); DCHECK_LT(data->number_of_elements(), new_data->capacity()); @@ -235,12 +234,11 @@ std::unique_ptr StringTable::Data::Resize( // Rehash the elements. for (InternalIndex i : InternalIndex::Range(data->capacity())) { - Object element = data->Get(cage_base, i); + Object element = data->Get(isolate, i); if (element == empty_element() || element == deleted_element()) continue; String string = String::cast(element); uint32_t hash = string.hash(); - InternalIndex insertion_index = - new_data->FindInsertionEntry(cage_base, hash); + InternalIndex insertion_index = new_data->FindInsertionEntry(isolate, hash); new_data->Set(insertion_index, string); } new_data->number_of_elements_ = data->number_of_elements(); @@ -267,7 +265,7 @@ InternalIndex StringTable::Data::FindEntry(LocalIsolate* isolate, } } -InternalIndex StringTable::Data::FindInsertionEntry(PtrComprCageBase cage_base, +InternalIndex StringTable::Data::FindInsertionEntry(IsolateRoot isolate, uint32_t hash) const { uint32_t count = 1; // EnsureCapacity will guarantee the hash table is never full. @@ -275,7 +273,7 @@ InternalIndex StringTable::Data::FindInsertionEntry(PtrComprCageBase cage_base, entry = NextProbe(entry, count++, capacity_)) { // TODO(leszeks): Consider delaying the decompression until after the // comparisons against empty/deleted. - Object element = Get(cage_base, entry); + Object element = Get(isolate, entry); if (element == empty_element() || element == deleted_element()) return entry; } @@ -316,12 +314,11 @@ void StringTable::Data::IterateElements(RootVisitor* visitor) { visitor->VisitRootPointers(Root::kStringTable, nullptr, first_slot, end_slot); } -void StringTable::Data::Print(PtrComprCageBase cage_base) const { +void StringTable::Data::Print(IsolateRoot isolate) const { OFStream os(stdout); os << "StringTable {" << std::endl; for (InternalIndex i : InternalIndex::Range(capacity_)) { - os << " " << i.as_uint32() << ": " << Brief(Get(cage_base, i)) - << std::endl; + os << " " << i.as_uint32() << ": " << Brief(Get(isolate, i)) << std::endl; } os << "}" << std::endl; } @@ -533,7 +530,7 @@ template Handle StringTable::LookupKey(LocalIsolate* isolate, template Handle StringTable::LookupKey(Isolate* isolate, StringTableInsertionKey* key); -StringTable::Data* StringTable::EnsureCapacity(PtrComprCageBase cage_base, +StringTable::Data* StringTable::EnsureCapacity(IsolateRoot isolate, int additional_elements) { // This call is only allowed while the write mutex is held. write_mutex_.AssertHeld(); @@ -563,7 +560,7 @@ StringTable::Data* StringTable::EnsureCapacity(PtrComprCageBase cage_base, if (new_capacity != -1) { std::unique_ptr new_data = - Data::Resize(cage_base, std::unique_ptr(data), new_capacity); + Data::Resize(isolate, std::unique_ptr(data), new_capacity); // `new_data` is the new owner of `data`. DCHECK_EQ(new_data->PreviousData(), data); // Release-store the new data pointer as `data_`, so that it can be @@ -672,8 +669,8 @@ Address StringTable::TryStringToIndexOrLookupExisting(Isolate* isolate, isolate, string, source, start); } -void StringTable::Print(PtrComprCageBase cage_base) const { - data_.load(std::memory_order_acquire)->Print(cage_base); +void StringTable::Print(IsolateRoot isolate) const { + data_.load(std::memory_order_acquire)->Print(isolate); } size_t StringTable::GetCurrentMemoryUsage() const { diff --git a/src/objects/string-table.h b/src/objects/string-table.h index fe87ce15f2..baf9518ea3 100644 --- a/src/objects/string-table.h +++ b/src/objects/string-table.h @@ -72,7 +72,7 @@ class V8_EXPORT_PRIVATE StringTable { static Address TryStringToIndexOrLookupExisting(Isolate* isolate, Address raw_string); - void Print(PtrComprCageBase cage_base) const; + void Print(IsolateRoot isolate) const; size_t GetCurrentMemoryUsage() const; // The following methods must be called either while holding the write lock, @@ -84,7 +84,7 @@ class V8_EXPORT_PRIVATE StringTable { private: class Data; - Data* EnsureCapacity(PtrComprCageBase cage_base, int additional_elements); + Data* EnsureCapacity(IsolateRoot isolate, int additional_elements); std::atomic data_; // Write mutex is mutable so that readers of concurrently mutated values (e.g. diff --git a/src/objects/string.cc b/src/objects/string.cc index ffa1be3aa3..a65cfc9bcf 100644 --- a/src/objects/string.cc +++ b/src/objects/string.cc @@ -1289,7 +1289,7 @@ Object String::LastIndexOf(Isolate* isolate, Handle receiver, bool String::HasOneBytePrefix(Vector str) { DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this)); return IsEqualToImpl( - str, GetPtrComprCageBase(*this), + str, GetIsolateForPtrCompr(*this), SharedStringAccessGuardIfNeeded::NotNeeded()); } diff --git a/src/objects/string.h b/src/objects/string.h index b8d47b5551..47cdacab96 100644 --- a/src/objects/string.h +++ b/src/objects/string.h @@ -332,7 +332,7 @@ class String : public TorqueGeneratedString { // whole string or just a prefix. // // This is main-thread only, like the Isolate* overload, but additionally - // computes the PtrComprCageBase for IsEqualToImpl. + // computes the IsolateRoot for IsEqualToImpl. template inline bool IsEqualTo(Vector str) const; @@ -546,15 +546,14 @@ class String : public TorqueGeneratedString { // Implementation of the IsEqualTo() public methods. Do not use directly. template V8_INLINE bool IsEqualToImpl( - Vector str, PtrComprCageBase cage_base, + Vector str, IsolateRoot isolate, const SharedStringAccessGuardIfNeeded& access_guard) const; // Out-of-line IsEqualToImpl for ConsString. template V8_NOINLINE static bool IsConsStringEqualToImpl( ConsString string, int slice_offset, Vector str, - PtrComprCageBase cage_base, - const SharedStringAccessGuardIfNeeded& access_guard); + IsolateRoot isolate, const SharedStringAccessGuardIfNeeded& access_guard); V8_EXPORT_PRIVATE static Handle SlowFlatten( Isolate* isolate, Handle cons, AllocationType allocation); diff --git a/src/objects/swiss-name-dictionary-inl.h b/src/objects/swiss-name-dictionary-inl.h index 343abfc8cc..71e21f1536 100644 --- a/src/objects/swiss-name-dictionary-inl.h +++ b/src/objects/swiss-name-dictionary-inl.h @@ -219,15 +219,15 @@ InternalIndex SwissNameDictionary::FindEntry(LocalIsolate* isolate, } Object SwissNameDictionary::LoadFromDataTable(int entry, int data_offset) { - return LoadFromDataTable(GetPtrComprCageBase(*this), entry, data_offset); + return LoadFromDataTable(GetIsolateForPtrCompr(*this), entry, data_offset); } -Object SwissNameDictionary::LoadFromDataTable(PtrComprCageBase cage_base, - int entry, int data_offset) { +Object SwissNameDictionary::LoadFromDataTable(IsolateRoot isolate, int entry, + int data_offset) { DCHECK_LT(static_cast(entry), static_cast(Capacity())); int offset = DataTableStartOffset() + (entry * kDataTableEntryCount + data_offset) * kTaggedSize; - return TaggedField::Relaxed_Load(cage_base, *this, offset); + return TaggedField::Relaxed_Load(isolate, *this, offset); } void SwissNameDictionary::StoreToDataTable(int entry, int data_offset, diff --git a/src/objects/swiss-name-dictionary.h b/src/objects/swiss-name-dictionary.h index 9ab225dd34..9849b3fa55 100644 --- a/src/objects/swiss-name-dictionary.h +++ b/src/objects/swiss-name-dictionary.h @@ -306,8 +306,7 @@ class V8_EXPORT_PRIVATE SwissNameDictionary : public HeapObject { inline ctrl_t GetCtrl(int entry); inline Object LoadFromDataTable(int entry, int data_offset); - inline Object LoadFromDataTable(PtrComprCageBase cage_base, int entry, - int data_offset); + inline Object LoadFromDataTable(IsolateRoot root, int entry, int data_offset); inline void StoreToDataTable(int entry, int data_offset, Object data); inline void StoreToDataTableNoBarrier(int entry, int data_offset, Object data); diff --git a/src/objects/tagged-field-inl.h b/src/objects/tagged-field-inl.h index 513f6a02d9..eaaa557431 100644 --- a/src/objects/tagged-field-inl.h +++ b/src/objects/tagged-field-inl.h @@ -61,10 +61,10 @@ T TaggedField::load(HeapObject host, int offset) { // static template -T TaggedField::load(PtrComprCageBase cage_base, - HeapObject host, int offset) { +T TaggedField::load(IsolateRoot isolate, HeapObject host, + int offset) { Tagged_t value = *location(host, offset); - return T(tagged_to_full(cage_base, value)); + return T(tagged_to_full(isolate, value)); } // static @@ -96,10 +96,10 @@ T TaggedField::Relaxed_Load(HeapObject host, int offset) { // static template -T TaggedField::Relaxed_Load(PtrComprCageBase cage_base, +T TaggedField::Relaxed_Load(IsolateRoot isolate, HeapObject host, int offset) { AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location(host, offset)); - return T(tagged_to_full(cage_base, value)); + return T(tagged_to_full(isolate, value)); } // static @@ -125,10 +125,10 @@ T TaggedField::Acquire_Load(HeapObject host, int offset) { // static template -T TaggedField::Acquire_Load(PtrComprCageBase cage_base, +T TaggedField::Acquire_Load(IsolateRoot isolate, HeapObject host, int offset) { AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location(host, offset)); - return T(tagged_to_full(cage_base, value)); + return T(tagged_to_full(isolate, value)); } // static diff --git a/src/objects/tagged-field.h b/src/objects/tagged-field.h index e3950fa0af..8560c54cc4 100644 --- a/src/objects/tagged-field.h +++ b/src/objects/tagged-field.h @@ -38,21 +38,20 @@ class TaggedField : public AllStatic { static inline Address address(HeapObject host, int offset = 0); static inline T load(HeapObject host, int offset = 0); - static inline T load(PtrComprCageBase cage_base, HeapObject host, - int offset = 0); + static inline T load(IsolateRoot isolate, HeapObject host, int offset = 0); static inline void store(HeapObject host, T value); static inline void store(HeapObject host, int offset, T value); static inline T Relaxed_Load(HeapObject host, int offset = 0); - static inline T Relaxed_Load(PtrComprCageBase cage_base, HeapObject host, + static inline T Relaxed_Load(IsolateRoot isolate, HeapObject host, int offset = 0); static inline void Relaxed_Store(HeapObject host, T value); static inline void Relaxed_Store(HeapObject host, int offset, T value); static inline T Acquire_Load(HeapObject host, int offset = 0); - static inline T Acquire_Load(PtrComprCageBase cage_base, HeapObject host, + static inline T Acquire_Load(IsolateRoot isolate, HeapObject host, int offset = 0); static inline void Release_Store(HeapObject host, T value); diff --git a/src/objects/templates-inl.h b/src/objects/templates-inl.h index d5a08fd88e..8d9107ec7d 100644 --- a/src/objects/templates-inl.h +++ b/src/objects/templates-inl.h @@ -45,13 +45,13 @@ RELEASE_ACQUIRE_ACCESSORS(FunctionTemplateInfo, call_code, HeapObject, // TODO(nicohartmann@, v8:11122): Let Torque generate this accessor. HeapObject FunctionTemplateInfo::rare_data(AcquireLoadTag) const { - PtrComprCageBase cage_base = GetPtrComprCageBase(*this); - return rare_data(cage_base, kAcquireLoad); + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return rare_data(isolate, kAcquireLoad); } -HeapObject FunctionTemplateInfo::rare_data(PtrComprCageBase cage_base, +HeapObject FunctionTemplateInfo::rare_data(IsolateRoot isolate, AcquireLoadTag) const { HeapObject value = - TaggedField::Acquire_Load(cage_base, *this, kRareDataOffset); + TaggedField::Acquire_Load(isolate, *this, kRareDataOffset); DCHECK(value.IsUndefined() || value.IsFunctionTemplateRareData()); return value; } @@ -75,8 +75,8 @@ FunctionTemplateRareData FunctionTemplateInfo::EnsureFunctionTemplateRareData( #define RARE_ACCESSORS(Name, CamelName, Type, Default) \ DEF_GETTER(FunctionTemplateInfo, Get##CamelName, Type) { \ - HeapObject extra = rare_data(cage_base, kAcquireLoad); \ - HeapObject undefined = GetReadOnlyRoots(cage_base).undefined_value(); \ + HeapObject extra = rare_data(isolate, kAcquireLoad); \ + HeapObject undefined = GetReadOnlyRoots(isolate).undefined_value(); \ return extra == undefined ? Default \ : FunctionTemplateRareData::cast(extra).Name(); \ } \ diff --git a/src/objects/templates.h b/src/objects/templates.h index 966b81167c..33c27b1182 100644 --- a/src/objects/templates.h +++ b/src/objects/templates.h @@ -92,7 +92,7 @@ class FunctionTemplateInfo // TODO(nicohartmann@, v8:11122): Let Torque generate the following accessor. inline HeapObject rare_data(AcquireLoadTag) const; - inline HeapObject rare_data(PtrComprCageBase cage_base, AcquireLoadTag) const; + inline HeapObject rare_data(IsolateRoot isolate, AcquireLoadTag) const; inline void set_rare_data( HeapObject value, ReleaseStoreTag, WriteBarrierMode mode = WriteBarrierMode::UPDATE_WRITE_BARRIER); diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc index 9cc26fa3e2..a9a6282abc 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc @@ -1508,10 +1508,10 @@ class RootsReferencesExtractor : public RootVisitor { OffHeapObjectSlot start, OffHeapObjectSlot end) override { DCHECK_EQ(root, Root::kStringTable); - PtrComprCageBase cage_base = Isolate::FromHeap(explorer_->heap_); + IsolateRoot isolate = Isolate::FromHeap(explorer_->heap_); for (OffHeapObjectSlot p = start; p < end; ++p) { explorer_->SetGcSubrootReference(root, description, visiting_weak_roots_, - p.load(cage_base)); + p.load(isolate)); } } diff --git a/src/torque/cc-generator.cc b/src/torque/cc-generator.cc index 0dea634ba4..7f9f662979 100644 --- a/src/torque/cc-generator.cc +++ b/src/torque/cc-generator.cc @@ -386,10 +386,10 @@ void CCGenerator::EmitInstruction(const LoadReferenceInstruction& instruction, out() << " " << result_name << " = "; if (instruction.type->IsSubtypeOf(TypeOracle::GetTaggedType())) { // Currently, all of the tagged loads we emit are for smi values, so there - // is no point in providing an PtrComprCageBase. If at some point we start + // is no point in providing an IsolateRoot. If at some point we start // emitting loads for tagged fields which might be HeapObjects, then we - // should plumb an PtrComprCageBase through the generated functions that - // need it. + // should plumb an IsolateRoot through the generated functions that need + // it. if (!instruction.type->IsSubtypeOf(TypeOracle::GetSmiType())) { Error( "Not supported in C++ output: LoadReference on non-smi tagged " diff --git a/src/torque/implementation-visitor.cc b/src/torque/implementation-visitor.cc index a2cf0fee86..e4f66777e9 100644 --- a/src/torque/implementation-visitor.cc +++ b/src/torque/implementation-visitor.cc @@ -4223,9 +4223,8 @@ void CppClassGenerator::GenerateFieldAccessors( hdr_ << " inline " << type_name << " " << name << "(" << (indexed ? "int i" : "") << ") const;\n"; if (can_contain_heap_objects) { - hdr_ << " inline " << type_name << " " << name - << "(PtrComprCageBase cage_base" << (indexed ? ", int i" : "") - << ") const;\n"; + hdr_ << " inline " << type_name << " " << name << "(IsolateRoot isolate" + << (indexed ? ", int i" : "") << ") const;\n"; } hdr_ << " inline void set_" << name << "(" << (indexed ? "int i, " : "") << type_name << " value" @@ -4234,14 +4233,14 @@ void CppClassGenerator::GenerateFieldAccessors( : "") << ");\n\n"; - // For tagged data, generate the extra getter that derives an PtrComprCageBase - // from the current object's pointer. + // For tagged data, generate the extra getter that derives an IsolateRoot from + // the current object's pointer. if (can_contain_heap_objects) { inl_ << "template \n"; inl_ << type_name << " " << gen_name_ << "::" << name << "(" << (indexed ? "int i" : "") << ") const {\n"; - inl_ << " PtrComprCageBase cage_base = GetPtrComprCageBase(*this);\n"; - inl_ << " return " << gen_name_ << "::" << name << "(cage_base" + inl_ << " IsolateRoot isolate = GetIsolateForPtrCompr(*this);\n"; + inl_ << " return " << gen_name_ << "::" << name << "(isolate" << (indexed ? ", i" : "") << ");\n"; inl_ << "}\n"; } @@ -4249,7 +4248,7 @@ void CppClassGenerator::GenerateFieldAccessors( // Generate the getter implementation. inl_ << "template \n"; inl_ << type_name << " " << gen_name_ << "::" << name << "("; - if (can_contain_heap_objects) inl_ << "PtrComprCageBase cage_base"; + if (can_contain_heap_objects) inl_ << "IsolateRoot isolate"; if (can_contain_heap_objects && indexed) inl_ << ", "; if (indexed) inl_ << "int i"; inl_ << ") const {\n"; @@ -4362,11 +4361,10 @@ void CppClassGenerator::EmitLoadFieldStatement( bool is_smi = field_type->IsSubtypeOf(TypeOracle::GetSmiType()); const std::string load_type = is_smi ? "Smi" : type_name; const char* postfix = is_smi ? ".value()" : ""; - const char* optional_cage_base = is_smi ? "" : "cage_base, "; + const char* optional_isolate = is_smi ? "" : "isolate, "; inl_ << "TaggedField<" << load_type << ">::" << load << "(" - << optional_cage_base << "*this, " << offset << ")" << postfix - << ";\n"; + << optional_isolate << "*this, " << offset << ")" << postfix << ";\n"; } if (CanContainHeapObjects(field_type)) { diff --git a/src/wasm/wasm-objects-inl.h b/src/wasm/wasm-objects-inl.h index 3da7e1650a..abae4ee951 100644 --- a/src/wasm/wasm-objects-inl.h +++ b/src/wasm/wasm-objects-inl.h @@ -59,13 +59,13 @@ CAST_ACCESSOR(WasmTypeInfo) CAST_ACCESSOR(WasmStruct) CAST_ACCESSOR(WasmArray) -#define OPTIONAL_ACCESSORS(holder, name, type, offset) \ - DEF_GETTER(holder, has_##name, bool) { \ - Object value = TaggedField::load(cage_base, *this); \ - return !value.IsUndefined(GetReadOnlyRoots(cage_base)); \ - } \ - ACCESSORS_CHECKED2(holder, name, type, offset, \ - !value.IsUndefined(GetReadOnlyRoots(cage_base)), true) +#define OPTIONAL_ACCESSORS(holder, name, type, offset) \ + DEF_GETTER(holder, has_##name, bool) { \ + Object value = TaggedField::load(isolate, *this); \ + return !value.IsUndefined(GetReadOnlyRoots(isolate)); \ + } \ + ACCESSORS_CHECKED2(holder, name, type, offset, \ + !value.IsUndefined(GetReadOnlyRoots(isolate)), true) #define PRIMITIVE_ACCESSORS(holder, name, type, offset) \ type holder::name() const { \ @@ -460,12 +460,6 @@ int WasmArray::GcSafeSizeFor(Map map, int length) { void WasmTypeInfo::clear_foreign_address(Isolate* isolate) { #ifdef V8_HEAP_SANDBOX - - // TODO(syg): V8_HEAP_SANDBOX doesn't work with pointer cage -#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE -#error "V8_HEAP_SANDBOX requires per-Isolate pointer compression cage" -#endif - // Due to the type-specific pointer tags for external pointers, we need to // allocate an entry in the table here even though it will just store nullptr. AllocateExternalPointerEntries(isolate); diff --git a/tools/debug_helper/debug-helper-internal.cc b/tools/debug_helper/debug-helper-internal.cc index 51c8da6f27..29af7ebdd7 100644 --- a/tools/debug_helper/debug-helper-internal.cc +++ b/tools/debug_helper/debug-helper-internal.cc @@ -14,7 +14,7 @@ namespace debug_helper_internal { bool IsPointerCompressed(uintptr_t address) { #if COMPRESS_POINTERS_BOOL - return address < i::kPtrComprCageReservationSize; + return address < i::kPtrComprHeapReservationSize; #else return false; #endif diff --git a/tools/debug_helper/get-object-properties.cc b/tools/debug_helper/get-object-properties.cc index 7199bc51d2..a7cc1414df 100644 --- a/tools/debug_helper/get-object-properties.cc +++ b/tools/debug_helper/get-object-properties.cc @@ -348,7 +348,7 @@ class ReadStringVisitor : public TqObjectVisitor { GetOrFinish(object->GetResourceDataValue(accessor_)); #ifdef V8_COMPRESS_POINTERS uintptr_t data_address = static_cast( - DecodeExternalPointer(GetPtrComprCageBaseFromOnHeapAddress( + DecodeExternalPointer(GetIsolateForPtrComprFromOnHeapAddress( heap_addresses_.any_heap_pointer), resource_data, kExternalStringResourceDataTag)); #else