Skip to content

Commit

Permalink
Implement some CacheIR guards
Browse files Browse the repository at this point in the history
There is one jit-test which fails if the `GuardIsNumber` test is
implemented backward, and there are 22 jit-tests which fail if
`GuardBooleanToInt32` swaps "true" and "false" results, so I'm
reasonably confident this implementation of these CacheIR ops is correct
and adequately tested.
  • Loading branch information
jameysharp committed Sep 18, 2023
1 parent 44df56b commit c46c3be
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions js/src/vm/PortableBaselineInterpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,26 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
DISPATCH_CACHEOP();
}

CACHEOP_CASE(GuardIsNumber) {
ValOperandId inputId = icregs.cacheIRReader.valOperandId();
Value v = Value::fromRawBits(icregs.icVals[inputId.id()]);
if (!v.isNumber()) {
return ICInterpretOpResult::NextIC;
}
DISPATCH_CACHEOP();
}

CACHEOP_CASE(GuardBooleanToInt32) {
ValOperandId inputId = icregs.cacheIRReader.valOperandId();
Int32OperandId resultId = icregs.cacheIRReader.int32OperandId();
Value v = Value::fromRawBits(icregs.icVals[inputId.id()]);
if (!v.isBoolean()) {
return ICInterpretOpResult::NextIC;
}
icregs.icVals[resultId.id()] = v.toBoolean() ? 1 : 0;
DISPATCH_CACHEOP();
}

CACHEOP_CASE(GuardToBoolean) {
ValOperandId inputId = icregs.cacheIRReader.valOperandId();
Value v = Value::fromRawBits(icregs.icVals[inputId.id()]);
Expand Down Expand Up @@ -1614,7 +1634,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
DISPATCH_CACHEOP();
}

CACHEOP_CASE_UNIMPL(GuardNoAllocationMetadataBuilder) {
CACHEOP_CASE(GuardNoAllocationMetadataBuilder) {
uint32_t builderAddrOffset = icregs.cacheIRReader.stubOffset();
uintptr_t builderAddr =
cstub->stubInfo()->getStubRawWord(cstub, builderAddrOffset);
Expand All @@ -1624,9 +1644,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
DISPATCH_CACHEOP();
}

CACHEOP_CASE_UNIMPL(GuardIsNumber)
CACHEOP_CASE_UNIMPL(GuardToNonGCThing)
CACHEOP_CASE_UNIMPL(GuardBooleanToInt32)
CACHEOP_CASE_UNIMPL(Int32ToIntPtr)
CACHEOP_CASE_UNIMPL(GuardNumberToIntPtrIndex)
CACHEOP_CASE_UNIMPL(GuardToInt32ModUint32)
Expand Down

0 comments on commit c46c3be

Please sign in to comment.