Index: test/cctest/test-run-wasm-relocation-arm64.cc |
diff --git a/test/cctest/test-run-wasm-relocation-arm64.cc b/test/cctest/test-run-wasm-relocation-arm64.cc |
index 48f9e85ba1769db731524897c16347c4f99be140..81530046274c6f954072db8f69277cc9b9ec853c 100644 |
--- a/test/cctest/test-run-wasm-relocation-arm64.cc |
+++ b/test/cctest/test-run-wasm-relocation-arm64.cc |
@@ -24,8 +24,7 @@ using namespace v8::internal::compiler; |
static int64_t DummyStaticFunction(Object* result) { return 1; } |
-TEST(WasmRelocationArm64) { |
- CcTest::InitializeVM(); |
+TEST(WasmRelocationArm64MemoryReference) { |
Isolate* isolate = CcTest::i_isolate(); |
HandleScope scope(isolate); |
v8::internal::byte buffer[4096]; |
@@ -79,4 +78,61 @@ TEST(WasmRelocationArm64) { |
#endif |
} |
+TEST(WasmRelocationArm64MemorySizeReference) { |
+ CcTest::InitializeVM(); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope scope(isolate); |
+ v8::internal::byte buffer[4096]; |
+ DummyStaticFunction(NULL); |
+ Immediate size = Immediate(512, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
+ Label fail; |
+ |
+ MacroAssembler masm(isolate, buffer, sizeof buffer, |
+ v8::internal::CodeObjectRequired::kYes); |
+ |
+ __ Mov(x0, size); |
+ __ Cmp(x0, size); |
+ __ B(ne, &fail); |
+ __ Ret(); |
+ __ Bind(&fail); |
+ __ Mov(x0, Immediate(0xdeadbeef)); |
+ __ Ret(); |
+ |
+ CodeDesc desc; |
+ masm.GetCode(&desc); |
+ Handle<Code> code = isolate->factory()->NewCode( |
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
+ |
+ CSignature0<int64_t> csig; |
+ CodeRunner<int64_t> runnable(isolate, code, &csig); |
+ int64_t ret_value = runnable.Call(); |
+ CHECK_NE(ret_value, 0xdeadbeef); |
+ |
+#ifdef DEBUG |
+ OFStream os(stdout); |
+ code->Print(os); |
+ ::printf("f() = %ld\n\n", ret_value); |
+#endif |
+ int32_t diff = 512; |
+ |
+ int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
+ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
+ RelocInfo::Mode mode = it.rinfo()->rmode(); |
+ if (RelocInfo::IsWasmMemorySizeReference(mode)) { |
+ it.rinfo()->update_wasm_memory_reference( |
+ reinterpret_cast<Address>(0x1234), reinterpret_cast<Address>(0x1234), |
+ it.rinfo()->wasm_memory_size_reference(), |
+ it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); |
+ } |
+ } |
+ |
+ ret_value = runnable.Call(); |
+ CHECK_NE(ret_value, 0xdeadbeef); |
+ |
+#ifdef DEBUG |
+ code->Print(os); |
+ ::printf("f() = %ld\n\n", ret_value); |
+#endif |
+} |
+ |
#undef __ |