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

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

Issue 1775443002: MIPS: Assembler changes for enabling GrowHeap in Wasm. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comments 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-wasm-relocation-disasm-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <iostream> // NOLINT(readability/streams)
29
30 #include "src/v8.h"
31 #include "test/cctest/cctest.h"
32
33 #include "src/disassembler.h"
34 #include "src/factory.h"
35 #include "src/macro-assembler.h"
36 #include "src/mips/assembler-mips-inl.h"
37 #include "src/mips/macro-assembler-mips.h"
38 #include "src/mips/simulator-mips.h"
39 #include "src/ostreams.h"
40 #include "test/cctest/compiler/c-signature.h"
41 #include "test/cctest/compiler/call-tester.h"
42
43 using namespace v8::base;
44 using namespace v8::internal;
45 using namespace v8::internal::compiler;
46
47 #define __ assm.
48
49 static int32_t DummyStaticFunction(Object* result) { return 1; }
50
51 TEST(WasmRelocationMips) {
52 CcTest::InitializeVM();
53 Isolate* isolate = CcTest::i_isolate();
54 HandleScope scope(isolate);
55 v8::internal::byte buffer[4096];
56 DummyStaticFunction(NULL);
57 int32_t imm = 1234567;
58
59 MacroAssembler assm(isolate, buffer, sizeof buffer,
60 v8::internal::CodeObjectRequired::kYes);
61
62 __ li(v0, Operand(imm, RelocInfo::WASM_MEMORY_REFERENCE));
63 __ Jump(ra);
64
65 CodeDesc desc;
66 assm.GetCode(&desc);
67 Handle<Code> code = isolate->factory()->NewCode(
68 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
69
70 USE(code);
71 CSignature0<int32_t> csig;
72 CodeRunner<int32_t> runnable(isolate, code, &csig);
73
74 int32_t ret_value = runnable.Call();
75 CHECK_EQ(ret_value, imm);
76
77 #ifdef DEBUG
78 OFStream os(stdout);
79 code->Print(os);
80 ::printf("f() = %d\n\n", ret_value);
81 #endif
82 size_t offset = 1234;
83
84 // Relocating references by offset
85 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
86 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
87 RelocInfo::Mode mode = it.rinfo()->rmode();
88 if (RelocInfo::IsWasmMemoryReference(mode)) {
89 // Dummy values of size used here as the objective of the test is to
90 // verify that the immediate is patched correctly
91 it.rinfo()->update_wasm_memory_reference(
92 it.rinfo()->wasm_memory_reference(),
93 it.rinfo()->wasm_memory_reference() + offset, 1, 2,
94 SKIP_ICACHE_FLUSH);
95 }
96 }
97
98 // Call into relocated code object
99 ret_value = runnable.Call();
100 CHECK_EQ((imm + offset), ret_value);
101
102 #ifdef DEBUG
103 code->Print(os);
104 ::printf("f() = %d\n\n", ret_value);
105 #endif
106 }
107
108 #undef __
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-wasm-relocation-disasm-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698