Index: runtime/vm/heap.cc |
=================================================================== |
--- runtime/vm/heap.cc (revision 20419) |
+++ runtime/vm/heap.cc (working copy) |
@@ -201,11 +201,16 @@ |
} |
-void Heap::EnableGrowthControl() { |
- old_space_->EnableGrowthControl(); |
+void Heap::SetGrowthControlState(bool state) { |
+ old_space_->SetGrowthControlState(state); |
} |
+bool Heap::GrowthControlState() { |
+ return old_space_->GrowthControlState(); |
+} |
+ |
+ |
void Heap::WriteProtect(bool read_only) { |
read_only_ = read_only; |
new_space_->WriteProtect(read_only); |
@@ -482,4 +487,18 @@ |
} |
#endif // defined(DEBUG) |
+ |
+NoHeapGrowthControlScope::NoHeapGrowthControlScope() |
+ : StackResource(Isolate::Current()) { |
+ Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
+ current_growth_controller_state_ = heap->GrowthControlState(); |
+ heap->DisableGrowthControl(); |
+} |
+ |
+ |
+NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
+ Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
+ heap->SetGrowthControlState(current_growth_controller_state_); |
+} |
+ |
} // namespace dart |