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

Side by Side Diff: test/cctest/test-run-wasm-relocation-arm.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/arm/assembler-arm-inl.h" 10 #include "src/arm/assembler-arm-inl.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 CcTest::InitializeVM(); 80 CcTest::InitializeVM();
81 Isolate* isolate = CcTest::i_isolate(); 81 Isolate* isolate = CcTest::i_isolate();
82 HandleScope scope(isolate); 82 HandleScope scope(isolate);
83 v8::internal::byte buffer[4096]; 83 v8::internal::byte buffer[4096];
84 DummyStaticFunction(NULL); 84 DummyStaticFunction(NULL);
85 int32_t size = 512; 85 int32_t size = 512;
86 Label fail; 86 Label fail;
87 87
88 Assembler assm(isolate, buffer, sizeof buffer); 88 Assembler assm(isolate, buffer, sizeof buffer);
89 89
90 __ mov(r0, Operand(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); 90 __ mov(r0, Operand(size, RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE));
91 __ cmp(r0, Operand(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); 91 __ cmp(r0, Operand(size, RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE));
92 __ b(ne, &fail); 92 __ b(ne, &fail);
93 __ mov(pc, Operand(lr)); 93 __ mov(pc, Operand(lr));
94 __ bind(&fail); 94 __ bind(&fail);
95 __ mov(r0, Operand(0xdeadbeef)); 95 __ mov(r0, Operand(0xdeadbeef));
96 __ mov(pc, Operand(lr)); 96 __ mov(pc, Operand(lr));
97 97
98 CodeDesc desc; 98 CodeDesc desc;
99 assm.GetCode(&desc); 99 assm.GetCode(&desc);
100 Handle<Code> code = isolate->factory()->NewCode( 100 Handle<Code> code = isolate->factory()->NewCode(
101 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 101 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
102 102
103 CSignature0<int32_t> csig; 103 CSignature0<int32_t> csig;
104 CodeRunner<int32_t> runnable(isolate, code, &csig); 104 CodeRunner<int32_t> runnable(isolate, code, &csig);
105 int32_t ret_value = runnable.Call(); 105 int32_t ret_value = runnable.Call();
106 CHECK_NE(ret_value, 0xdeadbeef); 106 CHECK_NE(ret_value, 0xdeadbeef);
107 107
108 #ifdef DEBUG 108 #ifdef DEBUG
109 OFStream os(stdout); 109 OFStream os(stdout);
110 code->Print(os); 110 code->Print(os);
111 ::printf("f() = %d\n\n", ret_value); 111 ::printf("f() = %d\n\n", ret_value);
112 #endif 112 #endif
113 size_t diff = 512; 113 size_t diff = 512;
114 114
115 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); 115 int mode_mask = (1 << RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE);
116 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { 116 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
117 RelocInfo::Mode mode = it.rinfo()->rmode(); 117 RelocInfo::Mode mode = it.rinfo()->rmode();
118 if (RelocInfo::IsWasmMemorySizeReference(mode)) { 118 if (RelocInfo::IsWasmMemorySizeReference(mode)) {
119 it.rinfo()->update_wasm_memory_reference( 119 it.rinfo()->update_wasm_memory_reference(
120 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), 120 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234),
121 it.rinfo()->wasm_memory_size_reference(), 121 it.rinfo()->wasm_memory_size_reference(),
122 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); 122 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH);
123 } 123 }
124 } 124 }
125 125
126 ret_value = runnable.Call(); 126 ret_value = runnable.Call();
127 CHECK_NE(ret_value, 0xdeadbeef); 127 CHECK_NE(ret_value, 0xdeadbeef);
128 128
129 #ifdef DEBUG 129 #ifdef DEBUG
130 code->Print(os); 130 code->Print(os);
131 ::printf("f() = %d\n\n", ret_value); 131 ::printf("f() = %d\n\n", ret_value);
132 #endif 132 #endif
133 } 133 }
134 #undef __ 134 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698