Commit ff0473d6 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm][arm] Support concurrent patching of jump table.

This is the port of concurrent jump table patching support to ARM. It
extends the corresponding stress test and changes the encoding of code
targets in jump table slots to use constant pool entries.

R=clemensh@chromium.org
TEST=cctest/test-jump-table-assembler
BUG=v8:8018

Change-Id: I4b709a7f14dace0f4eb9219f995d42ca607bb25f
Reviewed-on: https://chromium-review.googlesource.com/1164952
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54971}
parent 286602a5
......@@ -173,7 +173,6 @@ void TurboAssembler::Jump(Register target, Condition cond) { bx(target, cond); }
void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode,
Condition cond) {
DCHECK(RelocInfo::IsCodeTarget(rmode));
mov(pc, Operand(target, rmode), LeaveCC, cond);
}
......
......@@ -82,18 +82,9 @@ void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index,
}
void JumpTableAssembler::EmitJumpSlot(Address target) {
int offset =
target - reinterpret_cast<Address>(pc_) - Instruction::kPcLoadDelta;
DCHECK_EQ(0, offset % kInstrSize);
// If the offset is within 64 MB, emit a direct jump. Otherwise jump
// indirectly.
if (is_int26(offset)) {
b(offset); // 1 instr
} else {
// {Move32BitImmediate} emits either [movw, movt, mov] or [ldr, constant].
Move32BitImmediate(pc, Operand(target));
}
// Note that {Move32BitImmediate} emits [ldr, constant] for the relocation
// mode used below, we need this to allow concurrent patching of this slot.
Move32BitImmediate(pc, Operand(target, RelocInfo::WASM_CALL));
CheckConstPool(true, false); // force emit of const pool
}
......
......@@ -21,7 +21,7 @@ namespace wasm {
#define __ masm.
// TODO(v8:7424,v8:8018): Extend this test to all architectures.
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM
namespace {
......@@ -47,6 +47,12 @@ Address GenerateJumpTableThunk(Address jump_target) {
__ test(MemOperand(scratch, 0), Immediate(1));
__ j(not_zero, &exit);
__ jmp(jump_target, RelocInfo::NONE);
#elif V8_TARGET_ARCH_ARM
__ mov(scratch, Operand(stop_bit_address, RelocInfo::NONE));
__ ldr(scratch, MemOperand(scratch, 0));
__ tst(scratch, Operand(1));
__ b(ne, &exit);
__ Jump(jump_target, RelocInfo::NONE);
#else
#error Unsupported architecture
#endif
......@@ -68,7 +74,7 @@ class JumpTableRunner : public v8::base::Thread {
void Run() override {
TRACE("Runner #%d is starting ...\n", runner_id_);
GeneratedCode<void>::FromAddress(nullptr, slot_address_).Call();
GeneratedCode<void>::FromAddress(CcTest::i_isolate(), slot_address_).Call();
TRACE("Runner #%d is stopping ...\n", runner_id_);
USE(runner_id_);
}
......@@ -156,7 +162,7 @@ TEST(JumpTablePatchingStress) {
}
}
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM
#undef __
#undef TRACE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment