| 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_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
| 6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1611 |
| 1612 // An ArrayBuffer moved from new space to old space. | 1612 // An ArrayBuffer moved from new space to old space. |
| 1613 void PromoteArrayBuffer(Object* buffer); | 1613 void PromoteArrayBuffer(Object* buffer); |
| 1614 | 1614 |
| 1615 bool HasLowAllocationRate(); | 1615 bool HasLowAllocationRate(); |
| 1616 bool HasHighFragmentation(); | 1616 bool HasHighFragmentation(); |
| 1617 bool HasHighFragmentation(intptr_t used, intptr_t committed); | 1617 bool HasHighFragmentation(intptr_t used, intptr_t committed); |
| 1618 | 1618 |
| 1619 bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; } | 1619 bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; } |
| 1620 | 1620 |
| 1621 protected: | 1621 private: |
| 1622 // Methods made available to tests. | 1622 static const int kInitialStringTableSize = 2048; |
| 1623 static const int kInitialEvalCacheSize = 64; |
| 1624 static const int kInitialNumberStringCacheSize = 256; |
| 1625 |
| 1626 Heap(); |
| 1627 |
| 1628 int current_gc_flags() { return current_gc_flags_; } |
| 1629 void set_current_gc_flags(int flags) { |
| 1630 current_gc_flags_ = flags; |
| 1631 DCHECK(!ShouldFinalizeIncrementalMarking() || |
| 1632 !ShouldAbortIncrementalMarking()); |
| 1633 } |
| 1634 |
| 1635 inline bool ShouldReduceMemory() const { |
| 1636 return current_gc_flags_ & kReduceMemoryFootprintMask; |
| 1637 } |
| 1638 |
| 1639 inline bool ShouldAbortIncrementalMarking() const { |
| 1640 return current_gc_flags_ & kAbortIncrementalMarkingMask; |
| 1641 } |
| 1642 |
| 1643 inline bool ShouldFinalizeIncrementalMarking() const { |
| 1644 return current_gc_flags_ & kFinalizeIncrementalMarkingMask; |
| 1645 } |
| 1623 | 1646 |
| 1624 // Allocates a JS Map in the heap. | 1647 // Allocates a JS Map in the heap. |
| 1625 MUST_USE_RESULT AllocationResult | 1648 MUST_USE_RESULT AllocationResult |
| 1626 AllocateMap(InstanceType instance_type, int instance_size, | 1649 AllocateMap(InstanceType instance_type, int instance_size, |
| 1627 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1650 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
| 1628 | 1651 |
| 1629 // Allocates and initializes a new JavaScript object based on a | 1652 // Allocates and initializes a new JavaScript object based on a |
| 1630 // constructor. | 1653 // constructor. |
| 1631 // If allocation_site is non-null, then a memento is emitted after the object | 1654 // If allocation_site is non-null, then a memento is emitted after the object |
| 1632 // that points to the site. | 1655 // that points to the site. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 // the provided data as the relocation information. | 1690 // the provided data as the relocation information. |
| 1668 MUST_USE_RESULT AllocationResult | 1691 MUST_USE_RESULT AllocationResult |
| 1669 CopyCode(Code* code, Vector<byte> reloc_info); | 1692 CopyCode(Code* code, Vector<byte> reloc_info); |
| 1670 | 1693 |
| 1671 MUST_USE_RESULT AllocationResult CopyCode(Code* code); | 1694 MUST_USE_RESULT AllocationResult CopyCode(Code* code); |
| 1672 | 1695 |
| 1673 // Allocates a fixed array initialized with undefined values | 1696 // Allocates a fixed array initialized with undefined values |
| 1674 MUST_USE_RESULT AllocationResult | 1697 MUST_USE_RESULT AllocationResult |
| 1675 AllocateFixedArray(int length, PretenureFlag pretenure = NOT_TENURED); | 1698 AllocateFixedArray(int length, PretenureFlag pretenure = NOT_TENURED); |
| 1676 | 1699 |
| 1677 static const int kInitialStringTableSize = 2048; | |
| 1678 static const int kInitialEvalCacheSize = 64; | |
| 1679 static const int kInitialNumberStringCacheSize = 256; | |
| 1680 | |
| 1681 private: | |
| 1682 Heap(); | |
| 1683 | |
| 1684 int current_gc_flags() { return current_gc_flags_; } | |
| 1685 void set_current_gc_flags(int flags) { | |
| 1686 current_gc_flags_ = flags; | |
| 1687 DCHECK(!ShouldFinalizeIncrementalMarking() || | |
| 1688 !ShouldAbortIncrementalMarking()); | |
| 1689 } | |
| 1690 | |
| 1691 inline bool ShouldReduceMemory() const { | |
| 1692 return current_gc_flags_ & kReduceMemoryFootprintMask; | |
| 1693 } | |
| 1694 | |
| 1695 inline bool ShouldAbortIncrementalMarking() const { | |
| 1696 return current_gc_flags_ & kAbortIncrementalMarkingMask; | |
| 1697 } | |
| 1698 | |
| 1699 inline bool ShouldFinalizeIncrementalMarking() const { | |
| 1700 return current_gc_flags_ & kFinalizeIncrementalMarkingMask; | |
| 1701 } | |
| 1702 | |
| 1703 // The amount of external memory registered through the API kept alive | 1700 // The amount of external memory registered through the API kept alive |
| 1704 // by global handles | 1701 // by global handles |
| 1705 int64_t amount_of_external_allocated_memory_; | 1702 int64_t amount_of_external_allocated_memory_; |
| 1706 | 1703 |
| 1707 // Caches the amount of external memory registered at the last global gc. | 1704 // Caches the amount of external memory registered at the last global gc. |
| 1708 int64_t amount_of_external_allocated_memory_at_last_global_gc_; | 1705 int64_t amount_of_external_allocated_memory_at_last_global_gc_; |
| 1709 | 1706 |
| 1710 // This can be calculated directly from a pointer to the heap; however, it is | 1707 // This can be calculated directly from a pointer to the heap; however, it is |
| 1711 // more expedient to get at the isolate directly from within Heap methods. | 1708 // more expedient to get at the isolate directly from within Heap methods. |
| 1712 Isolate* isolate_; | 1709 Isolate* isolate_; |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2730 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2734 | 2731 |
| 2735 private: | 2732 private: |
| 2736 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2733 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2737 }; | 2734 }; |
| 2738 #endif // DEBUG | 2735 #endif // DEBUG |
| 2739 } | 2736 } |
| 2740 } // namespace v8::internal | 2737 } // namespace v8::internal |
| 2741 | 2738 |
| 2742 #endif // V8_HEAP_HEAP_H_ | 2739 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |