Skip to content

Commit

Permalink
Remove unnecessary CAPTURE_IP for property accesses
Browse files Browse the repository at this point in the history
Summary:
These operations do not throw or allocate, so they do not need a
`CAPTURE_IP`.

Reviewed By: tmikov

Differential Revision: D66923469

fbshipit-source-id: afe86c44235a941240b5db9658b7616834d8c2c9
  • Loading branch information
neildhar authored and facebook-github-bot committed Dec 9, 2024
1 parent 1c78336 commit 40c2e97
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions lib/VM/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2229,18 +2229,16 @@ CallResult<HermesValue> Interpreter::interpretFunction(
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
++NumGetByIdCacheHits;
CAPTURE_IP(
O1REG(GetById) = JSObject::getNamedSlotValueUnsafe(
obj, runtime, cacheEntry->slot)
.unboxToHV(runtime));
O1REG(GetById) =
JSObject::getNamedSlotValueUnsafe(obj, runtime, cacheEntry->slot)
.unboxToHV(runtime);
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> fastPathResult,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
OptValue<bool> fastPathResult =
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc);
if (LLVM_LIKELY(
fastPathResult.hasValue() && fastPathResult.getValue()) &&
!desc.flags.accessor) {
Expand All @@ -2266,10 +2264,8 @@ CallResult<HermesValue> Interpreter::interpretFunction(
assert(
!obj->isProxyObject() &&
"tryGetOwnNamedDescriptorFast returned true on Proxy");
CAPTURE_IP(
O1REG(GetById) =
JSObject::getNamedSlotValueUnsafe(obj, runtime, desc)
.unboxToHV(runtime));
O1REG(GetById) = JSObject::getNamedSlotValueUnsafe(obj, runtime, desc)
.unboxToHV(runtime);
ip = nextIP;
DISPATCH;
}
Expand All @@ -2279,7 +2275,7 @@ CallResult<HermesValue> Interpreter::interpretFunction(
// not-found.
if (fastPathResult.hasValue() && !fastPathResult.getValue() &&
LLVM_LIKELY(!obj->isProxyObject())) {
CAPTURE_IP_ASSIGN(JSObject * parent, obj->getParent(runtime));
JSObject *parent = obj->getParent(runtime);
// TODO: This isLazy check is because a lazy object is reported as
// having no properties and therefore cannot contain the property.
// This check does not belong here, it should be merged into
Expand All @@ -2288,10 +2284,9 @@ CallResult<HermesValue> Interpreter::interpretFunction(
LLVM_LIKELY(!obj->isLazy())) {
++NumGetByIdProtoHits;
// We've already checked that this isn't a Proxy.
CAPTURE_IP(
O1REG(GetById) = JSObject::getNamedSlotValueUnsafe(
parent, runtime, cacheEntry->slot)
.unboxToHV(runtime));
O1REG(GetById) = JSObject::getNamedSlotValueUnsafe(
parent, runtime, cacheEntry->slot)
.unboxToHV(runtime);
ip = nextIP;
DISPATCH;
}
Expand Down Expand Up @@ -2430,16 +2425,15 @@ CallResult<HermesValue> Interpreter::interpretFunction(
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
++NumPutByIdCacheHits;
CAPTURE_IP(JSObject::setNamedSlotValueUnsafe(
obj, runtime, cacheEntry->slot, shv));
JSObject::setNamedSlotValueUnsafe(
obj, runtime, cacheEntry->slot, shv);
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> hasOwnProp,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
OptValue<bool> hasOwnProp =
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc);
if (LLVM_LIKELY(hasOwnProp.hasValue() && hasOwnProp.getValue()) &&
!desc.flags.accessor && desc.flags.writable &&
!desc.flags.internalSetter) {
Expand All @@ -2463,8 +2457,7 @@ CallResult<HermesValue> Interpreter::interpretFunction(
}

// This must be valid because an own property was already found.
CAPTURE_IP(
JSObject::setNamedSlotValueUnsafe(obj, runtime, desc.slot, shv));
JSObject::setNamedSlotValueUnsafe(obj, runtime, desc.slot, shv);
ip = nextIP;
DISPATCH;
}
Expand Down Expand Up @@ -3380,8 +3373,8 @@ CallResult<HermesValue> Interpreter::interpretFunction(
CAPTURE_IP_ASSIGN(
SmallHermesValue shv,
SmallHermesValue::encodeHermesValue(O2REG(PutOwnBySlotIdx), runtime));
CAPTURE_IP(JSObject::setNamedSlotValueUnsafe(
vmcast<JSObject>(O1REG(PutOwnBySlotIdx)), runtime, idVal, shv));
JSObject::setNamedSlotValueUnsafe(
vmcast<JSObject>(O1REG(PutOwnBySlotIdx)), runtime, idVal, shv);
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
Expand Down

0 comments on commit 40c2e97

Please sign in to comment.