vendor/v8/src/frames.h in mustang-0.0.1 vs vendor/v8/src/frames.h in mustang-0.1.0
- old
+ new
@@ -26,10 +26,11 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_FRAMES_H_
#define V8_FRAMES_H_
+#include "handles.h"
#include "safepoint-table.h"
namespace v8 {
namespace internal {
@@ -42,38 +43,43 @@
int JSCallerSavedCode(int n);
// Forward declarations.
class StackFrameIterator;
-class Top;
class ThreadLocalTop;
+class Isolate;
-
-class PcToCodeCache : AllStatic {
+class PcToCodeCache {
public:
struct PcToCodeCacheEntry {
Address pc;
Code* code;
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);
};
class StackHandler BASE_EMBEDDED {
public:
@@ -197,16 +203,16 @@
// Get the code associated with this frame.
// This method could be called during marking phase of GC.
virtual Code* unchecked_code() const = 0;
// Get the code associated with this frame.
- Code* code() const { return GetContainingCode(pc()); }
+ Code* LookupCode(Isolate* isolate) 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,
@@ -422,11 +428,11 @@
offset_(offset),
is_constructor_(is_constructor) { }
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_; }
void Print();
@@ -450,16 +456,10 @@
// Access the parameters.
Object* GetParameter(int index) const;
int ComputeParametersCount() const;
- // Temporary way of getting access to the number of parameters
- // passed on the stack by the caller. Once argument adaptor frames
- // has been introduced on ARM, this number will always match the
- // computed parameters count.
- int GetProvidedParametersCount() const;
-
// Check if this frame is a constructor frame invoked through 'new'.
bool IsConstructor() const;
// Check if this frame has "adapted" arguments in the sense that the
// actual passed arguments are available in an arguments adaptor
@@ -616,11 +616,11 @@
explicit StackFrameIterator(ThreadLocalTop* thread);
// 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_;
}
@@ -679,10 +679,17 @@
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();
+ }
+
inline JavaScriptFrame* frame() const;
bool done() const { return iterator_.done(); }
void Advance();
@@ -716,11 +723,12 @@
};
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 {
ASSERT(is_working_iterator_);
return iterator_.frame();
@@ -766,11 +774,12 @@
return stack_validator_.IsValid(addr);
}
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
// is needed because the constructor will start looking at frames
// right away and we need to make sure it doesn't start inspecting
@@ -780,10 +789,11 @@
ActiveCountMaintainer() { active_count_++; }
~ActiveCountMaintainer() { active_count_--; }
};
ActiveCountMaintainer maintainer_;
+ // TODO(isolates): this is dangerous.
static int active_count_;
StackAddressValidator stack_validator_;
const bool is_valid_top_;
const bool is_valid_fp_;
const bool is_working_iterator_;
@@ -797,10 +807,11 @@
SafeJavaScriptFrameIterator;
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();
};
#endif