Fix test262 bug

Issues: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IA56WU?from=project-issue
Signed-off-by: 刘智杰 <liuzhijie9@huawei.com>

Change-Id: Id2823b4ed9a8bd757115588112d8fadc84f42e0d
This commit is contained in:
刘智杰 2024-06-13 15:53:16 +08:00
parent 42a04ff902
commit 1afaa81bc7
3 changed files with 23 additions and 0 deletions

View File

@ -722,6 +722,7 @@ public:
inline GateRef TaggedObjectIsJSDate(GateRef obj);
inline GateRef TaggedObjectIsTypedArray(GateRef obj);
inline GateRef TaggedObjectIsJSArray(GateRef obj);
inline GateRef TaggedIsBoundFunction(GateRef obj);
inline GateRef TaggedGetInt(GateRef x);
inline GateRef TaggedObjectIsString(GateRef obj);
inline GateRef TaggedObjectIsShared(GateRef obj);

View File

@ -304,6 +304,12 @@ GateRef CircuitBuilder::TaggedObjectIsJSArray(GateRef obj)
return Equal(objType, Int32(static_cast<int32_t>(JSType::JS_ARRAY)));
}
GateRef CircuitBuilder::TaggedIsBoundFunction(GateRef obj)
{
GateRef objType = GetObjectType(LoadHClass(obj));
return Equal(objType, Int32(static_cast<int32_t>(JSType::JS_BOUND_FUNCTION)));
}
inline GateRef CircuitBuilder::JudgeAotAndFastCall(GateRef jsFunc, JudgeMethodType type)
{
GateRef method = GetMethodFromFunction(jsFunc);

View File

@ -2666,6 +2666,22 @@ void TypedHCRLowering::LowerOrdinaryHasInstance(GateRef gate, GateRef glue)
DEFVALUE(object, (&builder_), VariableType::JS_ANY(), obj);
Label exit(&builder_);
Label targetIsBoundFunction(&builder_);
Label targetNotBoundFunction(&builder_);
// 2. If C has a [[BoundTargetFunction]] internal slot, then
// a. Let BC be the value of C's [[BoundTargetFunction]] internal slot.
// b. Return InstanceofOperator(O,BC) (see 12.9.4).
BRANCH_CIR(builder_.TaggedIsBoundFunction(target), &targetIsBoundFunction, &targetNotBoundFunction);
builder_.Bind(&targetIsBoundFunction);
{
GateRef boundTarget = builder_.LoadConstOffset(VariableType::JS_ANY(), target,
JSBoundFunction::BOUND_TARGET_OFFSET);
result = builder_.CallRuntime(glue, RTSTUB_ID(InstanceOf), Gate::InvalidGateRef,
{ obj, boundTarget }, gate);
builder_.Jump(&exit);
}
builder_.Bind(&targetNotBoundFunction);
// 3. If Type(O) is not Object, return false
Label objIsHeapObject(&builder_);
Label objIsEcmaObject(&builder_);