OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // Encode the function index as line number. | 614 // Encode the function index as line number. |
615 if (!line_key_.is_null()) { | 615 if (!line_key_.is_null()) { |
616 JSObject::AddProperty( | 616 JSObject::AddProperty( |
617 stack_frame, line_key_, | 617 stack_frame, line_key_, |
618 isolate_->factory()->NewNumberFromInt(frame->function_index()), NONE); | 618 isolate_->factory()->NewNumberFromInt(frame->function_index()), NONE); |
619 } | 619 } |
620 // Encode the byte offset as column. | 620 // Encode the byte offset as column. |
621 if (!column_key_.is_null()) { | 621 if (!column_key_.is_null()) { |
622 Code* code = frame->LookupCode(); | 622 Code* code = frame->LookupCode(); |
623 int offset = static_cast<int>(frame->pc() - code->instruction_start()); | 623 int offset = static_cast<int>(frame->pc() - code->instruction_start()); |
624 int position = code->SourcePosition(offset); | 624 int position = AbstractCode::cast(code)->SourcePosition(offset); |
625 // Make position 1-based. | 625 // Make position 1-based. |
626 if (position >= 0) ++position; | 626 if (position >= 0) ++position; |
627 JSObject::AddProperty(stack_frame, column_key_, | 627 JSObject::AddProperty(stack_frame, column_key_, |
628 isolate_->factory()->NewNumberFromInt(position), | 628 isolate_->factory()->NewNumberFromInt(position), |
629 NONE); | 629 NONE); |
630 } | 630 } |
631 | 631 |
632 return stack_frame; | 632 return stack_frame; |
633 } | 633 } |
634 | 634 |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 return ReThrow(thrown); | 1310 return ReThrow(thrown); |
1311 } | 1311 } |
1312 | 1312 |
1313 | 1313 |
1314 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1314 void Isolate::PrintCurrentStackTrace(FILE* out) { |
1315 StackTraceFrameIterator it(this); | 1315 StackTraceFrameIterator it(this); |
1316 while (!it.done()) { | 1316 while (!it.done()) { |
1317 HandleScope scope(this); | 1317 HandleScope scope(this); |
1318 // Find code position if recorded in relocation info. | 1318 // Find code position if recorded in relocation info. |
1319 StandardFrame* frame = it.frame(); | 1319 StandardFrame* frame = it.frame(); |
1320 int pos; | 1320 AbstractCode* abstract_code; |
| 1321 int code_offset; |
1321 if (frame->is_interpreted()) { | 1322 if (frame->is_interpreted()) { |
1322 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); | 1323 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); |
1323 pos = iframe->GetBytecodeArray()->SourcePosition( | 1324 abstract_code = AbstractCode::cast(iframe->GetBytecodeArray()); |
1324 iframe->GetBytecodeOffset()); | 1325 code_offset = iframe->GetBytecodeOffset(); |
1325 } else if (frame->is_java_script()) { | 1326 } else { |
| 1327 DCHECK(frame->is_java_script() || frame->is_wasm()); |
1326 Code* code = frame->LookupCode(); | 1328 Code* code = frame->LookupCode(); |
1327 int offset = static_cast<int>(frame->pc() - code->instruction_start()); | 1329 abstract_code = AbstractCode::cast(code); |
1328 pos = frame->LookupCode()->SourcePosition(offset); | 1330 code_offset = static_cast<int>(frame->pc() - code->instruction_start()); |
1329 } else { | |
1330 DCHECK(frame->is_wasm()); | |
1331 // TODO(clemensh): include wasm frames here | |
1332 continue; | |
1333 } | 1331 } |
| 1332 int pos = abstract_code->SourcePosition(code_offset); |
1334 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); | 1333 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); |
1335 Handle<Object> pos_obj(Smi::FromInt(pos), this); | 1334 Handle<Object> pos_obj(Smi::FromInt(pos), this); |
1336 // Fetch function and receiver. | 1335 // Fetch function and receiver. |
1337 Handle<JSFunction> fun(js_frame->function()); | 1336 Handle<JSFunction> fun(js_frame->function()); |
1338 Handle<Object> recv(js_frame->receiver(), this); | 1337 Handle<Object> recv(js_frame->receiver(), this); |
1339 // Advance to the next JavaScript frame and determine if the | 1338 // Advance to the next JavaScript frame and determine if the |
1340 // current frame is the top-level frame. | 1339 // current frame is the top-level frame. |
1341 it.Advance(); | 1340 it.Advance(); |
1342 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | 1341 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); |
1343 // Generate and print stack trace line. | 1342 // Generate and print stack trace line. |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3042 // Then check whether this scope intercepts. | 3041 // Then check whether this scope intercepts. |
3043 if ((flag & intercept_mask_)) { | 3042 if ((flag & intercept_mask_)) { |
3044 intercepted_flags_ |= flag; | 3043 intercepted_flags_ |= flag; |
3045 return true; | 3044 return true; |
3046 } | 3045 } |
3047 return false; | 3046 return false; |
3048 } | 3047 } |
3049 | 3048 |
3050 } // namespace internal | 3049 } // namespace internal |
3051 } // namespace v8 | 3050 } // namespace v8 |
OLD | NEW |