Commit 566d174e authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Use names of locals for inspecting Liftoff

This makes Liftoff inspection (scope reporting) also use the decoded
names of locals, which are now stored in a C++ data structure (see
https://crrev.com/c/2002541).
The call to {SetOwnPropertyIgnoreAttributes} had to be replaced by a
proper lookup first, to handle integer names and duplicate names
correctly. The test already covered these cases.

The test was extended by another unnamed local to also test the
generation of default names in case no name is provided.

R=thibaudm@chromium.org

Bug: v8:10019
Change-Id: I475bb4db9a32c39203180e9c8d3f8181c3882138
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002544
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65821}
parent 60104eda
......@@ -519,18 +519,28 @@ class DebugInfoImpl {
JSObject::AddProperty(isolate, local_scope_object, locals_name,
locals_obj, NONE);
for (int i = 0; i < num_locals; ++i) {
// TODO(clemensb): Get the proper name of the local.
// Parameters should come before locals in alphabetical ordering, so
// we name them "args" here.
const char* label = i < num_params ? "arg#%d" : "local#%d";
Handle<String> name = PrintFToOneByteString<true>(isolate, label, i);
Handle<Name> name;
if (!GetLocalNameString(isolate, native_module_, function->func_index,
i)
.ToHandle(&name)) {
// Parameters should come before locals in alphabetical ordering, so
// we name them "args" here.
const char* label = i < num_params ? "arg#%d" : "local#%d";
name = PrintFToOneByteString<true>(isolate, label, i);
}
WasmValue value =
GetValue(debug_side_table_entry, debug_side_table->local_type(i), i,
fp - debug_side_table->local_stack_offset(i));
Handle<Object> value_obj = WasmValueToValueObject(isolate, value);
JSObject::SetOwnPropertyIgnoreAttributes(locals_obj, name, value_obj,
NONE)
.Assert();
// {name} can be a string representation of an element index.
LookupIterator::Key lookup_key{isolate, name};
LookupIterator it(isolate, locals_obj, lookup_key, locals_obj,
LookupIterator::OWN_SKIP_INTERCEPTOR);
if (it.IsFound()) continue;
Object::AddDataProperty(&it, value_obj, NONE,
Just(ShouldThrow::kThrowOnError),
StoreOrigin::kNamed)
.Check();
}
}
......
......@@ -10,7 +10,7 @@ Setting breakpoint on line 2 (first instruction) of third function
scriptId : <scriptId>
}
Paused:
Script wasm://wasm/a094dcfe byte offset 85: Wasm opcode 0x20
Script wasm://wasm/89d60696 byte offset 85: Wasm opcode 0x20
Scope:
at C (interpreted) (0:85):
- scope (global):
......@@ -22,7 +22,7 @@ at B (liftoff) (0:76):
- scope (global):
globals: "global#0": 0 (number)
- scope (local):
locals: "arg#0": 42 (number), "local#1": 0 (number), "local#2": 7.199999809265137 (number), "local#3": 0 (number), "local#4": 0 (number)
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "local#5": 0 (number)
stack: "0": 42 (number), "1": 3 (number)
at A (liftoff) (0:54):
- scope (global):
......@@ -35,7 +35,7 @@ at (anonymous) (0:17):
-- skipped globals
Paused:
Script wasm://wasm/a094dcfe byte offset 87: Wasm opcode 0x24
Script wasm://wasm/89d60696 byte offset 87: Wasm opcode 0x24
Scope:
at C (interpreted) (0:87):
- scope (global):
......@@ -47,7 +47,7 @@ at B (liftoff) (0:76):
- scope (global):
globals: "global#0": 0 (number)
- scope (local):
locals: "arg#0": 42 (number), "local#1": 0 (number), "local#2": 7.199999809265137 (number), "local#3": 0 (number), "local#4": 0 (number)
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "local#5": 0 (number)
stack: "0": 42 (number), "1": 3 (number)
at A (liftoff) (0:54):
- scope (global):
......@@ -60,7 +60,7 @@ at (anonymous) (0:17):
-- skipped globals
Paused:
Script wasm://wasm/a094dcfe byte offset 89: Wasm opcode 0x41
Script wasm://wasm/89d60696 byte offset 89: Wasm opcode 0x41
Scope:
at C (interpreted) (0:89):
- scope (global):
......@@ -72,7 +72,7 @@ at B (liftoff) (0:76):
- scope (global):
globals: "global#0": 42 (number)
- scope (local):
locals: "arg#0": 42 (number), "local#1": 0 (number), "local#2": 7.199999809265137 (number), "local#3": 0 (number), "local#4": 0 (number)
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "local#5": 0 (number)
stack: "0": 42 (number), "1": 3 (number)
at A (liftoff) (0:54):
- scope (global):
......@@ -85,7 +85,7 @@ at (anonymous) (0:17):
-- skipped globals
Paused:
Script wasm://wasm/a094dcfe byte offset 91: Wasm opcode 0x21
Script wasm://wasm/89d60696 byte offset 91: Wasm opcode 0x21
Scope:
at C (interpreted) (0:91):
- scope (global):
......@@ -97,7 +97,7 @@ at B (liftoff) (0:76):
- scope (global):
globals: "global#0": 42 (number)
- scope (local):
locals: "arg#0": 42 (number), "local#1": 0 (number), "local#2": 7.199999809265137 (number), "local#3": 0 (number), "local#4": 0 (number)
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "local#5": 0 (number)
stack: "0": 42 (number), "1": 3 (number)
at A (liftoff) (0:54):
- scope (global):
......@@ -110,7 +110,7 @@ at (anonymous) (0:17):
-- skipped globals
Paused:
Script wasm://wasm/a094dcfe byte offset 93: Wasm opcode 0xb
Script wasm://wasm/89d60696 byte offset 93: Wasm opcode 0xb
Scope:
at C (interpreted) (0:93):
- scope (global):
......@@ -122,7 +122,7 @@ at B (liftoff) (0:76):
- scope (global):
globals: "global#0": 42 (number)
- scope (local):
locals: "arg#0": 42 (number), "local#1": 0 (number), "local#2": 7.199999809265137 (number), "local#3": 0 (number), "local#4": 0 (number)
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "local#5": 0 (number)
stack: "0": 42 (number), "1": 3 (number)
at A (liftoff) (0:54):
- scope (global):
......
......@@ -84,7 +84,7 @@ async function instantiateWasm() {
builder.addFunction('B (liftoff)', kSig_v_i)
.addLocals(
{i32_count: 1, f32_count: 3},
{i32_count: 1, f32_count: 4},
['i32_arg', 'i32_local', 'f32_local', '0', '0'])
.addBody([
// Load a parameter and a constant onto the operand stack.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment