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

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

Issue 2416543002: [wasm] Fix bounds check for zero initial memory. (Closed)
Patch Set: Created 4 years, 2 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
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iostream> // NOLINT(readability/streams) 5 #include <iostream> // NOLINT(readability/streams)
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 9
10 #include "src/arm64/simulator-arm64.h" 10 #include "src/arm64/simulator-arm64.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ::printf("f() = %" PRIx64 "\n\n", ret_value); 77 ::printf("f() = %" PRIx64 "\n\n", ret_value);
78 #endif 78 #endif
79 } 79 }
80 80
81 TEST(WasmRelocationArm64MemorySizeReference) { 81 TEST(WasmRelocationArm64MemorySizeReference) {
82 CcTest::InitializeVM(); 82 CcTest::InitializeVM();
83 Isolate* isolate = CcTest::i_isolate(); 83 Isolate* isolate = CcTest::i_isolate();
84 HandleScope scope(isolate); 84 HandleScope scope(isolate);
85 v8::internal::byte buffer[4096]; 85 v8::internal::byte buffer[4096];
86 DummyStaticFunction(NULL); 86 DummyStaticFunction(NULL);
87 Immediate size = Immediate(512, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); 87 Immediate size = Immediate(512, RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE);
88 Label fail; 88 Label fail;
89 89
90 MacroAssembler masm(isolate, buffer, sizeof buffer, 90 MacroAssembler masm(isolate, buffer, sizeof buffer,
91 v8::internal::CodeObjectRequired::kYes); 91 v8::internal::CodeObjectRequired::kYes);
92 92
93 __ Mov(x0, size); 93 __ Mov(x0, size);
94 __ Cmp(x0, size); 94 __ Cmp(x0, size);
95 __ B(ne, &fail); 95 __ B(ne, &fail);
96 __ Ret(); 96 __ Ret();
97 __ Bind(&fail); 97 __ Bind(&fail);
(...skipping 10 matching lines...) Expand all
108 int64_t ret_value = runnable.Call(); 108 int64_t ret_value = runnable.Call();
109 CHECK_NE(ret_value, 0xdeadbeef); 109 CHECK_NE(ret_value, 0xdeadbeef);
110 110
111 #ifdef DEBUG 111 #ifdef DEBUG
112 OFStream os(stdout); 112 OFStream os(stdout);
113 code->Print(os); 113 code->Print(os);
114 ::printf("f() = %" PRIx64 "\n\n", ret_value); 114 ::printf("f() = %" PRIx64 "\n\n", ret_value);
115 #endif 115 #endif
116 int32_t diff = 512; 116 int32_t diff = 512;
117 117
118 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); 118 int mode_mask = (1 << RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE);
119 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { 119 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
120 RelocInfo::Mode mode = it.rinfo()->rmode(); 120 RelocInfo::Mode mode = it.rinfo()->rmode();
121 if (RelocInfo::IsWasmMemorySizeReference(mode)) { 121 if (RelocInfo::IsWasmMemorySizeReference(mode)) {
122 it.rinfo()->update_wasm_memory_reference( 122 it.rinfo()->update_wasm_memory_reference(
123 reinterpret_cast<Address>(0x1234), reinterpret_cast<Address>(0x1234), 123 reinterpret_cast<Address>(0x1234), reinterpret_cast<Address>(0x1234),
124 it.rinfo()->wasm_memory_size_reference(), 124 it.rinfo()->wasm_memory_size_reference(),
125 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); 125 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH);
126 } 126 }
127 } 127 }
128 128
129 ret_value = runnable.Call(); 129 ret_value = runnable.Call();
130 CHECK_NE(ret_value, 0xdeadbeef); 130 CHECK_NE(ret_value, 0xdeadbeef);
131 131
132 #ifdef DEBUG 132 #ifdef DEBUG
133 code->Print(os); 133 code->Print(os);
134 ::printf("f() = %" PRIx64 "\n\n", ret_value); 134 ::printf("f() = %" PRIx64 "\n\n", ret_value);
135 #endif 135 #endif
136 } 136 }
137 137
138 #undef __ 138 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698