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 #ifndef V8_FRAMES_H_ | 5 #ifndef V8_FRAMES_H_ |
6 #define V8_FRAMES_H_ | 6 #define V8_FRAMES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/safepoint-table.h" | 10 #include "src/safepoint-table.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 class EntryFrame: public StackFrame { | 364 class EntryFrame: public StackFrame { |
365 public: | 365 public: |
366 virtual Type type() const { return ENTRY; } | 366 virtual Type type() const { return ENTRY; } |
367 | 367 |
368 virtual Code* unchecked_code() const; | 368 virtual Code* unchecked_code() const; |
369 | 369 |
370 // Garbage collection support. | 370 // Garbage collection support. |
371 virtual void Iterate(ObjectVisitor* v) const; | 371 virtual void Iterate(ObjectVisitor* v) const; |
372 | 372 |
373 static EntryFrame* cast(StackFrame* frame) { | 373 static EntryFrame* cast(StackFrame* frame) { |
374 ASSERT(frame->is_entry()); | 374 DCHECK(frame->is_entry()); |
375 return static_cast<EntryFrame*>(frame); | 375 return static_cast<EntryFrame*>(frame); |
376 } | 376 } |
377 virtual void SetCallerFp(Address caller_fp); | 377 virtual void SetCallerFp(Address caller_fp); |
378 | 378 |
379 protected: | 379 protected: |
380 inline explicit EntryFrame(StackFrameIteratorBase* iterator); | 380 inline explicit EntryFrame(StackFrameIteratorBase* iterator); |
381 | 381 |
382 // The caller stack pointer for entry frames is always zero. The | 382 // The caller stack pointer for entry frames is always zero. The |
383 // real information about the caller frame is available through the | 383 // real information about the caller frame is available through the |
384 // link to the top exit frame. | 384 // link to the top exit frame. |
385 virtual Address GetCallerStackPointer() const { return 0; } | 385 virtual Address GetCallerStackPointer() const { return 0; } |
386 | 386 |
387 private: | 387 private: |
388 virtual void ComputeCallerState(State* state) const; | 388 virtual void ComputeCallerState(State* state) const; |
389 virtual Type GetCallerState(State* state) const; | 389 virtual Type GetCallerState(State* state) const; |
390 | 390 |
391 friend class StackFrameIteratorBase; | 391 friend class StackFrameIteratorBase; |
392 }; | 392 }; |
393 | 393 |
394 | 394 |
395 class EntryConstructFrame: public EntryFrame { | 395 class EntryConstructFrame: public EntryFrame { |
396 public: | 396 public: |
397 virtual Type type() const { return ENTRY_CONSTRUCT; } | 397 virtual Type type() const { return ENTRY_CONSTRUCT; } |
398 | 398 |
399 virtual Code* unchecked_code() const; | 399 virtual Code* unchecked_code() const; |
400 | 400 |
401 static EntryConstructFrame* cast(StackFrame* frame) { | 401 static EntryConstructFrame* cast(StackFrame* frame) { |
402 ASSERT(frame->is_entry_construct()); | 402 DCHECK(frame->is_entry_construct()); |
403 return static_cast<EntryConstructFrame*>(frame); | 403 return static_cast<EntryConstructFrame*>(frame); |
404 } | 404 } |
405 | 405 |
406 protected: | 406 protected: |
407 inline explicit EntryConstructFrame(StackFrameIteratorBase* iterator); | 407 inline explicit EntryConstructFrame(StackFrameIteratorBase* iterator); |
408 | 408 |
409 private: | 409 private: |
410 friend class StackFrameIteratorBase; | 410 friend class StackFrameIteratorBase; |
411 }; | 411 }; |
412 | 412 |
413 | 413 |
414 // Exit frames are used to exit JavaScript execution and go to C. | 414 // Exit frames are used to exit JavaScript execution and go to C. |
415 class ExitFrame: public StackFrame { | 415 class ExitFrame: public StackFrame { |
416 public: | 416 public: |
417 virtual Type type() const { return EXIT; } | 417 virtual Type type() const { return EXIT; } |
418 | 418 |
419 virtual Code* unchecked_code() const; | 419 virtual Code* unchecked_code() const; |
420 | 420 |
421 Object*& code_slot() const; | 421 Object*& code_slot() const; |
422 Object*& constant_pool_slot() const; | 422 Object*& constant_pool_slot() const; |
423 | 423 |
424 // Garbage collection support. | 424 // Garbage collection support. |
425 virtual void Iterate(ObjectVisitor* v) const; | 425 virtual void Iterate(ObjectVisitor* v) const; |
426 | 426 |
427 virtual void SetCallerFp(Address caller_fp); | 427 virtual void SetCallerFp(Address caller_fp); |
428 | 428 |
429 static ExitFrame* cast(StackFrame* frame) { | 429 static ExitFrame* cast(StackFrame* frame) { |
430 ASSERT(frame->is_exit()); | 430 DCHECK(frame->is_exit()); |
431 return static_cast<ExitFrame*>(frame); | 431 return static_cast<ExitFrame*>(frame); |
432 } | 432 } |
433 | 433 |
434 // Compute the state and type of an exit frame given a frame | 434 // Compute the state and type of an exit frame given a frame |
435 // pointer. Used when constructing the first stack frame seen by an | 435 // pointer. Used when constructing the first stack frame seen by an |
436 // iterator and the frames following entry frames. | 436 // iterator and the frames following entry frames. |
437 static Type GetStateForFramePointer(Address fp, State* state); | 437 static Type GetStateForFramePointer(Address fp, State* state); |
438 static Address ComputeStackPointer(Address fp); | 438 static Address ComputeStackPointer(Address fp); |
439 static void FillState(Address fp, Address sp, State* state); | 439 static void FillState(Address fp, Address sp, State* state); |
440 | 440 |
(...skipping 19 matching lines...) Expand all Loading... |
460 | 460 |
461 // Access the expressions in the stack frame including locals. | 461 // Access the expressions in the stack frame including locals. |
462 inline Object* GetExpression(int index) const; | 462 inline Object* GetExpression(int index) const; |
463 inline void SetExpression(int index, Object* value); | 463 inline void SetExpression(int index, Object* value); |
464 int ComputeExpressionsCount() const; | 464 int ComputeExpressionsCount() const; |
465 static Object* GetExpression(Address fp, int index); | 465 static Object* GetExpression(Address fp, int index); |
466 | 466 |
467 virtual void SetCallerFp(Address caller_fp); | 467 virtual void SetCallerFp(Address caller_fp); |
468 | 468 |
469 static StandardFrame* cast(StackFrame* frame) { | 469 static StandardFrame* cast(StackFrame* frame) { |
470 ASSERT(frame->is_standard()); | 470 DCHECK(frame->is_standard()); |
471 return static_cast<StandardFrame*>(frame); | 471 return static_cast<StandardFrame*>(frame); |
472 } | 472 } |
473 | 473 |
474 protected: | 474 protected: |
475 inline explicit StandardFrame(StackFrameIteratorBase* iterator); | 475 inline explicit StandardFrame(StackFrameIteratorBase* iterator); |
476 | 476 |
477 virtual void ComputeCallerState(State* state) const; | 477 virtual void ComputeCallerState(State* state) const; |
478 | 478 |
479 // Accessors. | 479 // Accessors. |
480 inline Address caller_fp() const; | 480 inline Address caller_fp() const; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 | 603 |
604 // Build a list with summaries for this frame including all inlined frames. | 604 // Build a list with summaries for this frame including all inlined frames. |
605 virtual void Summarize(List<FrameSummary>* frames); | 605 virtual void Summarize(List<FrameSummary>* frames); |
606 | 606 |
607 // Architecture-specific register description. | 607 // Architecture-specific register description. |
608 static Register fp_register(); | 608 static Register fp_register(); |
609 static Register context_register(); | 609 static Register context_register(); |
610 static Register constant_pool_pointer_register(); | 610 static Register constant_pool_pointer_register(); |
611 | 611 |
612 static JavaScriptFrame* cast(StackFrame* frame) { | 612 static JavaScriptFrame* cast(StackFrame* frame) { |
613 ASSERT(frame->is_java_script()); | 613 DCHECK(frame->is_java_script()); |
614 return static_cast<JavaScriptFrame*>(frame); | 614 return static_cast<JavaScriptFrame*>(frame); |
615 } | 615 } |
616 | 616 |
617 static void PrintFunctionAndOffset(JSFunction* function, Code* code, | 617 static void PrintFunctionAndOffset(JSFunction* function, Code* code, |
618 Address pc, FILE* file, | 618 Address pc, FILE* file, |
619 bool print_line_number); | 619 bool print_line_number); |
620 | 620 |
621 static void PrintTop(Isolate* isolate, FILE* file, bool print_args, | 621 static void PrintTop(Isolate* isolate, FILE* file, bool print_args, |
622 bool print_line_number); | 622 bool print_line_number); |
623 | 623 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // JavaScript frames when the actual number of parameters does not | 692 // JavaScript frames when the actual number of parameters does not |
693 // match the formal number of parameters. | 693 // match the formal number of parameters. |
694 class ArgumentsAdaptorFrame: public JavaScriptFrame { | 694 class ArgumentsAdaptorFrame: public JavaScriptFrame { |
695 public: | 695 public: |
696 virtual Type type() const { return ARGUMENTS_ADAPTOR; } | 696 virtual Type type() const { return ARGUMENTS_ADAPTOR; } |
697 | 697 |
698 // Determine the code for the frame. | 698 // Determine the code for the frame. |
699 virtual Code* unchecked_code() const; | 699 virtual Code* unchecked_code() const; |
700 | 700 |
701 static ArgumentsAdaptorFrame* cast(StackFrame* frame) { | 701 static ArgumentsAdaptorFrame* cast(StackFrame* frame) { |
702 ASSERT(frame->is_arguments_adaptor()); | 702 DCHECK(frame->is_arguments_adaptor()); |
703 return static_cast<ArgumentsAdaptorFrame*>(frame); | 703 return static_cast<ArgumentsAdaptorFrame*>(frame); |
704 } | 704 } |
705 | 705 |
706 // Printing support. | 706 // Printing support. |
707 virtual void Print(StringStream* accumulator, | 707 virtual void Print(StringStream* accumulator, |
708 PrintMode mode, | 708 PrintMode mode, |
709 int index) const; | 709 int index) const; |
710 | 710 |
711 protected: | 711 protected: |
712 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); | 712 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); |
(...skipping 11 matching lines...) Expand all Loading... |
724 public: | 724 public: |
725 virtual Type type() const { return INTERNAL; } | 725 virtual Type type() const { return INTERNAL; } |
726 | 726 |
727 // Garbage collection support. | 727 // Garbage collection support. |
728 virtual void Iterate(ObjectVisitor* v) const; | 728 virtual void Iterate(ObjectVisitor* v) const; |
729 | 729 |
730 // Determine the code for the frame. | 730 // Determine the code for the frame. |
731 virtual Code* unchecked_code() const; | 731 virtual Code* unchecked_code() const; |
732 | 732 |
733 static InternalFrame* cast(StackFrame* frame) { | 733 static InternalFrame* cast(StackFrame* frame) { |
734 ASSERT(frame->is_internal()); | 734 DCHECK(frame->is_internal()); |
735 return static_cast<InternalFrame*>(frame); | 735 return static_cast<InternalFrame*>(frame); |
736 } | 736 } |
737 | 737 |
738 protected: | 738 protected: |
739 inline explicit InternalFrame(StackFrameIteratorBase* iterator); | 739 inline explicit InternalFrame(StackFrameIteratorBase* iterator); |
740 | 740 |
741 virtual Address GetCallerStackPointer() const; | 741 virtual Address GetCallerStackPointer() const; |
742 | 742 |
743 private: | 743 private: |
744 friend class StackFrameIteratorBase; | 744 friend class StackFrameIteratorBase; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 }; | 779 }; |
780 | 780 |
781 | 781 |
782 // Construct frames are special trampoline frames introduced to handle | 782 // Construct frames are special trampoline frames introduced to handle |
783 // function invocations through 'new'. | 783 // function invocations through 'new'. |
784 class ConstructFrame: public InternalFrame { | 784 class ConstructFrame: public InternalFrame { |
785 public: | 785 public: |
786 virtual Type type() const { return CONSTRUCT; } | 786 virtual Type type() const { return CONSTRUCT; } |
787 | 787 |
788 static ConstructFrame* cast(StackFrame* frame) { | 788 static ConstructFrame* cast(StackFrame* frame) { |
789 ASSERT(frame->is_construct()); | 789 DCHECK(frame->is_construct()); |
790 return static_cast<ConstructFrame*>(frame); | 790 return static_cast<ConstructFrame*>(frame); |
791 } | 791 } |
792 | 792 |
793 protected: | 793 protected: |
794 inline explicit ConstructFrame(StackFrameIteratorBase* iterator); | 794 inline explicit ConstructFrame(StackFrameIteratorBase* iterator); |
795 | 795 |
796 private: | 796 private: |
797 friend class StackFrameIteratorBase; | 797 friend class StackFrameIteratorBase; |
798 }; | 798 }; |
799 | 799 |
(...skipping 10 matching lines...) Expand all Loading... |
810 | 810 |
811 Isolate* isolate_; | 811 Isolate* isolate_; |
812 #define DECLARE_SINGLETON(ignore, type) type type##_; | 812 #define DECLARE_SINGLETON(ignore, type) type type##_; |
813 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) | 813 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) |
814 #undef DECLARE_SINGLETON | 814 #undef DECLARE_SINGLETON |
815 StackFrame* frame_; | 815 StackFrame* frame_; |
816 StackHandler* handler_; | 816 StackHandler* handler_; |
817 const bool can_access_heap_objects_; | 817 const bool can_access_heap_objects_; |
818 | 818 |
819 StackHandler* handler() const { | 819 StackHandler* handler() const { |
820 ASSERT(!done()); | 820 DCHECK(!done()); |
821 return handler_; | 821 return handler_; |
822 } | 822 } |
823 | 823 |
824 // Get the type-specific frame singleton in a given state. | 824 // Get the type-specific frame singleton in a given state. |
825 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); | 825 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); |
826 // A helper function, can return a NULL pointer. | 826 // A helper function, can return a NULL pointer. |
827 StackFrame* SingletonFor(StackFrame::Type type); | 827 StackFrame* SingletonFor(StackFrame::Type type); |
828 | 828 |
829 private: | 829 private: |
830 friend class StackFrame; | 830 friend class StackFrame; |
831 DISALLOW_COPY_AND_ASSIGN(StackFrameIteratorBase); | 831 DISALLOW_COPY_AND_ASSIGN(StackFrameIteratorBase); |
832 }; | 832 }; |
833 | 833 |
834 | 834 |
835 class StackFrameIterator: public StackFrameIteratorBase { | 835 class StackFrameIterator: public StackFrameIteratorBase { |
836 public: | 836 public: |
837 // An iterator that iterates over the isolate's current thread's stack, | 837 // An iterator that iterates over the isolate's current thread's stack, |
838 explicit StackFrameIterator(Isolate* isolate); | 838 explicit StackFrameIterator(Isolate* isolate); |
839 // An iterator that iterates over a given thread's stack. | 839 // An iterator that iterates over a given thread's stack. |
840 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); | 840 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); |
841 | 841 |
842 StackFrame* frame() const { | 842 StackFrame* frame() const { |
843 ASSERT(!done()); | 843 DCHECK(!done()); |
844 return frame_; | 844 return frame_; |
845 } | 845 } |
846 void Advance(); | 846 void Advance(); |
847 | 847 |
848 private: | 848 private: |
849 // Go back to the first frame. | 849 // Go back to the first frame. |
850 void Reset(ThreadLocalTop* top); | 850 void Reset(ThreadLocalTop* top); |
851 | 851 |
852 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); | 852 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); |
853 }; | 853 }; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 }; | 932 }; |
933 | 933 |
934 | 934 |
935 // Reads all frames on the current stack and copies them into the current | 935 // Reads all frames on the current stack and copies them into the current |
936 // zone memory. | 936 // zone memory. |
937 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 937 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
938 | 938 |
939 } } // namespace v8::internal | 939 } } // namespace v8::internal |
940 | 940 |
941 #endif // V8_FRAMES_H_ | 941 #endif // V8_FRAMES_H_ |
OLD | NEW |