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