OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_INL_H_ | 5 #ifndef V8_HEAP_INL_H_ |
6 #define V8_HEAP_INL_H_ | 6 #define V8_HEAP_INL_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/heap.h" | 10 #include "src/heap.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 | 520 |
521 bool Heap::CollectGarbage(AllocationSpace space, | 521 bool Heap::CollectGarbage(AllocationSpace space, |
522 const char* gc_reason, | 522 const char* gc_reason, |
523 const v8::GCCallbackFlags callbackFlags) { | 523 const v8::GCCallbackFlags callbackFlags) { |
524 const char* collector_reason = NULL; | 524 const char* collector_reason = NULL; |
525 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); | 525 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); |
526 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); | 526 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); |
527 } | 527 } |
528 | 528 |
529 | 529 |
530 int64_t Heap::AdjustAmountOfExternalAllocatedMemory( | 530 int64_t Heap::AdjustAmountOfExternalAllocatedMemory( |
Hannes Payer (out of office)
2014/06/04 12:18:30
Why don't we get rid of this method? It seems like
| |
531 int64_t change_in_bytes) { | 531 int64_t change_in_bytes) { |
532 ASSERT(HasBeenSetUp()); | 532 ASSERT(HasBeenSetUp()); |
533 int64_t amount = amount_of_external_allocated_memory_ + change_in_bytes; | 533 int64_t amount = amount_of_external_allocated_memory_ + change_in_bytes; |
534 if (change_in_bytes > 0) { | 534 if (change_in_bytes > 0) { |
535 // Avoid overflow. | 535 amount_of_external_allocated_memory_ = amount; |
jochen (gone - plz use gerrit)
2014/06/04 11:53:07
note that signed overflow is undefined, so these c
| |
536 if (amount > amount_of_external_allocated_memory_) { | |
537 amount_of_external_allocated_memory_ = amount; | |
538 } else { | |
539 // Give up and reset the counters in case of an overflow. | |
540 amount_of_external_allocated_memory_ = 0; | |
541 amount_of_external_allocated_memory_at_last_global_gc_ = 0; | |
542 } | |
543 int64_t amount_since_last_global_gc = PromotedExternalMemorySize(); | 536 int64_t amount_since_last_global_gc = PromotedExternalMemorySize(); |
544 if (amount_since_last_global_gc > external_allocation_limit_) { | 537 if (amount_since_last_global_gc > Internals::kExternalAllocationLimit) { |
545 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); | 538 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); |
546 } | 539 } |
547 } else { | 540 } else { |
548 // Avoid underflow. | 541 amount_of_external_allocated_memory_ = amount; |
549 if (amount >= 0) { | |
550 amount_of_external_allocated_memory_ = amount; | |
551 } else { | |
552 // Give up and reset the counters in case of an underflow. | |
553 amount_of_external_allocated_memory_ = 0; | |
554 amount_of_external_allocated_memory_at_last_global_gc_ = 0; | |
555 } | |
556 } | 542 } |
557 if (FLAG_trace_external_memory) { | 543 if (FLAG_trace_external_memory) { |
558 PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); | 544 PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); |
559 PrintF("Adjust amount of external memory: delta=%6" V8_PTR_PREFIX "d KB, " | 545 PrintF("Adjust amount of external memory: delta=%6" V8_PTR_PREFIX "d KB, " |
560 "amount=%6" V8_PTR_PREFIX "d KB, since_gc=%6" V8_PTR_PREFIX "d KB, " | 546 "amount=%6" V8_PTR_PREFIX "d KB, since_gc=%6" V8_PTR_PREFIX "d KB, " |
561 "isolate=0x%08" V8PRIxPTR ".\n", | 547 "isolate=0x%08" V8PRIxPTR ".\n", |
562 static_cast<intptr_t>(change_in_bytes / KB), | 548 static_cast<intptr_t>(change_in_bytes / KB), |
563 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB), | 549 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB), |
564 static_cast<intptr_t>(PromotedExternalMemorySize() / KB), | 550 static_cast<intptr_t>(PromotedExternalMemorySize() / KB), |
565 reinterpret_cast<intptr_t>(isolate())); | 551 reinterpret_cast<intptr_t>(isolate())); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 | 753 |
768 | 754 |
769 double GCTracer::SizeOfHeapObjects() { | 755 double GCTracer::SizeOfHeapObjects() { |
770 return (static_cast<double>(heap_->SizeOfObjects())) / MB; | 756 return (static_cast<double>(heap_->SizeOfObjects())) / MB; |
771 } | 757 } |
772 | 758 |
773 | 759 |
774 } } // namespace v8::internal | 760 } } // namespace v8::internal |
775 | 761 |
776 #endif // V8_HEAP_INL_H_ | 762 #endif // V8_HEAP_INL_H_ |
OLD | NEW |