| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  142   Object *script_or_undef = scripts->get(func_index); |  142   Object *script_or_undef = scripts->get(func_index); | 
|  143   if (!script_or_undef->IsUndefined(isolate)) { |  143   if (!script_or_undef->IsUndefined(isolate)) { | 
|  144     return Script::cast(script_or_undef); |  144     return Script::cast(script_or_undef); | 
|  145   } |  145   } | 
|  146  |  146  | 
|  147   Handle<Script> script = |  147   Handle<Script> script = | 
|  148       isolate->factory()->NewScript(isolate->factory()->empty_string()); |  148       isolate->factory()->NewScript(isolate->factory()->empty_string()); | 
|  149   scripts->set(func_index, *script); |  149   scripts->set(func_index, *script); | 
|  150  |  150  | 
|  151   script->set_type(Script::TYPE_WASM); |  151   script->set_type(Script::TYPE_WASM); | 
 |  152   script->set_wasm_object(debug_info->wasm_object()); | 
 |  153   script->set_wasm_function_index(func_index); | 
 |  154  | 
 |  155   int hash = 0; | 
 |  156   debug_info->get(kWasmDebugInfoWasmBytesHash)->ToInt32(&hash); | 
 |  157   char buffer[32]; | 
 |  158   SNPrintF(ArrayVector(buffer), "wasm://%08x/%d", hash, func_index); | 
 |  159   Handle<String> source_url = | 
 |  160       isolate->factory()->NewStringFromAsciiChecked(buffer, TENURED); | 
 |  161   script->set_source_url(*source_url); | 
|  152  |  162  | 
|  153   int func_bytes_len = |  163   int func_bytes_len = | 
|  154       GetFunctionOffsetAndLength(debug_info, func_index).second; |  164       GetFunctionOffsetAndLength(debug_info, func_index).second; | 
|  155   Handle<FixedArray> line_ends = isolate->factory()->NewFixedArray(1, TENURED); |  165   Handle<FixedArray> line_ends = isolate->factory()->NewFixedArray(1, TENURED); | 
|  156   line_ends->set(0, Smi::FromInt(func_bytes_len)); |  166   line_ends->set(0, Smi::FromInt(func_bytes_len)); | 
|  157   line_ends->set_map(isolate->heap()->fixed_cow_array_map()); |  167   line_ends->set_map(isolate->heap()->fixed_cow_array_map()); | 
|  158   script->set_line_ends(*line_ends); |  168   script->set_line_ends(*line_ends); | 
|  159  |  169  | 
|  160   // TODO(clemensh): Register this new script at the debugger. |  170   isolate->debug()->OnAfterCompile(script); | 
|  161  |  171  | 
|  162   return *script; |  172   return *script; | 
|  163 } |  173 } | 
|  164  |  174  | 
|  165 Handle<String> WasmDebugInfo::DisassembleFunction( |  175 Handle<String> WasmDebugInfo::DisassembleFunction( | 
|  166     Handle<WasmDebugInfo> debug_info, int func_index) { |  176     Handle<WasmDebugInfo> debug_info, int func_index) { | 
|  167   std::ostringstream disassembly_os; |  177   std::ostringstream disassembly_os; | 
|  168  |  178  | 
|  169   { |  179   { | 
|  170     Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index); |  180     Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index); | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  216   int idx = 0; |  226   int idx = 0; | 
|  217   for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { |  227   for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { | 
|  218     offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); |  228     offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); | 
|  219     offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); |  229     offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); | 
|  220     offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); |  230     offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); | 
|  221   } |  231   } | 
|  222   DCHECK_EQ(idx, offset_table->length()); |  232   DCHECK_EQ(idx, offset_table->length()); | 
|  223  |  233  | 
|  224   return offset_table; |  234   return offset_table; | 
|  225 } |  235 } | 
| OLD | NEW |