| OLD | NEW |
| 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 "src/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
| 6 #include "src/assert-scope.h" | 6 #include "src/assert-scope.h" |
| 7 #include "src/compiler/wasm-compiler.h" | 7 #include "src/compiler/wasm-compiler.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 WasmInterpreter interpreter_; | 31 WasmInterpreter interpreter_; |
| 32 Isolate* isolate_; | 32 Isolate* isolate_; |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 // Initialize in the right order, using helper methods to make this possible. | 35 // Initialize in the right order, using helper methods to make this possible. |
| 36 // WasmInterpreter has to be allocated in place, since it is not movable. | 36 // WasmInterpreter has to be allocated in place, since it is not movable. |
| 37 InterpreterHandle(Isolate* isolate, WasmDebugInfo* debug_info) | 37 InterpreterHandle(Isolate* isolate, WasmDebugInfo* debug_info) |
| 38 : instance_(debug_info->wasm_instance()->compiled_module()->module()), | 38 : instance_(debug_info->wasm_instance()->compiled_module()->module()), |
| 39 interpreter_(GetBytesEnv(&instance_, debug_info), &allocator_), | 39 interpreter_(GetBytesEnv(&instance_, debug_info), &allocator_), |
| 40 isolate_(isolate) { | 40 isolate_(isolate) { |
| 41 Handle<JSArrayBuffer> mem_buffer = | 41 if (debug_info->wasm_instance()->has_memory_buffer()) { |
| 42 handle(debug_info->wasm_instance()->memory_buffer(), isolate); | 42 JSArrayBuffer* mem_buffer = debug_info->wasm_instance()->memory_buffer(); |
| 43 if (mem_buffer->IsUndefined(isolate)) { | 43 instance_.mem_start = |
| 44 reinterpret_cast<byte*>(mem_buffer->backing_store()); |
| 45 CHECK(mem_buffer->byte_length()->ToUint32(&instance_.mem_size)); |
| 46 } else { |
| 44 DCHECK_EQ(0, instance_.module->min_mem_pages); | 47 DCHECK_EQ(0, instance_.module->min_mem_pages); |
| 45 instance_.mem_start = nullptr; | 48 instance_.mem_start = nullptr; |
| 46 instance_.mem_size = 0; | 49 instance_.mem_size = 0; |
| 47 } else { | |
| 48 instance_.mem_start = | |
| 49 reinterpret_cast<byte*>(mem_buffer->backing_store()); | |
| 50 CHECK(mem_buffer->byte_length()->ToUint32(&instance_.mem_size)); | |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 | 52 |
| 54 static ModuleBytesEnv GetBytesEnv(WasmInstance* instance, | 53 static ModuleBytesEnv GetBytesEnv(WasmInstance* instance, |
| 55 WasmDebugInfo* debug_info) { | 54 WasmDebugInfo* debug_info) { |
| 56 // Return raw pointer into heap. The WasmInterpreter will make its own copy | 55 // Return raw pointer into heap. The WasmInterpreter will make its own copy |
| 57 // of this data anyway, and there is no heap allocation in-between. | 56 // of this data anyway, and there is no heap allocation in-between. |
| 58 SeqOneByteString* bytes_str = | 57 SeqOneByteString* bytes_str = |
| 59 debug_info->wasm_instance()->compiled_module()->module_bytes(); | 58 debug_info->wasm_instance()->compiled_module()->module_bytes(); |
| 60 Vector<const byte> bytes(bytes_str->GetChars(), bytes_str->length()); | 59 Vector<const byte> bytes(bytes_str->GetChars(), bytes_str->length()); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 360 |
| 362 std::vector<std::pair<uint32_t, int>> WasmDebugInfo::GetInterpretedStack( | 361 std::vector<std::pair<uint32_t, int>> WasmDebugInfo::GetInterpretedStack( |
| 363 Address frame_pointer) { | 362 Address frame_pointer) { |
| 364 return GetInterpreterHandle(this)->GetInterpretedStack(frame_pointer); | 363 return GetInterpreterHandle(this)->GetInterpretedStack(frame_pointer); |
| 365 } | 364 } |
| 366 | 365 |
| 367 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( | 366 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( |
| 368 Address frame_pointer, int idx) { | 367 Address frame_pointer, int idx) { |
| 369 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); | 368 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); |
| 370 } | 369 } |
| OLD | NEW |