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

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

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, 5 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 | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | test/mjsunit/wasm/debug-break.js » ('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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // A helper for module environments that adds the ability to allocate memory 67 // A helper for module environments that adds the ability to allocate memory
68 // and global variables. Contains a built-in {WasmModule} and 68 // and global variables. Contains a built-in {WasmModule} and
69 // {WasmModuleInstance}. 69 // {WasmModuleInstance}.
70 class TestingModule : public ModuleEnv { 70 class TestingModule : public ModuleEnv {
71 public: 71 public:
72 explicit TestingModule(WasmExecutionMode mode = kExecuteCompiled) 72 explicit TestingModule(WasmExecutionMode mode = kExecuteCompiled)
73 : execution_mode_(mode), 73 : execution_mode_(mode),
74 instance_(&module_), 74 instance_(&module_),
75 isolate_(CcTest::InitIsolateOnce()), 75 isolate_(CcTest::InitIsolateOnce()),
76 zone_(&allocator_),
76 global_offset(0), 77 global_offset(0),
77 interpreter_(mode == kExecuteInterpreted 78 interpreter_(mode == kExecuteInterpreted
78 ? new WasmInterpreter(&instance_, &allocator_) 79 ? new WasmInterpreter(&instance_, &zone_)
79 : nullptr) { 80 : nullptr) {
80 module = &module_; 81 module = &module_;
81 instance = &instance_; 82 instance = &instance_;
82 instance->module = &module_; 83 instance->module = &module_;
83 instance->globals_start = global_data; 84 instance->globals_start = global_data;
84 module_.globals_size = kMaxGlobalsSize; 85 module_.globals_size = kMaxGlobalsSize;
85 instance->mem_start = nullptr; 86 instance->mem_start = nullptr;
86 instance->mem_size = 0; 87 instance->mem_size = 0;
87 origin = kWasmOrigin; 88 origin = kWasmOrigin;
88 memset(global_data, 0, sizeof(global_data)); 89 memset(global_data, 0, sizeof(global_data));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 WasmInterpreter* interpreter() { return interpreter_; } 235 WasmInterpreter* interpreter() { return interpreter_; }
235 WasmExecutionMode execution_mode() { return execution_mode_; } 236 WasmExecutionMode execution_mode() { return execution_mode_; }
236 237
237 private: 238 private:
238 WasmExecutionMode execution_mode_; 239 WasmExecutionMode execution_mode_;
239 WasmModule module_; 240 WasmModule module_;
240 WasmModuleInstance instance_; 241 WasmModuleInstance instance_;
241 Isolate* isolate_; 242 Isolate* isolate_;
242 v8::base::AccountingAllocator allocator_; 243 v8::base::AccountingAllocator allocator_;
244 Zone zone_;
243 uint32_t global_offset; 245 uint32_t global_offset;
244 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. 246 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data.
245 WasmInterpreter* interpreter_; 247 WasmInterpreter* interpreter_;
246 248
247 const WasmGlobal* AddGlobal(MachineType mem_type) { 249 const WasmGlobal* AddGlobal(MachineType mem_type) {
248 byte size = WasmOpcodes::MemSize(mem_type); 250 byte size = WasmOpcodes::MemSize(mem_type);
249 global_offset = (global_offset + size - 1) & ~(size - 1); // align 251 global_offset = (global_offset + size - 1) & ~(size - 1); // align
250 module_.globals.push_back({0, 0, mem_type, global_offset, false}); 252 module_.globals.push_back({0, 0, mem_type, global_offset, false});
251 global_offset += size; 253 global_offset += size;
252 // limit number of globals. 254 // limit number of globals.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 debug_name_(debug_name), 440 debug_name_(debug_name),
439 local_decls(main_zone(), sig), 441 local_decls(main_zone(), sig),
440 source_position_table_(this->graph()), 442 source_position_table_(this->graph()),
441 interpreter_(nullptr) { 443 interpreter_(nullptr) {
442 // Create our own function. 444 // Create our own function.
443 function_ = new WasmFunction(); 445 function_ = new WasmFunction();
444 function_->sig = sig; 446 function_->sig = sig;
445 function_->func_index = 0; 447 function_->func_index = 0;
446 function_->sig_index = 0; 448 function_->sig_index = 0;
447 if (mode == kExecuteInterpreted) { 449 if (mode == kExecuteInterpreted) {
448 interpreter_ = new WasmInterpreter(nullptr, zone()->allocator()); 450 interpreter_ = new WasmInterpreter(nullptr, zone());
449 int index = interpreter_->AddFunctionForTesting(function_); 451 int index = interpreter_->AddFunctionForTesting(function_);
450 CHECK_EQ(0, index); 452 CHECK_EQ(0, index);
451 } 453 }
452 } 454 }
453 455
454 explicit WasmFunctionCompiler( 456 explicit WasmFunctionCompiler(
455 FunctionSig* sig, TestingModule* module, 457 FunctionSig* sig, TestingModule* module,
456 Vector<const char> debug_name = ArrayVector("<WASM UNNAMED>")) 458 Vector<const char> debug_name = ArrayVector("<WASM UNNAMED>"))
457 : GraphAndBuilders(main_zone()), 459 : GraphAndBuilders(main_zone()),
458 execution_mode_(module->execution_mode()), 460 execution_mode_(module->execution_mode()),
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 // interpreter. 756 // interpreter.
755 #define WASM_EXEC_TEST(name) \ 757 #define WASM_EXEC_TEST(name) \
756 void RunWasm_##name(WasmExecutionMode execution_mode); \ 758 void RunWasm_##name(WasmExecutionMode execution_mode); \
757 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 759 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
758 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 760 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
759 void RunWasm_##name(WasmExecutionMode execution_mode) 761 void RunWasm_##name(WasmExecutionMode execution_mode)
760 762
761 } // namespace 763 } // namespace
762 764
763 #endif 765 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | test/mjsunit/wasm/debug-break.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698