diff options
Diffstat (limited to 'deps/v8/src/heap-inl.h')
-rw-r--r-- | deps/v8/src/heap-inl.h | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/deps/v8/src/heap-inl.h b/deps/v8/src/heap-inl.h index 9d79db246..4a827fef1 100644 --- a/deps/v8/src/heap-inl.h +++ b/deps/v8/src/heap-inl.h @@ -468,10 +468,12 @@ intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( // Avoid overflow. if (amount > amount_of_external_allocated_memory_) { amount_of_external_allocated_memory_ = amount; + } else { + // Give up and reset the counters in case of an overflow. + amount_of_external_allocated_memory_ = 0; + amount_of_external_allocated_memory_at_last_global_gc_ = 0; } - intptr_t amount_since_last_global_gc = - amount_of_external_allocated_memory_ - - amount_of_external_allocated_memory_at_last_global_gc_; + intptr_t amount_since_last_global_gc = PromotedExternalMemorySize(); if (amount_since_last_global_gc > external_allocation_limit_) { CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); } @@ -479,8 +481,19 @@ intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( // Avoid underflow. if (amount >= 0) { amount_of_external_allocated_memory_ = amount; + } else { + // Give up and reset the counters in case of an overflow. + amount_of_external_allocated_memory_ = 0; + amount_of_external_allocated_memory_at_last_global_gc_ = 0; } } + if (FLAG_trace_external_memory) { + PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); + PrintF("Adjust amount of external memory: delta=%6" V8_PTR_PREFIX "d KB, " + " amount=%6" V8_PTR_PREFIX "d KB, isolate=0x%08" V8PRIxPTR ".\n", + change_in_bytes / 1024, amount_of_external_allocated_memory_ / 1024, + reinterpret_cast<intptr_t>(isolate())); + } ASSERT(amount_of_external_allocated_memory_ >= 0); return amount_of_external_allocated_memory_; } @@ -757,37 +770,47 @@ double GCTracer::SizeOfHeapObjects() { } -#ifdef DEBUG DisallowAllocationFailure::DisallowAllocationFailure() { +#ifdef DEBUG old_state_ = HEAP->disallow_allocation_failure_; HEAP->disallow_allocation_failure_ = true; +#endif } DisallowAllocationFailure::~DisallowAllocationFailure() { +#ifdef DEBUG HEAP->disallow_allocation_failure_ = old_state_; -} #endif +} #ifdef DEBUG AssertNoAllocation::AssertNoAllocation() { - old_state_ = HEAP->allow_allocation(false); + Isolate* isolate = ISOLATE; + active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); + if (active_) { + old_state_ = isolate->heap()->allow_allocation(false); + } } AssertNoAllocation::~AssertNoAllocation() { - HEAP->allow_allocation(old_state_); + if (active_) HEAP->allow_allocation(old_state_); } DisableAssertNoAllocation::DisableAssertNoAllocation() { - old_state_ = HEAP->allow_allocation(true); + Isolate* isolate = ISOLATE; + active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); + if (active_) { + old_state_ = isolate->heap()->allow_allocation(true); + } } DisableAssertNoAllocation::~DisableAssertNoAllocation() { - HEAP->allow_allocation(old_state_); + if (active_) HEAP->allow_allocation(old_state_); } #else |