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

Side by Side Diff: test/cctest/compiler/test-run-wasm-machops.cc

Issue 1921203002: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable pointers to update wasm memory … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ben's review Created 4 years, 7 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 | « src/x64/assembler-x64-inl.h ('k') | test/cctest/test-run-wasm-relocation-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. Use of this 1 // Copyright 2016 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
13 #include "test/cctest/compiler/codegen-tester.h" 13 #include "test/cctest/compiler/codegen-tester.h"
14 #include "test/cctest/compiler/graph-builder-tester.h" 14 #include "test/cctest/compiler/graph-builder-tester.h"
15 #include "test/cctest/compiler/value-helper.h" 15 #include "test/cctest/compiler/value-helper.h"
16 16
17 using namespace v8::internal; 17 using namespace v8::internal;
18 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
19 19
20 static void UpdateMemoryReferences(Handle<Code> code, Address old_base, 20 static void UpdateMemoryReferences(Handle<Code> code, Address old_base,
21 Address new_base, size_t old_size, 21 Address new_base, uint32_t old_size,
22 size_t new_size) { 22 uint32_t new_size) {
23 Isolate* isolate = CcTest::i_isolate(); 23 Isolate* isolate = CcTest::i_isolate();
24 bool modified = false; 24 bool modified = false;
25 int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); 25 int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) |
26 RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
26 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { 27 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
27 RelocInfo::Mode mode = it.rinfo()->rmode(); 28 RelocInfo::Mode mode = it.rinfo()->rmode();
28 if (RelocInfo::IsWasmMemoryReference(mode)) { 29 if (RelocInfo::IsWasmMemoryReference(mode) ||
30 RelocInfo::IsWasmMemorySizeReference(mode)) {
29 // Patch addresses with change in memory start address 31 // Patch addresses with change in memory start address
30 it.rinfo()->update_wasm_memory_reference(old_base, new_base, old_size, 32 it.rinfo()->update_wasm_memory_reference(old_base, new_base, old_size,
31 new_size); 33 new_size);
32 modified = true; 34 modified = true;
33 } 35 }
34 } 36 }
35 if (modified) { 37 if (modified) {
36 Assembler::FlushICache(isolate, code->instruction_start(), 38 Assembler::FlushICache(isolate, code->instruction_start(),
37 code->instruction_size()); 39 code->instruction_size());
38 } 40 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 RunLoadStoreRelocationOffset<int8_t>(MachineType::Int8()); 138 RunLoadStoreRelocationOffset<int8_t>(MachineType::Int8());
137 RunLoadStoreRelocationOffset<uint8_t>(MachineType::Uint8()); 139 RunLoadStoreRelocationOffset<uint8_t>(MachineType::Uint8());
138 RunLoadStoreRelocationOffset<int16_t>(MachineType::Int16()); 140 RunLoadStoreRelocationOffset<int16_t>(MachineType::Int16());
139 RunLoadStoreRelocationOffset<uint16_t>(MachineType::Uint16()); 141 RunLoadStoreRelocationOffset<uint16_t>(MachineType::Uint16());
140 RunLoadStoreRelocationOffset<int32_t>(MachineType::Int32()); 142 RunLoadStoreRelocationOffset<int32_t>(MachineType::Int32());
141 RunLoadStoreRelocationOffset<uint32_t>(MachineType::Uint32()); 143 RunLoadStoreRelocationOffset<uint32_t>(MachineType::Uint32());
142 RunLoadStoreRelocationOffset<void*>(MachineType::AnyTagged()); 144 RunLoadStoreRelocationOffset<void*>(MachineType::AnyTagged());
143 RunLoadStoreRelocationOffset<float>(MachineType::Float32()); 145 RunLoadStoreRelocationOffset<float>(MachineType::Float32());
144 RunLoadStoreRelocationOffset<double>(MachineType::Float64()); 146 RunLoadStoreRelocationOffset<double>(MachineType::Float64());
145 } 147 }
148
149 TEST(Uint32LessThanRelocation) {
150 RawMachineAssemblerTester<uint32_t> m;
151 RawMachineLabel within_bounds, out_of_bounds;
152 Node* index = m.Int32Constant(0x200);
153 Node* limit =
154 m.RelocatableInt32Constant(0x200, RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
155 Node* cond = m.AddNode(m.machine()->Uint32LessThan(), index, limit);
156 m.Branch(cond, &within_bounds, &out_of_bounds);
157 m.Bind(&within_bounds);
158 m.Return(m.Int32Constant(0xaced));
159 m.Bind(&out_of_bounds);
160 m.Return(m.Int32Constant(0xdeadbeef));
161 // Check that index is out of bounds with current size
162 CHECK_EQ(0xdeadbeef, m.Call());
163 m.GenerateCode();
164
165 Handle<Code> code = m.GetCode();
166 UpdateMemoryReferences(code, reinterpret_cast<Address>(1234),
167 reinterpret_cast<Address>(1234), 0x200, 0x400);
168 // Check that after limit is increased, index is within bounds.
169 CHECK_EQ(0xaced, m.Call());
170 }
OLDNEW
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | test/cctest/test-run-wasm-relocation-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698