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

Side by Side Diff: test/cctest/test-wasm-relocation-disasm-ia32.cc

Issue 1759873002: Assembler changes for enabling GrowHeap in Wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix update method for ia32/x64 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 2016 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include <stdlib.h>
29
30 #include "src/v8.h"
31
32 #include "src/debug/debug.h"
33 #include "src/disasm.h"
34 #include "src/disassembler.h"
35 #include "src/ia32/frames-ia32.h"
36 #include "src/ic/ic.h"
37 #include "src/macro-assembler.h"
38 #include "test/cctest/cctest.h"
39 #include "test/cctest/compiler/c-signature.h"
40 #include "test/cctest/compiler/call-tester.h"
41
42 using namespace v8::internal;
43 using namespace v8::internal::compiler;
44
45 #define __ assm.
46
47 static int32_t DummyStaticFunction(Object* result) { return 1; }
48
49 TEST(WasmRelocationIa32) {
50 CcTest::InitializeVM();
51 Zone zone;
52 Isolate* isolate = CcTest::i_isolate();
53 HandleScope scope(isolate);
54 v8::internal::byte buffer[4096];
55 Assembler assm(isolate, buffer, sizeof buffer);
56 DummyStaticFunction(NULL);
57 int32_t imm = 1234567;
58
59 __ mov(eax, Immediate(reinterpret_cast<Address>(imm),
60 RelocInfo::WASM_MEMORY_REFERENCE));
61 __ nop();
62 __ ret(0);
63
64 CSignature0<int32_t> csig;
65 CodeDesc desc;
66 assm.GetCode(&desc);
67 Handle<Code> code = isolate->factory()->NewCode(
68 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
69 USE(code);
70
71 CodeRunner<int32_t> runnable(isolate, code, &csig);
72 int32_t ret_value = runnable.Call();
73 CHECK_EQ(ret_value, imm);
74
75 #ifdef OBJECT_PRINT
76 OFStream os(stdout);
77 code->Print(os);
78 byte* begin = code->instruction_start();
79 byte* end = begin + code->instruction_size();
80 disasm::Disassembler::Disassemble(stdout, begin, end);
81 #endif
82
83 size_t offset = 1234;
84
85 // Relocating references by offset
86 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
87 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
88 RelocInfo::Mode mode = it.rinfo()->rmode();
89 if (RelocInfo::IsWasmMemoryReference(mode)) {
90 // Dummy values of size used here as the objective of the test is to
91 // verify that the immediate is patched correctly
92 it.rinfo()->update_wasm_memory_reference(
93 it.rinfo()->wasm_memory_reference(),
94 it.rinfo()->wasm_memory_reference() + offset, 1, 2,
95 SKIP_ICACHE_FLUSH);
96 }
97 }
98
99 // Check if immediate is updated correctly
100 ret_value = runnable.Call();
101 CHECK_EQ(ret_value, imm + offset);
102
103 #ifdef OBJECT_PRINT
104 // OFStream os(stdout);
105 code->Print(os);
106 begin = code->instruction_start();
107 end = begin + code->instruction_size();
108 disasm::Disassembler::Disassemble(stdout, begin, end);
109 #endif
110 }
111
112 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698