| 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 inline Object* ToBoolean(bool condition); | 985 inline Object* ToBoolean(bool condition); |
| 986 | 986 |
| 987 // Code that should be run before and after each GC. Includes some | 987 // Code that should be run before and after each GC. Includes some |
| 988 // reporting/verification activities when compiled with DEBUG set. | 988 // reporting/verification activities when compiled with DEBUG set. |
| 989 void GarbageCollectionPrologue(); | 989 void GarbageCollectionPrologue(); |
| 990 void GarbageCollectionEpilogue(); | 990 void GarbageCollectionEpilogue(); |
| 991 | 991 |
| 992 // Performs garbage collection operation. | 992 // Performs garbage collection operation. |
| 993 // Returns whether there is a chance that another major GC could | 993 // Returns whether there is a chance that another major GC could |
| 994 // collect more garbage. | 994 // collect more garbage. |
| 995 bool CollectGarbage(AllocationSpace space, GarbageCollector collector); | 995 bool CollectGarbage(AllocationSpace space, |
| 996 GarbageCollector collector, |
| 997 const char* gc_reason, |
| 998 const char* collector_reason); |
| 996 | 999 |
| 997 // Performs garbage collection operation. | 1000 // Performs garbage collection operation. |
| 998 // Returns whether there is a chance that another major GC could | 1001 // Returns whether there is a chance that another major GC could |
| 999 // collect more garbage. | 1002 // collect more garbage. |
| 1000 inline bool CollectGarbage(AllocationSpace space); | 1003 inline bool CollectGarbage(AllocationSpace space, |
| 1004 const char* gc_reason = NULL); |
| 1001 | 1005 |
| 1002 static const int kNoGCFlags = 0; | 1006 static const int kNoGCFlags = 0; |
| 1003 static const int kMakeHeapIterableMask = 1; | 1007 static const int kMakeHeapIterableMask = 1; |
| 1008 static const int kReduceMemoryFootprintMask = 2; |
| 1004 | 1009 |
| 1005 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is | 1010 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
| 1006 // non-zero, then the slower precise sweeper is used, which leaves the heap | 1011 // non-zero, then the slower precise sweeper is used, which leaves the heap |
| 1007 // in a state where we can iterate over the heap visiting all objects. | 1012 // in a state where we can iterate over the heap visiting all objects. |
| 1008 void CollectAllGarbage(int flags); | 1013 void CollectAllGarbage(int flags, const char* gc_reason = NULL); |
| 1009 | 1014 |
| 1010 // Last hope GC, should try to squeeze as much as possible. | 1015 // Last hope GC, should try to squeeze as much as possible. |
| 1011 void CollectAllAvailableGarbage(); | 1016 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
| 1012 | 1017 |
| 1013 // Check whether the heap is currently iterable. | 1018 // Check whether the heap is currently iterable. |
| 1014 bool IsHeapIterable(); | 1019 bool IsHeapIterable(); |
| 1015 | 1020 |
| 1016 // Ensure that we have swept all spaces in such a way that we can iterate | 1021 // Ensure that we have swept all spaces in such a way that we can iterate |
| 1017 // over all objects. May cause a GC. | 1022 // over all objects. May cause a GC. |
| 1018 void EnsureHeapIsIterable(); | 1023 void EnsureHeapIsIterable(); |
| 1019 | 1024 |
| 1020 // Notify the heap that a context has been disposed. | 1025 // Notify the heap that a context has been disposed. |
| 1021 int NotifyContextDisposed() { return ++contexts_disposed_; } | 1026 int NotifyContextDisposed() { return ++contexts_disposed_; } |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 HeapObjectCallback gc_safe_size_of_old_object_; | 1706 HeapObjectCallback gc_safe_size_of_old_object_; |
| 1702 static int GcSafeSizeOfOldObject(HeapObject* object); | 1707 static int GcSafeSizeOfOldObject(HeapObject* object); |
| 1703 | 1708 |
| 1704 // Update the GC state. Called from the mark-compact collector. | 1709 // Update the GC state. Called from the mark-compact collector. |
| 1705 void MarkMapPointersAsEncoded(bool encoded) { | 1710 void MarkMapPointersAsEncoded(bool encoded) { |
| 1706 ASSERT(!encoded); | 1711 ASSERT(!encoded); |
| 1707 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | 1712 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
| 1708 } | 1713 } |
| 1709 | 1714 |
| 1710 // Checks whether a global GC is necessary | 1715 // Checks whether a global GC is necessary |
| 1711 GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1716 GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 1717 const char** reason); |
| 1712 | 1718 |
| 1713 // Performs garbage collection | 1719 // Performs garbage collection |
| 1714 // Returns whether there is a chance another major GC could | 1720 // Returns whether there is a chance another major GC could |
| 1715 // collect more garbage. | 1721 // collect more garbage. |
| 1716 bool PerformGarbageCollection(GarbageCollector collector, | 1722 bool PerformGarbageCollection(GarbageCollector collector, |
| 1717 GCTracer* tracer); | 1723 GCTracer* tracer); |
| 1718 | 1724 |
| 1719 | 1725 |
| 1720 inline void UpdateOldSpaceLimits(); | 1726 inline void UpdateOldSpaceLimits(); |
| 1721 | 1727 |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. | 2369 ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. |
| 2364 tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_; | 2370 tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_; |
| 2365 } | 2371 } |
| 2366 | 2372 |
| 2367 private: | 2373 private: |
| 2368 GCTracer* tracer_; | 2374 GCTracer* tracer_; |
| 2369 ScopeId scope_; | 2375 ScopeId scope_; |
| 2370 double start_time_; | 2376 double start_time_; |
| 2371 }; | 2377 }; |
| 2372 | 2378 |
| 2373 explicit GCTracer(Heap* heap); | 2379 explicit GCTracer(Heap* heap, |
| 2380 const char* gc_reason, |
| 2381 const char* collector_reason); |
| 2374 ~GCTracer(); | 2382 ~GCTracer(); |
| 2375 | 2383 |
| 2376 // Sets the collector. | 2384 // Sets the collector. |
| 2377 void set_collector(GarbageCollector collector) { collector_ = collector; } | 2385 void set_collector(GarbageCollector collector) { collector_ = collector; } |
| 2378 | 2386 |
| 2379 // Sets the GC count. | 2387 // Sets the GC count. |
| 2380 void set_gc_count(unsigned int count) { gc_count_ = count; } | 2388 void set_gc_count(unsigned int count) { gc_count_ = count; } |
| 2381 | 2389 |
| 2382 // Sets the full GC count. | 2390 // Sets the full GC count. |
| 2383 void set_full_gc_count(int count) { full_gc_count_ = count; } | 2391 void set_full_gc_count(int count) { full_gc_count_ = count; } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 intptr_t promoted_objects_size_; | 2433 intptr_t promoted_objects_size_; |
| 2426 | 2434 |
| 2427 // Incremental marking steps counters. | 2435 // Incremental marking steps counters. |
| 2428 int steps_count_; | 2436 int steps_count_; |
| 2429 double steps_took_; | 2437 double steps_took_; |
| 2430 double longest_step_; | 2438 double longest_step_; |
| 2431 int steps_count_since_last_gc_; | 2439 int steps_count_since_last_gc_; |
| 2432 double steps_took_since_last_gc_; | 2440 double steps_took_since_last_gc_; |
| 2433 | 2441 |
| 2434 Heap* heap_; | 2442 Heap* heap_; |
| 2443 |
| 2444 const char* gc_reason_; |
| 2445 const char* collector_reason_; |
| 2435 }; | 2446 }; |
| 2436 | 2447 |
| 2437 | 2448 |
| 2438 class StringSplitCache { | 2449 class StringSplitCache { |
| 2439 public: | 2450 public: |
| 2440 static Object* Lookup(FixedArray* cache, String* string, String* pattern); | 2451 static Object* Lookup(FixedArray* cache, String* string, String* pattern); |
| 2441 static void Enter(Heap* heap, | 2452 static void Enter(Heap* heap, |
| 2442 FixedArray* cache, | 2453 FixedArray* cache, |
| 2443 String* string, | 2454 String* string, |
| 2444 String* pattern, | 2455 String* pattern, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 private: | 2650 private: |
| 2640 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2651 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2641 }; | 2652 }; |
| 2642 #endif // DEBUG || LIVE_OBJECT_LIST | 2653 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2643 | 2654 |
| 2644 } } // namespace v8::internal | 2655 } } // namespace v8::internal |
| 2645 | 2656 |
| 2646 #undef HEAP | 2657 #undef HEAP |
| 2647 | 2658 |
| 2648 #endif // V8_HEAP_H_ | 2659 #endif // V8_HEAP_H_ |
| OLD | NEW |