[wasm] Change trace memory instr offset to be relative to module

Instead of {func-index}+{pc of instruction relative to function}, make
it {func-index}:{pc of instruction in module}. This is more consistent
with existing conventions
(https://webassembly.github.io/spec/web-api/index.html#conventions) and
other tools (like output of wasm-objdump).

Bug: v8:10773
Change-Id: I7ceecafd984e2d1adbb57266e1f7448762e23ac9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2842267
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74110}
This commit is contained in:
Ng Zhi An 2021-04-20 16:02:09 -07:00 committed by Commit Bot
parent 02820f3a08
commit c8f1b36d2b
4 changed files with 30 additions and 34 deletions

View File

@ -423,14 +423,10 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
frame->wasm_instance().memory_object().array_buffer().backing_store());
int func_index = frame->function_index();
int pos = frame->position();
// TODO(titzer): eliminate dependency on WasmModule definition here.
int func_start =
frame->wasm_instance().module()->functions[func_index].code.offset();
wasm::ExecutionTier tier = frame->wasm_code()->is_liftoff()
? wasm::ExecutionTier::kLiftoff
: wasm::ExecutionTier::kTurbofan;
wasm::TraceMemoryOperation(tier, info, func_index, pos - func_start,
mem_start);
wasm::TraceMemoryOperation(tier, info, func_index, pos, mem_start);
return ReadOnlyRoots(isolate).undefined_value();
}

View File

@ -50,7 +50,7 @@ void TraceMemoryOperation(base::Optional<ExecutionTier> tier,
}
const char* eng =
tier.has_value() ? ExecutionTierToString(tier.value()) : "?";
printf("%-11s func:%6d+0x%-6x%s %016" PRIuPTR " val: %s\n", eng, func_index,
printf("%-11s func:%6d:0x%-6x%s %016" PRIuPTR " val: %s\n", eng, func_index,
position, info->is_store ? " store to" : "load from", info->offset,
value.begin());
}

View File

@ -1,14 +1,14 @@
liftoff func: 0+0x3 load from 0000000000000004 val: i32:0 / 00000000
liftoff func: 1+0x3 load from 0000000000000001 val: i8:0 / 00
liftoff func: 3+0x5 store to 0000000000000004 val: i32:305419896 / 12345678
liftoff func: 0+0x3 load from 0000000000000002 val: i32:1450704896 / 56780000
liftoff func: 1+0x3 load from 0000000000000006 val: i8:52 / 34
liftoff func: 2+0x3 load from 0000000000000002 val: f32:68169720922112.000000 / 56780000
liftoff func: 4+0x5 store to 0000000000000004 val: i8:171 / ab
liftoff func: 0+0x3 load from 0000000000000002 val: i32:1454047232 / 56ab0000
liftoff func: 2+0x3 load from 0000000000000002 val: f32:94008244174848.000000 / 56ab0000
liftoff func: 6+0x7 store to 0000000000000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
liftoff func: 5+0x3 load from 0000000000000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
liftoff func: 7+0x3 load from 0000000000000004 val: i16:48879 / beef
liftoff func: 8+0x3 load from 0000000000000002 val: i64:-4688528683866062848 / beef0000beef0000
liftoff func: 9+0x3 load from 0000000000000002 val: f64:-0.000015 / beef0000beef0000
liftoff func: 0:0xab load from 0000000000000004 val: i32:0 / 00000000
liftoff func: 1:0xb4 load from 0000000000000001 val: i8:0 / 00
liftoff func: 3:0xc8 store to 0000000000000004 val: i32:305419896 / 12345678
liftoff func: 0:0xab load from 0000000000000002 val: i32:1450704896 / 56780000
liftoff func: 1:0xb4 load from 0000000000000006 val: i8:52 / 34
liftoff func: 2:0xbd load from 0000000000000002 val: f32:68169720922112.000000 / 56780000
liftoff func: 4:0xd2 store to 0000000000000004 val: i8:171 / ab
liftoff func: 0:0xab load from 0000000000000002 val: i32:1454047232 / 56ab0000
liftoff func: 2:0xbd load from 0000000000000002 val: f32:94008244174848.000000 / 56ab0000
liftoff func: 6:0xe8 store to 0000000000000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
liftoff func: 5:0xda load from 0000000000000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
liftoff func: 7:0xf1 load from 0000000000000004 val: i16:48879 / beef
liftoff func: 8:0xfa load from 0000000000000002 val: i64:-4688528683866062848 / beef0000beef0000
liftoff func: 9:0x103 load from 0000000000000002 val: f64:-0.000015 / beef0000beef0000

View File

@ -1,14 +1,14 @@
turbofan func: 0+0x3 load from 0000000000000004 val: i32:0 / 00000000
turbofan func: 1+0x3 load from 0000000000000001 val: i8:0 / 00
turbofan func: 3+0x5 store to 0000000000000004 val: i32:305419896 / 12345678
turbofan func: 0+0x3 load from 0000000000000002 val: i32:1450704896 / 56780000
turbofan func: 1+0x3 load from 0000000000000006 val: i8:52 / 34
turbofan func: 2+0x3 load from 0000000000000002 val: f32:68169720922112.000000 / 56780000
turbofan func: 4+0x5 store to 0000000000000004 val: i8:171 / ab
turbofan func: 0+0x3 load from 0000000000000002 val: i32:1454047232 / 56ab0000
turbofan func: 2+0x3 load from 0000000000000002 val: f32:94008244174848.000000 / 56ab0000
turbofan func: 6+0x7 store to 0000000000000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
turbofan func: 5+0x3 load from 0000000000000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
turbofan func: 7+0x3 load from 0000000000000004 val: i16:48879 / beef
turbofan func: 8+0x3 load from 0000000000000002 val: i64:-4688528683866062848 / beef0000beef0000
turbofan func: 9+0x3 load from 0000000000000002 val: f64:-0.000015 / beef0000beef0000
turbofan func: 0:0xab load from 0000000000000004 val: i32:0 / 00000000
turbofan func: 1:0xb4 load from 0000000000000001 val: i8:0 / 00
turbofan func: 3:0xc8 store to 0000000000000004 val: i32:305419896 / 12345678
turbofan func: 0:0xab load from 0000000000000002 val: i32:1450704896 / 56780000
turbofan func: 1:0xb4 load from 0000000000000006 val: i8:52 / 34
turbofan func: 2:0xbd load from 0000000000000002 val: f32:68169720922112.000000 / 56780000
turbofan func: 4:0xd2 store to 0000000000000004 val: i8:171 / ab
turbofan func: 0:0xab load from 0000000000000002 val: i32:1454047232 / 56ab0000
turbofan func: 2:0xbd load from 0000000000000002 val: f32:94008244174848.000000 / 56ab0000
turbofan func: 6:0xe8 store to 0000000000000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
turbofan func: 5:0xda load from 0000000000000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
turbofan func: 7:0xf1 load from 0000000000000004 val: i16:48879 / beef
turbofan func: 8:0xfa load from 0000000000000002 val: i64:-4688528683866062848 / beef0000beef0000
turbofan func: 9:0x103 load from 0000000000000002 val: f64:-0.000015 / beef0000beef0000