[ptr-compr][cleanup] Remove ROOT_PARAM, ROOT_VALUE and friends

... in favor of Isolate*. It seems that it's better to be uniform in
using Isolate* or isolate root value, so if we decide to pass isolate
root value instead of Isolate* it should better be done everywhere and
it will be a separate CL anyway.

Regarding the "optionality" of the isolate parameter - C++ compilers
are smart enough to optimize it away during inlining.

Bug: v8:9353
Change-Id: Idf86a792476f49393041ced1c54b8671f5b1794a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1653121
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62107}
This commit is contained in:
Igor Sheludko 2019-06-11 19:06:14 +02:00 committed by Commit Bot
parent 823795fc2b
commit 0ebc2b6d76
8 changed files with 44 additions and 65 deletions

View File

@ -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

View File

@ -34,11 +34,6 @@ V8_INLINE Address GetIsolateRoot<Isolate*>(Isolate* isolate) {
return isolate->isolate_root();
}
template <>
V8_INLINE Address GetIsolateRoot<const Isolate*>(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

View File

@ -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);

View File

@ -430,9 +430,8 @@ void SortIndices(Isolate* isolate, Handle<FixedArray> 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);

View File

@ -52,11 +52,11 @@ bool TaggedImpl<kRefType, StorageType>::GetHeapObject(
template <HeapObjectReferenceType kRefType, typename StorageType>
bool TaggedImpl<kRefType, StorageType>::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<kRefType, StorageType>::GetHeapObject(
template <HeapObjectReferenceType kRefType, typename StorageType>
bool TaggedImpl<kRefType, StorageType>::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<kRefType, StorageType>::GetHeapObjectIfStrong(
template <HeapObjectReferenceType kRefType, typename StorageType>
bool TaggedImpl<kRefType, StorageType>::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<Tagged_t>(ptr_))));
return true;
}
return false;
@ -132,11 +132,12 @@ HeapObject TaggedImpl<kRefType, StorageType>::GetHeapObjectAssumeStrong()
template <HeapObjectReferenceType kRefType, typename StorageType>
HeapObject TaggedImpl<kRefType, StorageType>::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<Tagged_t>(ptr_))));
}
//
@ -161,12 +162,12 @@ bool TaggedImpl<kRefType, StorageType>::GetHeapObjectIfWeak(
template <HeapObjectReferenceType kRefType, typename StorageType>
bool TaggedImpl<kRefType, StorageType>::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<kRefType, StorageType>::GetHeapObjectAssumeWeak() const {
template <HeapObjectReferenceType kRefType, typename StorageType>
HeapObject TaggedImpl<kRefType, StorageType>::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<kRefType, StorageType>::GetHeapObject() const {
}
template <HeapObjectReferenceType kRefType, typename StorageType>
HeapObject TaggedImpl<kRefType, StorageType>::GetHeapObject(ROOT_PARAM) const {
HeapObject TaggedImpl<kRefType, StorageType>::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<Tagged_t>(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<Tagged_t>(ptr_))));
}
}
@ -242,13 +245,14 @@ Object TaggedImpl<kRefType, StorageType>::GetHeapObjectOrSmi() const {
}
template <HeapObjectReferenceType kRefType, typename StorageType>
Object TaggedImpl<kRefType, StorageType>::GetHeapObjectOrSmi(ROOT_PARAM) const {
Object TaggedImpl<kRefType, StorageType>::GetHeapObjectOrSmi(
Isolate* isolate) const {
if (kIsFull) return GetHeapObjectOrSmi();
// Implementation for compressed pointers.
if (IsSmi()) {
return Object(DecompressTaggedSigned(ptr_));
return Object(DecompressTaggedSigned(static_cast<Tagged_t>(ptr_)));
}
return GetHeapObject(ROOT_VALUE);
return GetHeapObject(isolate);
}
} // namespace internal

View File

@ -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 <typename T>

View File

@ -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

View File

@ -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<HeapObjectReferenceType::WEAK, Tagged_t> {
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