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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 V(global_eval_symbol, "GlobalEval") \ | 188 V(global_eval_symbol, "GlobalEval") \ |
189 V(identity_hash_symbol, "v8::IdentityHash") \ | 189 V(identity_hash_symbol, "v8::IdentityHash") \ |
190 V(closure_symbol, "(closure)") | 190 V(closure_symbol, "(closure)") |
191 | 191 |
192 | 192 |
193 // Forward declaration of the GCTracer class. | 193 // Forward declaration of the GCTracer class. |
194 class GCTracer; | 194 class GCTracer; |
195 class HeapStats; | 195 class HeapStats; |
196 | 196 |
197 | 197 |
| 198 typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer); |
| 199 |
| 200 |
198 // The all static Heap captures the interface to the global object heap. | 201 // The all static Heap captures the interface to the global object heap. |
199 // All JavaScript contexts by this process share the same object heap. | 202 // All JavaScript contexts by this process share the same object heap. |
200 | 203 |
201 class Heap : public AllStatic { | 204 class Heap : public AllStatic { |
202 public: | 205 public: |
203 // Configure heap size before setup. Return false if the heap has been | 206 // Configure heap size before setup. Return false if the heap has been |
204 // setup already. | 207 // setup already. |
205 static bool ConfigureHeap(int max_semispace_size, int max_old_gen_size); | 208 static bool ConfigureHeap(int max_semispace_size, int max_old_gen_size); |
206 static bool ConfigureHeapDefault(); | 209 static bool ConfigureHeapDefault(); |
207 | 210 |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 }; | 934 }; |
932 | 935 |
933 static Object* NumberToString(Object* number); | 936 static Object* NumberToString(Object* number); |
934 | 937 |
935 static Map* MapForExternalArrayType(ExternalArrayType array_type); | 938 static Map* MapForExternalArrayType(ExternalArrayType array_type); |
936 static RootListIndex RootIndexForExternalArrayType( | 939 static RootListIndex RootIndexForExternalArrayType( |
937 ExternalArrayType array_type); | 940 ExternalArrayType array_type); |
938 | 941 |
939 static void RecordStats(HeapStats* stats); | 942 static void RecordStats(HeapStats* stats); |
940 | 943 |
| 944 // Copy block of memory from src to dst. Size of block should be aligned |
| 945 // by pointer size. |
| 946 static inline void CopyBlock(Object** dst, Object** src, int byte_size); |
| 947 |
| 948 // Optimized version of memmove for blocks with pointer size aligned sizes and |
| 949 // pointer size aligned addresses. |
| 950 static inline void MoveBlock(Object** dst, Object** src, size_t byte_size); |
| 951 |
| 952 // Check new space expansion criteria and expand semispaces if it was hit. |
| 953 static void CheckNewSpaceExpansionCriteria(); |
| 954 |
| 955 static inline void IncrementYoungSurvivorsCounter(int survived) { |
| 956 survived_since_last_expansion_ += survived; |
| 957 } |
| 958 |
| 959 static void UpdateNewSpaceReferencesInExternalStringTable( |
| 960 ExternalStringTableUpdaterCallback updater_func); |
| 961 |
| 962 // Helper function that governs the promotion policy from new space to |
| 963 // old. If the object's old address lies below the new space's age |
| 964 // mark or if we've already filled the bottom 1/16th of the to space, |
| 965 // we try to promote this object. |
| 966 static inline bool ShouldBePromoted(Address old_address, int object_size); |
| 967 |
941 private: | 968 private: |
942 static int reserved_semispace_size_; | 969 static int reserved_semispace_size_; |
943 static int max_semispace_size_; | 970 static int max_semispace_size_; |
944 static int initial_semispace_size_; | 971 static int initial_semispace_size_; |
945 static int max_old_generation_size_; | 972 static int max_old_generation_size_; |
946 static size_t code_range_size_; | 973 static size_t code_range_size_; |
947 | 974 |
948 // For keeping track of how much data has survived | 975 // For keeping track of how much data has survived |
949 // scavenge since last new space expansion. | 976 // scavenge since last new space expansion. |
950 static int survived_since_last_expansion_; | 977 static int survived_since_last_expansion_; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 | 1152 |
1126 static Object* CreateOddball(Map* map, | 1153 static Object* CreateOddball(Map* map, |
1127 const char* to_string, | 1154 const char* to_string, |
1128 Object* to_number); | 1155 Object* to_number); |
1129 | 1156 |
1130 // Allocate empty fixed array. | 1157 // Allocate empty fixed array. |
1131 static Object* AllocateEmptyFixedArray(); | 1158 static Object* AllocateEmptyFixedArray(); |
1132 | 1159 |
1133 // Performs a minor collection in new generation. | 1160 // Performs a minor collection in new generation. |
1134 static void Scavenge(); | 1161 static void Scavenge(); |
1135 static void ScavengeExternalStringTable(); | 1162 |
| 1163 static String* UpdateNewSpaceReferenceInExternalStringTableEntry( |
| 1164 Object** pointer); |
| 1165 |
1136 static Address DoScavenge(ObjectVisitor* scavenge_visitor, | 1166 static Address DoScavenge(ObjectVisitor* scavenge_visitor, |
1137 Address new_space_front); | 1167 Address new_space_front); |
1138 | 1168 |
1139 // Performs a major collection in the whole heap. | 1169 // Performs a major collection in the whole heap. |
1140 static void MarkCompact(GCTracer* tracer); | 1170 static void MarkCompact(GCTracer* tracer); |
1141 | 1171 |
1142 // Code to be run before and after mark-compact. | 1172 // Code to be run before and after mark-compact. |
1143 static void MarkCompactPrologue(bool is_compacting); | 1173 static void MarkCompactPrologue(bool is_compacting); |
1144 static void MarkCompactEpilogue(bool is_compacting); | 1174 static void MarkCompactEpilogue(bool is_compacting); |
1145 | 1175 |
1146 // Helper function used by CopyObject to copy a source object to an | 1176 // Helper function used by CopyObject to copy a source object to an |
1147 // allocated target object and update the forwarding pointer in the source | 1177 // allocated target object and update the forwarding pointer in the source |
1148 // object. Returns the target object. | 1178 // object. Returns the target object. |
1149 static inline HeapObject* MigrateObject(HeapObject* source, | 1179 static inline HeapObject* MigrateObject(HeapObject* source, |
1150 HeapObject* target, | 1180 HeapObject* target, |
1151 int size); | 1181 int size); |
1152 | 1182 |
1153 // Helper function that governs the promotion policy from new space to | |
1154 // old. If the object's old address lies below the new space's age | |
1155 // mark or if we've already filled the bottom 1/16th of the to space, | |
1156 // we try to promote this object. | |
1157 static inline bool ShouldBePromoted(Address old_address, int object_size); | |
1158 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 1183 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
1159 // Record the copy of an object in the NewSpace's statistics. | 1184 // Record the copy of an object in the NewSpace's statistics. |
1160 static void RecordCopiedObject(HeapObject* obj); | 1185 static void RecordCopiedObject(HeapObject* obj); |
1161 | 1186 |
1162 // Record statistics before and after garbage collection. | 1187 // Record statistics before and after garbage collection. |
1163 static void ReportStatisticsBeforeGC(); | 1188 static void ReportStatisticsBeforeGC(); |
1164 static void ReportStatisticsAfterGC(); | 1189 static void ReportStatisticsAfterGC(); |
1165 #endif | 1190 #endif |
1166 | 1191 |
1167 // Rebuild remembered set in an old space. | 1192 // Rebuild remembered set in an old space. |
1168 static void RebuildRSets(PagedSpace* space); | 1193 static void RebuildRSets(PagedSpace* space); |
1169 | 1194 |
1170 // Rebuild remembered set in the large object space. | 1195 // Rebuild remembered set in the large object space. |
1171 static void RebuildRSets(LargeObjectSpace* space); | 1196 static void RebuildRSets(LargeObjectSpace* space); |
1172 | 1197 |
1173 // Slow part of scavenge object. | 1198 // Slow part of scavenge object. |
1174 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); | 1199 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); |
1175 | 1200 |
1176 // Copy memory from src to dst. | |
1177 static inline void CopyBlock(Object** dst, Object** src, int byte_size); | |
1178 | |
1179 // Initializes a function with a shared part and prototype. | 1201 // Initializes a function with a shared part and prototype. |
1180 // Returns the function. | 1202 // Returns the function. |
1181 // Note: this code was factored out of AllocateFunction such that | 1203 // Note: this code was factored out of AllocateFunction such that |
1182 // other parts of the VM could use it. Specifically, a function that creates | 1204 // other parts of the VM could use it. Specifically, a function that creates |
1183 // instances of type JS_FUNCTION_TYPE benefit from the use of this function. | 1205 // instances of type JS_FUNCTION_TYPE benefit from the use of this function. |
1184 // Please note this does not perform a garbage collection. | 1206 // Please note this does not perform a garbage collection. |
1185 static inline Object* InitializeFunction(JSFunction* function, | 1207 static inline Object* InitializeFunction(JSFunction* function, |
1186 SharedFunctionInfo* shared, | 1208 SharedFunctionInfo* shared, |
1187 Object* prototype); | 1209 Object* prototype); |
1188 | 1210 |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 | 1820 |
1799 // To speed up scavenge collections new space string are kept | 1821 // To speed up scavenge collections new space string are kept |
1800 // separate from old space strings. | 1822 // separate from old space strings. |
1801 static List<Object*> new_space_strings_; | 1823 static List<Object*> new_space_strings_; |
1802 static List<Object*> old_space_strings_; | 1824 static List<Object*> old_space_strings_; |
1803 }; | 1825 }; |
1804 | 1826 |
1805 } } // namespace v8::internal | 1827 } } // namespace v8::internal |
1806 | 1828 |
1807 #endif // V8_HEAP_H_ | 1829 #endif // V8_HEAP_H_ |
OLD | NEW |