Cache isolate in the StackTrace object to that we don't call

Isolate::Current in the destructor, HandleScope and Zone.
TBR=iposva (already reviewed change on other client).
Review URL: http://codereview.chromium.org//8523013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1427 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
asiva@google.com
2011-11-10 21:08:18 +00:00
parent 117fc65a17
commit 2d388b751f
4 changed files with 25 additions and 26 deletions
+5 -6
View File
@@ -11,17 +11,16 @@
namespace dart {
StackResource::StackResource() {
Isolate* isolate = Isolate::Current();
previous_ = isolate->top_resource();
isolate->set_top_resource(this);
isolate_ = Isolate::Current();
previous_ = isolate_->top_resource();
isolate_->set_top_resource(this);
}
StackResource::~StackResource() {
Isolate* isolate = Isolate::Current();
StackResource* top = isolate->top_resource();
StackResource* top = isolate_->top_resource();
ASSERT(top == this);
isolate->set_top_resource(previous_);
isolate_->set_top_resource(previous_);
}
ZoneAllocated::~ZoneAllocated() {
+6
View File
@@ -9,6 +9,9 @@
namespace dart {
// Forward declarations.
class Isolate;
// Stack allocated objects subclass from this base class. Objects of this type
// cannot be allocated on either the C or object heaps. Destructors for objects
// of this type will not be run unless the stack is unwound through normal
@@ -35,11 +38,14 @@ class StackResource {
StackResource();
virtual ~StackResource();
Isolate* isolate() const { return isolate_; }
// The delete operator should be private instead of public, but unfortunately
// the compiler complains when compiling the destructors for subclasses.
void operator delete(void* pointer) { UNREACHABLE(); }
private:
Isolate* isolate_; // Current isolate for this stack resource.
StackResource* previous_;
void* operator new(uword size);
+10 -14
View File
@@ -70,45 +70,41 @@ int VMHandles::ZoneHandleCount() {
HandleScope::HandleScope() : StackResource() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate->no_handle_scope_depth() == 0);
VMHandles* handles = isolate->current_zone()->handles();
ASSERT(isolate()->no_handle_scope_depth() == 0);
VMHandles* handles = isolate()->current_zone()->handles();
ASSERT(handles != NULL);
saved_handle_block_ = handles->scoped_blocks_;
saved_handle_slot_ = handles->scoped_blocks_->next_handle_slot();
#if defined(DEBUG)
link_ = isolate->top_handle_scope();
isolate->set_top_handle_scope(this);
link_ = isolate()->top_handle_scope();
isolate()->set_top_handle_scope(this);
#endif
}
HandleScope::~HandleScope() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate->current_zone() != NULL);
VMHandles* handles = isolate->current_zone()->handles();
ASSERT(isolate()->current_zone() != NULL);
VMHandles* handles = isolate()->current_zone()->handles();
ASSERT(handles != NULL);
handles->scoped_blocks_ = saved_handle_block_;
handles->scoped_blocks_->set_next_handle_slot(saved_handle_slot_);
#if defined(DEBUG)
handles->VerifyScopedHandleState();
handles->ZapFreeScopedHandles();
ASSERT(isolate->top_handle_scope() == this);
isolate->set_top_handle_scope(link_);
ASSERT(isolate()->top_handle_scope() == this);
isolate()->set_top_handle_scope(link_);
#endif
}
#if defined(DEBUG)
NoHandleScope::NoHandleScope() : StackResource() {
Isolate* isolate = Isolate::Current();
isolate->IncrementNoHandleScopeDepth();
isolate()->IncrementNoHandleScopeDepth();
}
NoHandleScope::~NoHandleScope() {
Isolate* isolate = Isolate::Current();
isolate->DecrementNoHandleScopeDepth();
isolate()->DecrementNoHandleScopeDepth();
}
#endif // defined(DEBUG)
+4 -6
View File
@@ -223,16 +223,14 @@ Zone::Zone()
// Assert that there is no current zone as we only want to scope
// zones when transitioning from generated dart code to dart VM
// runtime code.
Isolate* isolate = Isolate::Current();
previous_ = isolate->current_zone();
Isolate::Current()->set_current_zone(this);
previous_ = isolate()->current_zone();
isolate()->set_current_zone(this);
}
Zone::~Zone() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate->current_zone() == this);
isolate->set_current_zone(previous_);
ASSERT(isolate()->current_zone() == this);
isolate()->set_current_zone(previous_);
}