diff --git a/src/common/globals.h b/src/common/globals.h index 5d4b957e84..65ee59d5c1 100644 --- a/src/common/globals.h +++ b/src/common/globals.h @@ -212,15 +212,6 @@ constexpr size_t kReservedCodeRangePages = 0; STATIC_ASSERT(kSystemPointerSize == (1 << kSystemPointerSizeLog2)); -// This macro is used for declaring and defining HeapObject getter methods that -// are a bit more efficient for the pointer compression case than the default -// parameterless getters because isolate root doesn't have to be computed from -// arbitrary field address but it comes "for free" instead. -// These alternatives are always defined (in order to avoid #ifdef mess but -// are not supposed to be used when pointer compression is not enabled. -#define ROOT_VALUE isolate_for_root -#define ROOT_PARAM Isolate* const ROOT_VALUE - #ifdef V8_COMPRESS_POINTERS static_assert( kSystemPointerSize == kInt64Size, @@ -234,11 +225,6 @@ constexpr int kTaggedSizeLog2 = 2; using Tagged_t = int32_t; using AtomicTagged_t = base::Atomic32; -#define DEFINE_ROOT_VALUE(isolate) ROOT_PARAM = isolate -#define WITH_ROOT_PARAM(...) ROOT_PARAM, ##__VA_ARGS__ -#define WITH_ROOT_VALUE(...) ROOT_VALUE, ##__VA_ARGS__ -#define WITH_ROOT(isolate_for_root, ...) isolate_for_root, ##__VA_ARGS__ - #else constexpr int kTaggedSize = kSystemPointerSize; @@ -249,11 +235,6 @@ constexpr int kTaggedSizeLog2 = kSystemPointerSizeLog2; using Tagged_t = Address; using AtomicTagged_t = base::AtomicWord; -#define DEFINE_ROOT_VALUE(isolate) -#define WITH_ROOT_PARAM(...) __VA_ARGS__ -#define WITH_ROOT_VALUE(...) __VA_ARGS__ -#define WITH_ROOT(isolate_for_root, ...) __VA_ARGS__ - #endif // V8_COMPRESS_POINTERS // Defines whether the branchless or branchful implementation of pointer diff --git a/src/common/ptr-compr-inl.h b/src/common/ptr-compr-inl.h index fd0f97e904..20ec90203c 100644 --- a/src/common/ptr-compr-inl.h +++ b/src/common/ptr-compr-inl.h @@ -34,11 +34,6 @@ V8_INLINE Address GetIsolateRoot(Isolate* isolate) { return isolate->isolate_root(); } -template <> -V8_INLINE Address GetIsolateRoot(const Isolate* isolate) { - return isolate->isolate_root(); -} - // Decompresses smi value. V8_INLINE Address DecompressTaggedSigned(Tagged_t raw_value) { // Current compression scheme requires |raw_value| to be sign-extended diff --git a/src/execution/frames.cc b/src/execution/frames.cc index af660a338e..a57c620558 100644 --- a/src/execution/frames.cc +++ b/src/execution/frames.cc @@ -972,7 +972,6 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const { parameters_limit); } - DEFINE_ROOT_VALUE(isolate()); // Visit pointer spill slots and locals. uint8_t* safepoint_bits = safepoint_entry.bits(); for (unsigned index = 0; index < stack_slots; index++) { @@ -992,7 +991,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const { if (!HAS_SMI_TAG(compressed_value)) { // We don't need to update smi values. *spill_slot.location() = - DecompressTaggedPointer(ROOT_VALUE, compressed_value); + DecompressTaggedPointer(isolate(), compressed_value); } #endif v->VisitRootPointer(Root::kTop, nullptr, spill_slot); diff --git a/src/objects/elements.cc b/src/objects/elements.cc index f322384b60..bccbb71130 100644 --- a/src/objects/elements.cc +++ b/src/objects/elements.cc @@ -430,9 +430,8 @@ void SortIndices(Isolate* isolate, Handle indices, AtomicSlot end(start + sort_size); std::sort(start, end, [isolate](Tagged_t elementA, Tagged_t elementB) { #ifdef V8_COMPRESS_POINTERS - DEFINE_ROOT_VALUE(isolate); - Object a(DecompressTaggedAny(ROOT_VALUE, elementA)); - Object b(DecompressTaggedAny(ROOT_VALUE, elementB)); + Object a(DecompressTaggedAny(isolate, elementA)); + Object b(DecompressTaggedAny(isolate, elementB)); #else Object a(elementA); Object b(elementB); diff --git a/src/objects/tagged-impl-inl.h b/src/objects/tagged-impl-inl.h index f735a241a8..909f65a959 100644 --- a/src/objects/tagged-impl-inl.h +++ b/src/objects/tagged-impl-inl.h @@ -52,11 +52,11 @@ bool TaggedImpl::GetHeapObject( template bool TaggedImpl::GetHeapObject( - ROOT_PARAM, HeapObject* result) const { + Isolate* isolate, HeapObject* result) const { if (kIsFull) return GetHeapObject(result); // Implementation for compressed pointers. if (!IsStrongOrWeak()) return false; - *result = GetHeapObject(ROOT_VALUE); + *result = GetHeapObject(isolate); return true; } @@ -79,14 +79,14 @@ bool TaggedImpl::GetHeapObject( template bool TaggedImpl::GetHeapObject( - ROOT_PARAM, HeapObject* result, + Isolate* isolate, HeapObject* result, HeapObjectReferenceType* reference_type) const { if (kIsFull) return GetHeapObject(result, reference_type); // Implementation for compressed pointers. if (!IsStrongOrWeak()) return false; *reference_type = IsWeakOrCleared() ? HeapObjectReferenceType::WEAK : HeapObjectReferenceType::STRONG; - *result = GetHeapObject(ROOT_VALUE); + *result = GetHeapObject(isolate); return true; } @@ -107,12 +107,12 @@ bool TaggedImpl::GetHeapObjectIfStrong( template bool TaggedImpl::GetHeapObjectIfStrong( - ROOT_PARAM, HeapObject* result) const { + Isolate* isolate, HeapObject* result) const { if (kIsFull) return GetHeapObjectIfStrong(result); // Implementation for compressed pointers. if (IsStrong()) { - *result = - HeapObject::cast(Object(DecompressTaggedPointer(ROOT_VALUE, ptr_))); + *result = HeapObject::cast( + Object(DecompressTaggedPointer(isolate, static_cast(ptr_)))); return true; } return false; @@ -132,11 +132,12 @@ HeapObject TaggedImpl::GetHeapObjectAssumeStrong() template HeapObject TaggedImpl::GetHeapObjectAssumeStrong( - ROOT_PARAM) const { + Isolate* isolate) const { if (kIsFull) return GetHeapObjectAssumeStrong(); // Implementation for compressed pointers. DCHECK(IsStrong()); - return HeapObject::cast(Object(DecompressTaggedPointer(ROOT_VALUE, ptr_))); + return HeapObject::cast( + Object(DecompressTaggedPointer(isolate, static_cast(ptr_)))); } // @@ -161,12 +162,12 @@ bool TaggedImpl::GetHeapObjectIfWeak( template bool TaggedImpl::GetHeapObjectIfWeak( - ROOT_PARAM, HeapObject* result) const { + Isolate* isolate, HeapObject* result) const { if (kIsFull) return GetHeapObjectIfWeak(result); // Implementation for compressed pointers. if (kCanBeWeak) { if (IsWeak()) { - *result = GetHeapObject(ROOT_VALUE); + *result = GetHeapObject(isolate); return true; } return false; @@ -189,11 +190,11 @@ HeapObject TaggedImpl::GetHeapObjectAssumeWeak() const { template HeapObject TaggedImpl::GetHeapObjectAssumeWeak( - ROOT_PARAM) const { + Isolate* isolate) const { if (kIsFull) return GetHeapObjectAssumeWeak(); // Implementation for compressed pointers. DCHECK(IsWeak()); - return GetHeapObject(ROOT_VALUE); + return GetHeapObject(isolate); } // @@ -214,17 +215,19 @@ HeapObject TaggedImpl::GetHeapObject() const { } template -HeapObject TaggedImpl::GetHeapObject(ROOT_PARAM) const { +HeapObject TaggedImpl::GetHeapObject( + Isolate* isolate) const { if (kIsFull) return GetHeapObject(); // Implementation for compressed pointers. DCHECK(!IsSmi()); if (kCanBeWeak) { DCHECK(!IsCleared()); - return HeapObject::cast(Object( - DecompressTaggedPointer(ROOT_VALUE, ptr_ & ~kWeakHeapObjectMask))); + return HeapObject::cast(Object(DecompressTaggedPointer( + isolate, static_cast(ptr_) & ~kWeakHeapObjectMask))); } else { DCHECK(!HAS_WEAK_HEAP_OBJECT_TAG(ptr_)); - return HeapObject::cast(Object(DecompressTaggedPointer(ROOT_VALUE, ptr_))); + return HeapObject::cast( + Object(DecompressTaggedPointer(isolate, static_cast(ptr_)))); } } @@ -242,13 +245,14 @@ Object TaggedImpl::GetHeapObjectOrSmi() const { } template -Object TaggedImpl::GetHeapObjectOrSmi(ROOT_PARAM) const { +Object TaggedImpl::GetHeapObjectOrSmi( + Isolate* isolate) const { if (kIsFull) return GetHeapObjectOrSmi(); // Implementation for compressed pointers. if (IsSmi()) { - return Object(DecompressTaggedSigned(ptr_)); + return Object(DecompressTaggedSigned(static_cast(ptr_))); } - return GetHeapObject(ROOT_VALUE); + return GetHeapObject(isolate); } } // namespace internal diff --git a/src/objects/tagged-impl.h b/src/objects/tagged-impl.h index 9478675539..111eabae2f 100644 --- a/src/objects/tagged-impl.h +++ b/src/objects/tagged-impl.h @@ -107,50 +107,51 @@ class TaggedImpl { // // The following set of methods get HeapObject out of the tagged value - // which may involve decompression in which case the ROOT_PARAM is required. + // which may involve decompression in which case the isolate root is required. // If the pointer compression is not enabled then the variants with - // ROOT_PARAM will be exactly the same as non-ROOT_PARAM ones. + // isolate parameter will be exactly the same as the ones witout isolate + // parameter. // // If this tagged value is a strong pointer to a HeapObject, returns true and // sets *result. Otherwise returns false. inline bool GetHeapObjectIfStrong(HeapObject* result) const; - inline bool GetHeapObjectIfStrong(ROOT_PARAM, HeapObject* result) const; + inline bool GetHeapObjectIfStrong(Isolate* isolate, HeapObject* result) const; // DCHECKs that this tagged value is a strong pointer to a HeapObject and // returns the HeapObject. inline HeapObject GetHeapObjectAssumeStrong() const; - inline HeapObject GetHeapObjectAssumeStrong(ROOT_PARAM) const; + inline HeapObject GetHeapObjectAssumeStrong(Isolate* isolate) const; // If this tagged value is a weak pointer to a HeapObject, returns true and // sets *result. Otherwise returns false. inline bool GetHeapObjectIfWeak(HeapObject* result) const; - inline bool GetHeapObjectIfWeak(ROOT_PARAM, HeapObject* result) const; + inline bool GetHeapObjectIfWeak(Isolate* isolate, HeapObject* result) const; // DCHECKs that this tagged value is a weak pointer to a HeapObject and // returns the HeapObject. inline HeapObject GetHeapObjectAssumeWeak() const; - inline HeapObject GetHeapObjectAssumeWeak(ROOT_PARAM) const; + inline HeapObject GetHeapObjectAssumeWeak(Isolate* isolate) const; // If this tagged value is a strong or weak pointer to a HeapObject, returns // true and sets *result. Otherwise returns false. inline bool GetHeapObject(HeapObject* result) const; - inline bool GetHeapObject(ROOT_PARAM, HeapObject* result) const; + inline bool GetHeapObject(Isolate* isolate, HeapObject* result) const; inline bool GetHeapObject(HeapObject* result, HeapObjectReferenceType* reference_type) const; - inline bool GetHeapObject(ROOT_PARAM, HeapObject* result, + inline bool GetHeapObject(Isolate* isolate, HeapObject* result, HeapObjectReferenceType* reference_type) const; // DCHECKs that this tagged value is a strong or a weak pointer to a // HeapObject and returns the HeapObject. inline HeapObject GetHeapObject() const; - inline HeapObject GetHeapObject(ROOT_PARAM) const; + inline HeapObject GetHeapObject(Isolate* isolate) const; // DCHECKs that this tagged value is a strong or a weak pointer to a // HeapObject or a Smi and returns the HeapObject or Smi. inline Object GetHeapObjectOrSmi() const; - inline Object GetHeapObjectOrSmi(ROOT_PARAM) const; + inline Object GetHeapObjectOrSmi(Isolate* isolate) const; // Cast operation is available only for full non-weak tagged values. template diff --git a/src/objects/tagged-value-inl.h b/src/objects/tagged-value-inl.h index 5eb0e20947..bfc80ed28a 100644 --- a/src/objects/tagged-value-inl.h +++ b/src/objects/tagged-value-inl.h @@ -17,17 +17,17 @@ namespace v8 { namespace internal { -Object StrongTaggedValue::ToObject(WITH_ROOT_PARAM(StrongTaggedValue object)) { +Object StrongTaggedValue::ToObject(Isolate* isolate, StrongTaggedValue object) { #ifdef V8_COMPRESS_POINTERS - return Object(DecompressTaggedAny(ROOT_VALUE, object.ptr())); + return Object(DecompressTaggedAny(isolate, object.ptr())); #else return Object(object.ptr()); #endif } -MaybeObject TaggedValue::ToMaybeObject(WITH_ROOT_PARAM(TaggedValue object)) { +MaybeObject TaggedValue::ToMaybeObject(Isolate* isolate, TaggedValue object) { #ifdef V8_COMPRESS_POINTERS - return MaybeObject(DecompressTaggedAny(ROOT_VALUE, object.ptr())); + return MaybeObject(DecompressTaggedAny(isolate, object.ptr())); #else return MaybeObject(object.ptr()); #endif diff --git a/src/objects/tagged-value.h b/src/objects/tagged-value.h index bb7609f7c3..3d21263754 100644 --- a/src/objects/tagged-value.h +++ b/src/objects/tagged-value.h @@ -22,7 +22,7 @@ class StrongTaggedValue constexpr StrongTaggedValue() : TaggedImpl() {} explicit constexpr StrongTaggedValue(Tagged_t ptr) : TaggedImpl(ptr) {} - inline static Object ToObject(WITH_ROOT_PARAM(StrongTaggedValue object)); + inline static Object ToObject(Isolate* isolate, StrongTaggedValue object); }; // Almost same as MaybeObject but this one deals with in-heap and potentially @@ -33,7 +33,7 @@ class TaggedValue : public TaggedImpl { constexpr TaggedValue() : TaggedImpl() {} explicit constexpr TaggedValue(Tagged_t ptr) : TaggedImpl(ptr) {} - inline static MaybeObject ToMaybeObject(WITH_ROOT_PARAM(TaggedValue object)); + inline static MaybeObject ToMaybeObject(Isolate* isolate, TaggedValue object); }; } // namespace internal