| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 return old_pointer_space_->allocation_limit_address(); | 610 return old_pointer_space_->allocation_limit_address(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 Address* OldDataSpaceAllocationTopAddress() { | 613 Address* OldDataSpaceAllocationTopAddress() { |
| 614 return old_data_space_->allocation_top_address(); | 614 return old_data_space_->allocation_top_address(); |
| 615 } | 615 } |
| 616 Address* OldDataSpaceAllocationLimitAddress() { | 616 Address* OldDataSpaceAllocationLimitAddress() { |
| 617 return old_data_space_->allocation_limit_address(); | 617 return old_data_space_->allocation_limit_address(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 // Uncommit unused semi space. | |
| 621 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } | |
| 622 | |
| 623 // Allocates and initializes a new JavaScript object based on a | 620 // Allocates and initializes a new JavaScript object based on a |
| 624 // constructor. | 621 // constructor. |
| 625 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 622 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 626 // failed. | 623 // failed. |
| 627 // Please note this does not perform a garbage collection. | 624 // Please note this does not perform a garbage collection. |
| 628 MUST_USE_RESULT MaybeObject* AllocateJSObject( | 625 MUST_USE_RESULT MaybeObject* AllocateJSObject( |
| 629 JSFunction* constructor, | 626 JSFunction* constructor, |
| 630 PretenureFlag pretenure = NOT_TENURED); | 627 PretenureFlag pretenure = NOT_TENURED); |
| 631 | 628 |
| 632 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( | 629 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 // Returns a failure in case it was decided that flattening was | 1165 // Returns a failure in case it was decided that flattening was |
| 1169 // necessary and failed. Note, if flattening is not necessary the | 1166 // necessary and failed. Note, if flattening is not necessary the |
| 1170 // string might stay non-flat even when not a failure is returned. | 1167 // string might stay non-flat even when not a failure is returned. |
| 1171 // | 1168 // |
| 1172 // Please note this function does not perform a garbage collection. | 1169 // Please note this function does not perform a garbage collection. |
| 1173 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); | 1170 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); |
| 1174 | 1171 |
| 1175 // Converts the given boolean condition to JavaScript boolean value. | 1172 // Converts the given boolean condition to JavaScript boolean value. |
| 1176 inline Object* ToBoolean(bool condition); | 1173 inline Object* ToBoolean(bool condition); |
| 1177 | 1174 |
| 1178 // Code that should be run before and after each GC. Includes some | |
| 1179 // reporting/verification activities when compiled with DEBUG set. | |
| 1180 void GarbageCollectionPrologue(); | |
| 1181 void GarbageCollectionEpilogue(); | |
| 1182 | |
| 1183 // Performs garbage collection operation. | 1175 // Performs garbage collection operation. |
| 1184 // Returns whether there is a chance that another major GC could | 1176 // Returns whether there is a chance that another major GC could |
| 1185 // collect more garbage. | 1177 // collect more garbage. |
| 1186 bool CollectGarbage(AllocationSpace space, | |
| 1187 GarbageCollector collector, | |
| 1188 const char* gc_reason, | |
| 1189 const char* collector_reason); | |
| 1190 | |
| 1191 // Performs garbage collection operation. | |
| 1192 // Returns whether there is a chance that another major GC could | |
| 1193 // collect more garbage. | |
| 1194 inline bool CollectGarbage(AllocationSpace space, | 1178 inline bool CollectGarbage(AllocationSpace space, |
| 1195 const char* gc_reason = NULL); | 1179 const char* gc_reason = NULL); |
| 1196 | 1180 |
| 1197 static const int kNoGCFlags = 0; | 1181 static const int kNoGCFlags = 0; |
| 1198 static const int kSweepPreciselyMask = 1; | 1182 static const int kSweepPreciselyMask = 1; |
| 1199 static const int kReduceMemoryFootprintMask = 2; | 1183 static const int kReduceMemoryFootprintMask = 2; |
| 1200 static const int kAbortIncrementalMarkingMask = 4; | 1184 static const int kAbortIncrementalMarkingMask = 4; |
| 1201 | 1185 |
| 1202 // Making the heap iterable requires us to sweep precisely and abort any | 1186 // Making the heap iterable requires us to sweep precisely and abort any |
| 1203 // incremental marking as well. | 1187 // incremental marking as well. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 return true; | 1406 return true; |
| 1423 #else | 1407 #else |
| 1424 #ifdef VERIFY_HEAP | 1408 #ifdef VERIFY_HEAP |
| 1425 return FLAG_verify_heap; | 1409 return FLAG_verify_heap; |
| 1426 #else | 1410 #else |
| 1427 return false; | 1411 return false; |
| 1428 #endif | 1412 #endif |
| 1429 #endif | 1413 #endif |
| 1430 } | 1414 } |
| 1431 | 1415 |
| 1432 // Fill in bogus values in from space | |
| 1433 void ZapFromSpace(); | |
| 1434 | |
| 1435 // Print short heap statistics. | 1416 // Print short heap statistics. |
| 1436 void PrintShortHeapStatistics(); | 1417 void PrintShortHeapStatistics(); |
| 1437 | 1418 |
| 1438 // Makes a new internalized string object | 1419 // Makes a new internalized string object |
| 1439 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 1420 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 1440 // failed. | 1421 // failed. |
| 1441 // Please note this function does not perform a garbage collection. | 1422 // Please note this function does not perform a garbage collection. |
| 1442 MUST_USE_RESULT MaybeObject* CreateInternalizedString( | 1423 MUST_USE_RESULT MaybeObject* CreateInternalizedString( |
| 1443 const char* str, int length, int hash); | 1424 const char* str, int length, int hash); |
| 1444 MUST_USE_RESULT MaybeObject* CreateInternalizedString(String* str); | 1425 MUST_USE_RESULT MaybeObject* CreateInternalizedString(String* str); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1468 void TracePathToGlobal(); | 1449 void TracePathToGlobal(); |
| 1469 #endif | 1450 #endif |
| 1470 | 1451 |
| 1471 // Callback function passed to Heap::Iterate etc. Copies an object if | 1452 // Callback function passed to Heap::Iterate etc. Copies an object if |
| 1472 // necessary, the object might be promoted to an old space. The caller must | 1453 // necessary, the object might be promoted to an old space. The caller must |
| 1473 // ensure the precondition that the object is (a) a heap object and (b) in | 1454 // ensure the precondition that the object is (a) a heap object and (b) in |
| 1474 // the heap's from space. | 1455 // the heap's from space. |
| 1475 static inline void ScavengePointer(HeapObject** p); | 1456 static inline void ScavengePointer(HeapObject** p); |
| 1476 static inline void ScavengeObject(HeapObject** p, HeapObject* object); | 1457 static inline void ScavengeObject(HeapObject** p, HeapObject* object); |
| 1477 | 1458 |
| 1478 // Commits from space if it is uncommitted. | |
| 1479 void EnsureFromSpaceIsCommitted(); | |
| 1480 | |
| 1481 // Support for partial snapshots. After calling this we have a linear | 1459 // Support for partial snapshots. After calling this we have a linear |
| 1482 // space to write objects in each space. | 1460 // space to write objects in each space. |
| 1483 void ReserveSpace(int *sizes, Address* addresses); | 1461 void ReserveSpace(int *sizes, Address* addresses); |
| 1484 | 1462 |
| 1485 // | 1463 // |
| 1486 // Support for the API. | 1464 // Support for the API. |
| 1487 // | 1465 // |
| 1488 | 1466 |
| 1489 bool CreateApiObjects(); | 1467 bool CreateApiObjects(); |
| 1490 | 1468 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 // Support for computing object sizes during GC. | 2057 // Support for computing object sizes during GC. |
| 2080 HeapObjectCallback gc_safe_size_of_old_object_; | 2058 HeapObjectCallback gc_safe_size_of_old_object_; |
| 2081 static int GcSafeSizeOfOldObject(HeapObject* object); | 2059 static int GcSafeSizeOfOldObject(HeapObject* object); |
| 2082 | 2060 |
| 2083 // Update the GC state. Called from the mark-compact collector. | 2061 // Update the GC state. Called from the mark-compact collector. |
| 2084 void MarkMapPointersAsEncoded(bool encoded) { | 2062 void MarkMapPointersAsEncoded(bool encoded) { |
| 2085 ASSERT(!encoded); | 2063 ASSERT(!encoded); |
| 2086 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | 2064 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
| 2087 } | 2065 } |
| 2088 | 2066 |
| 2067 // Code that should be run before and after each GC. Includes some |
| 2068 // reporting/verification activities when compiled with DEBUG set. |
| 2069 void GarbageCollectionPrologue(); |
| 2070 void GarbageCollectionEpilogue(); |
| 2071 |
| 2089 // Checks whether a global GC is necessary | 2072 // Checks whether a global GC is necessary |
| 2090 GarbageCollector SelectGarbageCollector(AllocationSpace space, | 2073 GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 2091 const char** reason); | 2074 const char** reason); |
| 2092 | 2075 |
| 2076 // Performs garbage collection operation. |
| 2077 // Returns whether there is a chance that another major GC could |
| 2078 // collect more garbage. |
| 2079 bool CollectGarbage(AllocationSpace space, |
| 2080 GarbageCollector collector, |
| 2081 const char* gc_reason, |
| 2082 const char* collector_reason); |
| 2083 |
| 2093 // Performs garbage collection | 2084 // Performs garbage collection |
| 2094 // Returns whether there is a chance another major GC could | 2085 // Returns whether there is a chance another major GC could |
| 2095 // collect more garbage. | 2086 // collect more garbage. |
| 2096 bool PerformGarbageCollection(GarbageCollector collector, | 2087 bool PerformGarbageCollection(GarbageCollector collector, |
| 2097 GCTracer* tracer); | 2088 GCTracer* tracer); |
| 2098 | 2089 |
| 2099 inline void UpdateOldSpaceLimits(); | 2090 inline void UpdateOldSpaceLimits(); |
| 2100 | 2091 |
| 2101 // Selects the proper allocation space depending on the given object | 2092 // Selects the proper allocation space depending on the given object |
| 2102 // size, pretenuring decision, and preferred old-space. | 2093 // size, pretenuring decision, and preferred old-space. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 // Allocate a tenured JS global property cell initialized with the hole. | 2153 // Allocate a tenured JS global property cell initialized with the hole. |
| 2163 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); | 2154 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); |
| 2164 | 2155 |
| 2165 // Allocate Box. | 2156 // Allocate Box. |
| 2166 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, | 2157 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, |
| 2167 PretenureFlag pretenure); | 2158 PretenureFlag pretenure); |
| 2168 | 2159 |
| 2169 // Performs a minor collection in new generation. | 2160 // Performs a minor collection in new generation. |
| 2170 void Scavenge(); | 2161 void Scavenge(); |
| 2171 | 2162 |
| 2163 // Commits from space if it is uncommitted. |
| 2164 void EnsureFromSpaceIsCommitted(); |
| 2165 |
| 2166 // Uncommit unused semi space. |
| 2167 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } |
| 2168 |
| 2169 // Fill in bogus values in from space |
| 2170 void ZapFromSpace(); |
| 2171 |
| 2172 static String* UpdateNewSpaceReferenceInExternalStringTableEntry( | 2172 static String* UpdateNewSpaceReferenceInExternalStringTableEntry( |
| 2173 Heap* heap, | 2173 Heap* heap, |
| 2174 Object** pointer); | 2174 Object** pointer); |
| 2175 | 2175 |
| 2176 Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front); | 2176 Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front); |
| 2177 static void ScavengeStoreBufferCallback(Heap* heap, | 2177 static void ScavengeStoreBufferCallback(Heap* heap, |
| 2178 MemoryChunk* page, | 2178 MemoryChunk* page, |
| 2179 StoreBufferEvent event); | 2179 StoreBufferEvent event); |
| 2180 | 2180 |
| 2181 // Performs a major collection in the whole heap. | 2181 // Performs a major collection in the whole heap. |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3090 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3091 | 3091 |
| 3092 private: | 3092 private: |
| 3093 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3093 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3094 }; | 3094 }; |
| 3095 #endif // DEBUG | 3095 #endif // DEBUG |
| 3096 | 3096 |
| 3097 } } // namespace v8::internal | 3097 } } // namespace v8::internal |
| 3098 | 3098 |
| 3099 #endif // V8_HEAP_H_ | 3099 #endif // V8_HEAP_H_ |
| OLD | NEW |