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

Side by Side Diff: test/cctest/test-run-wasm-relocation-x64.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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/disasm.h" 10 #include "src/disasm.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 TEST(WasmRelocationX64WasmMemorySizeReference) { 83 TEST(WasmRelocationX64WasmMemorySizeReference) {
84 CcTest::InitializeVM(); 84 CcTest::InitializeVM();
85 Isolate* isolate = CcTest::i_isolate(); 85 Isolate* isolate = CcTest::i_isolate();
86 HandleScope scope(isolate); 86 HandleScope scope(isolate);
87 v8::internal::byte buffer[4096]; 87 v8::internal::byte buffer[4096];
88 Assembler assm(isolate, buffer, sizeof buffer); 88 Assembler assm(isolate, buffer, sizeof buffer);
89 DummyStaticFunction(NULL); 89 DummyStaticFunction(NULL);
90 int32_t size = 512; 90 int32_t size = 512;
91 Label fail; 91 Label fail;
92 92
93 __ movl(rax, Immediate(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); 93 __ movl(rax, Immediate(size, RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE));
94 __ cmpl(rax, Immediate(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); 94 __ cmpl(rax, Immediate(size, RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE));
95 __ j(not_equal, &fail); 95 __ j(not_equal, &fail);
96 __ ret(0); 96 __ ret(0);
97 __ bind(&fail); 97 __ bind(&fail);
98 __ movl(rax, Immediate(0xdeadbeef)); 98 __ movl(rax, Immediate(0xdeadbeef));
99 __ ret(0); 99 __ ret(0);
100 100
101 CodeDesc desc; 101 CodeDesc desc;
102 assm.GetCode(&desc); 102 assm.GetCode(&desc);
103 Handle<Code> code = isolate->factory()->NewCode( 103 Handle<Code> code = isolate->factory()->NewCode(
104 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 104 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
105 USE(code); 105 USE(code);
106 106
107 CSignature0<int64_t> csig; 107 CSignature0<int64_t> csig;
108 CodeRunner<int64_t> runnable(isolate, code, &csig); 108 CodeRunner<int64_t> runnable(isolate, code, &csig);
109 int64_t ret_value = runnable.Call(); 109 int64_t ret_value = runnable.Call();
110 CHECK_NE(ret_value, 0xdeadbeef); 110 CHECK_NE(ret_value, 0xdeadbeef);
111 111
112 #ifdef OBJECT_PRINT 112 #ifdef OBJECT_PRINT
113 OFStream os(stdout); 113 OFStream os(stdout);
114 code->Print(os); 114 code->Print(os);
115 byte* begin = code->instruction_start(); 115 byte* begin = code->instruction_start();
116 byte* end = begin + code->instruction_size(); 116 byte* end = begin + code->instruction_size();
117 disasm::Disassembler::Disassemble(stdout, begin, end); 117 disasm::Disassembler::Disassemble(stdout, begin, end);
118 #endif 118 #endif
119 int32_t diff = 512; 119 int32_t diff = 512;
120 120
121 int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); 121 int mode_mask = (1 << RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE);
122 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { 122 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
123 RelocInfo::Mode mode = it.rinfo()->rmode(); 123 RelocInfo::Mode mode = it.rinfo()->rmode();
124 if (RelocInfo::IsWasmMemorySizeReference(mode)) { 124 if (RelocInfo::IsWasmMemorySizeReference(mode)) {
125 it.rinfo()->update_wasm_memory_reference( 125 it.rinfo()->update_wasm_memory_reference(
126 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), 126 reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234),
127 it.rinfo()->wasm_memory_size_reference(), 127 it.rinfo()->wasm_memory_size_reference(),
128 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); 128 it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH);
129 } 129 }
130 } 130 }
131 131
132 ret_value = runnable.Call(); 132 ret_value = runnable.Call();
133 CHECK_NE(ret_value, 0xdeadbeef); 133 CHECK_NE(ret_value, 0xdeadbeef);
134 134
135 #ifdef OBJECT_PRINT 135 #ifdef OBJECT_PRINT
136 code->Print(os); 136 code->Print(os);
137 begin = code->instruction_start(); 137 begin = code->instruction_start();
138 end = begin + code->instruction_size(); 138 end = begin + code->instruction_size();
139 disasm::Disassembler::Disassemble(stdout, begin, end); 139 disasm::Disassembler::Disassemble(stdout, begin, end);
140 #endif 140 #endif
141 } 141 }
142 #undef __ 142 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698