diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
commit | 33af2720f26c2b25bc7f75ce7eb454ff99db6d35 (patch) | |
tree | 9a38f0c96420edf503eebd6325dd8d2d8249f653 /deps/v8/src/frames.h | |
parent | 6afdca885adeeeed9eef8cbb01c3d97af0bc084d (diff) | |
download | node-33af2720f26c2b25bc7f75ce7eb454ff99db6d35.tar.gz |
Upgrade V8 to 3.4.8
Diffstat (limited to 'deps/v8/src/frames.h')
-rw-r--r-- | deps/v8/src/frames.h | 109 |
1 files changed, 75 insertions, 34 deletions
diff --git a/deps/v8/src/frames.h b/deps/v8/src/frames.h index 03e5e671b..aa91026fb 100644 --- a/deps/v8/src/frames.h +++ b/deps/v8/src/frames.h @@ -28,6 +28,8 @@ #ifndef V8_FRAMES_H_ #define V8_FRAMES_H_ +#include "allocation.h" +#include "handles.h" #include "safepoint-table.h" namespace v8 { @@ -44,11 +46,10 @@ int JSCallerSavedCode(int n); // Forward declarations. class StackFrameIterator; -class Top; class ThreadLocalTop; +class Isolate; - -class PcToCodeCache : AllStatic { +class PcToCodeCache { public: struct PcToCodeCacheEntry { Address pc; @@ -56,22 +57,28 @@ class PcToCodeCache : AllStatic { SafepointEntry safepoint_entry; }; - static PcToCodeCacheEntry* cache(int index) { - return &cache_[index]; + explicit PcToCodeCache(Isolate* isolate) : isolate_(isolate) { + Flush(); } - static Code* GcSafeFindCodeForPc(Address pc); - static Code* GcSafeCastToCode(HeapObject* object, Address pc); + Code* GcSafeFindCodeForPc(Address pc); + Code* GcSafeCastToCode(HeapObject* object, Address pc); - static void FlushPcToCodeCache() { + void Flush() { memset(&cache_[0], 0, sizeof(cache_)); } - static PcToCodeCacheEntry* GetCacheEntry(Address pc); + PcToCodeCacheEntry* GetCacheEntry(Address pc); private: + PcToCodeCacheEntry* cache(int index) { return &cache_[index]; } + + Isolate* isolate_; + static const int kPcToCodeCacheSize = 1024; - static PcToCodeCacheEntry cache_[kPcToCodeCacheSize]; + PcToCodeCacheEntry cache_[kPcToCodeCacheSize]; + + DISALLOW_COPY_AND_ASSIGN(PcToCodeCache); }; @@ -145,6 +152,12 @@ class StackFrame BASE_EMBEDDED { NO_ID = 0 }; + // Used to mark the outermost JS entry frame. + enum JsFrameMarker { + INNER_JSENTRY_FRAME = 0, + OUTERMOST_JSENTRY_FRAME = 1 + }; + struct State { State() : sp(NULL), fp(NULL), pc_address(NULL) { } Address sp; @@ -152,10 +165,12 @@ class StackFrame BASE_EMBEDDED { Address* pc_address; }; - // Copy constructor; it breaks the connection to host iterator. + // Copy constructor; it breaks the connection to host iterator + // (as an iterator usually lives on stack). StackFrame(const StackFrame& original) { this->state_ = original.state_; this->iterator_ = NULL; + this->isolate_ = original.isolate_; } // Type testers. @@ -199,17 +214,18 @@ class StackFrame BASE_EMBEDDED { virtual Code* unchecked_code() const = 0; // Get the code associated with this frame. - Code* code() const { return GetContainingCode(pc()); } + Code* LookupCode() const { + return GetContainingCode(isolate(), pc()); + } // Get the code object that contains the given pc. - static Code* GetContainingCode(Address pc) { - return PcToCodeCache::GetCacheEntry(pc)->code; - } + static inline Code* GetContainingCode(Isolate* isolate, Address pc); // Get the code object containing the given pc and fill in the // safepoint entry and the number of stack slots. The pc must be at // a safepoint. - static Code* GetSafepointData(Address pc, + static Code* GetSafepointData(Isolate* isolate, + Address pc, SafepointEntry* safepoint_entry, unsigned* stack_slots); @@ -224,9 +240,11 @@ class StackFrame BASE_EMBEDDED { int index) const { } protected: - explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } + inline explicit StackFrame(StackFrameIterator* iterator); virtual ~StackFrame() { } + Isolate* isolate() const { return isolate_; } + // Compute the stack pointer for the calling frame. virtual Address GetCallerStackPointer() const = 0; @@ -239,10 +257,11 @@ class StackFrame BASE_EMBEDDED { inline StackHandler* top_handler() const; // Compute the stack frame type for the given state. - static Type ComputeType(State* state); + static Type ComputeType(Isolate* isolate, State* state); private: const StackFrameIterator* iterator_; + Isolate* isolate_; State state_; // Fill in the state of the calling frame. @@ -251,6 +270,8 @@ class StackFrame BASE_EMBEDDED { // Get the type and the state of the calling frame. virtual Type GetCallerState(State* state) const; + static const intptr_t kIsolateTag = 1; + friend class StackFrameIterator; friend class StackHandlerIterator; friend class SafeStackFrameIterator; @@ -424,7 +445,7 @@ class FrameSummary BASE_EMBEDDED { Handle<Object> receiver() { return receiver_; } Handle<JSFunction> function() { return function_; } Handle<Code> code() { return code_; } - Address pc() { return reinterpret_cast<Address>(*code_) + offset_; } + Address pc() { return code_->address() + offset_; } int offset() { return offset_; } bool is_constructor() { return is_constructor_; } @@ -612,22 +633,28 @@ class ConstructFrame: public InternalFrame { class StackFrameIterator BASE_EMBEDDED { public: - // An iterator that iterates over the current thread's stack. + // An iterator that iterates over the current thread's stack, + // and uses current isolate. StackFrameIterator(); + // 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. - explicit StackFrameIterator(ThreadLocalTop* thread); + 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(bool use_top, Address fp, Address sp); + 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_)(); } @@ -635,6 +662,7 @@ class StackFrameIterator BASE_EMBEDDED { void Reset(); private: + Isolate* isolate_; #define DECLARE_SINGLETON(ignore, type) type type##_; STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) #undef DECLARE_SINGLETON @@ -670,13 +698,12 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED { public: JavaScriptFrameIteratorTemp() { if (!done()) Advance(); } - explicit JavaScriptFrameIteratorTemp(ThreadLocalTop* thread) : - iterator_(thread) { - if (!done()) Advance(); - } + inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate); // Skip frames until the frame with the given id is reached. - explicit JavaScriptFrameIteratorTemp(StackFrame::Id id); + explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); } + + inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id); JavaScriptFrameIteratorTemp(Address fp, Address sp, Address low_bound, Address high_bound) : @@ -684,6 +711,13 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED { 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(); + } + inline JavaScriptFrame* frame() const; bool done() const { return iterator_.done(); } @@ -698,6 +732,8 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED { void Reset(); private: + inline void AdvanceToId(StackFrame::Id id); + Iterator iterator_; }; @@ -712,6 +748,7 @@ typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator; class StackTraceFrameIterator: public JavaScriptFrameIterator { public: StackTraceFrameIterator(); + explicit StackTraceFrameIterator(Isolate* isolate); void Advance(); private: @@ -721,7 +758,8 @@ class StackTraceFrameIterator: public JavaScriptFrameIterator { class SafeStackFrameIterator BASE_EMBEDDED { public: - SafeStackFrameIterator(Address fp, Address sp, + SafeStackFrameIterator(Isolate* isolate, + Address fp, Address sp, Address low_bound, Address high_bound); StackFrame* frame() const { @@ -734,7 +772,7 @@ class SafeStackFrameIterator BASE_EMBEDDED { void Advance(); void Reset(); - static bool is_active() { return active_count_ > 0; } + static bool is_active(Isolate* isolate); static bool IsWithinBounds( Address low_bound, Address high_bound, Address addr) { @@ -771,7 +809,8 @@ class SafeStackFrameIterator BASE_EMBEDDED { bool CanIterateHandles(StackFrame* frame, StackHandler* handler); bool IsValidFrame(StackFrame* frame) const; bool IsValidCaller(StackFrame* frame); - static bool IsValidTop(Address low_bound, Address high_bound); + static bool IsValidTop(Isolate* isolate, + Address low_bound, Address high_bound); // This is a nasty hack to make sure the active count is incremented // before the constructor for the embedded iterator is invoked. This @@ -780,12 +819,13 @@ class SafeStackFrameIterator BASE_EMBEDDED { // heap objects. class ActiveCountMaintainer BASE_EMBEDDED { public: - ActiveCountMaintainer() { active_count_++; } - ~ActiveCountMaintainer() { active_count_--; } + explicit ActiveCountMaintainer(Isolate* isolate); + ~ActiveCountMaintainer(); + private: + Isolate* isolate_; }; ActiveCountMaintainer maintainer_; - static int active_count_; StackAddressValidator stack_validator_; const bool is_valid_top_; const bool is_valid_fp_; @@ -802,7 +842,8 @@ typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator { public: - explicit SafeStackTraceFrameIterator(Address fp, Address sp, + explicit SafeStackTraceFrameIterator(Isolate* isolate, + Address fp, Address sp, Address low_bound, Address high_bound); void Advance(); }; |