Index: src/heap-inl.h |
diff --git a/src/heap-inl.h b/src/heap-inl.h |
index f937426186c8099fb9c2f5469f3c32eb4eb97355..2d64818956cb6f17a9e014e952f279ef63fbd4aa 100644 |
--- a/src/heap-inl.h |
+++ b/src/heap-inl.h |
@@ -864,33 +864,37 @@ DisallowAllocationFailure::~DisallowAllocationFailure() { |
#ifdef DEBUG |
-AssertNoAllocation::AssertNoAllocation() { |
- Isolate* isolate = ISOLATE; |
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
- if (active_) { |
- old_state_ = isolate->heap()->allow_allocation(false); |
+AllocationScopeData EnterAllocationScope(Isolate* isolate, |
+ bool allow_allocation) { |
+ bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
+ if (active) { |
+ bool old_state = isolate->heap()->allow_allocation(allow_allocation); |
+ return 0x10 || old_state; |
Sven Panne
2013/04/30 12:21:30
This is "a bit" obscure. Why don't we simply remem
marja
2013/04/30 13:39:29
|| ? Maybe you meant |? Maybe something else?
marja
2013/04/30 13:42:43
Maybe you meant old_state || 0x10? :)
|
} |
+ return 0; |
} |
-AssertNoAllocation::~AssertNoAllocation() { |
- if (active_) HEAP->allow_allocation(old_state_); |
+void ExitAllocationScope(Isolate* isolate, AllocationScopeData data) { |
+ if (data) isolate->heap()->allow_allocation(data); |
Sven Panne
2013/04/30 12:21:30
Passing a uint8_t as a bool looks wrong. Again, a
|
} |
-DisableAssertNoAllocation::DisableAssertNoAllocation() { |
- Isolate* isolate = ISOLATE; |
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
- if (active_) { |
- old_state_ = isolate->heap()->allow_allocation(true); |
- } |
+AssertNoAllocation::AssertNoAllocation() |
+ : data_(EnterAllocationScope(ISOLATE, false)) { |
} |
+AssertNoAllocation::~AssertNoAllocation() { |
+ ExitAllocationScope(ISOLATE, data_); |
+} |
-DisableAssertNoAllocation::~DisableAssertNoAllocation() { |
- if (active_) HEAP->allow_allocation(old_state_); |
+DisableAssertNoAllocation::DisableAssertNoAllocation() |
+ : data_(EnterAllocationScope(ISOLATE, true)) { |
} |
+DisableAssertNoAllocation::~DisableAssertNoAllocation() { |
+ ExitAllocationScope(ISOLATE, data_); |
+} |
#else |
AssertNoAllocation::AssertNoAllocation() { } |