Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1285)

Unified Diff: src/wasm/wasm-debug.cc

Issue 2069823003: [wasm] Enable wasm frame inspection for debugging (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-wasm-debug
Patch Set: address yang's comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/wasm/wasm-debug.cc
diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc
index 414ce91af6ed0ce5f2e257893ac6be2710aa4cc7..f794323dca404cb3f7af2be08f03330d4f83291e 100644
--- a/src/wasm/wasm-debug.cc
+++ b/src/wasm/wasm-debug.cc
@@ -20,6 +20,7 @@ enum {
kWasmDebugInfoWasmObj,
kWasmDebugInfoWasmBytesHash,
kWasmDebugInfoFunctionByteOffsets,
+ kWasmDebugInfoFunctionScripts,
kWasmDebugInfoNumEntries
};
@@ -95,6 +96,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);
}
@@ -106,7 +112,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) {
@@ -118,6 +126,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);
ahaas 2016/06/17 07:25:44 I think it could be a good idea to add a wrapper f
Clemens Hammacher 2016/06/17 14:01:46 Done. This now calls GetFunctionOffsetAndLength.
+ 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) {
// TODO(clemensh): Implement this.
return false;

Powered by Google App Engine
This is Rietveld 408576698