Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: src/isolate.cc

Issue 1909353002: [wasm] Make wasm info available on the stack trace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-3
Patch Set: more gcmole problems Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 STATIC_CHAR_VECTOR("functionName")); 532 STATIC_CHAR_VECTOR("functionName"));
534 } 533 }
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 }
542 if (options & StackTrace::kIsWasm) {
543 wasm_key_ =
544 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isWasm"));
545 }
546 if (options & StackTrace::kWasmByteOffset) {
547 wasm_offset_key_ = factory()->InternalizeOneByteString(
548 STATIC_CHAR_VECTOR("wasmByteOffset"));
549 }
550 if (options & StackTrace::kWasmObject) {
551 wasm_object_key_ =
552 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("wasmObject"));
553 }
554 }
555
556 Handle<JSObject> NewStackFrameObject(const FrameSummary& summ) {
557 int position = summ.abstract_code()->SourcePosition(summ.code_offset());
558 return NewStackFrameObject(summ.function(), position,
559 summ.is_constructor());
543 } 560 }
544 561
545 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, 562 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position,
546 bool is_constructor) { 563 bool is_constructor) {
547 Handle<JSObject> stack_frame = 564 Handle<JSObject> stack_frame =
548 factory()->NewJSObject(isolate_->object_function()); 565 factory()->NewJSObject(isolate_->object_function());
566 Handle<Script> script(Script::cast(fun->shared()->script()));
549 567
550 // TODO(clemensh): this can be changed to a DCHECK once also WASM frames 568 if (!line_key_.is_null()) {
551 // define a script 569 int script_line_offset = script->line_offset();
552 if (!fun->shared()->script()->IsUndefined()) { 570 int line_number = Script::GetLineNumber(script, position);
553 Handle<Script> script(Script::cast(fun->shared()->script())); 571 // line_number is already shifted by the script_line_offset.
554 572 int relative_line_number = line_number - script_line_offset;
555 if (!line_key_.is_null()) { 573 if (!column_key_.is_null() && relative_line_number >= 0) {
556 int script_line_offset = script->line_offset(); 574 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
557 int line_number = Script::GetLineNumber(script, position); 575 int start =
558 // line_number is already shifted by the script_line_offset. 576 (relative_line_number == 0)
559 int relative_line_number = line_number - script_line_offset; 577 ? 0
560 if (!column_key_.is_null() && relative_line_number >= 0) { 578 : Smi::cast(line_ends->get(relative_line_number - 1))->value() +
561 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 579 1;
562 int start = (relative_line_number == 0) 580 int column_offset = position - start;
563 ? 0 581 if (relative_line_number == 0) {
564 : Smi::cast(line_ends->get(relative_line_number - 1)) 582 // For the case where the code is on the same line as the script
565 ->value() + 583 // tag.
566 1; 584 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 } 585 }
577 JSObject::AddProperty(stack_frame, line_key_, 586 JSObject::AddProperty(stack_frame, column_key_,
578 handle(Smi::FromInt(line_number + 1), isolate_), 587 handle(Smi::FromInt(column_offset + 1), isolate_),
579 NONE); 588 NONE);
580 } 589 }
590 JSObject::AddProperty(stack_frame, line_key_,
591 handle(Smi::FromInt(line_number + 1), isolate_),
592 NONE);
593 }
581 594
582 if (!script_id_key_.is_null()) { 595 if (!script_id_key_.is_null()) {
583 JSObject::AddProperty(stack_frame, script_id_key_, 596 JSObject::AddProperty(stack_frame, script_id_key_,
584 handle(Smi::FromInt(script->id()), isolate_), 597 handle(Smi::FromInt(script->id()), isolate_), NONE);
585 NONE); 598 }
586 }
587 599
588 if (!script_name_key_.is_null()) { 600 if (!script_name_key_.is_null()) {
589 JSObject::AddProperty(stack_frame, script_name_key_, 601 JSObject::AddProperty(stack_frame, script_name_key_,
590 handle(script->name(), isolate_), NONE); 602 handle(script->name(), isolate_), NONE);
591 } 603 }
592 604
593 if (!script_name_or_source_url_key_.is_null()) { 605 if (!script_name_or_source_url_key_.is_null()) {
594 Handle<Object> result = Script::GetNameOrSourceURL(script); 606 Handle<Object> result = Script::GetNameOrSourceURL(script);
595 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, 607 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result,
596 result, NONE); 608 NONE);
597 } 609 }
598 610
599 if (!eval_key_.is_null()) { 611 if (!eval_key_.is_null()) {
600 Handle<Object> is_eval = factory()->ToBoolean( 612 Handle<Object> is_eval = factory()->ToBoolean(
601 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); 613 script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
602 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); 614 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE);
603 }
604 } 615 }
605 616
606 if (!function_key_.is_null()) { 617 if (!function_key_.is_null()) {
607 Handle<Object> fun_name = JSFunction::GetDebugName(fun); 618 Handle<Object> fun_name = JSFunction::GetDebugName(fun);
608 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); 619 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE);
609 } 620 }
610 621
611 if (!constructor_key_.is_null()) { 622 if (!constructor_key_.is_null()) {
612 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); 623 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor);
613 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, 624 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj,
614 NONE); 625 NONE);
615 } 626 }
616 627
628 if (!wasm_key_.is_null()) {
629 JSObject::AddProperty(stack_frame, wasm_key_,
630 isolate_->factory()->false_value(), NONE);
631 }
632 return stack_frame;
633 }
634
635 Handle<JSObject> NewStackFrameObject(WasmFrame* frame) {
636 Handle<JSObject> stack_frame =
637 factory()->NewJSObject(isolate_->object_function());
638
639 Handle<Code> code;
640 auto get_code = [&code, frame, this] {
641 if (code.is_null()) code = handle(frame->LookupCode(), isolate_);
642 return code;
643 };
644 if (!function_key_.is_null()) {
645 Handle<Object> fun_name =
646 handle(frame->function_name(get_code()), isolate_);
647 if (fun_name->IsUndefined())
648 fun_name = isolate_->factory()->InternalizeUtf8String(
649 Vector<const char>("<WASM>"));
650 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE);
651 }
652 if (!wasm_key_.is_null()) {
653 JSObject::AddProperty(stack_frame, wasm_key_,
654 isolate_->factory()->true_value(), NONE);
655 }
656 if (!wasm_offset_key_.is_null()) {
657 int offset = static_cast<int>(frame->pc() - code->instruction_start());
658 int position = get_code()->SourcePosition(offset);
659 JSObject::AddProperty(stack_frame, wasm_offset_key_,
660 isolate_->factory()->NewNumberFromInt(position),
661 NONE);
662 }
663 if (!wasm_object_key_.is_null()) {
664 JSObject::AddProperty(stack_frame, wasm_object_key_,
665 handle(frame->wasm_obj(get_code()), isolate_),
666 NONE);
667 }
668
617 return stack_frame; 669 return stack_frame;
618 } 670 }
619 671
620 private: 672 private:
621 inline Factory* factory() { return isolate_->factory(); } 673 inline Factory* factory() { return isolate_->factory(); }
622 674
623 Isolate* isolate_; 675 Isolate* isolate_;
624 Handle<String> column_key_; 676 Handle<String> column_key_;
625 Handle<String> line_key_; 677 Handle<String> line_key_;
626 Handle<String> script_id_key_; 678 Handle<String> script_id_key_;
627 Handle<String> script_name_key_; 679 Handle<String> script_name_key_;
628 Handle<String> script_name_or_source_url_key_; 680 Handle<String> script_name_or_source_url_key_;
629 Handle<String> function_key_; 681 Handle<String> function_key_;
630 Handle<String> eval_key_; 682 Handle<String> eval_key_;
631 Handle<String> constructor_key_; 683 Handle<String> constructor_key_;
684 Handle<String> wasm_key_;
685 Handle<String> wasm_offset_key_;
686 Handle<String> wasm_object_key_;
632 }; 687 };
633 688
634 689
635 int PositionFromStackTrace(Handle<FixedArray> elements, int index) { 690 int PositionFromStackTrace(Handle<FixedArray> elements, int index) {
636 DisallowHeapAllocation no_gc; 691 DisallowHeapAllocation no_gc;
637 Object* maybe_code = elements->get(index + 2); 692 Object* maybe_code = elements->get(index + 2);
638 if (maybe_code->IsSmi()) { 693 if (maybe_code->IsSmi()) {
639 return Smi::cast(maybe_code)->value(); 694 return Smi::cast(maybe_code)->value();
640 } else { 695 } else {
641 AbstractCode* abstract_code = AbstractCode::cast(maybe_code); 696 AbstractCode* abstract_code = AbstractCode::cast(maybe_code);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 739 }
685 740
686 741
687 Handle<JSArray> Isolate::CaptureCurrentStackTrace( 742 Handle<JSArray> Isolate::CaptureCurrentStackTrace(
688 int frame_limit, StackTrace::StackTraceOptions options) { 743 int frame_limit, StackTrace::StackTraceOptions options) {
689 CaptureStackTraceHelper helper(this, options); 744 CaptureStackTraceHelper helper(this, options);
690 745
691 // Ensure no negative values. 746 // Ensure no negative values.
692 int limit = Max(frame_limit, 0); 747 int limit = Max(frame_limit, 0);
693 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); 748 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit);
749 Handle<FixedArray> stack_trace_elems(
750 FixedArray::cast(stack_trace->elements()), this);
694 751
695 StackTraceFrameIterator it(this);
696 int frames_seen = 0; 752 int frames_seen = 0;
697 while (!it.done() && (frames_seen < limit)) { 753 for (StackTraceFrameIterator it(this); !it.done() && (frames_seen < limit);
754 it.Advance()) {
698 StandardFrame* frame = it.frame(); 755 StandardFrame* frame = it.frame();
699 // Set initial size to the maximum inlining level + 1 for the outermost 756 if (frame->is_java_script()) {
700 // function. 757 // Set initial size to the maximum inlining level + 1 for the outermost
701 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 758 // function.
702 frame->Summarize(&frames); 759 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
703 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 760 JavaScriptFrame::cast(frame)->Summarize(&frames);
704 Handle<JSFunction> fun = frames[i].function(); 761 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
705 // Filter frames from other security contexts. 762 Handle<JSFunction> fun = frames[i].function();
706 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && 763 // Filter frames from other security contexts.
707 !this->context()->HasSameSecurityTokenAs(fun->context())) continue; 764 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
708 int position = 765 !this->context()->HasSameSecurityTokenAs(fun->context()))
709 frames[i].abstract_code()->SourcePosition(frames[i].code_offset()); 766 continue;
710 Handle<JSObject> stack_frame = 767 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]);
711 helper.NewStackFrameObject(fun, position, frames[i].is_constructor()); 768 stack_trace_elems->set(frames_seen, *new_frame_obj);
712 769 frames_seen++;
713 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); 770 }
771 } else if (frame->is_wasm()) {
772 WasmFrame* wasm_frame = WasmFrame::cast(frame);
773 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame);
774 stack_trace_elems->set(frames_seen, *new_frame_obj);
714 frames_seen++; 775 frames_seen++;
715 } 776 }
716 it.Advance();
717 } 777 }
718 778
719 stack_trace->set_length(Smi::FromInt(frames_seen)); 779 stack_trace->set_length(Smi::FromInt(frames_seen));
720 return stack_trace; 780 return stack_trace;
721 } 781 }
722 782
723 783
724 void Isolate::PrintStack(FILE* out, PrintStackMode mode) { 784 void Isolate::PrintStack(FILE* out, PrintStackMode mode) {
725 if (stack_trace_nesting_level_ == 0) { 785 if (stack_trace_nesting_level_ == 0) {
726 stack_trace_nesting_level_++; 786 stack_trace_nesting_level_++;
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 StackTraceFrameIterator it(this); 1385 StackTraceFrameIterator it(this);
1326 while (!it.done()) { 1386 while (!it.done()) {
1327 HandleScope scope(this); 1387 HandleScope scope(this);
1328 // Find code position if recorded in relocation info. 1388 // Find code position if recorded in relocation info.
1329 StandardFrame* frame = it.frame(); 1389 StandardFrame* frame = it.frame();
1330 int pos; 1390 int pos;
1331 if (frame->is_interpreted()) { 1391 if (frame->is_interpreted()) {
1332 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); 1392 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame);
1333 pos = iframe->GetBytecodeArray()->SourcePosition( 1393 pos = iframe->GetBytecodeArray()->SourcePosition(
1334 iframe->GetBytecodeOffset()); 1394 iframe->GetBytecodeOffset());
1335 } else { 1395 } else if (frame->is_java_script()) {
1336 Code* code = frame->LookupCode(); 1396 Code* code = frame->LookupCode();
1337 int offset = static_cast<int>(frame->pc() - code->instruction_start()); 1397 int offset = static_cast<int>(frame->pc() - code->instruction_start());
1338 pos = frame->LookupCode()->SourcePosition(offset); 1398 pos = frame->LookupCode()->SourcePosition(offset);
1399 } else {
1400 // TODO(clemensh): include wasm frames here
1401 continue;
1339 } 1402 }
1403 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
1340 Handle<Object> pos_obj(Smi::FromInt(pos), this); 1404 Handle<Object> pos_obj(Smi::FromInt(pos), this);
1341 // Fetch function and receiver. 1405 // Fetch function and receiver.
1342 Handle<JSFunction> fun(frame->function()); 1406 Handle<JSFunction> fun(js_frame->function());
1343 Handle<Object> recv(frame->receiver(), this); 1407 Handle<Object> recv(js_frame->receiver(), this);
1344 // Advance to the next JavaScript frame and determine if the 1408 // Advance to the next JavaScript frame and determine if the
1345 // current frame is the top-level frame. 1409 // current frame is the top-level frame.
1346 it.Advance(); 1410 it.Advance();
1347 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); 1411 Handle<Object> is_top_level = factory()->ToBoolean(it.done());
1348 // Generate and print stack trace line. 1412 // Generate and print stack trace line.
1349 Handle<String> line = 1413 Handle<String> line =
1350 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); 1414 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level);
1351 if (line->length() > 0) { 1415 if (line->length() > 0) {
1352 line->PrintOn(out); 1416 line->PrintOn(out);
1353 PrintF(out, "\n"); 1417 PrintF(out, "\n");
1354 } 1418 }
1355 } 1419 }
1356 } 1420 }
1357 1421
1358
1359 bool Isolate::ComputeLocation(MessageLocation* target) { 1422 bool Isolate::ComputeLocation(MessageLocation* target) {
1360 StackTraceFrameIterator it(this); 1423 StackTraceFrameIterator it(this);
1361 if (!it.done()) { 1424 if (it.done()) return false;
1362 StandardFrame* frame = it.frame(); 1425 StandardFrame* frame = it.frame();
1363 JSFunction* fun = frame->function(); 1426 // TODO(clemensh): handle wasm frames
1364 Object* script = fun->shared()->script(); 1427 if (!frame->is_java_script()) return false;
1365 if (script->IsScript() && 1428 JSFunction* fun = JavaScriptFrame::cast(frame)->function();
1366 !(Script::cast(script)->source()->IsUndefined())) { 1429 Object* script = fun->shared()->script();
1367 Handle<Script> casted_script(Script::cast(script)); 1430 if (!script->IsScript() || (Script::cast(script)->source()->IsUndefined()))
1368 // Compute the location from the function and the relocation info of the 1431 return false;
1369 // baseline code. For optimized code this will use the deoptimization 1432 Handle<Script> casted_script(Script::cast(script));
1370 // information to get canonical location information. 1433 // Compute the location from the function and the relocation info of the
1371 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 1434 // baseline code. For optimized code this will use the deoptimization
1372 frame->Summarize(&frames); 1435 // information to get canonical location information.
1373 FrameSummary& summary = frames.last(); 1436 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
1374 int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); 1437 JavaScriptFrame::cast(frame)->Summarize(&frames);
1375 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); 1438 FrameSummary& summary = frames.last();
1376 return true; 1439 int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
1377 } 1440 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
1378 } 1441 return true;
1379 return false;
1380 } 1442 }
1381 1443
1382
1383 bool Isolate::ComputeLocationFromException(MessageLocation* target, 1444 bool Isolate::ComputeLocationFromException(MessageLocation* target,
1384 Handle<Object> exception) { 1445 Handle<Object> exception) {
1385 if (!exception->IsJSObject()) return false; 1446 if (!exception->IsJSObject()) return false;
1386 1447
1387 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); 1448 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol();
1388 Handle<Object> start_pos = JSReceiver::GetDataProperty( 1449 Handle<Object> start_pos = JSReceiver::GetDataProperty(
1389 Handle<JSObject>::cast(exception), start_pos_symbol); 1450 Handle<JSObject>::cast(exception), start_pos_symbol);
1390 if (!start_pos->IsSmi()) return false; 1451 if (!start_pos->IsSmi()) return false;
1391 int start_pos_value = Handle<Smi>::cast(start_pos)->value(); 1452 int start_pos_value = Handle<Smi>::cast(start_pos)->value();
1392 1453
(...skipping 20 matching lines...) Expand all
1413 Handle<Name> key = factory()->stack_trace_symbol(); 1474 Handle<Name> key = factory()->stack_trace_symbol();
1414 Handle<Object> property = 1475 Handle<Object> property =
1415 JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key); 1476 JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key);
1416 if (!property->IsJSArray()) return false; 1477 if (!property->IsJSArray()) return false;
1417 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 1478 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
1418 1479
1419 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); 1480 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements()));
1420 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); 1481 int elements_limit = Smi::cast(simple_stack_trace->length())->value();
1421 1482
1422 for (int i = 1; i < elements_limit; i += 4) { 1483 for (int i = 1; i < elements_limit; i += 4) {
1423 Handle<JSFunction> fun = 1484 Handle<Object> fun_obj = handle(elements->get(i + 1), this);
1424 handle(JSFunction::cast(elements->get(i + 1)), this); 1485 if (fun_obj->IsSmi()) {
1486 // TODO(clemensh): handle wasm frames
1487 return false;
1488 }
1489 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
1425 if (!fun->shared()->IsSubjectToDebugging()) continue; 1490 if (!fun->shared()->IsSubjectToDebugging()) continue;
1426 1491
1427 Object* script = fun->shared()->script(); 1492 Object* script = fun->shared()->script();
1428 if (script->IsScript() && 1493 if (script->IsScript() &&
1429 !(Script::cast(script)->source()->IsUndefined())) { 1494 !(Script::cast(script)->source()->IsUndefined())) {
1430 int pos = PositionFromStackTrace(elements, i); 1495 int pos = PositionFromStackTrace(elements, i);
1431 Handle<Script> casted_script(Script::cast(script)); 1496 Handle<Script> casted_script(Script::cast(script));
1432 *target = MessageLocation(casted_script, pos, pos + 1); 1497 *target = MessageLocation(casted_script, pos, pos + 1);
1433 return true; 1498 return true;
1434 } 1499 }
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 // Then check whether this scope intercepts. 3059 // Then check whether this scope intercepts.
2995 if ((flag & intercept_mask_)) { 3060 if ((flag & intercept_mask_)) {
2996 intercepted_flags_ |= flag; 3061 intercepted_flags_ |= flag;
2997 return true; 3062 return true;
2998 } 3063 }
2999 return false; 3064 return false;
3000 } 3065 }
3001 3066
3002 } // namespace internal 3067 } // namespace internal
3003 } // namespace v8 3068 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698