| Index: src/wasm/wasm-debug.cc
|
| diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc
|
| index 979fad83310dda0e9062237cd45215da5cda277e..27b43017493e67b8dc71f582b5253c9024cad6c1 100644
|
| --- a/src/wasm/wasm-debug.cc
|
| +++ b/src/wasm/wasm-debug.cc
|
| @@ -22,59 +22,6 @@ enum {
|
| kWasmDebugInfoNumEntries
|
| };
|
|
|
| -// TODO(clemensh): Move asm.js offset tables to the compiled module.
|
| -FixedArray *GetAsmJsOffsetTables(Handle<WasmDebugInfo> debug_info,
|
| - Isolate *isolate) {
|
| - Object *offset_tables = debug_info->get(kWasmDebugInfoAsmJsOffsets);
|
| - if (!offset_tables->IsUndefined(isolate)) {
|
| - return FixedArray::cast(offset_tables);
|
| - }
|
| -
|
| - Handle<WasmInstanceObject> wasm_instance(debug_info->wasm_instance(),
|
| - isolate);
|
| - Handle<WasmCompiledModule> compiled_module(
|
| - wasm_instance->get_compiled_module(), isolate);
|
| - DCHECK(compiled_module->has_asm_js_offset_tables());
|
| -
|
| - AsmJsOffsetsResult asm_offsets;
|
| - {
|
| - Handle<ByteArray> asm_offset_tables =
|
| - compiled_module->asm_js_offset_tables();
|
| - DisallowHeapAllocation no_gc;
|
| - const byte *bytes_start = asm_offset_tables->GetDataStartAddress();
|
| - const byte *bytes_end = bytes_start + asm_offset_tables->length();
|
| - asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end);
|
| - }
|
| - // Wasm bytes must be valid and must contain asm.js offset table.
|
| - DCHECK(asm_offsets.ok());
|
| - DCHECK_GE(static_cast<size_t>(kMaxInt), asm_offsets.val.size());
|
| - int num_functions = static_cast<int>(asm_offsets.val.size());
|
| - DCHECK_EQ(
|
| - wasm::GetNumberOfFunctions(handle(debug_info->wasm_instance())),
|
| - static_cast<int>(num_functions +
|
| - compiled_module->module()->num_imported_functions));
|
| - Handle<FixedArray> all_tables =
|
| - isolate->factory()->NewFixedArray(num_functions);
|
| - debug_info->set(kWasmDebugInfoAsmJsOffsets, *all_tables);
|
| - for (int func = 0; func < num_functions; ++func) {
|
| - std::vector<std::pair<int, int>> &func_asm_offsets = asm_offsets.val[func];
|
| - if (func_asm_offsets.empty()) continue;
|
| - size_t array_size = 2 * kIntSize * func_asm_offsets.size();
|
| - CHECK_LE(array_size, static_cast<size_t>(kMaxInt));
|
| - ByteArray *arr =
|
| - *isolate->factory()->NewByteArray(static_cast<int>(array_size));
|
| - all_tables->set(func, arr);
|
| - int idx = 0;
|
| - for (std::pair<int, int> p : func_asm_offsets) {
|
| - // Byte offsets must be strictly monotonously increasing:
|
| - DCHECK(idx == 0 || p.first > arr->get_int(idx - 2));
|
| - arr->set_int(idx++, p.first);
|
| - arr->set_int(idx++, p.second);
|
| - }
|
| - DCHECK_EQ(arr->length(), idx * kIntSize);
|
| - }
|
| - return *all_tables;
|
| -}
|
| } // namespace
|
|
|
| Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<WasmInstanceObject> instance) {
|
| @@ -113,35 +60,3 @@ WasmDebugInfo *WasmDebugInfo::cast(Object *object) {
|
| WasmInstanceObject *WasmDebugInfo::wasm_instance() {
|
| return WasmInstanceObject::cast(get(kWasmDebugInfoWasmObj));
|
| }
|
| -
|
| -int WasmDebugInfo::GetAsmJsSourcePosition(Handle<WasmDebugInfo> debug_info,
|
| - int func_index, int byte_offset) {
|
| - Isolate *isolate = debug_info->GetIsolate();
|
| - Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate);
|
| - FixedArray *offset_tables = GetAsmJsOffsetTables(debug_info, isolate);
|
| -
|
| - WasmCompiledModule *compiled_module = instance->get_compiled_module();
|
| - int num_imported_functions =
|
| - compiled_module->module()->num_imported_functions;
|
| - DCHECK_LE(num_imported_functions, func_index);
|
| - func_index -= num_imported_functions;
|
| - DCHECK_LT(func_index, offset_tables->length());
|
| - ByteArray *offset_table = ByteArray::cast(offset_tables->get(func_index));
|
| -
|
| - // Binary search for the current byte offset.
|
| - int left = 0; // inclusive
|
| - int right = offset_table->length() / kIntSize / 2; // exclusive
|
| - DCHECK_LT(left, right);
|
| - while (right - left > 1) {
|
| - int mid = left + (right - left) / 2;
|
| - if (offset_table->get_int(2 * mid) <= byte_offset) {
|
| - left = mid;
|
| - } else {
|
| - right = mid;
|
| - }
|
| - }
|
| - // There should be an entry for each position that could show up on the stack
|
| - // trace:
|
| - DCHECK_EQ(byte_offset, offset_table->get_int(2 * left));
|
| - return offset_table->get_int(2 * left + 1);
|
| -}
|
|
|