Revert r7483 "Move SafeStackFrameIterator::active_count_ into an isolate."

It broke the Mac build.

Sampler::SampleStack() can't use Isolate::Current() when called from
the sampler thread (from SampleContext). We have to pass the isolate
pointer.

TBR=mikhail.naganov@gmail.com

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7485 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vitalyr@chromium.org 2011-04-01 16:21:26 +00:00
parent 6952f68ee3
commit 24596cae32
3 changed files with 15 additions and 34 deletions

View File

@ -39,6 +39,9 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
int SafeStackFrameIterator::active_count_ = 0;
// Iterator that supports traversing the stack handlers of a // Iterator that supports traversing the stack handlers of a
// particular frame. Needs to know the top of the handler chain. // particular frame. Needs to know the top of the handler chain.
class StackHandlerIterator BASE_EMBEDDED { class StackHandlerIterator BASE_EMBEDDED {
@ -218,24 +221,10 @@ 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( SafeStackFrameIterator::SafeStackFrameIterator(
Isolate* isolate, Isolate* isolate,
Address fp, Address sp, Address low_bound, Address high_bound) : Address fp, Address sp, Address low_bound, Address high_bound) :
maintainer_(isolate), maintainer_(),
stack_validator_(low_bound, high_bound), stack_validator_(low_bound, high_bound),
is_valid_top_(IsValidTop(isolate, low_bound, high_bound)), is_valid_top_(IsValidTop(isolate, low_bound, high_bound)),
is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
@ -244,10 +233,6 @@ SafeStackFrameIterator::SafeStackFrameIterator(
iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { 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, bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
Address low_bound, Address high_bound) { Address low_bound, Address high_bound) {
@ -403,14 +388,13 @@ StackFrame::Type StackFrame::ComputeType(State* state) {
const int offset = StandardFrameConstants::kMarkerOffset; const int offset = StandardFrameConstants::kMarkerOffset;
Object* marker = Memory::Object_at(state->fp + offset); Object* marker = Memory::Object_at(state->fp + offset);
if (!marker->IsSmi()) { if (!marker->IsSmi()) {
Isolate* isolate = Isolate::Current();
// If we're using a "safe" stack iterator, we treat optimized // If we're using a "safe" stack iterator, we treat optimized
// frames as normal JavaScript frames to avoid having to look // frames as normal JavaScript frames to avoid having to look
// into the heap to determine the state. This is safe as long // into the heap to determine the state. This is safe as long
// as nobody tries to GC... // as nobody tries to GC...
if (SafeStackFrameIterator::is_active(isolate)) if (SafeStackFrameIterator::is_active()) return JAVA_SCRIPT;
return JAVA_SCRIPT; Code::Kind kind = GetContainingCode(Isolate::Current(),
Code::Kind kind = GetContainingCode(isolate, *(state->pc_address))->kind(); *(state->pc_address))->kind();
ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION); ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION);
return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT; return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT;
} }
@ -555,7 +539,7 @@ void OptimizedFrame::Iterate(ObjectVisitor* v) const {
// Make sure that we're not doing "safe" stack frame iteration. We cannot // Make sure that we're not doing "safe" stack frame iteration. We cannot
// possibly find pointers in optimized frames in that state. // possibly find pointers in optimized frames in that state.
ASSERT(!SafeStackFrameIterator::is_active(Isolate::Current())); ASSERT(!SafeStackFrameIterator::is_active());
// Compute the safepoint information. // Compute the safepoint information.
unsigned stack_slots = 0; unsigned stack_slots = 0;
@ -656,9 +640,8 @@ Code* JavaScriptFrame::unchecked_code() const {
Address JavaScriptFrame::GetCallerStackPointer() const { Address JavaScriptFrame::GetCallerStackPointer() const {
int arguments; int arguments;
Isolate* isolate = Isolate::Current(); if (SafeStackFrameIterator::is_active() ||
if (SafeStackFrameIterator::is_active(isolate) || HEAP->gc_state() != Heap::NOT_IN_GC) {
isolate->heap()->gc_state() != Heap::NOT_IN_GC) {
// If the we are currently iterating the safe stack the // If the we are currently iterating the safe stack the
// arguments for frames are traversed as if they were // arguments for frames are traversed as if they were
// expression stack elements of the calling frame. The reason for // expression stack elements of the calling frame. The reason for

View File

@ -739,7 +739,7 @@ class SafeStackFrameIterator BASE_EMBEDDED {
void Advance(); void Advance();
void Reset(); void Reset();
static bool is_active(Isolate* isolate); static bool is_active() { return active_count_ > 0; }
static bool IsWithinBounds( static bool IsWithinBounds(
Address low_bound, Address high_bound, Address addr) { Address low_bound, Address high_bound, Address addr) {
@ -786,13 +786,13 @@ class SafeStackFrameIterator BASE_EMBEDDED {
// heap objects. // heap objects.
class ActiveCountMaintainer BASE_EMBEDDED { class ActiveCountMaintainer BASE_EMBEDDED {
public: public:
explicit ActiveCountMaintainer(Isolate* isolate); ActiveCountMaintainer() { active_count_++; }
~ActiveCountMaintainer(); ~ActiveCountMaintainer() { active_count_--; }
private:
Isolate* isolate_;
}; };
ActiveCountMaintainer maintainer_; ActiveCountMaintainer maintainer_;
// TODO(isolates): this is dangerous.
static int active_count_;
StackAddressValidator stack_validator_; StackAddressValidator stack_validator_;
const bool is_valid_top_; const bool is_valid_top_;
const bool is_valid_fp_; const bool is_valid_fp_;

View File

@ -316,8 +316,6 @@ typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
/* AstNode state. */ \ /* AstNode state. */ \
V(unsigned, ast_node_id, 0) \ V(unsigned, ast_node_id, 0) \
V(unsigned, ast_node_count, 0) \ V(unsigned, ast_node_count, 0) \
/* SafeStackFrameIterator activations count. */ \
V(int, safe_stack_iterator_counter, 0) \
ISOLATE_PLATFORM_INIT_LIST(V) \ ISOLATE_PLATFORM_INIT_LIST(V) \
ISOLATE_LOGGING_INIT_LIST(V) \ ISOLATE_LOGGING_INIT_LIST(V) \
ISOLATE_DEBUGGER_INIT_LIST(V) ISOLATE_DEBUGGER_INIT_LIST(V)