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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 JSObject *wasm0 = wasm_object(); | 140 JSObject *wasm0 = wasm_object(); |
141 Handle<JSObject> wasm(wasm0, isolate); | 141 Handle<JSObject> wasm(wasm0, isolate); |
142 | 142 |
143 Handle<Script> script = | 143 Handle<Script> script = |
144 isolate->factory()->NewScript(isolate->factory()->empty_string()); | 144 isolate->factory()->NewScript(isolate->factory()->empty_string()); |
145 scripts->set(func_index, *script); | 145 scripts->set(func_index, *script); |
146 | 146 |
147 script->set_type(Script::TYPE_WASM); | 147 script->set_type(Script::TYPE_WASM); |
| 148 script->set_wasm_object(*wasm); |
| 149 script->set_wasm_function_index(func_index); |
| 150 |
| 151 int hash = 0; |
| 152 get(kWasmDebugInfoWasmBytesHash)->ToInt32(&hash); |
| 153 char buffer[32]; |
| 154 SNPrintF(ArrayVector(buffer), "wasm://%08x/%d", hash, func_index); |
| 155 Handle<String> source_url = |
| 156 isolate->factory()->NewStringFromAsciiChecked(buffer, TENURED); |
| 157 script->set_source_url(*source_url); |
148 | 158 |
149 Handle<ByteArray> offset_arr(GetOrCreateFunctionOffsetTable(this), isolate); | 159 Handle<ByteArray> offset_arr(GetOrCreateFunctionOffsetTable(this), isolate); |
150 int func_bytes_len = offset_arr->get_int(2 * func_index + 1); | 160 int func_bytes_len = offset_arr->get_int(2 * func_index + 1); |
151 Handle<FixedArray> line_ends = isolate->factory()->NewFixedArray(1, TENURED); | 161 Handle<FixedArray> line_ends = isolate->factory()->NewFixedArray(1, TENURED); |
152 line_ends->set(0, Smi::FromInt(func_bytes_len)); | 162 line_ends->set(0, Smi::FromInt(func_bytes_len)); |
153 line_ends->set_map(isolate->heap()->fixed_cow_array_map()); | 163 line_ends->set_map(isolate->heap()->fixed_cow_array_map()); |
154 script->set_line_ends(*line_ends); | 164 script->set_line_ends(*line_ends); |
155 | 165 |
156 int hash = 0; | 166 isolate->debug()->OnAfterCompile(script); |
157 get(kWasmDebugInfoWasmBytesHash)->ToInt32(&hash); | |
158 | |
159 // TODO(clemensh): Register this new script at the debugger. | |
160 USE(hash); | |
161 | 167 |
162 return *script; | 168 return *script; |
163 } | 169 } |
164 | 170 |
165 bool WasmDebugInfo::SetBreakPoint(int byte_offset) { return false; } | 171 bool WasmDebugInfo::SetBreakPoint(int byte_offset) { return false; } |
166 | 172 |
167 Handle<String> WasmDebugInfo::DisassembleFunction(int func_index) { | 173 Handle<String> WasmDebugInfo::DisassembleFunction(int func_index) { |
168 std::ostringstream disassembly_os; | 174 std::ostringstream disassembly_os; |
169 | 175 |
170 { | 176 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 int idx = 0; | 223 int idx = 0; |
218 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { | 224 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { |
219 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); | 225 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); |
220 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); | 226 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); |
221 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); | 227 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); |
222 } | 228 } |
223 DCHECK_EQ(idx, offset_table->length()); | 229 DCHECK_EQ(idx, offset_table->length()); |
224 | 230 |
225 return offset_table; | 231 return offset_table; |
226 } | 232 } |
OLD | NEW |