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

Unified Diff: src/frames.h

Issue 6794019: Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A couple more changes Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/execution.cc ('k') | src/frames.cc » ('j') | src/frames.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/frames.h
diff --git a/src/frames.h b/src/frames.h
index 3294eeee26eb08d371d54de249d352f81b90f018..092fd422a4b49c85d9a4e7dda05a4425f7f55bfc 100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -158,10 +158,14 @@ 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). But as we need
+ // a pointer to isolate, we store it in place of the iterator ptr,
+ // and tag accordingly.
StackFrame(const StackFrame& original) {
this->state_ = original.state_;
- this->iterator_ = NULL;
+ this->tagged_isolate_ptr_ =
+ reinterpret_cast<intptr_t>(original.isolate()) | kIsolateTag;
}
// Type testers.
@@ -205,8 +209,8 @@ class StackFrame BASE_EMBEDDED {
virtual Code* unchecked_code() const = 0;
// Get the code associated with this frame.
- Code* LookupCode(Isolate* isolate) const {
- return GetContainingCode(isolate, pc());
+ Code* LookupCode() const {
+ return GetContainingCode(isolate(), pc());
}
// Get the code object that contains the given pc.
@@ -215,7 +219,8 @@ class StackFrame BASE_EMBEDDED {
// 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);
@@ -233,6 +238,8 @@ class StackFrame BASE_EMBEDDED {
explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { }
virtual ~StackFrame() { }
+ inline Isolate* isolate() const;
+
// Compute the stack pointer for the calling frame.
virtual Address GetCallerStackPointer() const = 0;
@@ -245,10 +252,13 @@ 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_;
+ union {
+ const StackFrameIterator* iterator_;
+ intptr_t tagged_isolate_ptr_;
+ };
State state_;
// Fill in the state of the calling frame.
@@ -257,6 +267,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;
@@ -609,11 +621,15 @@ 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,
@@ -625,6 +641,8 @@ class StackFrameIterator BASE_EMBEDDED {
return frame_;
}
+ Isolate* isolate() const { return isolate_; }
+
bool done() const { return frame_ == NULL; }
void Advance() { (this->*advance_)(); }
@@ -637,6 +655,7 @@ class StackFrameIterator BASE_EMBEDDED {
#undef DECLARE_SINGLETON
StackFrame* frame_;
StackHandler* handler_;
+ Isolate* isolate_;
ThreadLocalTop* thread_;
Address fp_;
Address sp_;
@@ -667,13 +686,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) :
@@ -702,6 +720,8 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
void Reset();
private:
+ inline void AdvanceToId(StackFrame::Id id);
+
Iterator iterator_;
};
@@ -716,6 +736,7 @@ typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
class StackTraceFrameIterator: public JavaScriptFrameIterator {
public:
StackTraceFrameIterator();
+ explicit StackTraceFrameIterator(Isolate* isolate);
void Advance();
private:
@@ -739,7 +760,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) {
@@ -786,13 +807,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_;
- // TODO(isolates): this is dangerous.
- static int active_count_;
StackAddressValidator stack_validator_;
const bool is_valid_top_;
const bool is_valid_fp_;
« no previous file with comments | « src/execution.cc ('k') | src/frames.cc » ('j') | src/frames.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698