OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 #endif | 1189 #endif |
1190 | 1190 |
1191 void AddGCPrologueCallback( | 1191 void AddGCPrologueCallback( |
1192 GCPrologueCallback callback, GCType gc_type_filter); | 1192 GCPrologueCallback callback, GCType gc_type_filter); |
1193 void RemoveGCPrologueCallback(GCPrologueCallback callback); | 1193 void RemoveGCPrologueCallback(GCPrologueCallback callback); |
1194 | 1194 |
1195 void AddGCEpilogueCallback( | 1195 void AddGCEpilogueCallback( |
1196 GCEpilogueCallback callback, GCType gc_type_filter); | 1196 GCEpilogueCallback callback, GCType gc_type_filter); |
1197 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | 1197 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
1198 | 1198 |
1199 void SetGlobalGCPrologueCallback(GCCallback callback) { | |
1200 ASSERT((callback == NULL) ^ (global_gc_prologue_callback_ == NULL)); | |
1201 global_gc_prologue_callback_ = callback; | |
1202 } | |
1203 void SetGlobalGCEpilogueCallback(GCCallback callback) { | |
1204 ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL)); | |
1205 global_gc_epilogue_callback_ = callback; | |
1206 } | |
1207 | |
1208 // Heap root getters. We have versions with and without type::cast() here. | 1199 // Heap root getters. We have versions with and without type::cast() here. |
1209 // You can't use type::cast during GC because the assert fails. | 1200 // You can't use type::cast during GC because the assert fails. |
1210 // TODO(1490): Try removing the unchecked accessors, now that GC marking does | 1201 // TODO(1490): Try removing the unchecked accessors, now that GC marking does |
1211 // not corrupt the map. | 1202 // not corrupt the map. |
1212 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1203 #define ROOT_ACCESSOR(type, name, camel_name) \ |
1213 type* name() { \ | 1204 type* name() { \ |
1214 return type::cast(roots_[k##camel_name##RootIndex]); \ | 1205 return type::cast(roots_[k##camel_name##RootIndex]); \ |
1215 } \ | 1206 } \ |
1216 type* raw_unchecked_##name() { \ | 1207 type* raw_unchecked_##name() { \ |
1217 return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \ | 1208 return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \ |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 return &error_object_list_; | 1622 return &error_object_list_; |
1632 } | 1623 } |
1633 | 1624 |
1634 // Returns the current sweep generation. | 1625 // Returns the current sweep generation. |
1635 int sweep_generation() { | 1626 int sweep_generation() { |
1636 return sweep_generation_; | 1627 return sweep_generation_; |
1637 } | 1628 } |
1638 | 1629 |
1639 inline Isolate* isolate(); | 1630 inline Isolate* isolate(); |
1640 | 1631 |
1641 inline void CallGlobalGCPrologueCallback() { | 1632 void CallGCPrologueCallbacks(GCType gc_type); |
1642 if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_(); | 1633 void CallGCEpilogueCallbacks(GCType gc_type); |
1643 } | |
1644 | |
1645 inline void CallGlobalGCEpilogueCallback() { | |
1646 if (global_gc_epilogue_callback_ != NULL) global_gc_epilogue_callback_(); | |
1647 } | |
1648 | 1634 |
1649 inline bool OldGenerationAllocationLimitReached(); | 1635 inline bool OldGenerationAllocationLimitReached(); |
1650 | 1636 |
1651 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { | 1637 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { |
1652 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); | 1638 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); |
1653 } | 1639 } |
1654 | 1640 |
1655 void QueueMemoryChunkForFree(MemoryChunk* chunk); | 1641 void QueueMemoryChunkForFree(MemoryChunk* chunk); |
1656 void FreeQueuedChunks(); | 1642 void FreeQueuedChunks(); |
1657 | 1643 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 : callback(callback), gc_type(gc_type) { | 1915 : callback(callback), gc_type(gc_type) { |
1930 } | 1916 } |
1931 bool operator==(const GCEpilogueCallbackPair& pair) const { | 1917 bool operator==(const GCEpilogueCallbackPair& pair) const { |
1932 return pair.callback == callback; | 1918 return pair.callback == callback; |
1933 } | 1919 } |
1934 GCEpilogueCallback callback; | 1920 GCEpilogueCallback callback; |
1935 GCType gc_type; | 1921 GCType gc_type; |
1936 }; | 1922 }; |
1937 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; | 1923 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
1938 | 1924 |
1939 GCCallback global_gc_prologue_callback_; | |
1940 GCCallback global_gc_epilogue_callback_; | |
1941 | |
1942 // Support for computing object sizes during GC. | 1925 // Support for computing object sizes during GC. |
1943 HeapObjectCallback gc_safe_size_of_old_object_; | 1926 HeapObjectCallback gc_safe_size_of_old_object_; |
1944 static int GcSafeSizeOfOldObject(HeapObject* object); | 1927 static int GcSafeSizeOfOldObject(HeapObject* object); |
1945 | 1928 |
1946 // Update the GC state. Called from the mark-compact collector. | 1929 // Update the GC state. Called from the mark-compact collector. |
1947 void MarkMapPointersAsEncoded(bool encoded) { | 1930 void MarkMapPointersAsEncoded(bool encoded) { |
1948 ASSERT(!encoded); | 1931 ASSERT(!encoded); |
1949 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | 1932 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
1950 } | 1933 } |
1951 | 1934 |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 2880 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
2898 | 2881 |
2899 private: | 2882 private: |
2900 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2883 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2901 }; | 2884 }; |
2902 #endif // DEBUG | 2885 #endif // DEBUG |
2903 | 2886 |
2904 } } // namespace v8::internal | 2887 } } // namespace v8::internal |
2905 | 2888 |
2906 #endif // V8_HEAP_H_ | 2889 #endif // V8_HEAP_H_ |
OLD | NEW |