diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 18f705768a..98b8e69375 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -4836,7 +4836,7 @@ void Heap::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) { } void Heap::TracePossibleWrapper(JSObject* js_object) { - DCHECK(js_object->WasConstructedFromApiFunction()); + DCHECK(js_object->IsApiWrapper()); if (js_object->GetEmbedderFieldCount() >= 2 && js_object->GetEmbedderField(0) && js_object->GetEmbedderField(0) != ReadOnlyRoots(this).undefined_value() && diff --git a/src/objects.cc b/src/objects.cc index 4a2f4c8c72..e90a722e1f 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -3324,7 +3324,7 @@ bool JSObject::IsUnmodifiedApiObject(Object** o) { HeapObject* heap_object = HeapObject::cast(object); if (!object->IsJSObject()) return false; JSObject* js_object = JSObject::cast(object); - if (!js_object->WasConstructedFromApiFunction()) return false; + if (!js_object->IsApiWrapper()) return false; Object* maybe_constructor = js_object->map()->GetConstructor(); if (!maybe_constructor->IsJSFunction()) return false; JSFunction* constructor = JSFunction::cast(maybe_constructor); @@ -16078,34 +16078,10 @@ bool FixedArrayBase::IsCowArray() const { return map() == GetReadOnlyRoots().fixed_cow_array_map(); } -bool JSObject::WasConstructedFromApiFunction() { +bool JSObject::IsApiWrapper() { auto instance_type = map()->instance_type(); - bool is_api_object = instance_type == JS_API_OBJECT_TYPE || - instance_type == JS_SPECIAL_API_OBJECT_TYPE; - bool is_wasm_object = - instance_type == WASM_GLOBAL_TYPE || instance_type == WASM_MEMORY_TYPE || - instance_type == WASM_MODULE_TYPE || - instance_type == WASM_INSTANCE_TYPE || instance_type == WASM_TABLE_TYPE; -#ifdef ENABLE_SLOW_DCHECKS - if (FLAG_enable_slow_asserts) { - Object* maybe_constructor = map()->GetConstructor(); - if (maybe_constructor->IsJSFunction()) { - JSFunction* constructor = JSFunction::cast(maybe_constructor); - DCHECK_EQ(constructor->shared()->IsApiFunction(), - is_api_object || is_wasm_object); - } else if (maybe_constructor->IsFunctionTemplateInfo()) { - DCHECK(is_api_object || is_wasm_object); - } else { - return false; - } - } -#endif - // TODO(titzer): Clean this up somehow. WebAssembly objects should not be - // considered "constructed from API functions" even though they have - // function template info, since that would make the V8 GC identify them to - // the embedder, e.g. the Oilpan GC. - USE(is_wasm_object); - return is_api_object; + return instance_type == JS_API_OBJECT_TYPE || + instance_type == JS_SPECIAL_API_OBJECT_TYPE; } const char* Symbol::PrivateSymbolToName() const { diff --git a/src/objects.h b/src/objects.h index 04751cc6ae..f84f29a3a1 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2520,7 +2520,12 @@ class JSObject: public JSReceiver { inline Object* GetEmbedderField(int index); inline void SetEmbedderField(int index, Object* value); inline void SetEmbedderField(int index, Smi* value); - bool WasConstructedFromApiFunction(); + + // Returns true when the object is potentially a wrapper that gets special + // garbage collection treatment. + // TODO(mlippautz): Make check exact and replace the pattern match in + // Heap::TracePossibleWrapper. + bool IsApiWrapper(); // Returns a new map with all transitions dropped from the object's current // map and the ElementsKind set.