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

Unified Diff: runtime/vm/dart_api_state.h

Issue 11028145: Changed StackZone and ApiZone to be containers for Zone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor tweak to use RawError instead of RawObject. Created 8 years, 2 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 | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_state.h
diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
index c851b3142194696734f22d4829f846db7a180c1d..55b5ad0e4ef5f63129c3b360f1d0cce47510ad61 100644
--- a/runtime/vm/dart_api_state.h
+++ b/runtime/vm/dart_api_state.h
@@ -28,10 +28,22 @@ namespace dart {
class ApiZone {
public:
// Create an empty zone.
- ApiZone() : zone_() { }
+ ApiZone() : zone_() {
+ Isolate* isolate = Isolate::Current();
+ Zone* current_zone = isolate != NULL ? isolate->current_zone() : NULL;
+ zone_.Link(current_zone);
+ if (isolate != NULL) {
+ isolate->set_current_zone(&zone_);
+ }
+ }
// Delete all memory associated with the zone.
- ~ApiZone() { }
+ ~ApiZone() {
+ Isolate* isolate = Isolate::Current();
+ if (isolate != NULL && isolate->current_zone() == &zone_) {
+ isolate->set_current_zone(zone_.previous_);
+ }
+ }
// Allocates an array sized to hold 'len' elements of type
// 'ElementType'. Checks for integer overflow when performing the
@@ -61,9 +73,9 @@ class ApiZone {
// due to internal fragmentation in the segments.
intptr_t SizeInBytes() const { return zone_.SizeInBytes(); }
- private:
- Zone* GetBaseZone() { return &zone_; }
+ Zone* GetZone() { return &zone_; }
+ private:
Zone zone_;
template<typename T> friend class ApiGrowableArray;
@@ -446,7 +458,7 @@ class ApiLocalScope {
uword stack_marker() const { return stack_marker_; }
void set_previous(ApiLocalScope* value) { previous_ = value; }
LocalHandles* local_handles() { return &local_handles_; }
- ApiZone* zone() { return &zone_; }
+ Zone* zone() { return zone_.GetZone(); }
private:
ApiLocalScope* previous_;
@@ -653,7 +665,7 @@ class ApiNativeScope {
Thread::GetThreadLocal(Api::api_native_key_));
}
- ApiZone* zone() { return &zone_; }
+ Zone* zone() { return zone_.GetZone(); }
private:
ApiZone zone_;
@@ -671,10 +683,10 @@ class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> {
explicit ApiGrowableArray(int initial_capacity)
: BaseGrowableArray<T, ValueObject>(
initial_capacity,
- ApiNativeScope::Current()->zone()->GetBaseZone()) {}
+ ApiNativeScope::Current()->zone()) {}
ApiGrowableArray()
: BaseGrowableArray<T, ValueObject>(
- ApiNativeScope::Current()->zone()->GetBaseZone()) {}
+ ApiNativeScope::Current()->zone()) {}
};
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698