Commit 9be47f57 authored by clemensh's avatar clemensh Committed by Commit bot

[wasm] Do also output WASM frames on detailed stack traces

Till now, they were just skipped. With this patch, they now show up in
the DevTools on uncaught Errors with function name <WASM> and no line
number or file name information (see new test case:
https://chromiumcodereview.appspot.com/1875083002).

R=jfb@chromium.org, titzer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1865553004

Cr-Commit-Position: refs/heads/master@{#35615}
parent 9c927d0f
......@@ -1333,6 +1333,16 @@ JSFunction* WasmFrame::function() const {
return *fun;
}
void WasmFrame::Summarize(List<FrameSummary>* functions) const {
DCHECK(functions->length() == 0);
Code* code = LookupCode();
int offset = static_cast<int>(pc() - code->instruction_start());
AbstractCode* abstract_code = AbstractCode::cast(code);
Handle<JSFunction> fun(function(), isolate());
FrameSummary summary(receiver(), *fun, abstract_code, offset, false);
functions->Add(summary);
}
void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); }
Address WasmFrame::GetCallerStackPointer() const {
......
......@@ -976,6 +976,8 @@ class WasmFrame : public StandardFrame {
JSFunction* function() const override;
void Summarize(List<FrameSummary>* frames) const override;
protected:
inline explicit WasmFrame(StackFrameIteratorBase* iterator);
......
......@@ -547,46 +547,60 @@ class CaptureStackTraceHelper {
Handle<JSObject> stack_frame =
factory()->NewJSObject(isolate_->object_function());
Handle<Script> script(Script::cast(fun->shared()->script()));
if (!line_key_.is_null()) {
int script_line_offset = script->line_offset();
int line_number = Script::GetLineNumber(script, position);
// line_number is already shifted by the script_line_offset.
int relative_line_number = line_number - script_line_offset;
if (!column_key_.is_null() && relative_line_number >= 0) {
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
int start = (relative_line_number == 0) ? 0 :
Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
int column_offset = position - start;
if (relative_line_number == 0) {
// For the case where the code is on the same line as the script
// tag.
column_offset += script->column_offset();
// TODO(clemensh): this can be changed to a DCHECK once also WASM frames
// define a script
if (!fun->shared()->script()->IsUndefined()) {
Handle<Script> script(Script::cast(fun->shared()->script()));
if (!line_key_.is_null()) {
int script_line_offset = script->line_offset();
int line_number = Script::GetLineNumber(script, position);
// line_number is already shifted by the script_line_offset.
int relative_line_number = line_number - script_line_offset;
if (!column_key_.is_null() && relative_line_number >= 0) {
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
int start = (relative_line_number == 0)
? 0
: Smi::cast(line_ends->get(relative_line_number - 1))
->value() +
1;
int column_offset = position - start;
if (relative_line_number == 0) {
// For the case where the code is on the same line as the script
// tag.
column_offset += script->column_offset();
}
JSObject::AddProperty(
stack_frame, column_key_,
handle(Smi::FromInt(column_offset + 1), isolate_), NONE);
}
JSObject::AddProperty(stack_frame, column_key_,
handle(Smi::FromInt(column_offset + 1), isolate_),
JSObject::AddProperty(stack_frame, line_key_,
handle(Smi::FromInt(line_number + 1), isolate_),
NONE);
}
JSObject::AddProperty(stack_frame, line_key_,
handle(Smi::FromInt(line_number + 1), isolate_),
NONE);
}
if (!script_id_key_.is_null()) {
JSObject::AddProperty(stack_frame, script_id_key_,
handle(Smi::FromInt(script->id()), isolate_), NONE);
}
if (!script_id_key_.is_null()) {
JSObject::AddProperty(stack_frame, script_id_key_,
handle(Smi::FromInt(script->id()), isolate_),
NONE);
}
if (!script_name_key_.is_null()) {
JSObject::AddProperty(stack_frame, script_name_key_,
handle(script->name(), isolate_), NONE);
}
if (!script_name_key_.is_null()) {
JSObject::AddProperty(stack_frame, script_name_key_,
handle(script->name(), isolate_), NONE);
}
if (!script_name_or_source_url_key_.is_null()) {
Handle<Object> result = Script::GetNameOrSourceURL(script);
JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result,
NONE);
if (!script_name_or_source_url_key_.is_null()) {
Handle<Object> result = Script::GetNameOrSourceURL(script);
JSObject::AddProperty(stack_frame, script_name_or_source_url_key_,
result, NONE);
}
if (!eval_key_.is_null()) {
Handle<Object> is_eval = factory()->ToBoolean(
script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE);
}
}
if (!function_key_.is_null()) {
......@@ -594,12 +608,6 @@ class CaptureStackTraceHelper {
JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE);
}
if (!eval_key_.is_null()) {
Handle<Object> is_eval = factory()->ToBoolean(
script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE);
}
if (!constructor_key_.is_null()) {
Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor);
JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj,
......
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