diff --git a/ecmascript/mem/dynamic_object_operator.cpp b/ecmascript/mem/dynamic_object_operator.cpp index 6dce31e1e19b0f423a63ebf879f6e79efc45776c..138851d21afdae66514924649d004dff50e6a51a 100644 --- a/ecmascript/mem/dynamic_object_operator.cpp +++ b/ecmascript/mem/dynamic_object_operator.cpp @@ -55,7 +55,7 @@ void RefFieldObjectVisitor::VisitAllRefFields(TaggedObject *obj) // Note this will update the stack param, not the slot of object hclass // But sinc hclass in non-movable, so current all visitor will not update hlass field, so it's ok VisitObjectHClassImpl(obj->GetClass()); - ObjectXRay::VisitObjectBody(obj, obj->GetClass(), *this); + ObjectXRay::VisitObjectBodyFast(obj, obj->GetClass(), *this); } void RefFieldObjectVisitor::visit(ObjectSlot slot) diff --git a/ecmascript/mem/object_xray.h b/ecmascript/mem/object_xray.h index ee374be6f1bf50e92c0cc9c3d0442e7268fcc823..b318501bf04992080d9e395169cb2bee23984021 100644 --- a/ecmascript/mem/object_xray.h +++ b/ecmascript/mem/object_xray.h @@ -157,19 +157,33 @@ public: vm->GetJSThread()->IterateJitCodeMap(updater); } - template + template + ALWAYS_INLINE static inline void VisitObjectBodyFast(TaggedObject *object, JSHClass *klass, + BaseObjectVisitor &visitor) + { + JSType type = klass->GetObjectType(); + switch (type) { + case JSType::JS_OBJECT: + JSObject::Cast(object)->VisitRangeSlot(visitor); + return; + case JSType::JS_FUNCTION: + JSFunction::Cast(object)->VisitRangeSlot(visitor); + return; + case JSType::TAGGED_ARRAY: + TaggedArray::Cast(object)->VisitRangeSlot(visitor); + return; + default: + VisitObjectBody(object, klass, visitor); + return; + } + } + + template static inline void VisitObjectBody(TaggedObject *object, JSHClass *klass, BaseObjectVisitor &visitor) { // handle body JSType type = klass->GetObjectType(); - if constexpr (isCMCGC) { - // fastpath for cmcgc - if (type == JSType::JS_TYPED_ARRAY) { - JSTypedArray::Cast(object)->VisitRangeSlot(visitor); - return; - } - } switch (type) { case JSType::JS_OBJECT: case JSType::JS_XREF_OBJECT: