Skip to content

Commit

Permalink
Merge pull request mozilla#20 from bytecodealliance/pbl-guards
Browse files Browse the repository at this point in the history
Implement some CacheIR guards
  • Loading branch information
cfallin authored Sep 19, 2023
2 parents 44df56b + c46c3be commit 4702293
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 4702293

Please sign in to comment.