diff --git a/include/v8-local-handle.h b/include/v8-local-handle.h index cbf87f949d..633c5633c5 100644 --- a/include/v8-local-handle.h +++ b/include/v8-local-handle.h @@ -53,6 +53,7 @@ class Utils; namespace internal { template class CustomArguments; +class SamplingHeapProfiler; } // namespace internal namespace api_internal { @@ -313,6 +314,7 @@ class Local { friend class BasicTracedReference; template friend class TracedReference; + friend class v8::internal::SamplingHeapProfiler; explicit V8_INLINE Local(T* that) : val_(that) {} V8_INLINE static Local New(Isolate* isolate, T* that) { diff --git a/src/objects/objects-inl.h b/src/objects/objects-inl.h index f2108a8a61..680e870981 100644 --- a/src/objects/objects-inl.h +++ b/src/objects/objects-inl.h @@ -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(); \ diff --git a/src/profiler/sampling-heap-profiler.cc b/src/profiler/sampling-heap-profiler.cc index 50a32dd4d5..6747f7bceb 100644 --- a/src/profiler/sampling-heap-profiler.cc +++ b/src/profiler/sampling-heap-profiler.cc @@ -81,7 +81,12 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) { HeapObject heap_object = HeapObject::FromAddress(soon_object); Handle obj(heap_object, isolate_); - Local 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 loc(reinterpret_cast(obj.location())); AllocationNode* node = AddStack(); node->allocations_[size]++;