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/frames.h" | 5 #include "src/frames.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 external_callback_scope_->scope_address() < frame_->fp()) { | 318 external_callback_scope_->scope_address() < frame_->fp()) { |
319 // As long as the setup of a frame is not atomic, we may happen to be | 319 // As long as the setup of a frame is not atomic, we may happen to be |
320 // in an interval where an ExternalCallbackScope is already created, | 320 // in an interval where an ExternalCallbackScope is already created, |
321 // but the frame is not yet entered. So we are actually observing | 321 // but the frame is not yet entered. So we are actually observing |
322 // the previous frame. | 322 // the previous frame. |
323 // Skip all the ExternalCallbackScope's that are below the current fp. | 323 // Skip all the ExternalCallbackScope's that are below the current fp. |
324 last_callback_scope = external_callback_scope_; | 324 last_callback_scope = external_callback_scope_; |
325 external_callback_scope_ = external_callback_scope_->previous(); | 325 external_callback_scope_ = external_callback_scope_->previous(); |
326 } | 326 } |
327 if (frame_->is_java_script()) break; | 327 if (frame_->is_java_script()) break; |
328 if (frame_->is_exit()) { | 328 if (frame_->is_exit() || frame_->is_builtin_exit()) { |
329 // Some of the EXIT frames may have ExternalCallbackScope allocated on | 329 // Some of the EXIT frames may have ExternalCallbackScope allocated on |
330 // top of them. In that case the scope corresponds to the first EXIT | 330 // top of them. In that case the scope corresponds to the first EXIT |
331 // frame beneath it. There may be other EXIT frames on top of the | 331 // frame beneath it. There may be other EXIT frames on top of the |
332 // ExternalCallbackScope, just skip them as we cannot collect any useful | 332 // ExternalCallbackScope, just skip them as we cannot collect any useful |
333 // information about them. | 333 // information about them. |
334 if (last_callback_scope) { | 334 if (last_callback_scope) { |
335 frame_->state_.pc_address = | 335 frame_->state_.pc_address = |
336 last_callback_scope->callback_entrypoint_address(); | 336 last_callback_scope->callback_entrypoint_address(); |
337 } | 337 } |
338 break; | 338 break; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 DCHECK(marker->IsSmi()); | 481 DCHECK(marker->IsSmi()); |
482 StackFrame::Type candidate = | 482 StackFrame::Type candidate = |
483 static_cast<StackFrame::Type>(Smi::cast(marker)->value()); | 483 static_cast<StackFrame::Type>(Smi::cast(marker)->value()); |
484 switch (candidate) { | 484 switch (candidate) { |
485 case ENTRY: | 485 case ENTRY: |
486 case ENTRY_CONSTRUCT: | 486 case ENTRY_CONSTRUCT: |
487 case EXIT: | 487 case EXIT: |
| 488 case BUILTIN_EXIT: |
488 case STUB: | 489 case STUB: |
489 case STUB_FAILURE_TRAMPOLINE: | 490 case STUB_FAILURE_TRAMPOLINE: |
490 case INTERNAL: | 491 case INTERNAL: |
491 case CONSTRUCT: | 492 case CONSTRUCT: |
492 case ARGUMENTS_ADAPTOR: | 493 case ARGUMENTS_ADAPTOR: |
493 case WASM_TO_JS: | 494 case WASM_TO_JS: |
494 case WASM: | 495 case WASM: |
495 return candidate; | 496 return candidate; |
496 case JS_TO_WASM: | 497 case JS_TO_WASM: |
497 case JAVA_SCRIPT: | 498 case JAVA_SCRIPT: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 Code* EntryConstructFrame::unchecked_code() const { | 552 Code* EntryConstructFrame::unchecked_code() const { |
552 return isolate()->heap()->js_construct_entry_code(); | 553 return isolate()->heap()->js_construct_entry_code(); |
553 } | 554 } |
554 | 555 |
555 | 556 |
556 Object*& ExitFrame::code_slot() const { | 557 Object*& ExitFrame::code_slot() const { |
557 const int offset = ExitFrameConstants::kCodeOffset; | 558 const int offset = ExitFrameConstants::kCodeOffset; |
558 return Memory::Object_at(fp() + offset); | 559 return Memory::Object_at(fp() + offset); |
559 } | 560 } |
560 | 561 |
561 | |
562 Code* ExitFrame::unchecked_code() const { | 562 Code* ExitFrame::unchecked_code() const { |
563 return reinterpret_cast<Code*>(code_slot()); | 563 return reinterpret_cast<Code*>(code_slot()); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 void ExitFrame::ComputeCallerState(State* state) const { | 567 void ExitFrame::ComputeCallerState(State* state) const { |
568 // Set up the caller state. | 568 // Set up the caller state. |
569 state->sp = caller_sp(); | 569 state->sp = caller_sp(); |
570 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); | 570 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); |
571 state->pc_address = ResolveReturnAddressLocation( | 571 state->pc_address = ResolveReturnAddressLocation( |
(...skipping 21 matching lines...) Expand all Loading... |
593 Address ExitFrame::GetCallerStackPointer() const { | 593 Address ExitFrame::GetCallerStackPointer() const { |
594 return fp() + ExitFrameConstants::kCallerSPOffset; | 594 return fp() + ExitFrameConstants::kCallerSPOffset; |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { | 598 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { |
599 if (fp == 0) return NONE; | 599 if (fp == 0) return NONE; |
600 Address sp = ComputeStackPointer(fp); | 600 Address sp = ComputeStackPointer(fp); |
601 FillState(fp, sp, state); | 601 FillState(fp, sp, state); |
602 DCHECK(*state->pc_address != NULL); | 602 DCHECK(*state->pc_address != NULL); |
| 603 |
| 604 return ComputeFrameType(fp); |
| 605 } |
| 606 |
| 607 StackFrame::Type ExitFrame::ComputeFrameType(Address fp) { |
| 608 // Distinguish between between regular and builtin exit frames. |
| 609 // Default to EXIT in all hairy cases (e.g., when called from profiler). |
| 610 const int offset = ExitFrameConstants::kFrameTypeOffset; |
| 611 Object* marker = Memory::Object_at(fp + offset); |
| 612 |
| 613 if (!marker->IsSmi()) { |
| 614 return EXIT; |
| 615 } |
| 616 |
| 617 StackFrame::Type frame_type = |
| 618 static_cast<StackFrame::Type>(Smi::cast(marker)->value()); |
| 619 if (frame_type == EXIT || frame_type == BUILTIN_EXIT) { |
| 620 return frame_type; |
| 621 } |
| 622 |
603 return EXIT; | 623 return EXIT; |
604 } | 624 } |
605 | 625 |
606 Address ExitFrame::ComputeStackPointer(Address fp) { | 626 Address ExitFrame::ComputeStackPointer(Address fp) { |
607 MSAN_MEMORY_IS_INITIALIZED(fp + ExitFrameConstants::kSPOffset, kPointerSize); | 627 MSAN_MEMORY_IS_INITIALIZED(fp + ExitFrameConstants::kSPOffset, kPointerSize); |
608 return Memory::Address_at(fp + ExitFrameConstants::kSPOffset); | 628 return Memory::Address_at(fp + ExitFrameConstants::kSPOffset); |
609 } | 629 } |
610 | 630 |
611 void ExitFrame::FillState(Address fp, Address sp, State* state) { | 631 void ExitFrame::FillState(Address fp, Address sp, State* state) { |
612 state->sp = sp; | 632 state->sp = sp; |
613 state->fp = fp; | 633 state->fp = fp; |
614 state->pc_address = ResolveReturnAddressLocation( | 634 state->pc_address = ResolveReturnAddressLocation( |
615 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); | 635 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); |
616 // The constant pool recorded in the exit frame is not associated | 636 // The constant pool recorded in the exit frame is not associated |
617 // with the pc in this state (the return address into a C entry | 637 // with the pc in this state (the return address into a C entry |
618 // stub). ComputeCallerState will retrieve the constant pool | 638 // stub). ComputeCallerState will retrieve the constant pool |
619 // together with the associated caller pc. | 639 // together with the associated caller pc. |
620 state->constant_pool_address = NULL; | 640 state->constant_pool_address = NULL; |
621 } | 641 } |
622 | 642 |
| 643 JSFunction* BuiltinExitFrame::function() const { |
| 644 return JSFunction::cast(function_slot_object()); |
| 645 } |
| 646 |
623 Address StandardFrame::GetExpressionAddress(int n) const { | 647 Address StandardFrame::GetExpressionAddress(int n) const { |
624 const int offset = StandardFrameConstants::kExpressionsOffset; | 648 const int offset = StandardFrameConstants::kExpressionsOffset; |
625 return fp() + offset - n * kPointerSize; | 649 return fp() + offset - n * kPointerSize; |
626 } | 650 } |
627 | 651 |
628 Address InterpretedFrame::GetExpressionAddress(int n) const { | 652 Address InterpretedFrame::GetExpressionAddress(int n) const { |
629 const int offset = InterpreterFrameConstants::kExpressionsOffset; | 653 const int offset = InterpreterFrameConstants::kExpressionsOffset; |
630 return fp() + offset - n * kPointerSize; | 654 return fp() + offset - n * kPointerSize; |
631 } | 655 } |
632 | 656 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 int frame_header_size = StandardFrameConstants::kFixedFrameSizeFromFp; | 695 int frame_header_size = StandardFrameConstants::kFixedFrameSizeFromFp; |
672 Object* marker = | 696 Object* marker = |
673 Memory::Object_at(fp() + CommonFrameConstants::kContextOrFrameTypeOffset); | 697 Memory::Object_at(fp() + CommonFrameConstants::kContextOrFrameTypeOffset); |
674 if (marker->IsSmi()) { | 698 if (marker->IsSmi()) { |
675 StackFrame::Type candidate = | 699 StackFrame::Type candidate = |
676 static_cast<StackFrame::Type>(Smi::cast(marker)->value()); | 700 static_cast<StackFrame::Type>(Smi::cast(marker)->value()); |
677 switch (candidate) { | 701 switch (candidate) { |
678 case ENTRY: | 702 case ENTRY: |
679 case ENTRY_CONSTRUCT: | 703 case ENTRY_CONSTRUCT: |
680 case EXIT: | 704 case EXIT: |
| 705 case BUILTIN_EXIT: |
681 case STUB_FAILURE_TRAMPOLINE: | 706 case STUB_FAILURE_TRAMPOLINE: |
682 case ARGUMENTS_ADAPTOR: | 707 case ARGUMENTS_ADAPTOR: |
683 case STUB: | 708 case STUB: |
684 case INTERNAL: | 709 case INTERNAL: |
685 case CONSTRUCT: | 710 case CONSTRUCT: |
686 case JS_TO_WASM: | 711 case JS_TO_WASM: |
687 case WASM_TO_JS: | 712 case WASM_TO_JS: |
688 case WASM: | 713 case WASM: |
689 frame_header_size = TypedFrameConstants::kFixedFrameSizeFromFp; | 714 frame_header_size = TypedFrameConstants::kFixedFrameSizeFromFp; |
690 break; | 715 break; |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1816 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1792 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1817 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1793 list.Add(frame, zone); | 1818 list.Add(frame, zone); |
1794 } | 1819 } |
1795 return list.ToVector(); | 1820 return list.ToVector(); |
1796 } | 1821 } |
1797 | 1822 |
1798 | 1823 |
1799 } // namespace internal | 1824 } // namespace internal |
1800 } // namespace v8 | 1825 } // namespace v8 |
OLD | NEW |