| Index: src/wasm/wasm-debug.cc
|
| diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc
|
| index bd770de04412f166fae99cea8c8be0e4e06677d0..3e464ed4e82a27d4bb26c674dd9d3ccba1c740bc 100644
|
| --- a/src/wasm/wasm-debug.cc
|
| +++ b/src/wasm/wasm-debug.cc
|
| @@ -20,6 +20,7 @@ enum {
|
| kWasmDebugInfoWasmObj,
|
| kWasmDebugInfoWasmBytesHash,
|
| kWasmDebugInfoFunctionByteOffsets,
|
| + kWasmDebugInfoFunctionScripts,
|
| kWasmDebugInfoNumEntries
|
| };
|
|
|
| @@ -97,6 +98,11 @@ Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<JSObject> wasm) {
|
| Handle<Object> hash_obj = factory->NewNumberFromInt(hash, TENURED);
|
| arr->set(kWasmDebugInfoWasmBytesHash, *hash_obj);
|
|
|
| + int num_functions = wasm::GetNumberOfFunctions(*wasm);
|
| + Handle<FixedArray> functionScripts =
|
| + factory->NewFixedArray(num_functions, TENURED);
|
| + arr->set(kWasmDebugInfoFunctionScripts, *functionScripts);
|
| +
|
| return Handle<WasmDebugInfo>::cast(arr);
|
| }
|
|
|
| @@ -108,7 +114,9 @@ bool WasmDebugInfo::IsDebugInfo(Object *object) {
|
| IsWasmObject(arr->get(kWasmDebugInfoWasmObj)) &&
|
| arr->get(kWasmDebugInfoWasmBytesHash)->IsNumber() &&
|
| (arr->get(kWasmDebugInfoFunctionByteOffsets)->IsUndefined(isolate) ||
|
| - arr->get(kWasmDebugInfoFunctionByteOffsets)->IsByteArray());
|
| + arr->get(kWasmDebugInfoFunctionByteOffsets)->IsByteArray()) &&
|
| + (arr->get(kWasmDebugInfoFunctionScripts)->IsUndefined(isolate) ||
|
| + arr->get(kWasmDebugInfoFunctionScripts)->IsFixedArray());
|
| }
|
|
|
| WasmDebugInfo *WasmDebugInfo::cast(Object *object) {
|
| @@ -120,6 +128,40 @@ JSObject *WasmDebugInfo::wasm_object() {
|
| return JSObject::cast(get(kWasmDebugInfoWasmObj));
|
| }
|
|
|
| +Script *WasmDebugInfo::GetFunctionScript(int func_index) {
|
| + Isolate *isolate = GetIsolate();
|
| + FixedArray *scripts = FixedArray::cast(get(kWasmDebugInfoFunctionScripts));
|
| + DCHECK(func_index >= 0 && func_index < scripts->length());
|
| + Object *script_or_undef = scripts->get(func_index);
|
| + if (!script_or_undef->IsUndefined(isolate)) {
|
| + return Script::cast(script_or_undef);
|
| + }
|
| +
|
| + JSObject *wasm0 = wasm_object();
|
| + Handle<JSObject> wasm(wasm0, isolate);
|
| +
|
| + Handle<Script> script =
|
| + isolate->factory()->NewScript(isolate->factory()->empty_string());
|
| + scripts->set(func_index, *script);
|
| +
|
| + script->set_type(Script::TYPE_WASM);
|
| +
|
| + Handle<ByteArray> offset_arr(GetOrCreateFunctionOffsetTable(this), isolate);
|
| + int func_bytes_len = offset_arr->get_int(2 * func_index + 1);
|
| + Handle<FixedArray> line_ends = isolate->factory()->NewFixedArray(1, TENURED);
|
| + line_ends->set(0, Smi::FromInt(func_bytes_len));
|
| + line_ends->set_map(isolate->heap()->fixed_cow_array_map());
|
| + script->set_line_ends(*line_ends);
|
| +
|
| + int hash = 0;
|
| + get(kWasmDebugInfoWasmBytesHash)->ToInt32(&hash);
|
| +
|
| + // TODO(clemensh): Register this new script at the debugger.
|
| + USE(hash);
|
| +
|
| + return *script;
|
| +}
|
| +
|
| bool WasmDebugInfo::SetBreakPoint(int byte_offset) { return false; }
|
|
|
| Handle<String> WasmDebugInfo::DisassembleFunction(int func_index) {
|
|
|