If prototype is at end need to return false

Signed-off-by: liujia178 <liujia178@huawei.com>
This commit is contained in:
liujia178 2024-05-16 13:55:17 +10:30
parent b08fb1f83d
commit 79d37cf96f
5 changed files with 25 additions and 18 deletions

View File

@ -4662,27 +4662,25 @@ GateRef StubBuilder::OrdinaryHasInstance(GateRef glue, GateRef target, GateRef o
BRANCH(TaggedIsNull(*object), &afterLoop, &loopHead);
LoopBegin(&loopHead);
{
GateRef isEqual = SameValue(glue, *object, *constructorPrototype);
BRANCH(isEqual, &strictEqual1, &notStrictEqual1);
Bind(&strictEqual1);
object = GetPrototype(glue, *object);
Branch(HasPendingException(glue), &shouldReturn, &shouldContinue);
Bind(&shouldReturn);
{
result = TaggedTrue();
result = Exception();
Jump(&exit);
}
Bind(&notStrictEqual1);
Bind(&shouldContinue);
{
object = GetPrototype(glue, *object);
BRANCH(HasPendingException(glue), &shouldReturn, &shouldContinue);
Bind(&shouldReturn);
GateRef isEqual = SameValue(glue, *object, *constructorPrototype);
Branch(isEqual, &strictEqual1, &notStrictEqual1);
Bind(&strictEqual1);
{
result = Exception();
result = TaggedTrue();
Jump(&exit);
}
Bind(&notStrictEqual1);
Branch(TaggedIsNull(*object), &afterLoop, &loopEnd);
}
Bind(&shouldContinue);
BRANCH(TaggedIsNull(*object), &afterLoop, &loopEnd);
}
Bind(&loopEnd);
LoopEnd(&loopHead, env, glue);

View File

@ -346,11 +346,11 @@ bool JSFunction::OrdinaryHasInstance(JSThread *thread, const JSHandle<JSTaggedVa
// d.If SameValue(P, O) is true, return true.
JSMutableHandle<JSTaggedValue> object(thread, obj.GetTaggedValue());
while (!object->IsNull()) {
object.Update(JSTaggedValue::GetPrototype(thread, object));
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
if (JSTaggedValue::SameValue(object, constructorPrototype)) {
return true;
}
object.Update(JSTaggedValue::GetPrototype(thread, object));
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
}
return false;
}

View File

@ -17,3 +17,5 @@ test success
test success
CallbackFn is not callable
TypeError
false
false

View File

@ -87,4 +87,13 @@ try {
Array instanceof function_prototype_changed;
} catch (e) {
print(e.name)
}
}
var A = {};
function Func() { }
Func.prototype = A;
print(A instanceof Func);
var proto_desc = Object.getOwnPropertyDescriptor(RegExp, "prototype");
var proto = proto_desc.value;
print(proto instanceof RegExp);

View File

@ -1992,7 +1992,6 @@
"mjsunit/math-floor-part2.js",
"mjsunit/typedarray-resizablearraybuffer-detach.js",
"mjsunit/copy-on-write-assert.js",
"mjsunit/instanceof.js",
"mjsunit/whitespaces3.js",
"mjsunit/string-case.js",
"mjsunit/getter-in-value-prototype.js",
@ -3073,7 +3072,6 @@
"mjsunit/es6/string-iterator5.js",
"mjsunit/es6/block-const-assign.js",
"mjsunit/es6/throw-type-error-function-restrictions.js",
"mjsunit/es6/regexp-prototype.js",
"mjsunit/es6/set-iterator-5.js",
"mjsunit/es6/classes-lazy-parsing.js",
"mjsunit/es6/regexp-tostring.js",