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

Side by Side Diff: src/frames.h

Issue 6800012: Version 3.2.8... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/execution.cc ('k') | src/frames.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 NO_ID = 0 151 NO_ID = 0
152 }; 152 };
153 153
154 struct State { 154 struct State {
155 State() : sp(NULL), fp(NULL), pc_address(NULL) { } 155 State() : sp(NULL), fp(NULL), pc_address(NULL) { }
156 Address sp; 156 Address sp;
157 Address fp; 157 Address fp;
158 Address* pc_address; 158 Address* pc_address;
159 }; 159 };
160 160
161 // Copy constructor; it breaks the connection to host iterator. 161 // Copy constructor; it breaks the connection to host iterator
162 // (as an iterator usually lives on stack).
162 StackFrame(const StackFrame& original) { 163 StackFrame(const StackFrame& original) {
163 this->state_ = original.state_; 164 this->state_ = original.state_;
164 this->iterator_ = NULL; 165 this->iterator_ = NULL;
166 this->isolate_ = original.isolate_;
165 } 167 }
166 168
167 // Type testers. 169 // Type testers.
168 bool is_entry() const { return type() == ENTRY; } 170 bool is_entry() const { return type() == ENTRY; }
169 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } 171 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; }
170 bool is_exit() const { return type() == EXIT; } 172 bool is_exit() const { return type() == EXIT; }
171 bool is_optimized() const { return type() == OPTIMIZED; } 173 bool is_optimized() const { return type() == OPTIMIZED; }
172 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } 174 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
173 bool is_internal() const { return type() == INTERNAL; } 175 bool is_internal() const { return type() == INTERNAL; }
174 bool is_construct() const { return type() == CONSTRUCT; } 176 bool is_construct() const { return type() == CONSTRUCT; }
(...skipping 23 matching lines...) Expand all
198 bool HasHandler() const; 200 bool HasHandler() const;
199 201
200 // Get the type of this frame. 202 // Get the type of this frame.
201 virtual Type type() const = 0; 203 virtual Type type() const = 0;
202 204
203 // Get the code associated with this frame. 205 // Get the code associated with this frame.
204 // This method could be called during marking phase of GC. 206 // This method could be called during marking phase of GC.
205 virtual Code* unchecked_code() const = 0; 207 virtual Code* unchecked_code() const = 0;
206 208
207 // Get the code associated with this frame. 209 // Get the code associated with this frame.
208 Code* LookupCode(Isolate* isolate) const { 210 Code* LookupCode() const {
209 return GetContainingCode(isolate, pc()); 211 return GetContainingCode(isolate(), pc());
210 } 212 }
211 213
212 // Get the code object that contains the given pc. 214 // Get the code object that contains the given pc.
213 static inline Code* GetContainingCode(Isolate* isolate, Address pc); 215 static inline Code* GetContainingCode(Isolate* isolate, Address pc);
214 216
215 // Get the code object containing the given pc and fill in the 217 // Get the code object containing the given pc and fill in the
216 // safepoint entry and the number of stack slots. The pc must be at 218 // safepoint entry and the number of stack slots. The pc must be at
217 // a safepoint. 219 // a safepoint.
218 static Code* GetSafepointData(Address pc, 220 static Code* GetSafepointData(Isolate* isolate,
221 Address pc,
219 SafepointEntry* safepoint_entry, 222 SafepointEntry* safepoint_entry,
220 unsigned* stack_slots); 223 unsigned* stack_slots);
221 224
222 virtual void Iterate(ObjectVisitor* v) const = 0; 225 virtual void Iterate(ObjectVisitor* v) const = 0;
223 static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder); 226 static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder);
224 227
225 228
226 // Printing support. 229 // Printing support.
227 enum PrintMode { OVERVIEW, DETAILS }; 230 enum PrintMode { OVERVIEW, DETAILS };
228 virtual void Print(StringStream* accumulator, 231 virtual void Print(StringStream* accumulator,
229 PrintMode mode, 232 PrintMode mode,
230 int index) const { } 233 int index) const { }
231 234
232 protected: 235 protected:
233 explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } 236 inline explicit StackFrame(StackFrameIterator* iterator);
234 virtual ~StackFrame() { } 237 virtual ~StackFrame() { }
235 238
239 Isolate* isolate() const { return isolate_; }
240
236 // Compute the stack pointer for the calling frame. 241 // Compute the stack pointer for the calling frame.
237 virtual Address GetCallerStackPointer() const = 0; 242 virtual Address GetCallerStackPointer() const = 0;
238 243
239 // Printing support. 244 // Printing support.
240 static void PrintIndex(StringStream* accumulator, 245 static void PrintIndex(StringStream* accumulator,
241 PrintMode mode, 246 PrintMode mode,
242 int index); 247 int index);
243 248
244 // Get the top handler from the current stack iterator. 249 // Get the top handler from the current stack iterator.
245 inline StackHandler* top_handler() const; 250 inline StackHandler* top_handler() const;
246 251
247 // Compute the stack frame type for the given state. 252 // Compute the stack frame type for the given state.
248 static Type ComputeType(State* state); 253 static Type ComputeType(Isolate* isolate, State* state);
249 254
250 private: 255 private:
251 const StackFrameIterator* iterator_; 256 const StackFrameIterator* iterator_;
257 Isolate* isolate_;
252 State state_; 258 State state_;
253 259
254 // Fill in the state of the calling frame. 260 // Fill in the state of the calling frame.
255 virtual void ComputeCallerState(State* state) const = 0; 261 virtual void ComputeCallerState(State* state) const = 0;
256 262
257 // Get the type and the state of the calling frame. 263 // Get the type and the state of the calling frame.
258 virtual Type GetCallerState(State* state) const; 264 virtual Type GetCallerState(State* state) const;
259 265
266 static const intptr_t kIsolateTag = 1;
267
260 friend class StackFrameIterator; 268 friend class StackFrameIterator;
261 friend class StackHandlerIterator; 269 friend class StackHandlerIterator;
262 friend class SafeStackFrameIterator; 270 friend class SafeStackFrameIterator;
263 271
264 private: 272 private:
265 void operator=(const StackFrame& original); 273 void operator=(const StackFrame& original);
266 }; 274 };
267 275
268 276
269 // Entry frames are used to enter JavaScript execution from C. 277 // Entry frames are used to enter JavaScript execution from C.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 explicit ConstructFrame(StackFrameIterator* iterator) 610 explicit ConstructFrame(StackFrameIterator* iterator)
603 : InternalFrame(iterator) { } 611 : InternalFrame(iterator) { }
604 612
605 private: 613 private:
606 friend class StackFrameIterator; 614 friend class StackFrameIterator;
607 }; 615 };
608 616
609 617
610 class StackFrameIterator BASE_EMBEDDED { 618 class StackFrameIterator BASE_EMBEDDED {
611 public: 619 public:
612 // An iterator that iterates over the current thread's stack. 620 // An iterator that iterates over the current thread's stack,
621 // and uses current isolate.
613 StackFrameIterator(); 622 StackFrameIterator();
614 623
624 // An iterator that iterates over the isolate's current thread's stack,
625 explicit StackFrameIterator(Isolate* isolate);
626
615 // An iterator that iterates over a given thread's stack. 627 // An iterator that iterates over a given thread's stack.
616 explicit StackFrameIterator(ThreadLocalTop* thread); 628 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
617 629
618 // An iterator that can start from a given FP address. 630 // An iterator that can start from a given FP address.
619 // If use_top, then work as usual, if fp isn't NULL, use it, 631 // If use_top, then work as usual, if fp isn't NULL, use it,
620 // otherwise, do nothing. 632 // otherwise, do nothing.
621 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp); 633 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp);
622 634
623 StackFrame* frame() const { 635 StackFrame* frame() const {
624 ASSERT(!done()); 636 ASSERT(!done());
625 return frame_; 637 return frame_;
626 } 638 }
627 639
640 Isolate* isolate() const { return isolate_; }
641
628 bool done() const { return frame_ == NULL; } 642 bool done() const { return frame_ == NULL; }
629 void Advance() { (this->*advance_)(); } 643 void Advance() { (this->*advance_)(); }
630 644
631 // Go back to the first frame. 645 // Go back to the first frame.
632 void Reset(); 646 void Reset();
633 647
634 private: 648 private:
649 Isolate* isolate_;
635 #define DECLARE_SINGLETON(ignore, type) type type##_; 650 #define DECLARE_SINGLETON(ignore, type) type type##_;
636 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) 651 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
637 #undef DECLARE_SINGLETON 652 #undef DECLARE_SINGLETON
638 StackFrame* frame_; 653 StackFrame* frame_;
639 StackHandler* handler_; 654 StackHandler* handler_;
640 ThreadLocalTop* thread_; 655 ThreadLocalTop* thread_;
641 Address fp_; 656 Address fp_;
642 Address sp_; 657 Address sp_;
643 void (StackFrameIterator::*advance_)(); 658 void (StackFrameIterator::*advance_)();
644 659
(...skipping 15 matching lines...) Expand all
660 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); 675 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
661 }; 676 };
662 677
663 678
664 // Iterator that supports iterating through all JavaScript frames. 679 // Iterator that supports iterating through all JavaScript frames.
665 template<typename Iterator> 680 template<typename Iterator>
666 class JavaScriptFrameIteratorTemp BASE_EMBEDDED { 681 class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
667 public: 682 public:
668 JavaScriptFrameIteratorTemp() { if (!done()) Advance(); } 683 JavaScriptFrameIteratorTemp() { if (!done()) Advance(); }
669 684
670 explicit JavaScriptFrameIteratorTemp(ThreadLocalTop* thread) : 685 inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);
671 iterator_(thread) {
672 if (!done()) Advance();
673 }
674 686
675 // Skip frames until the frame with the given id is reached. 687 // Skip frames until the frame with the given id is reached.
676 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id); 688 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }
689
690 inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id);
677 691
678 JavaScriptFrameIteratorTemp(Address fp, Address sp, 692 JavaScriptFrameIteratorTemp(Address fp, Address sp,
679 Address low_bound, Address high_bound) : 693 Address low_bound, Address high_bound) :
680 iterator_(fp, sp, low_bound, high_bound) { 694 iterator_(fp, sp, low_bound, high_bound) {
681 if (!done()) Advance(); 695 if (!done()) Advance();
682 } 696 }
683 697
684 JavaScriptFrameIteratorTemp(Isolate* isolate, 698 JavaScriptFrameIteratorTemp(Isolate* isolate,
685 Address fp, Address sp, 699 Address fp, Address sp,
686 Address low_bound, Address high_bound) : 700 Address low_bound, Address high_bound) :
687 iterator_(isolate, fp, sp, low_bound, high_bound) { 701 iterator_(isolate, fp, sp, low_bound, high_bound) {
688 if (!done()) Advance(); 702 if (!done()) Advance();
689 } 703 }
690 704
691 inline JavaScriptFrame* frame() const; 705 inline JavaScriptFrame* frame() const;
692 706
693 bool done() const { return iterator_.done(); } 707 bool done() const { return iterator_.done(); }
694 void Advance(); 708 void Advance();
695 709
696 // Advance to the frame holding the arguments for the current 710 // Advance to the frame holding the arguments for the current
697 // frame. This only affects the current frame if it has adapted 711 // frame. This only affects the current frame if it has adapted
698 // arguments. 712 // arguments.
699 void AdvanceToArgumentsFrame(); 713 void AdvanceToArgumentsFrame();
700 714
701 // Go back to the first frame. 715 // Go back to the first frame.
702 void Reset(); 716 void Reset();
703 717
704 private: 718 private:
719 inline void AdvanceToId(StackFrame::Id id);
720
705 Iterator iterator_; 721 Iterator iterator_;
706 }; 722 };
707 723
708 724
709 typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator; 725 typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
710 726
711 727
712 // NOTE: The stack trace frame iterator is an iterator that only 728 // NOTE: The stack trace frame iterator is an iterator that only
713 // traverse proper JavaScript frames; that is JavaScript frames that 729 // traverse proper JavaScript frames; that is JavaScript frames that
714 // have proper JavaScript functions. This excludes the problematic 730 // have proper JavaScript functions. This excludes the problematic
715 // functions in runtime.js. 731 // functions in runtime.js.
716 class StackTraceFrameIterator: public JavaScriptFrameIterator { 732 class StackTraceFrameIterator: public JavaScriptFrameIterator {
717 public: 733 public:
718 StackTraceFrameIterator(); 734 StackTraceFrameIterator();
735 explicit StackTraceFrameIterator(Isolate* isolate);
719 void Advance(); 736 void Advance();
720 737
721 private: 738 private:
722 bool IsValidFrame(); 739 bool IsValidFrame();
723 }; 740 };
724 741
725 742
726 class SafeStackFrameIterator BASE_EMBEDDED { 743 class SafeStackFrameIterator BASE_EMBEDDED {
727 public: 744 public:
728 SafeStackFrameIterator(Isolate* isolate, 745 SafeStackFrameIterator(Isolate* isolate,
729 Address fp, Address sp, 746 Address fp, Address sp,
730 Address low_bound, Address high_bound); 747 Address low_bound, Address high_bound);
731 748
732 StackFrame* frame() const { 749 StackFrame* frame() const {
733 ASSERT(is_working_iterator_); 750 ASSERT(is_working_iterator_);
734 return iterator_.frame(); 751 return iterator_.frame();
735 } 752 }
736 753
737 bool done() const { return iteration_done_ ? true : iterator_.done(); } 754 bool done() const { return iteration_done_ ? true : iterator_.done(); }
738 755
739 void Advance(); 756 void Advance();
740 void Reset(); 757 void Reset();
741 758
742 static bool is_active() { return active_count_ > 0; } 759 static bool is_active(Isolate* isolate);
743 760
744 static bool IsWithinBounds( 761 static bool IsWithinBounds(
745 Address low_bound, Address high_bound, Address addr) { 762 Address low_bound, Address high_bound, Address addr) {
746 return low_bound <= addr && addr <= high_bound; 763 return low_bound <= addr && addr <= high_bound;
747 } 764 }
748 765
749 private: 766 private:
750 class StackAddressValidator { 767 class StackAddressValidator {
751 public: 768 public:
752 StackAddressValidator(Address low_bound, Address high_bound) 769 StackAddressValidator(Address low_bound, Address high_bound)
(...skipping 26 matching lines...) Expand all
779 static bool IsValidTop(Isolate* isolate, 796 static bool IsValidTop(Isolate* isolate,
780 Address low_bound, Address high_bound); 797 Address low_bound, Address high_bound);
781 798
782 // This is a nasty hack to make sure the active count is incremented 799 // This is a nasty hack to make sure the active count is incremented
783 // before the constructor for the embedded iterator is invoked. This 800 // before the constructor for the embedded iterator is invoked. This
784 // is needed because the constructor will start looking at frames 801 // is needed because the constructor will start looking at frames
785 // right away and we need to make sure it doesn't start inspecting 802 // right away and we need to make sure it doesn't start inspecting
786 // heap objects. 803 // heap objects.
787 class ActiveCountMaintainer BASE_EMBEDDED { 804 class ActiveCountMaintainer BASE_EMBEDDED {
788 public: 805 public:
789 ActiveCountMaintainer() { active_count_++; } 806 explicit ActiveCountMaintainer(Isolate* isolate);
790 ~ActiveCountMaintainer() { active_count_--; } 807 ~ActiveCountMaintainer();
808 private:
809 Isolate* isolate_;
791 }; 810 };
792 811
793 ActiveCountMaintainer maintainer_; 812 ActiveCountMaintainer maintainer_;
794 // TODO(isolates): this is dangerous.
795 static int active_count_;
796 StackAddressValidator stack_validator_; 813 StackAddressValidator stack_validator_;
797 const bool is_valid_top_; 814 const bool is_valid_top_;
798 const bool is_valid_fp_; 815 const bool is_valid_fp_;
799 const bool is_working_iterator_; 816 const bool is_working_iterator_;
800 bool iteration_done_; 817 bool iteration_done_;
801 StackFrameIterator iterator_; 818 StackFrameIterator iterator_;
802 }; 819 };
803 820
804 821
805 #ifdef ENABLE_LOGGING_AND_PROFILING 822 #ifdef ENABLE_LOGGING_AND_PROFILING
(...skipping 22 matching lines...) Expand all
828 }; 845 };
829 846
830 847
831 // Reads all frames on the current stack and copies them into the current 848 // Reads all frames on the current stack and copies them into the current
832 // zone memory. 849 // zone memory.
833 Vector<StackFrame*> CreateStackMap(); 850 Vector<StackFrame*> CreateStackMap();
834 851
835 } } // namespace v8::internal 852 } } // namespace v8::internal
836 853
837 #endif // V8_FRAMES_H_ 854 #endif // V8_FRAMES_H_
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698