Skip to content

Commit 9f08d6e

Browse files
committedJul 27, 2018
[MERGE #5527 @kfarnung] Update JsInstanceOf to use OP_IsInst
Merge pull request #5527 from kfarnung:jsinstanceof `OP_IsInst` correctly handles the ES6 `Symbol.hasInstance` property when determining whether an object is an instance of a constructor.
2 parents a2aa450 + 8661d43 commit 9f08d6e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎lib/Jsrt/Jsrt.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,8 @@ CHAKRA_API JsInstanceOf(_In_ JsValueRef object, _In_ JsValueRef constructor, _Ou
14151415
VALIDATE_INCOMING_REFERENCE(constructor, scriptContext);
14161416
PARAM_NOT_NULL(result);
14171417

1418-
*result = Js::RecyclableObject::FromVar(constructor)->HasInstance(object, scriptContext) ? true : false;
1418+
Js::Var value = Js::JavascriptOperators::OP_IsInst(object, constructor, scriptContext, nullptr);
1419+
*result = !!Js::JavascriptBoolean::FromVar(value)->GetValue();
14191420

14201421
return JsNoError;
14211422
});

‎lib/Runtime/Debug/TTActionEvents.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ namespace TTD
506506
Js::Var constructor = InflateVarInReplay(executeContext, GetVarItem_1(action));
507507
TTD_REPLAY_VALIDATE_INCOMING_REFERENCE(constructor, ctx);
508508

509-
//Result is not needed but trigger computation for any effects
510-
Js::RecyclableObject::FromVar(constructor)->HasInstance(object, ctx);
509+
// Result is not needed but trigger computation for any effects
510+
Js::JavascriptOperators::OP_IsInst(object, constructor, ctx, nullptr);
511511
}
512512

513513
void EqualsAction_Execute(const EventLogEntry* evt, ThreadContextTTD* executeContext)

0 commit comments

Comments
 (0)
Please sign in to comment.