Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/cctest/test-run-wasm-relocation-arm64.cc

Issue 1759873002: Assembler changes for enabling GrowHeap in Wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <iostream> // NOLINT(readability/streams)
6
7 #include "src/v8.h"
8 #include "test/cctest/cctest.h"
9
10 #include "src/arm64/simulator-arm64.h"
11 #include "src/arm64/utils-arm64.h"
12 #include "src/disassembler.h"
13 #include "src/factory.h"
14 #include "src/macro-assembler.h"
15 #include "src/ostreams.h"
16 #include "test/cctest/compiler/c-signature.h"
17 #include "test/cctest/compiler/call-tester.h"
18
19 using namespace v8::base;
20 using namespace v8::internal;
21 using namespace v8::internal::compiler;
22
23 #define __ masm.
24
25 static int64_t DummyStaticFunction(Object* result) { return 1; }
26
27 TEST(WasmRelocationArm64) {
28 CcTest::InitializeVM();
29 Isolate* isolate = CcTest::i_isolate();
30 HandleScope scope(isolate);
31 v8::internal::byte buffer[4096];
32 DummyStaticFunction(NULL);
33 int64_t imm = 1234567;
34
35 MacroAssembler masm(isolate, buffer, sizeof buffer,
36 v8::internal::CodeObjectRequired::kYes);
37
38 __ Mov(x0, Immediate(imm, RelocInfo::WASM_MEMORY_REFERENCE));
39 __ Ret();
40
41 CodeDesc desc;
42 masm.GetCode(&desc);
43 Handle<Code> code = isolate->factory()->NewCode(
44 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
45
46 CSignature0<int64_t> csig;
47 CodeRunner<int64_t> runnable(isolate, code, &csig);
48 int64_t ret_value = runnable.Call();
49 CHECK_EQ(ret_value, imm);
50
51 #ifdef DEBUG
52 OFStream os(stdout);
53 code->Print(os);
54 ::printf("f() = %ld\n\n", ret_value);
55 #endif
56 size_t offset = 1234;
57
58 // Relocating reference by offset
59 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
60 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
61 RelocInfo::Mode mode = it.rinfo()->rmode();
62 if (RelocInfo::IsWasmMemoryReference(mode)) {
63 // Dummy values of size used here as the objective of the test is to
64 // verify that the immediate is patched correctly
65 it.rinfo()->update_wasm_memory_reference(
66 it.rinfo()->wasm_memory_reference(),
67 it.rinfo()->wasm_memory_reference() + offset, 1, 2,
68 SKIP_ICACHE_FLUSH);
69 }
70 }
71
72 // Call into relocated code object
73 ret_value = runnable.Call();
74 CHECK_EQ((imm + offset), ret_value);
75
76 #ifdef DEBUG
77 code->Print(os);
78 ::printf("f() = %ld\n\n", ret_value);
79 #endif
80 }
81
82 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-run-wasm-relocation-arm.cc ('k') | test/cctest/test-run-wasm-relocation-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698