Skip to content

Commit

Permalink
Remove common handler for access by slot index
Browse files Browse the repository at this point in the history
Summary:
Simplify the interpreter control flow since these are relatively simple
operations.

Reviewed By: dannysu

Differential Revision: D68188202

fbshipit-source-id: 3a49b8d2572c2189b430b18dfba7eb0b67be6155
  • Loading branch information
neildhar authored and facebook-github-bot committed Jan 31, 2025
1 parent b211d9a commit 6bf2a6a
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions lib/VM/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3563,43 +3563,51 @@ CallResult<HermesValue> Interpreter::interpretFunction(
DISPATCH;
}
CASE(PutOwnBySlotIdxLong) {
nextIP = NEXTINST(PutOwnBySlotIdxLong);
idVal = ip->iPutOwnBySlotIdxLong.op3;
goto putOwnBySlotIdx;
assert(
O1REG(PutOwnBySlotIdxLong).isObject() &&
"Object argument of PutOwnBySlotIdx must be an object");
ENCODE_HV_AS_SHV(shv, O2REG(PutOwnBySlotIdxLong));
JSObject::setNamedSlotValueUnsafe(
vmcast<JSObject>(O1REG(PutOwnBySlotIdxLong)),
runtime,
ip->iPutOwnBySlotIdxLong.op3,
shv);
ip = NEXTINST(PutOwnBySlotIdxLong);
DISPATCH;
}
CASE(PutOwnBySlotIdx) {
nextIP = NEXTINST(PutOwnBySlotIdx);
idVal = ip->iPutOwnBySlotIdx.op3;
assert(
O1REG(PutOwnBySlotIdx).isObject() &&
"Object argument of PutOwnBySlotIdx must be an object");
ENCODE_HV_AS_SHV(shv, O2REG(PutOwnBySlotIdx));
JSObject::setNamedSlotValueUnsafe(
vmcast<JSObject>(O1REG(PutOwnBySlotIdx)),
runtime,
ip->iPutOwnBySlotIdx.op3,
shv);
ip = NEXTINST(PutOwnBySlotIdx);
DISPATCH;
}
putOwnBySlotIdx: {
assert(
O1REG(PutOwnBySlotIdx).isObject() &&
"Object argument of PutOwnBySlotIdx must be an object");
ENCODE_HV_AS_SHV(shv, O2REG(PutOwnBySlotIdx));
JSObject::setNamedSlotValueUnsafe(
vmcast<JSObject>(O1REG(PutOwnBySlotIdx)), runtime, idVal, shv);
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}

CASE(GetOwnBySlotIdxLong) {
nextIP = NEXTINST(GetOwnBySlotIdxLong);
idVal = ip->iGetOwnBySlotIdxLong.op3;
goto getOwnBySlotIdx;
O1REG(GetOwnBySlotIdxLong) =
JSObject::getNamedSlotValueUnsafe(
vmcast<JSObject>(O2REG(GetOwnBySlotIdxLong)),
runtime,
ip->iGetOwnBySlotIdxLong.op3)
.unboxToHV(runtime);
ip = NEXTINST(GetOwnBySlotIdxLong);
DISPATCH;
}
CASE(GetOwnBySlotIdx) {
nextIP = NEXTINST(GetOwnBySlotIdx);
idVal = ip->iGetOwnBySlotIdx.op3;
}
getOwnBySlotIdx: {
O1REG(GetOwnBySlotIdx) =
JSObject::getNamedSlotValueUnsafe(
vmcast<JSObject>(O2REG(GetOwnBySlotIdx)), runtime, idVal)
.unboxToHV(runtime);
ip = nextIP;
DISPATCH;
}
O1REG(GetOwnBySlotIdx) = JSObject::getNamedSlotValueUnsafe(
vmcast<JSObject>(O2REG(GetOwnBySlotIdx)),
runtime,
ip->iGetOwnBySlotIdx.op3)
.unboxToHV(runtime);
ip = NEXTINST(GetOwnBySlotIdx);
DISPATCH;
}

CASE_OUTOFLINE(DelByVal);

Expand Down

0 comments on commit 6bf2a6a

Please sign in to comment.