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

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

Issue 2096863003: [wasm] prototype for breakpoint support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@extend-script-functionality
Patch Set: Created 4 years, 6 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/wasm/wasm-module.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('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. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/wasm/wasm-macro-gen.h" 9 #include "src/wasm/wasm-macro-gen.h"
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 kExprI32Add); 171 kExprI32Add);
172 172
173 WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Uint32(), 173 WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Uint32(),
174 MachineType::Uint32()); 174 MachineType::Uint32());
175 175
176 r.Build(code, code + arraysize(code)); 176 r.Build(code, code + arraysize(code));
177 177
178 WasmInterpreter* interpreter = r.interpreter(); 178 WasmInterpreter* interpreter = r.interpreter();
179 WasmInterpreter::Thread* thread = interpreter->GetThread(0); 179 WasmInterpreter::Thread* thread = interpreter->GetThread(0);
180 for (int i = 0; i < kNumBreakpoints; i++) { 180 for (int i = 0; i < kNumBreakpoints; i++) {
181 interpreter->SetBreakpoint(r.function(), kLocalsDeclSize + offsets[i], 181 interpreter->SetBreakpoint(r.function()->func_index,
182 true); 182 kLocalsDeclSize + offsets[i], true);
183 } 183 }
184 184
185 FOR_UINT32_INPUTS(a) { 185 FOR_UINT32_INPUTS(a) {
186 for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) { 186 for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) {
187 thread->Reset(); 187 thread->Reset();
188 WasmVal args[] = {WasmVal(*a), WasmVal(b)}; 188 WasmVal args[] = {WasmVal(*a), WasmVal(b)};
189 thread->PushFrame(r.function(), args); 189 thread->PushFrame(r.function(), args);
190 190
191 for (int i = 0; i < kNumBreakpoints; i++) { 191 for (int i = 0; i < kNumBreakpoints; i++) {
192 thread->Run(); // run to next breakpoint 192 thread->Run(); // run to next breakpoint
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 r.Build(code, code + arraysize(code)); 254 r.Build(code, code + arraysize(code));
255 255
256 WasmInterpreter* interpreter = r.interpreter(); 256 WasmInterpreter* interpreter = r.interpreter();
257 WasmInterpreter::Thread* thread = interpreter->GetThread(0); 257 WasmInterpreter::Thread* thread = interpreter->GetThread(0);
258 258
259 FOR_UINT32_INPUTS(a) { 259 FOR_UINT32_INPUTS(a) {
260 for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) { 260 for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) {
261 // Run with and without breakpoints. 261 // Run with and without breakpoints.
262 for (int do_break = 0; do_break < 2; do_break++) { 262 for (int do_break = 0; do_break < 2; do_break++) {
263 interpreter->SetBreakpoint(r.function(), kLocalsDeclSize + offsets[0], 263 interpreter->SetBreakpoint(r.function()->func_index,
264 do_break); 264 kLocalsDeclSize + offsets[0], do_break);
265 thread->Reset(); 265 thread->Reset();
266 WasmVal args[] = {WasmVal(*a), WasmVal(b)}; 266 WasmVal args[] = {WasmVal(*a), WasmVal(b)};
267 thread->PushFrame(r.function(), args); 267 thread->PushFrame(r.function(), args);
268 268
269 if (do_break) { 269 if (do_break) {
270 thread->Run(); // run to next breakpoint 270 thread->Run(); // run to next breakpoint
271 // Check the thread stopped at the right pc. 271 // Check the thread stopped at the right pc.
272 CHECK_EQ(WasmInterpreter::PAUSED, thread->state()); 272 CHECK_EQ(WasmInterpreter::PAUSED, thread->state());
273 CHECK_EQ(kLocalsDeclSize + offsets[0], thread->GetBreakpointPc()); 273 CHECK_EQ(kLocalsDeclSize + offsets[0], thread->GetBreakpointPc());
274 } 274 }
275 275
276 thread->Run(); // run to completion 276 thread->Run(); // run to completion
277 277
278 // Check the thread finished with the right value. 278 // Check the thread finished with the right value.
279 CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); 279 CHECK_EQ(WasmInterpreter::FINISHED, thread->state());
280 uint32_t expected = (*a) & (b); 280 uint32_t expected = (*a) & (b);
281 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); 281 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>());
282 } 282 }
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 } // namespace wasm 287 } // namespace wasm
288 } // namespace internal 288 } // namespace internal
289 } // namespace v8 289 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698