Commit b16d51ef authored by clemensh's avatar clemensh Committed by Commit bot

[wasm] Make reported "column number" 1-based

We report the byte offset as column number, but devtools assumes them
to be 1-based and subtracts one unconditionally before further
processing it. It's a bit unfortunate, but because of that we have to
just add 1 to the reported column number on the public StackTrace API.

R=ahaas@chromium.org, titzer@chromium.org
BUG=chromium:613110

Review-Url: https://codereview.chromium.org/2071563002
Cr-Commit-Position: refs/heads/master@{#37036}
parent d9bf520a
......@@ -621,6 +621,8 @@ class CaptureStackTraceHelper {
Code* code = frame->LookupCode();
int offset = static_cast<int>(frame->pc() - code->instruction_start());
int position = code->SourcePosition(offset);
// Make position 1-based.
if (position >= 0) ++position;
JSObject::AddProperty(stack_frame, column_key_,
isolate_->factory()->NewNumberFromInt(position),
NONE);
......
......@@ -141,8 +141,9 @@ RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
if (it.IsFound()) {
DCHECK(JSReceiver::GetDataProperty(&it)->IsSmi());
// Make column number 1-based here.
Maybe<bool> data_set = JSReceiver::SetDataProperty(
&it, handle(Smi::FromInt(byte_offset), isolate));
&it, handle(Smi::FromInt(byte_offset + 1), isolate));
DCHECK(data_set.IsJust() && data_set.FromJust() == true);
USE(data_set);
}
......
......@@ -110,12 +110,12 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
CHECK(returnObjMaybe.is_null());
// Line number is 1-based, with 0 == kNoLineNumberInfo.
// The column is 1-based, so add 1 to the actual byte offset.
ExceptionInfo expected_exceptions[] = {
{"a", 3, 8}, // -
{"js", 4, 2}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 1}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 3}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // -
{"callFn", 1, 24} // -
};
CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
......@@ -155,10 +155,10 @@ TEST(CollectDetailedWasmStack_WasmError) {
Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
CHECK(maybe_return_obj.is_null());
// Line number is 1-based, with 0 == kNoLineNumberInfo.
// The column is 1-based, so add 1 to the actual byte offset.
ExceptionInfo expected_exceptions[] = {
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 1}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 1}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // -
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // -
{"callFn", 1, 24} //-
};
CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
......
......@@ -88,8 +88,9 @@ TEST(Unreachable) {
Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
CHECK(returnObjMaybe.is_null());
// The column is 1-based, so add 1 to the actual byte offset.
ExceptionInfo expected_exceptions[] = {
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 1}, // --
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // --
{"callFn", 1, 24} // --
};
CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
......@@ -129,10 +130,10 @@ TEST(IllegalLoad) {
Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
CHECK(returnObjMaybe.is_null());
// Line number is 1-based, with 0 == kNoLineNumberInfo.
// The column is 1-based, so add 1 to the actual byte offset.
ExceptionInfo expected_exceptions[] = {
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 6}, // --
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // --
{"<WASM UNNAMED>", static_cast<int>(wasm_index), 7}, // --
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 3}, // --
{"callFn", 1, 24} // --
};
CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
......
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