[static-roots] Use operator== in HeapObject::Is##Type

Replace SafeEquals with normal equals operator in `IsUndefined` and
friends. This will allow us to have more efficient checks with static
roots, since pointers do not need to be decompressed.

After this change calling Is##Type on CodeObjects is no longer possible.
This is ensured by dchecks in operator==. The change might reveal more
callers that need to be fixed.

Bug: v8:13466
Change-Id: I3353d10aebb7a192a77281c44e4159f0da336297
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4106849
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Auto-Submit: Olivier Flückiger <olivf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84974}
This commit is contained in:
Olivier Flückiger 2022-12-14 16:09:10 +00:00 committed by V8 LUCI CQ
parent 53e7cf253a
commit f6d85958e0
3 changed files with 9 additions and 2 deletions

View File

@ -53,6 +53,7 @@ class Utils;
namespace internal {
template <typename T>
class CustomArguments;
class SamplingHeapProfiler;
} // namespace internal
namespace api_internal {
@ -313,6 +314,7 @@ class Local {
friend class BasicTracedReference;
template <class F>
friend class TracedReference;
friend class v8::internal::SamplingHeapProfiler;
explicit V8_INLINE Local(T* that) : val_(that) {}
V8_INLINE static Local<T> New(Isolate* isolate, T* that) {

View File

@ -110,7 +110,7 @@ IS_TYPE_FUNCTION_DEF(CodeT)
return Is##Type(ReadOnlyRoots(isolate)); \
} \
bool Object::Is##Type(ReadOnlyRoots roots) const { \
return SafeEquals(roots.Value()); \
return (*this) == roots.Value(); \
} \
bool Object::Is##Type() const { \
return IsHeapObject() && HeapObject::cast(*this).Is##Type(); \

View File

@ -81,7 +81,12 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) {
HeapObject heap_object = HeapObject::FromAddress(soon_object);
Handle<Object> obj(heap_object, isolate_);
Local<v8::Value> loc = v8::Utils::ToLocal(obj);
// Since soon_object can be in code space we can't use v8::Utils::ToLocal.
DCHECK(obj.is_null() ||
(obj->IsSmi() ||
(V8_EXTERNAL_CODE_SPACE_BOOL && IsCodeSpaceObject(heap_object)) ||
!obj->IsTheHole()));
Local<v8::Value> loc(reinterpret_cast<v8::Value*>(obj.location()));
AllocationNode* node = AddStack();
node->allocations_[size]++;