| Index: src/heap-inl.h
|
| diff --git a/src/heap-inl.h b/src/heap-inl.h
|
| index f937426186c8099fb9c2f5469f3c32eb4eb97355..18a2cf351b33f1eb2886fe8b8658519159a445b1 100644
|
| --- a/src/heap-inl.h
|
| +++ b/src/heap-inl.h
|
| @@ -650,6 +650,10 @@ inline bool Heap::allow_allocation(bool new_state) {
|
| return old;
|
| }
|
|
|
| +inline void Heap::set_allow_allocation(bool allocation_allowed) {
|
| + allocation_allowed_ = allocation_allowed;
|
| +}
|
| +
|
| #endif
|
|
|
|
|
| @@ -864,33 +868,36 @@ DisallowAllocationFailure::~DisallowAllocationFailure() {
|
|
|
|
|
| #ifdef DEBUG
|
| -AssertNoAllocation::AssertNoAllocation() {
|
| - Isolate* isolate = ISOLATE;
|
| - active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
|
| - if (active_) {
|
| - old_state_ = isolate->heap()->allow_allocation(false);
|
| +bool EnterAllocationScope(Isolate* isolate, bool allow_allocation) {
|
| + bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
|
| + bool last_state = isolate->heap()->IsAllocationAllowed();
|
| + if (active) {
|
| + isolate->heap()->set_allow_allocation(allow_allocation);
|
| }
|
| + return last_state;
|
| }
|
|
|
|
|
| -AssertNoAllocation::~AssertNoAllocation() {
|
| - if (active_) HEAP->allow_allocation(old_state_);
|
| +void ExitAllocationScope(Isolate* isolate, bool last_state) {
|
| + isolate->heap()->set_allow_allocation(last_state);
|
| }
|
|
|
|
|
| -DisableAssertNoAllocation::DisableAssertNoAllocation() {
|
| - Isolate* isolate = ISOLATE;
|
| - active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
|
| - if (active_) {
|
| - old_state_ = isolate->heap()->allow_allocation(true);
|
| - }
|
| +AssertNoAllocation::AssertNoAllocation()
|
| + : last_state_(EnterAllocationScope(ISOLATE, false)) {
|
| }
|
|
|
| +AssertNoAllocation::~AssertNoAllocation() {
|
| + ExitAllocationScope(ISOLATE, last_state_);
|
| +}
|
|
|
| -DisableAssertNoAllocation::~DisableAssertNoAllocation() {
|
| - if (active_) HEAP->allow_allocation(old_state_);
|
| +DisableAssertNoAllocation::DisableAssertNoAllocation()
|
| + : last_state_(EnterAllocationScope(ISOLATE, true)) {
|
| }
|
|
|
| +DisableAssertNoAllocation::~DisableAssertNoAllocation() {
|
| + ExitAllocationScope(ISOLATE, last_state_);
|
| +}
|
| #else
|
|
|
| AssertNoAllocation::AssertNoAllocation() { }
|
|
|