| Index: src/frames.h
|
| diff --git a/src/frames.h b/src/frames.h
|
| index 039f5854b42ce9cc38d098c3448d4f209c36db40..57ed9aed623c16de13cd98caf212c6d032eeae64 100644
|
| --- a/src/frames.h
|
| +++ b/src/frames.h
|
| @@ -51,7 +51,7 @@ int JSCallerSavedCode(int n);
|
|
|
|
|
| // Forward declarations.
|
| -class StackFrameIterator;
|
| +class StackFrameIteratorBase;
|
| class ThreadLocalTop;
|
| class Isolate;
|
|
|
| @@ -310,7 +310,7 @@ class StackFrame BASE_EMBEDDED {
|
| Isolate* isolate() const { return isolate_; }
|
|
|
| protected:
|
| - inline explicit StackFrame(StackFrameIterator* iterator);
|
| + inline explicit StackFrame(StackFrameIteratorBase* iterator);
|
| virtual ~StackFrame() { }
|
|
|
| // Compute the stack pointer for the calling frame.
|
| @@ -325,10 +325,14 @@ class StackFrame BASE_EMBEDDED {
|
| inline StackHandler* top_handler() const;
|
|
|
| // Compute the stack frame type for the given state.
|
| - static Type ComputeType(Isolate* isolate, State* state);
|
| + static Type ComputeType(const StackFrameIteratorBase* iterator, State* state);
|
| +
|
| +#ifdef DEBUG
|
| + bool can_access_heap_objects() const;
|
| +#endif
|
|
|
| private:
|
| - const StackFrameIterator* iterator_;
|
| + const StackFrameIteratorBase* iterator_;
|
| Isolate* isolate_;
|
| State state_;
|
|
|
| @@ -341,6 +345,7 @@ class StackFrame BASE_EMBEDDED {
|
| static const intptr_t kIsolateTag = 1;
|
|
|
| friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| friend class StackHandlerIterator;
|
| friend class SafeStackFrameIterator;
|
|
|
| @@ -366,7 +371,7 @@ class EntryFrame: public StackFrame {
|
| virtual void SetCallerFp(Address caller_fp);
|
|
|
| protected:
|
| - inline explicit EntryFrame(StackFrameIterator* iterator);
|
| + inline explicit EntryFrame(StackFrameIteratorBase* iterator);
|
|
|
| // The caller stack pointer for entry frames is always zero. The
|
| // real information about the caller frame is available through the
|
| @@ -377,7 +382,7 @@ class EntryFrame: public StackFrame {
|
| virtual void ComputeCallerState(State* state) const;
|
| virtual Type GetCallerState(State* state) const;
|
|
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -393,10 +398,10 @@ class EntryConstructFrame: public EntryFrame {
|
| }
|
|
|
| protected:
|
| - inline explicit EntryConstructFrame(StackFrameIterator* iterator);
|
| + inline explicit EntryConstructFrame(StackFrameIteratorBase* iterator);
|
|
|
| private:
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -427,14 +432,14 @@ class ExitFrame: public StackFrame {
|
| static void FillState(Address fp, Address sp, State* state);
|
|
|
| protected:
|
| - inline explicit ExitFrame(StackFrameIterator* iterator);
|
| + inline explicit ExitFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| private:
|
| virtual void ComputeCallerState(State* state) const;
|
|
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -460,7 +465,7 @@ class StandardFrame: public StackFrame {
|
| }
|
|
|
| protected:
|
| - inline explicit StandardFrame(StackFrameIterator* iterator);
|
| + inline explicit StandardFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual void ComputeCallerState(State* state) const;
|
|
|
| @@ -497,7 +502,7 @@ class StandardFrame: public StackFrame {
|
|
|
| private:
|
| friend class StackFrame;
|
| - friend class StackFrameIterator;
|
| + friend class SafeStackFrameIterator;
|
| };
|
|
|
|
|
| @@ -603,7 +608,7 @@ class JavaScriptFrame: public StandardFrame {
|
| bool print_line_number);
|
|
|
| protected:
|
| - inline explicit JavaScriptFrame(StackFrameIterator* iterator);
|
| + inline explicit JavaScriptFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| @@ -616,7 +621,7 @@ class JavaScriptFrame: public StandardFrame {
|
| private:
|
| inline Object* function_slot_object() const;
|
|
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -631,13 +636,13 @@ class StubFrame : public StandardFrame {
|
| virtual Code* unchecked_code() const;
|
|
|
| protected:
|
| - inline explicit StubFrame(StackFrameIterator* iterator);
|
| + inline explicit StubFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| virtual int GetNumberOfIncomingArguments() const;
|
|
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -660,12 +665,12 @@ class OptimizedFrame : public JavaScriptFrame {
|
| DeoptimizationInputData* GetDeoptimizationData(int* deopt_index);
|
|
|
| protected:
|
| - inline explicit OptimizedFrame(StackFrameIterator* iterator);
|
| + inline explicit OptimizedFrame(StackFrameIteratorBase* iterator);
|
|
|
| private:
|
| JSFunction* LiteralAt(FixedArray* literal_array, int literal_id);
|
|
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -690,14 +695,14 @@ class ArgumentsAdaptorFrame: public JavaScriptFrame {
|
| int index) const;
|
|
|
| protected:
|
| - inline explicit ArgumentsAdaptorFrame(StackFrameIterator* iterator);
|
| + inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual int GetNumberOfIncomingArguments() const;
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| private:
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -717,12 +722,12 @@ class InternalFrame: public StandardFrame {
|
| }
|
|
|
| protected:
|
| - inline explicit InternalFrame(StackFrameIterator* iterator);
|
| + inline explicit InternalFrame(StackFrameIteratorBase* iterator);
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| private:
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -750,12 +755,12 @@ class StubFailureTrampolineFrame: public StandardFrame {
|
|
|
| protected:
|
| inline explicit StubFailureTrampolineFrame(
|
| - StackFrameIterator* iterator);
|
| + StackFrameIteratorBase* iterator);
|
|
|
| virtual Address GetCallerStackPointer() const;
|
|
|
| private:
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| @@ -771,50 +776,30 @@ class ConstructFrame: public InternalFrame {
|
| }
|
|
|
| protected:
|
| - inline explicit ConstructFrame(StackFrameIterator* iterator);
|
| + inline explicit ConstructFrame(StackFrameIteratorBase* iterator);
|
|
|
| private:
|
| - friend class StackFrameIterator;
|
| + friend class StackFrameIteratorBase;
|
| };
|
|
|
|
|
| -class StackFrameIterator BASE_EMBEDDED {
|
| +class StackFrameIteratorBase BASE_EMBEDDED {
|
| public:
|
| - // An iterator that iterates over the isolate's current thread's stack,
|
| - explicit StackFrameIterator(Isolate* isolate);
|
| -
|
| - // An iterator that iterates over a given thread's stack.
|
| - StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
|
| -
|
| - // An iterator that can start from a given FP address.
|
| - // If use_top, then work as usual, if fp isn't NULL, use it,
|
| - // otherwise, do nothing.
|
| - StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp);
|
| -
|
| - StackFrame* frame() const {
|
| - ASSERT(!done());
|
| - return frame_;
|
| - }
|
| -
|
| Isolate* isolate() const { return isolate_; }
|
|
|
| bool done() const { return frame_ == NULL; }
|
| - void Advance() { (this->*advance_)(); }
|
|
|
| - // Go back to the first frame.
|
| - void Reset();
|
| + protected:
|
| + // An iterator that iterates over a given thread's stack.
|
| + StackFrameIteratorBase(Isolate* isolate, bool can_access_heap_objects);
|
|
|
| - private:
|
| Isolate* isolate_;
|
| #define DECLARE_SINGLETON(ignore, type) type type##_;
|
| STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
|
| #undef DECLARE_SINGLETON
|
| StackFrame* frame_;
|
| StackHandler* handler_;
|
| - ThreadLocalTop* thread_;
|
| - Address fp_;
|
| - Address sp_;
|
| - void (StackFrameIterator::*advance_)();
|
| + const bool can_access_heap_objects_;
|
|
|
| StackHandler* handler() const {
|
| ASSERT(!done());
|
| @@ -826,44 +811,40 @@ class StackFrameIterator BASE_EMBEDDED {
|
| // A helper function, can return a NULL pointer.
|
| StackFrame* SingletonFor(StackFrame::Type type);
|
|
|
| - void AdvanceWithHandler();
|
| - void AdvanceWithoutHandler();
|
| -
|
| + private:
|
| friend class StackFrame;
|
| - friend class SafeStackFrameIterator;
|
| - DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
|
| + DISALLOW_COPY_AND_ASSIGN(StackFrameIteratorBase);
|
| };
|
|
|
|
|
| -// Iterator that supports iterating through all JavaScript frames.
|
| -template<typename Iterator>
|
| -class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
|
| +class StackFrameIterator: public StackFrameIteratorBase {
|
| public:
|
| - inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);
|
| + // An iterator that iterates over the isolate's current thread's stack,
|
| + explicit StackFrameIterator(Isolate* isolate);
|
| + // An iterator that iterates over a given thread's stack.
|
| + StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
|
|
|
| - inline JavaScriptFrameIteratorTemp(Isolate* isolate, ThreadLocalTop* top);
|
| + StackFrame* frame() const {
|
| + ASSERT(!done());
|
| + return frame_;
|
| + }
|
| + void Advance();
|
|
|
| - // Skip frames until the frame with the given id is reached.
|
| - explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }
|
| + private:
|
| + // Go back to the first frame.
|
| + void Reset(ThreadLocalTop* top);
|
|
|
| - inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id);
|
| + DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
|
| +};
|
|
|
| - JavaScriptFrameIteratorTemp(Address fp,
|
| - Address sp,
|
| - Address low_bound,
|
| - Address high_bound) :
|
| - iterator_(fp, sp, low_bound, high_bound) {
|
| - if (!done()) Advance();
|
| - }
|
|
|
| - JavaScriptFrameIteratorTemp(Isolate* isolate,
|
| - Address fp,
|
| - Address sp,
|
| - Address low_bound,
|
| - Address high_bound) :
|
| - iterator_(isolate, fp, sp, low_bound, high_bound) {
|
| - if (!done()) Advance();
|
| - }
|
| +// Iterator that supports iterating through all JavaScript frames.
|
| +class JavaScriptFrameIterator BASE_EMBEDDED {
|
| + public:
|
| + inline explicit JavaScriptFrameIterator(Isolate* isolate);
|
| + inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top);
|
| + // Skip frames until the frame with the given id is reached.
|
| + JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id);
|
|
|
| inline JavaScriptFrame* frame() const;
|
|
|
| @@ -875,26 +856,17 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
|
| // arguments.
|
| void AdvanceToArgumentsFrame();
|
|
|
| - // Go back to the first frame.
|
| - void Reset();
|
| -
|
| private:
|
| - inline void AdvanceToId(StackFrame::Id id);
|
| -
|
| - Iterator iterator_;
|
| + StackFrameIterator iterator_;
|
| };
|
|
|
|
|
| -typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
|
| -
|
| -
|
| // NOTE: The stack trace frame iterator is an iterator that only
|
| // traverse proper JavaScript frames; that is JavaScript frames that
|
| // have proper JavaScript functions. This excludes the problematic
|
| // functions in runtime.js.
|
| class StackTraceFrameIterator: public JavaScriptFrameIterator {
|
| public:
|
| - StackTraceFrameIterator();
|
| explicit StackTraceFrameIterator(Isolate* isolate);
|
| void Advance();
|
|
|
| @@ -903,95 +875,28 @@ class StackTraceFrameIterator: public JavaScriptFrameIterator {
|
| };
|
|
|
|
|
| -class SafeStackFrameIterator BASE_EMBEDDED {
|
| +class SafeStackFrameIterator: public StackFrameIteratorBase {
|
| public:
|
| SafeStackFrameIterator(Isolate* isolate,
|
| Address fp, Address sp,
|
| Address low_bound, Address high_bound);
|
|
|
| - StackFrame* frame() const {
|
| - ASSERT(is_working_iterator_);
|
| - return iterator_.frame();
|
| - }
|
| -
|
| - bool done() const { return iteration_done_ ? true : iterator_.done(); }
|
| -
|
| + inline JavaScriptFrame* frame() const;
|
| void Advance();
|
| - void Reset();
|
| -
|
| - static bool is_active(Isolate* isolate);
|
| -
|
| - static bool IsWithinBounds(
|
| - Address low_bound, Address high_bound, Address addr) {
|
| - return low_bound <= addr && addr <= high_bound;
|
| - }
|
|
|
| private:
|
| - class StackAddressValidator {
|
| - public:
|
| - StackAddressValidator(Address low_bound, Address high_bound)
|
| - : low_bound_(low_bound), high_bound_(high_bound) { }
|
| - bool IsValid(Address addr) const {
|
| - return IsWithinBounds(low_bound_, high_bound_, addr);
|
| - }
|
| - private:
|
| - Address low_bound_;
|
| - Address high_bound_;
|
| - };
|
| -
|
| - class ExitFrameValidator {
|
| - public:
|
| - explicit ExitFrameValidator(const StackAddressValidator& validator)
|
| - : validator_(validator) { }
|
| - ExitFrameValidator(Address low_bound, Address high_bound)
|
| - : validator_(low_bound, high_bound) { }
|
| - bool IsValidFP(Address fp);
|
| - private:
|
| - StackAddressValidator validator_;
|
| - };
|
| + void AdvanceOneFrame();
|
|
|
| bool IsValidStackAddress(Address addr) const {
|
| - return stack_validator_.IsValid(addr);
|
| + return low_bound_ <= addr && addr <= high_bound_;
|
| }
|
| - bool CanIterateHandles(StackFrame* frame, StackHandler* handler);
|
| bool IsValidFrame(StackFrame* frame) const;
|
| bool IsValidCaller(StackFrame* frame);
|
| - static bool IsValidTop(Isolate* isolate,
|
| - Address low_bound, Address high_bound);
|
| + bool IsValidExitFrame(Address fp) const;
|
| + bool IsValidTop(ThreadLocalTop* top) const;
|
|
|
| - // This is a nasty hack to make sure the active count is incremented
|
| - // before the constructor for the embedded iterator is invoked. This
|
| - // is needed because the constructor will start looking at frames
|
| - // right away and we need to make sure it doesn't start inspecting
|
| - // heap objects.
|
| - class ActiveCountMaintainer BASE_EMBEDDED {
|
| - public:
|
| - explicit ActiveCountMaintainer(Isolate* isolate);
|
| - ~ActiveCountMaintainer();
|
| - private:
|
| - Isolate* isolate_;
|
| - };
|
| -
|
| - ActiveCountMaintainer maintainer_;
|
| - StackAddressValidator stack_validator_;
|
| - const bool is_valid_top_;
|
| - const bool is_valid_fp_;
|
| - const bool is_working_iterator_;
|
| - bool iteration_done_;
|
| - StackFrameIterator iterator_;
|
| -};
|
| -
|
| -
|
| -typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator>
|
| - SafeJavaScriptFrameIterator;
|
| -
|
| -
|
| -class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator {
|
| - public:
|
| - explicit SafeStackTraceFrameIterator(Isolate* isolate,
|
| - Address fp, Address sp,
|
| - Address low_bound, Address high_bound);
|
| - void Advance();
|
| + const Address low_bound_;
|
| + const Address high_bound_;
|
| };
|
|
|
|
|
|
|