Commit 538bd6c7 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm][arm64] Extend jump table stress test to ARM64.

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

Change-Id: I1bb4c52a912a7c7ec7fbaf19c79cb7c7dd00a13e
Reviewed-on: https://chromium-review.googlesource.com/1167283
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55016}
parent 60d1277f
......@@ -106,10 +106,7 @@ void Decoder<V>::DecodePCRelAddressing(Instruction* instr) {
template<typename V>
void Decoder<V>::DecodeBranchSystemException(Instruction* instr) {
DCHECK((instr->Bits(27, 24) == 0x4) ||
(instr->Bits(27, 24) == 0x5) ||
(instr->Bits(27, 24) == 0x6) ||
(instr->Bits(27, 24) == 0x7) );
DCHECK_EQ(0x4, instr->Bits(27, 24) & 0xC); // 0x4, 0x5, 0x6, 0x7
switch (instr->Bits(31, 29)) {
case 0:
......@@ -203,10 +200,7 @@ void Decoder<V>::DecodeBranchSystemException(Instruction* instr) {
template<typename V>
void Decoder<V>::DecodeLoadStore(Instruction* instr) {
DCHECK((instr->Bits(27, 24) == 0x8) ||
(instr->Bits(27, 24) == 0x9) ||
(instr->Bits(27, 24) == 0xC) ||
(instr->Bits(27, 24) == 0xD) );
DCHECK_EQ(0x8, instr->Bits(27, 24) & 0xA); // 0x8, 0x9, 0xC, 0xD
if ((instr->Bit(28) == 0) && (instr->Bit(29) == 0) && (instr->Bit(26) == 1)) {
DecodeNEONLoadStore(instr);
......
......@@ -104,6 +104,9 @@ void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index,
}
void JumpTableAssembler::EmitJumpSlot(Address target) {
// TODO(wasm): Currently this is guaranteed to be a {near_call} and hence is
// patchable concurrently. Once {kMaxWasmCodeMemory} is raised on ARM64, make
// sure concurrent patching is still supported.
Jump(target, RelocInfo::NONE);
}
......
......@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "src/assembler-inl.h"
#include "src/macro-assembler-inl.h"
#include "src/simulator.h"
#include "src/utils.h"
#include "src/wasm/jump-table-assembler.h"
#include "test/cctest/cctest.h"
#include "test/common/assembler-tester.h"
......@@ -21,7 +23,8 @@ namespace wasm {
#define __ masm.
// TODO(v8:7424,v8:8018): Extend this test to all architectures.
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || \
V8_TARGET_ARCH_ARM64
namespace {
......@@ -29,8 +32,18 @@ static volatile int global_stop_bit = 0;
Address GenerateJumpTableThunk(Address jump_target) {
size_t allocated;
#if V8_TARGET_ARCH_ARM64
// TODO(wasm): Currently {kMaxWasmCodeMemory} limits code sufficiently, so
// that the jump table only supports {near_call} distances.
Address random_addr = reinterpret_cast<Address>(GetRandomMmapAddr());
const uintptr_t kThunkAddrMask = (1 << WhichPowerOf2(kMaxWasmCodeMemory)) - 1;
void* address = reinterpret_cast<void*>((jump_target & ~kThunkAddrMask) |
(random_addr & kThunkAddrMask));
#else
void* address = GetRandomMmapAddr();
#endif
byte* buffer = AllocateAssemblerBuffer(
&allocated, AssemblerBase::kMinimalBufferSize, GetRandomMmapAddr());
&allocated, AssemblerBase::kMinimalBufferSize, address);
MacroAssembler masm(nullptr, AssemblerOptions{}, buffer,
static_cast<int>(allocated), CodeObjectRequired::kNo);
......@@ -53,6 +66,12 @@ Address GenerateJumpTableThunk(Address jump_target) {
__ tst(scratch, Operand(1));
__ b(ne, &exit);
__ Jump(jump_target, RelocInfo::NONE);
#elif V8_TARGET_ARCH_ARM64
__ Mov(scratch, Operand(stop_bit_address, RelocInfo::NONE));
__ Ldr(scratch, MemOperand(scratch, 0));
__ Tbnz(scratch, 0, &exit);
__ Mov(scratch, Immediate(jump_target, RelocInfo::NONE));
__ Br(scratch);
#else
#error Unsupported architecture
#endif
......@@ -162,7 +181,8 @@ TEST(JumpTablePatchingStress) {
}
}
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM ||
// V8_TARGET_ARCH_ARM64
#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