| 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/wasm/wasm-debug.h" | 5 #include "src/wasm/wasm-debug.h" |
| 6 | 6 |
| 7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.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/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 ByteArray *GetOrCreateFunctionOffsetTable(Handle<WasmDebugInfo> debug_info) { | 27 ByteArray *GetOrCreateFunctionOffsetTable(Handle<WasmDebugInfo> debug_info) { |
| 28 Object *offset_table = debug_info->get(kWasmDebugInfoFunctionByteOffsets); | 28 Object *offset_table = debug_info->get(kWasmDebugInfoFunctionByteOffsets); |
| 29 Isolate *isolate = debug_info->GetIsolate(); | 29 Isolate *isolate = debug_info->GetIsolate(); |
| 30 if (!offset_table->IsUndefined(isolate)) return ByteArray::cast(offset_table); | 30 if (!offset_table->IsUndefined(isolate)) return ByteArray::cast(offset_table); |
| 31 | 31 |
| 32 FunctionOffsetsResult function_offsets; | 32 FunctionOffsetsResult function_offsets; |
| 33 { | 33 { |
| 34 DisallowHeapAllocation no_gc; | 34 DisallowHeapAllocation no_gc; |
| 35 Handle<JSObject> wasm_object(debug_info->wasm_object(), isolate); | |
| 36 uint32_t num_imported_functions = | |
| 37 wasm::GetNumImportedFunctions(wasm_object); | |
| 38 SeqOneByteString *wasm_bytes = | 35 SeqOneByteString *wasm_bytes = |
| 39 wasm::GetWasmBytes(debug_info->wasm_object()); | 36 wasm::GetWasmBytes(debug_info->wasm_object()); |
| 40 const byte *bytes_start = wasm_bytes->GetChars(); | 37 const byte *bytes_start = wasm_bytes->GetChars(); |
| 41 const byte *bytes_end = bytes_start + wasm_bytes->length(); | 38 const byte *bytes_end = bytes_start + wasm_bytes->length(); |
| 42 function_offsets = wasm::DecodeWasmFunctionOffsets(bytes_start, bytes_end, | 39 function_offsets = wasm::DecodeWasmFunctionOffsets(bytes_start, bytes_end); |
| 43 num_imported_functions); | |
| 44 } | 40 } |
| 45 DCHECK(function_offsets.ok()); | 41 DCHECK(function_offsets.ok()); |
| 46 size_t array_size = 2 * kIntSize * function_offsets.val.size(); | 42 size_t array_size = 2 * kIntSize * function_offsets.val.size(); |
| 47 CHECK_LE(array_size, static_cast<size_t>(kMaxInt)); | 43 CHECK_LE(array_size, static_cast<size_t>(kMaxInt)); |
| 48 ByteArray *arr = | 44 ByteArray *arr = |
| 49 *isolate->factory()->NewByteArray(static_cast<int>(array_size)); | 45 *isolate->factory()->NewByteArray(static_cast<int>(array_size)); |
| 50 int idx = 0; | 46 int idx = 0; |
| 51 for (std::pair<int, int> p : function_offsets.val) { | 47 for (std::pair<int, int> p : function_offsets.val) { |
| 52 arr->set_int(idx++, p.first); | 48 arr->set_int(idx++, p.first); |
| 53 arr->set_int(idx++, p.second); | 49 arr->set_int(idx++, p.second); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 int idx = 0; | 225 int idx = 0; |
| 230 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { | 226 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { |
| 231 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); | 227 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); |
| 232 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); | 228 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); |
| 233 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); | 229 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); |
| 234 } | 230 } |
| 235 DCHECK_EQ(idx, offset_table->length()); | 231 DCHECK_EQ(idx, offset_table->length()); |
| 236 | 232 |
| 237 return offset_table; | 233 return offset_table; |
| 238 } | 234 } |
| OLD | NEW |