Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/heap.h

Issue 9323007: Tweak compaction candidate selection to avoid keeping page with low occupancy around. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 inline Object* ToBoolean(bool condition); 1018 inline Object* ToBoolean(bool condition);
1019 1019
1020 // Code that should be run before and after each GC. Includes some 1020 // Code that should be run before and after each GC. Includes some
1021 // reporting/verification activities when compiled with DEBUG set. 1021 // reporting/verification activities when compiled with DEBUG set.
1022 void GarbageCollectionPrologue(); 1022 void GarbageCollectionPrologue();
1023 void GarbageCollectionEpilogue(); 1023 void GarbageCollectionEpilogue();
1024 1024
1025 // Performs garbage collection operation. 1025 // Performs garbage collection operation.
1026 // Returns whether there is a chance that another major GC could 1026 // Returns whether there is a chance that another major GC could
1027 // collect more garbage. 1027 // collect more garbage.
1028 bool CollectGarbage(AllocationSpace space, GarbageCollector collector); 1028 bool CollectGarbage(AllocationSpace space,
1029 GarbageCollector collector,
1030 const char* gc_reason,
1031 const char* collector_reason);
1029 1032
1030 // Performs garbage collection operation. 1033 // Performs garbage collection operation.
1031 // Returns whether there is a chance that another major GC could 1034 // Returns whether there is a chance that another major GC could
1032 // collect more garbage. 1035 // collect more garbage.
1033 inline bool CollectGarbage(AllocationSpace space); 1036 inline bool CollectGarbage(AllocationSpace space,
1037 const char* gc_reason = NULL);
1034 1038
1035 static const int kNoGCFlags = 0; 1039 static const int kNoGCFlags = 0;
1036 static const int kMakeHeapIterableMask = 1; 1040 static const int kMakeHeapIterableMask = 1;
1041 static const int kReduceMemoryFootprintMask = 2;
1037 1042
1038 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is 1043 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is
1039 // non-zero, then the slower precise sweeper is used, which leaves the heap 1044 // non-zero, then the slower precise sweeper is used, which leaves the heap
1040 // in a state where we can iterate over the heap visiting all objects. 1045 // in a state where we can iterate over the heap visiting all objects.
1041 void CollectAllGarbage(int flags); 1046 void CollectAllGarbage(int flags, const char* gc_reason = NULL);
1042 1047
1043 // Last hope GC, should try to squeeze as much as possible. 1048 // Last hope GC, should try to squeeze as much as possible.
1044 void CollectAllAvailableGarbage(); 1049 void CollectAllAvailableGarbage(const char* gc_reason = NULL);
1045 1050
1046 // Check whether the heap is currently iterable. 1051 // Check whether the heap is currently iterable.
1047 bool IsHeapIterable(); 1052 bool IsHeapIterable();
1048 1053
1049 // Ensure that we have swept all spaces in such a way that we can iterate 1054 // Ensure that we have swept all spaces in such a way that we can iterate
1050 // over all objects. May cause a GC. 1055 // over all objects. May cause a GC.
1051 void EnsureHeapIsIterable(); 1056 void EnsureHeapIsIterable();
1052 1057
1053 // Notify the heap that a context has been disposed. 1058 // Notify the heap that a context has been disposed.
1054 int NotifyContextDisposed() { return ++contexts_disposed_; } 1059 int NotifyContextDisposed() { return ++contexts_disposed_; }
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 HeapObjectCallback gc_safe_size_of_old_object_; 1739 HeapObjectCallback gc_safe_size_of_old_object_;
1735 static int GcSafeSizeOfOldObject(HeapObject* object); 1740 static int GcSafeSizeOfOldObject(HeapObject* object);
1736 1741
1737 // Update the GC state. Called from the mark-compact collector. 1742 // Update the GC state. Called from the mark-compact collector.
1738 void MarkMapPointersAsEncoded(bool encoded) { 1743 void MarkMapPointersAsEncoded(bool encoded) {
1739 ASSERT(!encoded); 1744 ASSERT(!encoded);
1740 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; 1745 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject;
1741 } 1746 }
1742 1747
1743 // Checks whether a global GC is necessary 1748 // Checks whether a global GC is necessary
1744 GarbageCollector SelectGarbageCollector(AllocationSpace space); 1749 GarbageCollector SelectGarbageCollector(AllocationSpace space,
1750 const char** reason);
1745 1751
1746 // Performs garbage collection 1752 // Performs garbage collection
1747 // Returns whether there is a chance another major GC could 1753 // Returns whether there is a chance another major GC could
1748 // collect more garbage. 1754 // collect more garbage.
1749 bool PerformGarbageCollection(GarbageCollector collector, 1755 bool PerformGarbageCollection(GarbageCollector collector,
1750 GCTracer* tracer); 1756 GCTracer* tracer);
1751 1757
1752 1758
1753 inline void UpdateOldSpaceLimits(); 1759 inline void UpdateOldSpaceLimits();
1754 1760
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. 2363 ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned.
2358 tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_; 2364 tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_;
2359 } 2365 }
2360 2366
2361 private: 2367 private:
2362 GCTracer* tracer_; 2368 GCTracer* tracer_;
2363 ScopeId scope_; 2369 ScopeId scope_;
2364 double start_time_; 2370 double start_time_;
2365 }; 2371 };
2366 2372
2367 explicit GCTracer(Heap* heap); 2373 explicit GCTracer(Heap* heap,
2374 const char* gc_reason,
2375 const char* collector_reason);
2368 ~GCTracer(); 2376 ~GCTracer();
2369 2377
2370 // Sets the collector. 2378 // Sets the collector.
2371 void set_collector(GarbageCollector collector) { collector_ = collector; } 2379 void set_collector(GarbageCollector collector) { collector_ = collector; }
2372 2380
2373 // Sets the GC count. 2381 // Sets the GC count.
2374 void set_gc_count(unsigned int count) { gc_count_ = count; } 2382 void set_gc_count(unsigned int count) { gc_count_ = count; }
2375 2383
2376 // Sets the full GC count. 2384 // Sets the full GC count.
2377 void set_full_gc_count(int count) { full_gc_count_ = count; } 2385 void set_full_gc_count(int count) { full_gc_count_ = count; }
2378 2386
2379 void increment_promoted_objects_size(int object_size) { 2387 void increment_promoted_objects_size(int object_size) {
2380 promoted_objects_size_ += object_size; 2388 promoted_objects_size_ += object_size;
2381 } 2389 }
2382 2390
2383 private: 2391 private:
2384 // Returns a string matching the collector. 2392 // Returns a string matching the collector.
2385 const char* CollectorString(); 2393 const char* CollectorString();
2386 2394
2387 // Returns size of object in heap (in MB). 2395 // Returns size of object in heap (in MB).
2388 inline double SizeOfHeapObjects(); 2396 inline double SizeOfHeapObjects();
2389 2397
2390 double start_time_; // Timestamp set in the constructor. 2398 // Timestamp set in the constructor.
2391 intptr_t start_size_; // Size of objects in heap set in constructor. 2399 double start_time_;
2392 GarbageCollector collector_; // Type of collector. 2400
2401 // Size of objects in heap set in constructor.
2402 intptr_t start_object_size_;
2403
2404 // Size of memory allocated from OS set in constructor.
2405 intptr_t start_memory_size_;
2406
2407 // Type of collector.
2408 GarbageCollector collector_;
2393 2409
2394 // A count (including this one, e.g. the first collection is 1) of the 2410 // A count (including this one, e.g. the first collection is 1) of the
2395 // number of garbage collections. 2411 // number of garbage collections.
2396 unsigned int gc_count_; 2412 unsigned int gc_count_;
2397 2413
2398 // A count (including this one) of the number of full garbage collections. 2414 // A count (including this one) of the number of full garbage collections.
2399 int full_gc_count_; 2415 int full_gc_count_;
2400 2416
2401 // Amounts of time spent in different scopes during GC. 2417 // Amounts of time spent in different scopes during GC.
2402 double scopes_[Scope::kNumberOfScopes]; 2418 double scopes_[Scope::kNumberOfScopes];
(...skipping 14 matching lines...) Expand all
2417 intptr_t promoted_objects_size_; 2433 intptr_t promoted_objects_size_;
2418 2434
2419 // Incremental marking steps counters. 2435 // Incremental marking steps counters.
2420 int steps_count_; 2436 int steps_count_;
2421 double steps_took_; 2437 double steps_took_;
2422 double longest_step_; 2438 double longest_step_;
2423 int steps_count_since_last_gc_; 2439 int steps_count_since_last_gc_;
2424 double steps_took_since_last_gc_; 2440 double steps_took_since_last_gc_;
2425 2441
2426 Heap* heap_; 2442 Heap* heap_;
2443
2444 const char* gc_reason_;
2445 const char* collector_reason_;
2427 }; 2446 };
2428 2447
2429 2448
2430 class StringSplitCache { 2449 class StringSplitCache {
2431 public: 2450 public:
2432 static Object* Lookup(FixedArray* cache, String* string, String* pattern); 2451 static Object* Lookup(FixedArray* cache, String* string, String* pattern);
2433 static void Enter(Heap* heap, 2452 static void Enter(Heap* heap,
2434 FixedArray* cache, 2453 FixedArray* cache,
2435 String* string, 2454 String* string,
2436 String* pattern, 2455 String* pattern,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 AssertNoAllocation no_alloc; // i.e. no gc allowed. 2648 AssertNoAllocation no_alloc; // i.e. no gc allowed.
2630 2649
2631 private: 2650 private:
2632 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2651 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2633 }; 2652 };
2634 #endif // DEBUG || LIVE_OBJECT_LIST 2653 #endif // DEBUG || LIVE_OBJECT_LIST
2635 2654
2636 } } // namespace v8::internal 2655 } } // namespace v8::internal
2637 2656
2638 #endif // V8_HEAP_H_ 2657 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/extensions/gc-extension.cc ('k') | src/heap.cc » ('j') | src/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698