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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 870 |
871 // Invoke Shrink on shrinkable spaces. | 871 // Invoke Shrink on shrinkable spaces. |
872 static void Shrink(); | 872 static void Shrink(); |
873 | 873 |
874 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 874 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
875 static inline HeapState gc_state() { return gc_state_; } | 875 static inline HeapState gc_state() { return gc_state_; } |
876 | 876 |
877 #ifdef DEBUG | 877 #ifdef DEBUG |
878 static bool IsAllocationAllowed() { return allocation_allowed_; } | 878 static bool IsAllocationAllowed() { return allocation_allowed_; } |
879 static inline bool allow_allocation(bool enable); | 879 static inline bool allow_allocation(bool enable); |
880 static bool IsGCAllowed() { return gc_allowed_; } | |
881 static inline bool allow_gc(bool enable); | |
882 | 880 |
883 static bool disallow_allocation_failure() { | 881 static bool disallow_allocation_failure() { |
884 return disallow_allocation_failure_; | 882 return disallow_allocation_failure_; |
885 } | 883 } |
886 | 884 |
887 static void TracePathToObject(Object* target); | 885 static void TracePathToObject(Object* target); |
888 static void TracePathToGlobal(); | 886 static void TracePathToGlobal(); |
889 #endif | 887 #endif |
890 | 888 |
891 // Callback function passed to Heap::Iterate etc. Copies an object if | 889 // Callback function passed to Heap::Iterate etc. Copies an object if |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1071 |
1074 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1072 #define ROOT_ACCESSOR(type, name, camel_name) \ |
1075 static inline void set_##name(type* value) { \ | 1073 static inline void set_##name(type* value) { \ |
1076 roots_[k##camel_name##RootIndex] = value; \ | 1074 roots_[k##camel_name##RootIndex] = value; \ |
1077 } | 1075 } |
1078 ROOT_LIST(ROOT_ACCESSOR) | 1076 ROOT_LIST(ROOT_ACCESSOR) |
1079 #undef ROOT_ACCESSOR | 1077 #undef ROOT_ACCESSOR |
1080 | 1078 |
1081 #ifdef DEBUG | 1079 #ifdef DEBUG |
1082 static bool allocation_allowed_; | 1080 static bool allocation_allowed_; |
1083 static bool gc_allowed_; | |
1084 | 1081 |
1085 // If the --gc-interval flag is set to a positive value, this | 1082 // If the --gc-interval flag is set to a positive value, this |
1086 // variable holds the value indicating the number of allocations | 1083 // variable holds the value indicating the number of allocations |
1087 // remain until the next failure and garbage collection. | 1084 // remain until the next failure and garbage collection. |
1088 static int allocation_timeout_; | 1085 static int allocation_timeout_; |
1089 | 1086 |
1090 // Do we expect to be able to handle allocation failure at this | 1087 // Do we expect to be able to handle allocation failure at this |
1091 // time? | 1088 // time? |
1092 static bool disallow_allocation_failure_; | 1089 static bool disallow_allocation_failure_; |
1093 #endif // DEBUG | 1090 #endif // DEBUG |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 } | 1673 } |
1677 | 1674 |
1678 ~AssertNoAllocation() { | 1675 ~AssertNoAllocation() { |
1679 Heap::allow_allocation(old_state_); | 1676 Heap::allow_allocation(old_state_); |
1680 } | 1677 } |
1681 | 1678 |
1682 private: | 1679 private: |
1683 bool old_state_; | 1680 bool old_state_; |
1684 }; | 1681 }; |
1685 | 1682 |
1686 class AssertNoGC { | |
1687 public: | |
1688 AssertNoGC() { | |
1689 old_state_ = Heap::allow_gc(false); | |
1690 } | |
1691 | |
1692 ~AssertNoGC() { | |
1693 Heap::allow_gc(old_state_); | |
1694 } | |
1695 | |
1696 private: | |
1697 bool old_state_; | |
1698 }; | |
1699 | |
1700 class DisableAssertNoAllocation { | 1683 class DisableAssertNoAllocation { |
1701 public: | 1684 public: |
1702 DisableAssertNoAllocation() { | 1685 DisableAssertNoAllocation() { |
1703 old_state_ = Heap::allow_allocation(true); | 1686 old_state_ = Heap::allow_allocation(true); |
1704 } | 1687 } |
1705 | 1688 |
1706 ~DisableAssertNoAllocation() { | 1689 ~DisableAssertNoAllocation() { |
1707 Heap::allow_allocation(old_state_); | 1690 Heap::allow_allocation(old_state_); |
1708 } | 1691 } |
1709 | 1692 |
1710 private: | 1693 private: |
1711 bool old_state_; | 1694 bool old_state_; |
1712 }; | 1695 }; |
1713 | 1696 |
1714 #else // ndef DEBUG | 1697 #else // ndef DEBUG |
1715 | 1698 |
1716 class AssertNoAllocation { | 1699 class AssertNoAllocation { |
1717 public: | 1700 public: |
1718 AssertNoAllocation() { } | 1701 AssertNoAllocation() { } |
1719 ~AssertNoAllocation() { } | 1702 ~AssertNoAllocation() { } |
1720 }; | 1703 }; |
1721 | 1704 |
1722 class AssertNoGC { | |
1723 public: | |
1724 AssertNoGC() { } | |
1725 ~AssertNoGC() { } | |
1726 }; | |
1727 | |
1728 class DisableAssertNoAllocation { | 1705 class DisableAssertNoAllocation { |
1729 public: | 1706 public: |
1730 DisableAssertNoAllocation() { } | 1707 DisableAssertNoAllocation() { } |
1731 ~DisableAssertNoAllocation() { } | 1708 ~DisableAssertNoAllocation() { } |
1732 }; | 1709 }; |
1733 | 1710 |
1734 #endif | 1711 #endif |
1735 | 1712 |
1736 // GCTracer collects and prints ONE line after each garbage collector | 1713 // GCTracer collects and prints ONE line after each garbage collector |
1737 // invocation IFF --trace_gc is used. | 1714 // invocation IFF --trace_gc is used. |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 | 1975 |
1999 // To speed up scavenge collections new space string are kept | 1976 // To speed up scavenge collections new space string are kept |
2000 // separate from old space strings. | 1977 // separate from old space strings. |
2001 static List<Object*> new_space_strings_; | 1978 static List<Object*> new_space_strings_; |
2002 static List<Object*> old_space_strings_; | 1979 static List<Object*> old_space_strings_; |
2003 }; | 1980 }; |
2004 | 1981 |
2005 } } // namespace v8::internal | 1982 } } // namespace v8::internal |
2006 | 1983 |
2007 #endif // V8_HEAP_H_ | 1984 #endif // V8_HEAP_H_ |
OLD | NEW |