Chromium Code Reviews| Index: src/isolate.cc |
| diff --git a/src/isolate.cc b/src/isolate.cc |
| index 5876af004fc56d7be5cccb9e1d9b360e43c71f20..6beff10f196e3a3275d2c6d52fea30be307c7f86 100644 |
| --- a/src/isolate.cc |
| +++ b/src/isolate.cc |
| @@ -501,9 +501,12 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, |
| Handle<Object> recv(exit_frame->receiver(), this); |
| Handle<Code> code(exit_frame->LookupCode(), this); |
| - int offset = |
| + const int offset = |
| static_cast<int>(exit_frame->pc() - code->instruction_start()); |
| + // TODO(jgruber): The offset should be strictly non-negative. This is |
| + // not the case on win64_rel. Find out why. |
|
ulan
2016/08/30 10:15:56
Are planning to fix it before landing?
jgruber
2016/08/30 12:11:33
This was fixed already in https://codereview.chrom
|
| + |
| int flags = 0; |
| if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict; |
| if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor; |
| @@ -1395,36 +1398,20 @@ Object* Isolate::PromoteScheduledException() { |
| void Isolate::PrintCurrentStackTrace(FILE* out) { |
| - StackTraceFrameIterator it(this); |
| - while (!it.done()) { |
| + for (StackTraceFrameIterator it(this); !it.done(); it.Advance()) { |
| + if (!it.is_javascript()) continue; |
| + |
| HandleScope scope(this); |
| - // Find code position if recorded in relocation info. |
| - StandardFrame* frame = it.frame(); |
| - AbstractCode* abstract_code; |
| - int code_offset; |
| - if (frame->is_interpreted()) { |
| - InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); |
| - abstract_code = AbstractCode::cast(iframe->GetBytecodeArray()); |
| - code_offset = iframe->GetBytecodeOffset(); |
| - } else { |
| - DCHECK(frame->is_java_script() || frame->is_wasm()); |
| - Code* code = frame->LookupCode(); |
| - abstract_code = AbstractCode::cast(code); |
| - code_offset = static_cast<int>(frame->pc() - code->instruction_start()); |
| - } |
| - int pos = abstract_code->SourcePosition(code_offset); |
| - JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); |
| - Handle<Object> pos_obj(Smi::FromInt(pos), this); |
| - // Fetch function and receiver. |
| - Handle<JSFunction> fun(js_frame->function(), this); |
| - Handle<Object> recv(js_frame->receiver(), this); |
| - // Advance to the next JavaScript frame and determine if the |
| - // current frame is the top-level frame. |
| - it.Advance(); |
| - Handle<Object> is_top_level = factory()->ToBoolean(it.done()); |
| - // Generate and print stack trace line. |
| - Handle<String> line = |
| - Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
| + JavaScriptFrame* frame = it.javascript_frame(); |
| + |
| + Handle<Object> receiver(frame->receiver(), this); |
| + Handle<JSFunction> function(frame->function(), this); |
| + Handle<AbstractCode> code(AbstractCode::cast(frame->LookupCode()), this); |
| + const int offset = |
| + static_cast<int>(frame->pc() - code->instruction_start()); |
| + |
| + JSStackFrame site(this, receiver, function, code, offset); |
| + Handle<String> line = site.ToString().ToHandleChecked(); |
| if (line->length() > 0) { |
| line->PrintOn(out); |
| PrintF(out, "\n"); |