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 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 String* hidden_string() { return hidden_string_; } | 846 String* hidden_string() { return hidden_string_; } |
847 | 847 |
848 void set_native_contexts_list(Object* object) { | 848 void set_native_contexts_list(Object* object) { |
849 native_contexts_list_ = object; | 849 native_contexts_list_ = object; |
850 } | 850 } |
851 Object* native_contexts_list() const { return native_contexts_list_; } | 851 Object* native_contexts_list() const { return native_contexts_list_; } |
852 | 852 |
853 void set_array_buffers_list(Object* object) { array_buffers_list_ = object; } | 853 void set_array_buffers_list(Object* object) { array_buffers_list_ = object; } |
854 Object* array_buffers_list() const { return array_buffers_list_; } | 854 Object* array_buffers_list() const { return array_buffers_list_; } |
855 | 855 |
| 856 void set_new_array_buffer_views_list(Object* object) { |
| 857 new_array_buffer_views_list_ = object; |
| 858 } |
| 859 Object* new_array_buffer_views_list() const { |
| 860 return new_array_buffer_views_list_; |
| 861 } |
| 862 |
856 void set_allocation_sites_list(Object* object) { | 863 void set_allocation_sites_list(Object* object) { |
857 allocation_sites_list_ = object; | 864 allocation_sites_list_ = object; |
858 } | 865 } |
859 Object* allocation_sites_list() { return allocation_sites_list_; } | 866 Object* allocation_sites_list() { return allocation_sites_list_; } |
860 | 867 |
861 // Used in CreateAllocationSiteStub and the (de)serializer. | 868 // Used in CreateAllocationSiteStub and the (de)serializer. |
862 Object** allocation_sites_list_address() { return &allocation_sites_list_; } | 869 Object** allocation_sites_list_address() { return &allocation_sites_list_; } |
863 | 870 |
864 Object* weak_object_to_code_table() { return weak_object_to_code_table_; } | 871 Object* weak_object_to_code_table() { return weak_object_to_code_table_; } |
865 | 872 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 // trigger the event. In order to track ALL allocations one must turn off | 1453 // trigger the event. In order to track ALL allocations one must turn off |
1447 // FLAG_inline_new and FLAG_use_allocation_folding. | 1454 // FLAG_inline_new and FLAG_use_allocation_folding. |
1448 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); | 1455 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); |
1449 | 1456 |
1450 // This event is triggered after object is moved to a new place. | 1457 // This event is triggered after object is moved to a new place. |
1451 inline void OnMoveEvent(HeapObject* target, HeapObject* source, | 1458 inline void OnMoveEvent(HeapObject* target, HeapObject* source, |
1452 int size_in_bytes); | 1459 int size_in_bytes); |
1453 | 1460 |
1454 bool deserialization_complete() const { return deserialization_complete_; } | 1461 bool deserialization_complete() const { return deserialization_complete_; } |
1455 | 1462 |
| 1463 bool promotion_failure() const { return promotion_failure_; } |
| 1464 void set_promotion_failure(bool promotion_failure) { |
| 1465 promotion_failure_ = promotion_failure; |
| 1466 } |
| 1467 |
1456 protected: | 1468 protected: |
1457 // Methods made available to tests. | 1469 // Methods made available to tests. |
1458 | 1470 |
1459 // Allocates a JS Map in the heap. | 1471 // Allocates a JS Map in the heap. |
1460 MUST_USE_RESULT AllocationResult | 1472 MUST_USE_RESULT AllocationResult |
1461 AllocateMap(InstanceType instance_type, int instance_size, | 1473 AllocateMap(InstanceType instance_type, int instance_size, |
1462 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1474 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
1463 | 1475 |
1464 // Allocates and initializes a new JavaScript object based on a | 1476 // Allocates and initializes a new JavaScript object based on a |
1465 // constructor. | 1477 // constructor. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 | 1623 |
1612 // Indicates that an allocation has failed in the old generation since the | 1624 // Indicates that an allocation has failed in the old generation since the |
1613 // last GC. | 1625 // last GC. |
1614 bool old_gen_exhausted_; | 1626 bool old_gen_exhausted_; |
1615 | 1627 |
1616 // Indicates that inline bump-pointer allocation has been globally disabled | 1628 // Indicates that inline bump-pointer allocation has been globally disabled |
1617 // for all spaces. This is used to disable allocations in generated code. | 1629 // for all spaces. This is used to disable allocations in generated code. |
1618 bool inline_allocation_disabled_; | 1630 bool inline_allocation_disabled_; |
1619 | 1631 |
1620 // Weak list heads, threaded through the objects. | 1632 // Weak list heads, threaded through the objects. |
1621 // List heads are initilized lazily and contain the undefined_value at start. | 1633 // List heads are initialized lazily and contain the undefined_value at start. |
1622 Object* native_contexts_list_; | 1634 Object* native_contexts_list_; |
1623 Object* array_buffers_list_; | 1635 Object* array_buffers_list_; |
1624 Object* allocation_sites_list_; | 1636 Object* allocation_sites_list_; |
1625 | 1637 |
| 1638 // This is a global list of array buffer views in new space. When the views |
| 1639 // get promoted, they are removed form the list and added to the corresponding |
| 1640 // array buffer. |
| 1641 Object* new_array_buffer_views_list_; |
| 1642 |
1626 // WeakHashTable that maps objects embedded in optimized code to dependent | 1643 // WeakHashTable that maps objects embedded in optimized code to dependent |
1627 // code list. It is initilized lazily and contains the undefined_value at | 1644 // code list. It is initialized lazily and contains the undefined_value at |
1628 // start. | 1645 // start. |
1629 Object* weak_object_to_code_table_; | 1646 Object* weak_object_to_code_table_; |
1630 | 1647 |
1631 // List of encountered weak collections (JSWeakMap and JSWeakSet) during | 1648 // List of encountered weak collections (JSWeakMap and JSWeakSet) during |
1632 // marking. It is initialized during marking, destroyed after marking and | 1649 // marking. It is initialized during marking, destroyed after marking and |
1633 // contains Smi(0) while marking is not active. | 1650 // contains Smi(0) while marking is not active. |
1634 Object* encountered_weak_collections_; | 1651 Object* encountered_weak_collections_; |
1635 | 1652 |
1636 Object* encountered_weak_cells_; | 1653 Object* encountered_weak_cells_; |
1637 | 1654 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 StoreBufferEvent event); | 1970 StoreBufferEvent event); |
1954 | 1971 |
1955 // Performs a major collection in the whole heap. | 1972 // Performs a major collection in the whole heap. |
1956 void MarkCompact(); | 1973 void MarkCompact(); |
1957 | 1974 |
1958 // Code to be run before and after mark-compact. | 1975 // Code to be run before and after mark-compact. |
1959 void MarkCompactPrologue(); | 1976 void MarkCompactPrologue(); |
1960 void MarkCompactEpilogue(); | 1977 void MarkCompactEpilogue(); |
1961 | 1978 |
1962 void ProcessNativeContexts(WeakObjectRetainer* retainer); | 1979 void ProcessNativeContexts(WeakObjectRetainer* retainer); |
1963 void ProcessArrayBuffers(WeakObjectRetainer* retainer); | 1980 void ProcessArrayBuffers(WeakObjectRetainer* retainer, bool stop_after_young); |
| 1981 void ProcessNewArrayBufferViews(WeakObjectRetainer* retainer); |
1964 void ProcessAllocationSites(WeakObjectRetainer* retainer); | 1982 void ProcessAllocationSites(WeakObjectRetainer* retainer); |
1965 | 1983 |
1966 // Deopts all code that contains allocation instruction which are tenured or | 1984 // Deopts all code that contains allocation instruction which are tenured or |
1967 // not tenured. Moreover it clears the pretenuring allocation site statistics. | 1985 // not tenured. Moreover it clears the pretenuring allocation site statistics. |
1968 void ResetAllAllocationSitesDependentCode(PretenureFlag flag); | 1986 void ResetAllAllocationSitesDependentCode(PretenureFlag flag); |
1969 | 1987 |
1970 // Evaluates local pretenuring for the old space and calls | 1988 // Evaluates local pretenuring for the old space and calls |
1971 // ResetAllTenuredAllocationSitesDependentCode if too many objects died in | 1989 // ResetAllTenuredAllocationSitesDependentCode if too many objects died in |
1972 // the old space. | 1990 // the old space. |
1973 void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc); | 1991 void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; | 2144 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
2127 | 2145 |
2128 MemoryChunk* chunks_queued_for_free_; | 2146 MemoryChunk* chunks_queued_for_free_; |
2129 | 2147 |
2130 base::Mutex relocation_mutex_; | 2148 base::Mutex relocation_mutex_; |
2131 | 2149 |
2132 int gc_callbacks_depth_; | 2150 int gc_callbacks_depth_; |
2133 | 2151 |
2134 bool deserialization_complete_; | 2152 bool deserialization_complete_; |
2135 | 2153 |
| 2154 // A promotion failure indicates that old space promotion failed during |
| 2155 // gc, i.e., some objects that should have gotten promoted had to stay in |
| 2156 // the new space (they were copied to the other semi-space). |
| 2157 bool promotion_failure_; |
| 2158 |
2136 friend class AlwaysAllocateScope; | 2159 friend class AlwaysAllocateScope; |
2137 friend class Deserializer; | 2160 friend class Deserializer; |
2138 friend class Factory; | 2161 friend class Factory; |
2139 friend class GCCallbacksScope; | 2162 friend class GCCallbacksScope; |
2140 friend class GCTracer; | 2163 friend class GCTracer; |
2141 friend class HeapIterator; | 2164 friend class HeapIterator; |
2142 friend class Isolate; | 2165 friend class Isolate; |
2143 friend class MarkCompactCollector; | 2166 friend class MarkCompactCollector; |
2144 friend class MarkCompactMarkingVisitor; | 2167 friend class MarkCompactMarkingVisitor; |
2145 friend class MapCompact; | 2168 friend class MapCompact; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2617 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2595 | 2618 |
2596 private: | 2619 private: |
2597 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2620 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2598 }; | 2621 }; |
2599 #endif // DEBUG | 2622 #endif // DEBUG |
2600 } | 2623 } |
2601 } // namespace v8::internal | 2624 } // namespace v8::internal |
2602 | 2625 |
2603 #endif // V8_HEAP_HEAP_H_ | 2626 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |