OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 // Utility to invoke the scavenger. This is needed in test code to | 668 // Utility to invoke the scavenger. This is needed in test code to |
669 // ensure correct callback for weak global handles. | 669 // ensure correct callback for weak global handles. |
670 static void PerformScavenge(); | 670 static void PerformScavenge(); |
671 | 671 |
672 #ifdef DEBUG | 672 #ifdef DEBUG |
673 // Utility used with flag gc-greedy. | 673 // Utility used with flag gc-greedy. |
674 static bool GarbageCollectionGreedyCheck(); | 674 static bool GarbageCollectionGreedyCheck(); |
675 #endif | 675 #endif |
676 | 676 |
| 677 static void AddGCPrologueCallback( |
| 678 GCEpilogueCallback callback, GCType gc_type_filter); |
| 679 static void RemoveGCPrologueCallback(GCEpilogueCallback callback); |
| 680 |
| 681 static void AddGCEpilogueCallback( |
| 682 GCEpilogueCallback callback, GCType gc_type_filter); |
| 683 static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
| 684 |
677 static void SetGlobalGCPrologueCallback(GCCallback callback) { | 685 static void SetGlobalGCPrologueCallback(GCCallback callback) { |
| 686 ASSERT((callback == NULL) ^ (global_gc_prologue_callback_ == NULL)); |
678 global_gc_prologue_callback_ = callback; | 687 global_gc_prologue_callback_ = callback; |
679 } | 688 } |
680 static void SetGlobalGCEpilogueCallback(GCCallback callback) { | 689 static void SetGlobalGCEpilogueCallback(GCCallback callback) { |
| 690 ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL)); |
681 global_gc_epilogue_callback_ = callback; | 691 global_gc_epilogue_callback_ = callback; |
682 } | 692 } |
683 | 693 |
684 // Heap root getters. We have versions with and without type::cast() here. | 694 // Heap root getters. We have versions with and without type::cast() here. |
685 // You can't use type::cast during GC because the assert fails. | 695 // You can't use type::cast during GC because the assert fails. |
686 #define ROOT_ACCESSOR(type, name, camel_name) \ | 696 #define ROOT_ACCESSOR(type, name, camel_name) \ |
687 static inline type* name() { \ | 697 static inline type* name() { \ |
688 return type::cast(roots_[k##camel_name##RootIndex]); \ | 698 return type::cast(roots_[k##camel_name##RootIndex]); \ |
689 } \ | 699 } \ |
690 static inline type* raw_unchecked_##name() { \ | 700 static inline type* raw_unchecked_##name() { \ |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 static const StringTypeTable string_type_table[]; | 1049 static const StringTypeTable string_type_table[]; |
1040 static const ConstantSymbolTable constant_symbol_table[]; | 1050 static const ConstantSymbolTable constant_symbol_table[]; |
1041 static const StructTable struct_table[]; | 1051 static const StructTable struct_table[]; |
1042 | 1052 |
1043 // The special hidden symbol which is an empty string, but does not match | 1053 // The special hidden symbol which is an empty string, but does not match |
1044 // any string when looked up in properties. | 1054 // any string when looked up in properties. |
1045 static String* hidden_symbol_; | 1055 static String* hidden_symbol_; |
1046 | 1056 |
1047 // GC callback function, called before and after mark-compact GC. | 1057 // GC callback function, called before and after mark-compact GC. |
1048 // Allocations in the callback function are disallowed. | 1058 // Allocations in the callback function are disallowed. |
| 1059 struct GCPrologueCallbackPair { |
| 1060 GCPrologueCallbackPair(GCPrologueCallback callback, GCType gc_type) |
| 1061 : callback(callback), gc_type(gc_type) { |
| 1062 } |
| 1063 bool operator==(const GCPrologueCallbackPair& pair) const { |
| 1064 return pair.callback == callback; |
| 1065 } |
| 1066 GCPrologueCallback callback; |
| 1067 GCType gc_type; |
| 1068 }; |
| 1069 static List<GCPrologueCallbackPair> gc_prologue_callbacks_; |
| 1070 |
| 1071 struct GCEpilogueCallbackPair { |
| 1072 GCEpilogueCallbackPair(GCEpilogueCallback callback, GCType gc_type) |
| 1073 : callback(callback), gc_type(gc_type) { |
| 1074 } |
| 1075 bool operator==(const GCEpilogueCallbackPair& pair) const { |
| 1076 return pair.callback == callback; |
| 1077 } |
| 1078 GCEpilogueCallback callback; |
| 1079 GCType gc_type; |
| 1080 }; |
| 1081 static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
| 1082 |
1049 static GCCallback global_gc_prologue_callback_; | 1083 static GCCallback global_gc_prologue_callback_; |
1050 static GCCallback global_gc_epilogue_callback_; | 1084 static GCCallback global_gc_epilogue_callback_; |
1051 | 1085 |
1052 // Checks whether a global GC is necessary | 1086 // Checks whether a global GC is necessary |
1053 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1087 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
1054 | 1088 |
1055 // Performs garbage collection | 1089 // Performs garbage collection |
1056 static void PerformGarbageCollection(AllocationSpace space, | 1090 static void PerformGarbageCollection(AllocationSpace space, |
1057 GarbageCollector collector, | 1091 GarbageCollector collector, |
1058 GCTracer* tracer); | 1092 GCTracer* tracer); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 void set_collector(GarbageCollector collector) { collector_ = collector; } | 1615 void set_collector(GarbageCollector collector) { collector_ = collector; } |
1582 | 1616 |
1583 // Sets the GC count. | 1617 // Sets the GC count. |
1584 void set_gc_count(int count) { gc_count_ = count; } | 1618 void set_gc_count(int count) { gc_count_ = count; } |
1585 | 1619 |
1586 // Sets the full GC count. | 1620 // Sets the full GC count. |
1587 void set_full_gc_count(int count) { full_gc_count_ = count; } | 1621 void set_full_gc_count(int count) { full_gc_count_ = count; } |
1588 | 1622 |
1589 // Sets the flag that this is a compacting full GC. | 1623 // Sets the flag that this is a compacting full GC. |
1590 void set_is_compacting() { is_compacting_ = true; } | 1624 void set_is_compacting() { is_compacting_ = true; } |
| 1625 bool is_compacting() const { return is_compacting_; } |
1591 | 1626 |
1592 // Increment and decrement the count of marked objects. | 1627 // Increment and decrement the count of marked objects. |
1593 void increment_marked_count() { ++marked_count_; } | 1628 void increment_marked_count() { ++marked_count_; } |
1594 void decrement_marked_count() { --marked_count_; } | 1629 void decrement_marked_count() { --marked_count_; } |
1595 | 1630 |
1596 int marked_count() { return marked_count_; } | 1631 int marked_count() { return marked_count_; } |
1597 | 1632 |
1598 private: | 1633 private: |
1599 // Returns a string matching the collector. | 1634 // Returns a string matching the collector. |
1600 const char* CollectorString(); | 1635 const char* CollectorString(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 | 1798 |
1764 // To speed up scavenge collections new space string are kept | 1799 // To speed up scavenge collections new space string are kept |
1765 // separate from old space strings. | 1800 // separate from old space strings. |
1766 static List<Object*> new_space_strings_; | 1801 static List<Object*> new_space_strings_; |
1767 static List<Object*> old_space_strings_; | 1802 static List<Object*> old_space_strings_; |
1768 }; | 1803 }; |
1769 | 1804 |
1770 } } // namespace v8::internal | 1805 } } // namespace v8::internal |
1771 | 1806 |
1772 #endif // V8_HEAP_H_ | 1807 #endif // V8_HEAP_H_ |
OLD | NEW |