Move SafeStackFrameIterator::active_count_ into an isolate.

R=ager@chromium.org,vitalyr@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6771047

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7483 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0b40589e
......@@ -39,9 +39,6 @@
namespace v8 {
namespace internal {
int SafeStackFrameIterator::active_count_ = 0;
// Iterator that supports traversing the stack handlers of a
// particular frame. Needs to know the top of the handler chain.
class StackHandlerIterator BASE_EMBEDDED {
......@@ -221,10 +218,24 @@ bool SafeStackFrameIterator::ExitFrameValidator::IsValidFP(Address fp) {
}
SafeStackFrameIterator::ActiveCountMaintainer::ActiveCountMaintainer(
Isolate* isolate)
: isolate_(isolate) {
isolate_->set_safe_stack_iterator_counter(
isolate_->safe_stack_iterator_counter() + 1);
}
SafeStackFrameIterator::ActiveCountMaintainer::~ActiveCountMaintainer() {
isolate_->set_safe_stack_iterator_counter(
isolate_->safe_stack_iterator_counter() - 1);
}
SafeStackFrameIterator::SafeStackFrameIterator(
Isolate* isolate,
Address fp, Address sp, Address low_bound, Address high_bound) :
maintainer_(),
maintainer_(isolate),
stack_validator_(low_bound, high_bound),
is_valid_top_(IsValidTop(isolate, low_bound, high_bound)),
is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
......@@ -233,6 +244,10 @@ SafeStackFrameIterator::SafeStackFrameIterator(
iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) {
}
bool SafeStackFrameIterator::is_active(Isolate* isolate) {
return isolate->safe_stack_iterator_counter() > 0;
}
bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
Address low_bound, Address high_bound) {
......@@ -388,13 +403,14 @@ StackFrame::Type StackFrame::ComputeType(State* state) {
const int offset = StandardFrameConstants::kMarkerOffset;
Object* marker = Memory::Object_at(state->fp + offset);
if (!marker->IsSmi()) {
Isolate* isolate = Isolate::Current();
// If we're using a "safe" stack iterator, we treat optimized
// frames as normal JavaScript frames to avoid having to look
// into the heap to determine the state. This is safe as long
// as nobody tries to GC...
if (SafeStackFrameIterator::is_active()) return JAVA_SCRIPT;
Code::Kind kind = GetContainingCode(Isolate::Current(),
*(state->pc_address))->kind();
if (SafeStackFrameIterator::is_active(isolate))
return JAVA_SCRIPT;
Code::Kind kind = GetContainingCode(isolate, *(state->pc_address))->kind();
ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION);
return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT;
}
......@@ -539,7 +555,7 @@ void OptimizedFrame::Iterate(ObjectVisitor* v) const {
// Make sure that we're not doing "safe" stack frame iteration. We cannot
// possibly find pointers in optimized frames in that state.
ASSERT(!SafeStackFrameIterator::is_active());
ASSERT(!SafeStackFrameIterator::is_active(Isolate::Current()));
// Compute the safepoint information.
unsigned stack_slots = 0;
......@@ -640,8 +656,9 @@ Code* JavaScriptFrame::unchecked_code() const {
Address JavaScriptFrame::GetCallerStackPointer() const {
int arguments;
if (SafeStackFrameIterator::is_active() ||
HEAP->gc_state() != Heap::NOT_IN_GC) {
Isolate* isolate = Isolate::Current();
if (SafeStackFrameIterator::is_active(isolate) ||
isolate->heap()->gc_state() != Heap::NOT_IN_GC) {
// If the we are currently iterating the safe stack the
// arguments for frames are traversed as if they were
// expression stack elements of the calling frame. The reason for
......
......@@ -739,7 +739,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 +786,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_;
......
......@@ -316,6 +316,8 @@ typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
/* AstNode state. */ \
V(unsigned, ast_node_id, 0) \
V(unsigned, ast_node_count, 0) \
/* SafeStackFrameIterator activations count. */ \
V(int, safe_stack_iterator_counter, 0) \
ISOLATE_PLATFORM_INIT_LIST(V) \
ISOLATE_LOGGING_INIT_LIST(V) \
ISOLATE_DEBUGGER_INIT_LIST(V)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment