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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 String* hidden_string() { return hidden_string_; } | 852 String* hidden_string() { return hidden_string_; } |
853 | 853 |
854 void set_native_contexts_list(Object* object) { | 854 void set_native_contexts_list(Object* object) { |
855 native_contexts_list_ = object; | 855 native_contexts_list_ = object; |
856 } | 856 } |
857 Object* native_contexts_list() const { return native_contexts_list_; } | 857 Object* native_contexts_list() const { return native_contexts_list_; } |
858 | 858 |
859 void set_array_buffers_list(Object* object) { array_buffers_list_ = object; } | 859 void set_array_buffers_list(Object* object) { array_buffers_list_ = object; } |
860 Object* array_buffers_list() const { return array_buffers_list_; } | 860 Object* array_buffers_list() const { return array_buffers_list_; } |
861 | 861 |
862 void set_new_array_buffer_views_list(Object* object) { | |
863 new_array_buffer_views_list_ = object; | |
864 } | |
865 Object* new_array_buffer_views_list() const { | |
866 return new_array_buffer_views_list_; | |
867 } | |
868 | |
869 void set_allocation_sites_list(Object* object) { | 862 void set_allocation_sites_list(Object* object) { |
870 allocation_sites_list_ = object; | 863 allocation_sites_list_ = object; |
871 } | 864 } |
872 Object* allocation_sites_list() { return allocation_sites_list_; } | 865 Object* allocation_sites_list() { return allocation_sites_list_; } |
873 | 866 |
874 // Used in CreateAllocationSiteStub and the (de)serializer. | 867 // Used in CreateAllocationSiteStub and the (de)serializer. |
875 Object** allocation_sites_list_address() { return &allocation_sites_list_; } | 868 Object** allocation_sites_list_address() { return &allocation_sites_list_; } |
876 | 869 |
877 void set_encountered_weak_collections(Object* weak_collection) { | 870 void set_encountered_weak_collections(Object* weak_collection) { |
878 encountered_weak_collections_ = weak_collection; | 871 encountered_weak_collections_ = weak_collection; |
(...skipping 567 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 | 1439 // trigger the event. In order to track ALL allocations one must turn off |
1447 // FLAG_inline_new and FLAG_use_allocation_folding. | 1440 // FLAG_inline_new and FLAG_use_allocation_folding. |
1448 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); | 1441 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); |
1449 | 1442 |
1450 // This event is triggered after object is moved to a new place. | 1443 // This event is triggered after object is moved to a new place. |
1451 inline void OnMoveEvent(HeapObject* target, HeapObject* source, | 1444 inline void OnMoveEvent(HeapObject* target, HeapObject* source, |
1452 int size_in_bytes); | 1445 int size_in_bytes); |
1453 | 1446 |
1454 bool deserialization_complete() const { return deserialization_complete_; } | 1447 bool deserialization_complete() const { return deserialization_complete_; } |
1455 | 1448 |
1456 bool promotion_failure() const { return promotion_failure_; } | |
1457 void set_promotion_failure(bool promotion_failure) { | |
1458 promotion_failure_ = promotion_failure; | |
1459 } | |
1460 | |
1461 protected: | 1449 protected: |
1462 // Methods made available to tests. | 1450 // Methods made available to tests. |
1463 | 1451 |
1464 // Allocates a JS Map in the heap. | 1452 // Allocates a JS Map in the heap. |
1465 MUST_USE_RESULT AllocationResult | 1453 MUST_USE_RESULT AllocationResult |
1466 AllocateMap(InstanceType instance_type, int instance_size, | 1454 AllocateMap(InstanceType instance_type, int instance_size, |
1467 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1455 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
1468 | 1456 |
1469 // Allocates and initializes a new JavaScript object based on a | 1457 // Allocates and initializes a new JavaScript object based on a |
1470 // constructor. | 1458 // constructor. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 | 1604 |
1617 // Indicates that an allocation has failed in the old generation since the | 1605 // Indicates that an allocation has failed in the old generation since the |
1618 // last GC. | 1606 // last GC. |
1619 bool old_gen_exhausted_; | 1607 bool old_gen_exhausted_; |
1620 | 1608 |
1621 // Indicates that inline bump-pointer allocation has been globally disabled | 1609 // Indicates that inline bump-pointer allocation has been globally disabled |
1622 // for all spaces. This is used to disable allocations in generated code. | 1610 // for all spaces. This is used to disable allocations in generated code. |
1623 bool inline_allocation_disabled_; | 1611 bool inline_allocation_disabled_; |
1624 | 1612 |
1625 // Weak list heads, threaded through the objects. | 1613 // Weak list heads, threaded through the objects. |
1626 // List heads are initialized lazily and contain the undefined_value at start. | 1614 // List heads are initilized lazily and contain the undefined_value at start. |
1627 Object* native_contexts_list_; | 1615 Object* native_contexts_list_; |
1628 Object* array_buffers_list_; | 1616 Object* array_buffers_list_; |
1629 Object* allocation_sites_list_; | 1617 Object* allocation_sites_list_; |
1630 | 1618 |
1631 // This is a global list of array buffer views in new space. When the views | |
1632 // get promoted, they are removed form the list and added to the corresponding | |
1633 // array buffer. | |
1634 Object* new_array_buffer_views_list_; | |
1635 | |
1636 // List of encountered weak collections (JSWeakMap and JSWeakSet) during | 1619 // List of encountered weak collections (JSWeakMap and JSWeakSet) during |
1637 // marking. It is initialized during marking, destroyed after marking and | 1620 // marking. It is initialized during marking, destroyed after marking and |
1638 // contains Smi(0) while marking is not active. | 1621 // contains Smi(0) while marking is not active. |
1639 Object* encountered_weak_collections_; | 1622 Object* encountered_weak_collections_; |
1640 | 1623 |
1641 Object* encountered_weak_cells_; | 1624 Object* encountered_weak_cells_; |
1642 | 1625 |
1643 StoreBufferRebuilder store_buffer_rebuilder_; | 1626 StoreBufferRebuilder store_buffer_rebuilder_; |
1644 | 1627 |
1645 struct StringTypeTable { | 1628 struct StringTypeTable { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 StoreBufferEvent event); | 1941 StoreBufferEvent event); |
1959 | 1942 |
1960 // Performs a major collection in the whole heap. | 1943 // Performs a major collection in the whole heap. |
1961 void MarkCompact(); | 1944 void MarkCompact(); |
1962 | 1945 |
1963 // Code to be run before and after mark-compact. | 1946 // Code to be run before and after mark-compact. |
1964 void MarkCompactPrologue(); | 1947 void MarkCompactPrologue(); |
1965 void MarkCompactEpilogue(); | 1948 void MarkCompactEpilogue(); |
1966 | 1949 |
1967 void ProcessNativeContexts(WeakObjectRetainer* retainer); | 1950 void ProcessNativeContexts(WeakObjectRetainer* retainer); |
1968 void ProcessArrayBuffers(WeakObjectRetainer* retainer, bool stop_after_young); | 1951 void ProcessArrayBuffers(WeakObjectRetainer* retainer); |
1969 void ProcessNewArrayBufferViews(WeakObjectRetainer* retainer); | |
1970 void ProcessAllocationSites(WeakObjectRetainer* retainer); | 1952 void ProcessAllocationSites(WeakObjectRetainer* retainer); |
1971 | 1953 |
1972 // Deopts all code that contains allocation instruction which are tenured or | 1954 // Deopts all code that contains allocation instruction which are tenured or |
1973 // not tenured. Moreover it clears the pretenuring allocation site statistics. | 1955 // not tenured. Moreover it clears the pretenuring allocation site statistics. |
1974 void ResetAllAllocationSitesDependentCode(PretenureFlag flag); | 1956 void ResetAllAllocationSitesDependentCode(PretenureFlag flag); |
1975 | 1957 |
1976 // Evaluates local pretenuring for the old space and calls | 1958 // Evaluates local pretenuring for the old space and calls |
1977 // ResetAllTenuredAllocationSitesDependentCode if too many objects died in | 1959 // ResetAllTenuredAllocationSitesDependentCode if too many objects died in |
1978 // the old space. | 1960 // the old space. |
1979 void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc); | 1961 void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; | 2101 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
2120 | 2102 |
2121 MemoryChunk* chunks_queued_for_free_; | 2103 MemoryChunk* chunks_queued_for_free_; |
2122 | 2104 |
2123 base::Mutex relocation_mutex_; | 2105 base::Mutex relocation_mutex_; |
2124 | 2106 |
2125 int gc_callbacks_depth_; | 2107 int gc_callbacks_depth_; |
2126 | 2108 |
2127 bool deserialization_complete_; | 2109 bool deserialization_complete_; |
2128 | 2110 |
2129 // A promotion failure indicates that old space promotion failed during | |
2130 // gc, i.e., some objects that should have gotten promoted had to stay in | |
2131 // the new space (they were copied to the other semi-space). | |
2132 bool promotion_failure_; | |
2133 | |
2134 friend class AlwaysAllocateScope; | 2111 friend class AlwaysAllocateScope; |
2135 friend class Deserializer; | 2112 friend class Deserializer; |
2136 friend class Factory; | 2113 friend class Factory; |
2137 friend class GCCallbacksScope; | 2114 friend class GCCallbacksScope; |
2138 friend class GCTracer; | 2115 friend class GCTracer; |
2139 friend class HeapIterator; | 2116 friend class HeapIterator; |
2140 friend class Isolate; | 2117 friend class Isolate; |
2141 friend class MarkCompactCollector; | 2118 friend class MarkCompactCollector; |
2142 friend class MarkCompactMarkingVisitor; | 2119 friend class MarkCompactMarkingVisitor; |
2143 friend class MapCompact; | 2120 friend class MapCompact; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2569 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2593 | 2570 |
2594 private: | 2571 private: |
2595 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2572 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2596 }; | 2573 }; |
2597 #endif // DEBUG | 2574 #endif // DEBUG |
2598 } | 2575 } |
2599 } // namespace v8::internal | 2576 } // namespace v8::internal |
2600 | 2577 |
2601 #endif // V8_HEAP_HEAP_H_ | 2578 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |