Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-place interpreter: fix clobbered register in call and reduce memory usage for if and br #16890

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Source/JavaScriptCore/llint/InPlaceInterpreter.asm
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,9 @@ instructionLabel(_if)
nextIPIntInstruction()
.ipint_if_taken:
# Skip LEB128
loadq 8[PM, MC], PC
advanceMC(16)
loadb 8[PM, MC], t0
advanceMC(9)
advancePCByReg(t0)
nextIPIntInstruction()

instructionLabel(_else)
Expand Down Expand Up @@ -742,8 +743,9 @@ instructionLabel(_br_if)
# pop i32
popInt32(t0, t2)
bineq t0, 0, _ipint_br
loadi 12[PM, MC], PC
advanceMC(16)
loadb 12[PM, MC], t0
advanceMC(13)
advancePCByReg(t0)
nextIPIntInstruction()

instructionLabel(_br_table)
Expand Down Expand Up @@ -3490,7 +3492,7 @@ _ipint_call_impl:
# Get function data
move t0, a1
move wasmInstance, a0
cCall2(_ipint_extern_call)
operationCall(macro() cCall2(_ipint_extern_call) end)

# FIXME: switch offlineasm unalignedglobal to take alignment and optionally pad with breakpoint instructions (rdar://113594783)
macro mintAlign()
Expand Down
13 changes: 7 additions & 6 deletions Source/JavaScriptCore/wasm/WasmIPIntGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,10 @@ PartialResult WARN_UNUSED_RETURN IPIntGenerator::addIf(ExpressionType, BlockSign
block.m_pendingOffset = m_metadata->m_metadata.size();
// 4B PC of else
// 4B MC of else
m_metadata->addBlankSpace(8);
// 8B PC of if (skip type signature)
m_metadata->addRawValue(m_parser->offset() - m_metadata->m_bytecodeOffset);
auto length = m_metadata->m_metadata.size();
m_metadata->addBlankSpace(9);
// 1B instruction length
WRITE_TO_METADATA(m_metadata->m_metadata.data() + length + 8, getCurrentInstructionLength(), uint8_t);
return { };
}

Expand Down Expand Up @@ -1112,10 +1113,10 @@ PartialResult WARN_UNUSED_RETURN IPIntGenerator::addBranch(ControlType& block, E
{
auto size = m_metadata->m_metadata.size();
block.m_awaitingUpdate.append(size);
m_metadata->addBlankSpace(16);
m_metadata->addBlankSpace(13);
WRITE_TO_METADATA(m_metadata->m_metadata.data() + size + 8, stack.size() - block.branchTargetArity(), uint16_t);
WRITE_TO_METADATA(m_metadata->m_metadata.data() + size + 10, block.branchTargetArity(), uint16_t);
WRITE_TO_METADATA(m_metadata->m_metadata.data() + size + 12, m_parser->offset() - m_metadata->m_bytecodeOffset, uint32_t);
WRITE_TO_METADATA(m_metadata->m_metadata.data() + size + 12, getCurrentInstructionLength(), uint8_t);
return { };
}
PartialResult WARN_UNUSED_RETURN IPIntGenerator::addSwitch(ExpressionType, const Vector<ControlType*>& jumps, ControlType& defaultJump, const Stack& stack)
Expand All @@ -1124,7 +1125,7 @@ PartialResult WARN_UNUSED_RETURN IPIntGenerator::addSwitch(ExpressionType, const
// Metadata layout
// 0 - 3 number of jump targets (including end)
// 8 - 15 4B PC for t0, 4B MC for t0
// 16 - 19 2B pop, 2B keep, 4B empty
// 16 - 19 2B pop, 2B keep
// 20 and on repeat for each branch target
m_metadata->addBlankSpace(4);
WRITE_TO_METADATA(m_metadata->m_metadata.data() + size, jumps.size() + 1, uint32_t);
Expand Down