| Index: src/isolate.cc
|
| diff --git a/src/isolate.cc b/src/isolate.cc
|
| index edf92eec5cb8e84f7534337a4abfce1c1cb132a7..b8c0931b20eb46eb369ee55c8e8124b793745912 100644
|
| --- a/src/isolate.cc
|
| +++ b/src/isolate.cc
|
| @@ -387,60 +387,58 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
|
| case StackFrame::JAVA_SCRIPT:
|
| case StackFrame::OPTIMIZED:
|
| case StackFrame::INTERPRETED:
|
| - case StackFrame::BUILTIN: {
|
| - JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
|
| + case StackFrame::BUILTIN:
|
| + case StackFrame::WASM_COMPILED:
|
| + case StackFrame::WASM_INTERPRETED: {
|
| // Set initial size to the maximum inlining level + 1 for the outermost
|
| // function.
|
| List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
|
| - js_frame->Summarize(&frames);
|
| + StandardFrame::cast(frame)->Summarize(&frames);
|
| for (int i = frames.length() - 1; i >= 0; i--) {
|
| - Handle<JSFunction> fun = frames[i].function();
|
| - Handle<Object> recv = frames[i].receiver();
|
| - // Filter out internal frames that we do not want to show.
|
| - if (!IsVisibleInStackTrace(*fun, *caller, &seen_caller)) continue;
|
| - // Filter out frames from other security contexts.
|
| - if (!this->context()->HasSameSecurityTokenAs(fun->context())) {
|
| - continue;
|
| - }
|
| - elements = MaybeGrow(this, elements, cursor, cursor + 4);
|
| -
|
| - Handle<AbstractCode> abstract_code = frames[i].abstract_code();
|
| -
|
| - Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this);
|
| - // The stack trace API should not expose receivers and function
|
| - // objects on frames deeper than the top-most one with a strict mode
|
| - // function. The number of sloppy frames is stored as first element in
|
| - // the result array.
|
| - if (!encountered_strict_function) {
|
| - if (is_strict(fun->shared()->language_mode())) {
|
| - encountered_strict_function = true;
|
| - } else {
|
| - sloppy_frames++;
|
| + if (frames[i].is_javascript()) {
|
| + Handle<JSFunction> fun = frames[i].function();
|
| + Handle<Object> recv = frames[i].receiver();
|
| + // Filter out internal frames that we do not want to show.
|
| + if (!IsVisibleInStackTrace(*fun, *caller, &seen_caller)) continue;
|
| + // Filter out frames from other security contexts.
|
| + if (!this->context()->HasSameSecurityTokenAs(fun->context())) {
|
| + continue;
|
| + }
|
| + elements = MaybeGrow(this, elements, cursor, cursor + 4);
|
| +
|
| + Handle<AbstractCode> abstract_code = frames[i].abstract_code();
|
| +
|
| + Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this);
|
| + // The stack trace API should not expose receivers and function
|
| + // objects on frames deeper than the top-most one with a strict mode
|
| + // function. The number of sloppy frames is stored as first element
|
| + // in
|
| + // the result array.
|
| + if (!encountered_strict_function) {
|
| + if (is_strict(fun->shared()->language_mode())) {
|
| + encountered_strict_function = true;
|
| + } else {
|
| + sloppy_frames++;
|
| + }
|
| }
|
| + elements->set(cursor++, *recv);
|
| + elements->set(cursor++, *fun);
|
| + elements->set(cursor++, *abstract_code);
|
| + elements->set(cursor++, *offset);
|
| + frames_seen++;
|
| + } else {
|
| + DCHECK(frames[i].is_wasm());
|
| + elements = MaybeGrow(this, elements, cursor, cursor + 4);
|
| + elements->set(cursor++, *frames[i].wasm_object());
|
| + elements->set(cursor++,
|
| + Smi::FromInt(frames[i].wasm_function_index()));
|
| + elements->set(cursor++, *frames[i].abstract_code());
|
| + elements->set(cursor++, Smi::FromInt(frames[i].code_offset()));
|
| + frames_seen++;
|
| }
|
| - elements->set(cursor++, *recv);
|
| - elements->set(cursor++, *fun);
|
| - elements->set(cursor++, *abstract_code);
|
| - elements->set(cursor++, *offset);
|
| - frames_seen++;
|
| }
|
| } break;
|
|
|
| - case StackFrame::WASM: {
|
| - WasmFrame* wasm_frame = WasmFrame::cast(frame);
|
| - Code* code = wasm_frame->unchecked_code();
|
| - Handle<AbstractCode> abstract_code =
|
| - Handle<AbstractCode>(AbstractCode::cast(code));
|
| - int offset =
|
| - static_cast<int>(wasm_frame->pc() - code->instruction_start());
|
| - elements = MaybeGrow(this, elements, cursor, cursor + 4);
|
| - elements->set(cursor++, wasm_frame->wasm_obj());
|
| - elements->set(cursor++, Smi::FromInt(wasm_frame->function_index()));
|
| - elements->set(cursor++, *abstract_code);
|
| - elements->set(cursor++, Smi::FromInt(offset));
|
| - frames_seen++;
|
| - } break;
|
| -
|
| default:
|
| break;
|
| }
|
| @@ -540,9 +538,46 @@ class CaptureStackTraceHelper {
|
| }
|
|
|
| Handle<JSObject> NewStackFrameObject(FrameSummary& summ) {
|
| - int position = summ.abstract_code()->SourcePosition(summ.code_offset());
|
| - return NewStackFrameObject(summ.function(), position,
|
| - summ.is_constructor());
|
| + if (summ.is_javascript()) {
|
| + int position = summ.abstract_code()->SourcePosition(summ.code_offset());
|
| + return NewStackFrameObject(summ.function(), position,
|
| + summ.is_constructor());
|
| + }
|
| +
|
| + DCHECK(summ.is_wasm());
|
| + Handle<JSObject> stack_frame =
|
| + factory()->NewJSObject(isolate_->object_function());
|
| +
|
| + if (!function_key_.is_null()) {
|
| + Handle<String> name = wasm::GetWasmFunctionName(
|
| + isolate_, summ.wasm_object(), summ.wasm_function_index());
|
| + JSObject::AddProperty(stack_frame, function_key_, name, NONE);
|
| + }
|
| + // Encode the function index as line number.
|
| + if (!line_key_.is_null()) {
|
| + JSObject::AddProperty(
|
| + stack_frame, line_key_,
|
| + handle(Smi::FromInt(summ.wasm_function_index()), isolate_), NONE);
|
| + }
|
| + // Encode the byte offset as column.
|
| + if (!column_key_.is_null()) {
|
| + int position =
|
| + summ.abstract_code()->GetCode()->SourcePosition(summ.code_offset());
|
| + // Make position 1-based.
|
| + if (position >= 0) ++position;
|
| + JSObject::AddProperty(stack_frame, column_key_,
|
| + isolate_->factory()->NewNumberFromInt(position),
|
| + NONE);
|
| + }
|
| + if (!script_id_key_.is_null()) {
|
| + Script* script = summ.script();
|
| + // Null pointer can only happen during testing.
|
| + int script_id = script ? script->id() : -1;
|
| + JSObject::AddProperty(stack_frame, script_id_key_,
|
| + handle(Smi::FromInt(script_id), isolate_), NONE);
|
| + }
|
| +
|
| + return stack_frame;
|
| }
|
|
|
| Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position,
|
| @@ -601,42 +636,6 @@ class CaptureStackTraceHelper {
|
| return stack_frame;
|
| }
|
|
|
| - Handle<JSObject> NewStackFrameObject(WasmFrame* frame) {
|
| - Handle<JSObject> stack_frame =
|
| - factory()->NewJSObject(isolate_->object_function());
|
| -
|
| - if (!function_key_.is_null()) {
|
| - Handle<String> name = wasm::GetWasmFunctionName(
|
| - isolate_, handle(frame->wasm_obj(), isolate_),
|
| - frame->function_index());
|
| - JSObject::AddProperty(stack_frame, function_key_, name, NONE);
|
| - }
|
| - // Encode the function index as line number.
|
| - if (!line_key_.is_null()) {
|
| - JSObject::AddProperty(
|
| - stack_frame, line_key_,
|
| - isolate_->factory()->NewNumberFromInt(frame->function_index()), NONE);
|
| - }
|
| - // Encode the byte offset as column.
|
| - if (!column_key_.is_null()) {
|
| - 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);
|
| - }
|
| - if (!script_id_key_.is_null()) {
|
| - int script_id = frame->script()->id();
|
| - JSObject::AddProperty(stack_frame, script_id_key_,
|
| - handle(Smi::FromInt(script_id), isolate_), NONE);
|
| - }
|
| -
|
| - return stack_frame;
|
| - }
|
| -
|
| private:
|
| inline Factory* factory() { return isolate_->factory(); }
|
|
|
| @@ -717,25 +716,18 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
| int frames_seen = 0;
|
| for (StackTraceFrameIterator it(this); !it.done() && (frames_seen < limit);
|
| it.Advance()) {
|
| - StandardFrame* frame = it.frame();
|
| - if (frame->is_java_script()) {
|
| - // Set initial size to the maximum inlining level + 1 for the outermost
|
| - // function.
|
| - List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
|
| - JavaScriptFrame::cast(frame)->Summarize(&frames);
|
| - for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
|
| - Handle<JSFunction> fun = frames[i].function();
|
| - // Filter frames from other security contexts.
|
| - if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
|
| - !this->context()->HasSameSecurityTokenAs(fun->context()))
|
| - continue;
|
| - Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]);
|
| - stack_trace_elems->set(frames_seen, *new_frame_obj);
|
| - frames_seen++;
|
| - }
|
| - } else {
|
| - WasmFrame* wasm_frame = WasmFrame::cast(frame);
|
| - Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame);
|
| + // Set initial size to the maximum inlining level + 1 for the outermost
|
| + // function.
|
| + List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
|
| + it.frame()->Summarize(&frames);
|
| + for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
|
| + // Filter frames from other security contexts.
|
| + if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
|
| + frames[i].is_javascript() &&
|
| + !this->context()->HasSameSecurityTokenAs(
|
| + frames[i].function()->context()))
|
| + continue;
|
| + Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]);
|
| stack_trace_elems->set(frames_seen, *new_frame_obj);
|
| frames_seen++;
|
| }
|
|
|