Chromium Code Reviews| 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 elements->set(cursor++, *offset); | 426 elements->set(cursor++, *offset); |
| 427 frames_seen++; | 427 frames_seen++; |
| 428 } | 428 } |
| 429 } break; | 429 } break; |
| 430 | 430 |
| 431 case StackFrame::WASM: { | 431 case StackFrame::WASM: { |
| 432 WasmFrame* wasm_frame = WasmFrame::cast(frame); | 432 WasmFrame* wasm_frame = WasmFrame::cast(frame); |
| 433 Code* code = wasm_frame->unchecked_code(); | 433 Code* code = wasm_frame->unchecked_code(); |
| 434 Handle<AbstractCode> abstract_code = | 434 Handle<AbstractCode> abstract_code = |
| 435 Handle<AbstractCode>(AbstractCode::cast(code)); | 435 Handle<AbstractCode>(AbstractCode::cast(code)); |
| 436 Handle<JSFunction> fun = factory()->NewFunction( | 436 int offset = |
| 437 factory()->NewStringFromAsciiChecked("<WASM>")); | 437 static_cast<int>(wasm_frame->pc() - code->instruction_start()); |
| 438 elements = MaybeGrow(this, elements, cursor, cursor + 4); | 438 elements = MaybeGrow(this, elements, cursor, cursor + 4); |
| 439 // TODO(jfb) Pass module object. | 439 elements->set(cursor++, wasm_frame->wasm_obj()); |
| 440 elements->set(cursor++, *factory()->undefined_value()); | 440 elements->set(cursor++, Smi::FromInt(wasm_frame->function_index())); |
| 441 elements->set(cursor++, *fun); | |
| 442 elements->set(cursor++, *abstract_code); | 441 elements->set(cursor++, *abstract_code); |
| 443 elements->set(cursor++, Internals::IntToSmi(0)); | 442 elements->set(cursor++, Smi::FromInt(offset)); |
| 444 frames_seen++; | 443 frames_seen++; |
| 445 } break; | 444 } break; |
| 446 | 445 |
| 447 default: | 446 default: |
| 448 break; | 447 break; |
| 449 } | 448 } |
| 450 } | 449 } |
| 451 elements->set(0, Smi::FromInt(sloppy_frames)); | 450 elements->set(0, Smi::FromInt(sloppy_frames)); |
| 452 elements->Shrink(cursor); | 451 elements->Shrink(cursor); |
| 453 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); | 452 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 535 if (options & StackTrace::kIsEval) { | 534 if (options & StackTrace::kIsEval) { |
| 536 eval_key_ = | 535 eval_key_ = |
| 537 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); | 536 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); |
| 538 } | 537 } |
| 539 if (options & StackTrace::kIsConstructor) { | 538 if (options & StackTrace::kIsConstructor) { |
| 540 constructor_key_ = factory()->InternalizeOneByteString( | 539 constructor_key_ = factory()->InternalizeOneByteString( |
| 541 STATIC_CHAR_VECTOR("isConstructor")); | 540 STATIC_CHAR_VECTOR("isConstructor")); |
| 542 } | 541 } |
| 543 } | 542 } |
| 544 | 543 |
| 544 Handle<JSObject> NewStackFrameObject(FrameSummary& summ) { | |
|
Yang
2016/05/03 18:59:07
This seems to have just one caller. Can we inline
Clemens Hammacher
2016/05/04 09:06:20
We could, but I am not sure if it would make the c
| |
| 545 int position = summ.abstract_code()->SourcePosition(summ.code_offset()); | |
| 546 return NewStackFrameObject(summ.function(), position, | |
| 547 summ.is_constructor()); | |
| 548 } | |
| 549 | |
| 545 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, | 550 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, |
| 546 bool is_constructor) { | 551 bool is_constructor) { |
| 547 Handle<JSObject> stack_frame = | 552 Handle<JSObject> stack_frame = |
| 548 factory()->NewJSObject(isolate_->object_function()); | 553 factory()->NewJSObject(isolate_->object_function()); |
| 554 Handle<Script> script(Script::cast(fun->shared()->script())); | |
| 549 | 555 |
| 550 // TODO(clemensh): this can be changed to a DCHECK once also WASM frames | 556 if (!line_key_.is_null()) { |
| 551 // define a script | 557 int script_line_offset = script->line_offset(); |
| 552 if (!fun->shared()->script()->IsUndefined()) { | 558 int line_number = Script::GetLineNumber(script, position); |
| 553 Handle<Script> script(Script::cast(fun->shared()->script())); | 559 // line_number is already shifted by the script_line_offset. |
| 554 | 560 int relative_line_number = line_number - script_line_offset; |
| 555 if (!line_key_.is_null()) { | 561 if (!column_key_.is_null() && relative_line_number >= 0) { |
| 556 int script_line_offset = script->line_offset(); | 562 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| 557 int line_number = Script::GetLineNumber(script, position); | 563 int start = |
| 558 // line_number is already shifted by the script_line_offset. | 564 (relative_line_number == 0) |
| 559 int relative_line_number = line_number - script_line_offset; | 565 ? 0 |
| 560 if (!column_key_.is_null() && relative_line_number >= 0) { | 566 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + |
| 561 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 567 1; |
| 562 int start = (relative_line_number == 0) | 568 int column_offset = position - start; |
| 563 ? 0 | 569 if (relative_line_number == 0) { |
| 564 : Smi::cast(line_ends->get(relative_line_number - 1)) | 570 // For the case where the code is on the same line as the script |
|
Yang
2016/05/03 18:59:07
Can this comment fit on a single line?
Clemens Hammacher
2016/05/04 09:06:20
Done.
| |
| 565 ->value() + | 571 // tag. |
| 566 1; | 572 column_offset += script->column_offset(); |
| 567 int column_offset = position - start; | |
| 568 if (relative_line_number == 0) { | |
| 569 // For the case where the code is on the same line as the script | |
| 570 // tag. | |
| 571 column_offset += script->column_offset(); | |
| 572 } | |
| 573 JSObject::AddProperty( | |
| 574 stack_frame, column_key_, | |
| 575 handle(Smi::FromInt(column_offset + 1), isolate_), NONE); | |
| 576 } | 573 } |
| 577 JSObject::AddProperty(stack_frame, line_key_, | 574 JSObject::AddProperty(stack_frame, column_key_, |
| 578 handle(Smi::FromInt(line_number + 1), isolate_), | 575 handle(Smi::FromInt(column_offset + 1), isolate_), |
| 579 NONE); | 576 NONE); |
| 580 } | 577 } |
| 578 JSObject::AddProperty(stack_frame, line_key_, | |
| 579 handle(Smi::FromInt(line_number + 1), isolate_), | |
| 580 NONE); | |
| 581 } | |
| 581 | 582 |
| 582 if (!script_id_key_.is_null()) { | 583 if (!script_id_key_.is_null()) { |
| 583 JSObject::AddProperty(stack_frame, script_id_key_, | 584 JSObject::AddProperty(stack_frame, script_id_key_, |
| 584 handle(Smi::FromInt(script->id()), isolate_), | 585 handle(Smi::FromInt(script->id()), isolate_), NONE); |
| 585 NONE); | 586 } |
| 586 } | |
| 587 | 587 |
| 588 if (!script_name_key_.is_null()) { | 588 if (!script_name_key_.is_null()) { |
| 589 JSObject::AddProperty(stack_frame, script_name_key_, | 589 JSObject::AddProperty(stack_frame, script_name_key_, |
| 590 handle(script->name(), isolate_), NONE); | 590 handle(script->name(), isolate_), NONE); |
| 591 } | 591 } |
| 592 | 592 |
| 593 if (!script_name_or_source_url_key_.is_null()) { | 593 if (!script_name_or_source_url_key_.is_null()) { |
| 594 Handle<Object> result = Script::GetNameOrSourceURL(script); | 594 Handle<Object> result = Script::GetNameOrSourceURL(script); |
| 595 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, | 595 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result, |
| 596 result, NONE); | 596 NONE); |
| 597 } | 597 } |
| 598 | 598 |
| 599 if (!eval_key_.is_null()) { | 599 if (!eval_key_.is_null()) { |
| 600 Handle<Object> is_eval = factory()->ToBoolean( | 600 Handle<Object> is_eval = factory()->ToBoolean( |
| 601 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); | 601 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); |
| 602 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); | 602 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); |
| 603 } | |
| 604 } | 603 } |
| 605 | 604 |
| 606 if (!function_key_.is_null()) { | 605 if (!function_key_.is_null()) { |
| 607 Handle<Object> fun_name = JSFunction::GetDebugName(fun); | 606 Handle<Object> fun_name = JSFunction::GetDebugName(fun); |
| 608 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); | 607 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); |
| 609 } | 608 } |
| 610 | 609 |
| 611 if (!constructor_key_.is_null()) { | 610 if (!constructor_key_.is_null()) { |
| 612 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); | 611 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); |
| 613 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, | 612 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, |
| 614 NONE); | 613 NONE); |
| 615 } | 614 } |
| 615 return stack_frame; | |
| 616 } | |
| 617 | |
| 618 Handle<JSObject> NewStackFrameObject(WasmFrame* frame) { | |
| 619 Handle<JSObject> stack_frame = | |
| 620 factory()->NewJSObject(isolate_->object_function()); | |
| 621 | |
| 622 Handle<Code> code; | |
| 623 auto get_code = [&code, frame, this] { | |
|
Yang
2016/05/03 18:59:07
Let's not use a lambda here. In fact, I consider t
Clemens Hammacher
2016/05/04 09:06:20
With the change from above, this is now obsolete a
| |
| 624 if (code.is_null()) code = handle(frame->LookupCode(), isolate_); | |
| 625 return code; | |
| 626 }; | |
| 627 if (!function_key_.is_null()) { | |
| 628 Handle<Object> fun_name = | |
| 629 handle(frame->function_name(get_code()), isolate_); | |
| 630 if (fun_name->IsUndefined()) | |
| 631 fun_name = isolate_->factory()->InternalizeUtf8String( | |
| 632 Vector<const char>("<WASM>")); | |
| 633 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); | |
| 634 } | |
| 635 // Encode the function index as line number. | |
| 636 if (!line_key_.is_null()) { | |
| 637 JSObject::AddProperty(stack_frame, line_key_, | |
| 638 isolate_->factory()->NewNumberFromInt( | |
| 639 frame->function_index(get_code())), | |
| 640 NONE); | |
| 641 } | |
| 642 // Encode the byte offset as column. | |
| 643 if (!column_key_.is_null()) { | |
| 644 int offset = static_cast<int>(frame->pc() - code->instruction_start()); | |
| 645 int position = get_code()->SourcePosition(offset); | |
| 646 JSObject::AddProperty(stack_frame, column_key_, | |
| 647 isolate_->factory()->NewNumberFromInt(position), | |
| 648 NONE); | |
| 649 } | |
| 616 | 650 |
| 617 return stack_frame; | 651 return stack_frame; |
| 618 } | 652 } |
| 619 | 653 |
| 620 private: | 654 private: |
| 621 inline Factory* factory() { return isolate_->factory(); } | 655 inline Factory* factory() { return isolate_->factory(); } |
| 622 | 656 |
| 623 Isolate* isolate_; | 657 Isolate* isolate_; |
| 624 Handle<String> column_key_; | 658 Handle<String> column_key_; |
| 625 Handle<String> line_key_; | 659 Handle<String> line_key_; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 } | 718 } |
| 685 | 719 |
| 686 | 720 |
| 687 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 721 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
| 688 int frame_limit, StackTrace::StackTraceOptions options) { | 722 int frame_limit, StackTrace::StackTraceOptions options) { |
| 689 CaptureStackTraceHelper helper(this, options); | 723 CaptureStackTraceHelper helper(this, options); |
| 690 | 724 |
| 691 // Ensure no negative values. | 725 // Ensure no negative values. |
| 692 int limit = Max(frame_limit, 0); | 726 int limit = Max(frame_limit, 0); |
| 693 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 727 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
| 728 Handle<FixedArray> stack_trace_elems( | |
| 729 FixedArray::cast(stack_trace->elements()), this); | |
| 694 | 730 |
| 695 StackTraceFrameIterator it(this); | |
| 696 int frames_seen = 0; | 731 int frames_seen = 0; |
| 697 while (!it.done() && (frames_seen < limit)) { | 732 for (StackTraceFrameIterator it(this); !it.done() && (frames_seen < limit); |
| 733 it.Advance()) { | |
| 698 StandardFrame* frame = it.frame(); | 734 StandardFrame* frame = it.frame(); |
| 699 // Set initial size to the maximum inlining level + 1 for the outermost | 735 if (frame->is_java_script()) { |
| 700 // function. | 736 // Set initial size to the maximum inlining level + 1 for the outermost |
| 701 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 737 // function. |
| 702 frame->Summarize(&frames); | 738 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 703 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 739 JavaScriptFrame::cast(frame)->Summarize(&frames); |
| 704 Handle<JSFunction> fun = frames[i].function(); | 740 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
| 705 // Filter frames from other security contexts. | 741 Handle<JSFunction> fun = frames[i].function(); |
| 706 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && | 742 // Filter frames from other security contexts. |
| 707 !this->context()->HasSameSecurityTokenAs(fun->context())) continue; | 743 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && |
| 708 int position = | 744 !this->context()->HasSameSecurityTokenAs(fun->context())) |
| 709 frames[i].abstract_code()->SourcePosition(frames[i].code_offset()); | 745 continue; |
| 710 Handle<JSObject> stack_frame = | 746 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]); |
| 711 helper.NewStackFrameObject(fun, position, frames[i].is_constructor()); | 747 stack_trace_elems->set(frames_seen, *new_frame_obj); |
| 712 | 748 frames_seen++; |
| 713 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); | 749 } |
| 750 } else if (frame->is_wasm()) { | |
|
Yang
2016/05/03 18:59:07
Can the frame be not wasm at this point? How about
Clemens Hammacher
2016/05/04 09:06:20
You are right, it will always be wasm. I changed i
| |
| 751 WasmFrame* wasm_frame = WasmFrame::cast(frame); | |
| 752 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame); | |
| 753 stack_trace_elems->set(frames_seen, *new_frame_obj); | |
| 714 frames_seen++; | 754 frames_seen++; |
| 715 } | 755 } |
| 716 it.Advance(); | |
| 717 } | 756 } |
| 718 | 757 |
| 719 stack_trace->set_length(Smi::FromInt(frames_seen)); | 758 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 720 return stack_trace; | 759 return stack_trace; |
| 721 } | 760 } |
| 722 | 761 |
| 723 | 762 |
| 724 void Isolate::PrintStack(FILE* out, PrintStackMode mode) { | 763 void Isolate::PrintStack(FILE* out, PrintStackMode mode) { |
| 725 if (stack_trace_nesting_level_ == 0) { | 764 if (stack_trace_nesting_level_ == 0) { |
| 726 stack_trace_nesting_level_++; | 765 stack_trace_nesting_level_++; |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1325 StackTraceFrameIterator it(this); | 1364 StackTraceFrameIterator it(this); |
| 1326 while (!it.done()) { | 1365 while (!it.done()) { |
| 1327 HandleScope scope(this); | 1366 HandleScope scope(this); |
| 1328 // Find code position if recorded in relocation info. | 1367 // Find code position if recorded in relocation info. |
| 1329 StandardFrame* frame = it.frame(); | 1368 StandardFrame* frame = it.frame(); |
| 1330 int pos; | 1369 int pos; |
| 1331 if (frame->is_interpreted()) { | 1370 if (frame->is_interpreted()) { |
| 1332 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); | 1371 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); |
| 1333 pos = iframe->GetBytecodeArray()->SourcePosition( | 1372 pos = iframe->GetBytecodeArray()->SourcePosition( |
| 1334 iframe->GetBytecodeOffset()); | 1373 iframe->GetBytecodeOffset()); |
| 1335 } else { | 1374 } else if (frame->is_java_script()) { |
| 1336 Code* code = frame->LookupCode(); | 1375 Code* code = frame->LookupCode(); |
| 1337 int offset = static_cast<int>(frame->pc() - code->instruction_start()); | 1376 int offset = static_cast<int>(frame->pc() - code->instruction_start()); |
| 1338 pos = frame->LookupCode()->SourcePosition(offset); | 1377 pos = frame->LookupCode()->SourcePosition(offset); |
| 1378 } else { | |
| 1379 // TODO(clemensh): include wasm frames here | |
|
Yang
2016/05/03 18:59:07
add a DCHECK that this frame is wasm.
Clemens Hammacher
2016/05/04 09:06:20
Done.
| |
| 1380 continue; | |
| 1339 } | 1381 } |
| 1382 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); | |
| 1340 Handle<Object> pos_obj(Smi::FromInt(pos), this); | 1383 Handle<Object> pos_obj(Smi::FromInt(pos), this); |
| 1341 // Fetch function and receiver. | 1384 // Fetch function and receiver. |
| 1342 Handle<JSFunction> fun(frame->function()); | 1385 Handle<JSFunction> fun(js_frame->function()); |
| 1343 Handle<Object> recv(frame->receiver(), this); | 1386 Handle<Object> recv(js_frame->receiver(), this); |
| 1344 // Advance to the next JavaScript frame and determine if the | 1387 // Advance to the next JavaScript frame and determine if the |
| 1345 // current frame is the top-level frame. | 1388 // current frame is the top-level frame. |
| 1346 it.Advance(); | 1389 it.Advance(); |
| 1347 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | 1390 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); |
| 1348 // Generate and print stack trace line. | 1391 // Generate and print stack trace line. |
| 1349 Handle<String> line = | 1392 Handle<String> line = |
| 1350 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 1393 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
| 1351 if (line->length() > 0) { | 1394 if (line->length() > 0) { |
| 1352 line->PrintOn(out); | 1395 line->PrintOn(out); |
| 1353 PrintF(out, "\n"); | 1396 PrintF(out, "\n"); |
| 1354 } | 1397 } |
| 1355 } | 1398 } |
| 1356 } | 1399 } |
| 1357 | 1400 |
| 1358 | |
| 1359 bool Isolate::ComputeLocation(MessageLocation* target) { | 1401 bool Isolate::ComputeLocation(MessageLocation* target) { |
| 1360 StackTraceFrameIterator it(this); | 1402 StackTraceFrameIterator it(this); |
| 1361 if (!it.done()) { | 1403 if (it.done()) return false; |
| 1362 StandardFrame* frame = it.frame(); | 1404 StandardFrame* frame = it.frame(); |
| 1363 JSFunction* fun = frame->function(); | 1405 // TODO(clemensh): handle wasm frames |
| 1364 Object* script = fun->shared()->script(); | 1406 if (!frame->is_java_script()) return false; |
| 1365 if (script->IsScript() && | 1407 JSFunction* fun = JavaScriptFrame::cast(frame)->function(); |
| 1366 !(Script::cast(script)->source()->IsUndefined())) { | 1408 Object* script = fun->shared()->script(); |
| 1367 Handle<Script> casted_script(Script::cast(script)); | 1409 if (!script->IsScript() || (Script::cast(script)->source()->IsUndefined())) |
|
Yang
2016/05/03 18:59:07
add brackets around if-body on line break.
Clemens Hammacher
2016/05/04 09:06:20
Done.
| |
| 1368 // Compute the location from the function and the relocation info of the | 1410 return false; |
| 1369 // baseline code. For optimized code this will use the deoptimization | 1411 Handle<Script> casted_script(Script::cast(script)); |
| 1370 // information to get canonical location information. | 1412 // Compute the location from the function and the relocation info of the |
| 1371 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 1413 // baseline code. For optimized code this will use the deoptimization |
| 1372 frame->Summarize(&frames); | 1414 // information to get canonical location information. |
| 1373 FrameSummary& summary = frames.last(); | 1415 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 1374 int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); | 1416 JavaScriptFrame::cast(frame)->Summarize(&frames); |
| 1375 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); | 1417 FrameSummary& summary = frames.last(); |
| 1376 return true; | 1418 int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); |
| 1377 } | 1419 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); |
| 1378 } | 1420 return true; |
| 1379 return false; | |
| 1380 } | 1421 } |
| 1381 | 1422 |
| 1382 | |
| 1383 bool Isolate::ComputeLocationFromException(MessageLocation* target, | 1423 bool Isolate::ComputeLocationFromException(MessageLocation* target, |
| 1384 Handle<Object> exception) { | 1424 Handle<Object> exception) { |
| 1385 if (!exception->IsJSObject()) return false; | 1425 if (!exception->IsJSObject()) return false; |
| 1386 | 1426 |
| 1387 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); | 1427 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); |
| 1388 Handle<Object> start_pos = JSReceiver::GetDataProperty( | 1428 Handle<Object> start_pos = JSReceiver::GetDataProperty( |
| 1389 Handle<JSObject>::cast(exception), start_pos_symbol); | 1429 Handle<JSObject>::cast(exception), start_pos_symbol); |
| 1390 if (!start_pos->IsSmi()) return false; | 1430 if (!start_pos->IsSmi()) return false; |
| 1391 int start_pos_value = Handle<Smi>::cast(start_pos)->value(); | 1431 int start_pos_value = Handle<Smi>::cast(start_pos)->value(); |
| 1392 | 1432 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1413 Handle<Name> key = factory()->stack_trace_symbol(); | 1453 Handle<Name> key = factory()->stack_trace_symbol(); |
| 1414 Handle<Object> property = | 1454 Handle<Object> property = |
| 1415 JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key); | 1455 JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key); |
| 1416 if (!property->IsJSArray()) return false; | 1456 if (!property->IsJSArray()) return false; |
| 1417 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); | 1457 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); |
| 1418 | 1458 |
| 1419 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); | 1459 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); |
| 1420 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); | 1460 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); |
| 1421 | 1461 |
| 1422 for (int i = 1; i < elements_limit; i += 4) { | 1462 for (int i = 1; i < elements_limit; i += 4) { |
| 1423 Handle<JSFunction> fun = | 1463 Handle<Object> fun_obj = handle(elements->get(i + 1), this); |
| 1424 handle(JSFunction::cast(elements->get(i + 1)), this); | 1464 if (fun_obj->IsSmi()) { |
| 1465 // TODO(clemensh): handle wasm frames | |
| 1466 return false; | |
| 1467 } | |
| 1468 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); | |
| 1425 if (!fun->shared()->IsSubjectToDebugging()) continue; | 1469 if (!fun->shared()->IsSubjectToDebugging()) continue; |
| 1426 | 1470 |
| 1427 Object* script = fun->shared()->script(); | 1471 Object* script = fun->shared()->script(); |
| 1428 if (script->IsScript() && | 1472 if (script->IsScript() && |
| 1429 !(Script::cast(script)->source()->IsUndefined())) { | 1473 !(Script::cast(script)->source()->IsUndefined())) { |
| 1430 int pos = PositionFromStackTrace(elements, i); | 1474 int pos = PositionFromStackTrace(elements, i); |
| 1431 Handle<Script> casted_script(Script::cast(script)); | 1475 Handle<Script> casted_script(Script::cast(script)); |
| 1432 *target = MessageLocation(casted_script, pos, pos + 1); | 1476 *target = MessageLocation(casted_script, pos, pos + 1); |
| 1433 return true; | 1477 return true; |
| 1434 } | 1478 } |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2999 // Then check whether this scope intercepts. | 3043 // Then check whether this scope intercepts. |
| 3000 if ((flag & intercept_mask_)) { | 3044 if ((flag & intercept_mask_)) { |
| 3001 intercepted_flags_ |= flag; | 3045 intercepted_flags_ |= flag; |
| 3002 return true; | 3046 return true; |
| 3003 } | 3047 } |
| 3004 return false; | 3048 return false; |
| 3005 } | 3049 } |
| 3006 | 3050 |
| 3007 } // namespace internal | 3051 } // namespace internal |
| 3008 } // namespace v8 | 3052 } // namespace v8 |
| OLD | NEW |