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

Side by Side Diff: src/heap.h

Issue 173465: Only pass idle notifications on from the API if V8 has been... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 836 }
837 837
838 // True if we have reached the allocation limit in the old generation that 838 // True if we have reached the allocation limit in the old generation that
839 // should artificially cause a GC right now. 839 // should artificially cause a GC right now.
840 static bool OldGenerationAllocationLimitReached() { 840 static bool OldGenerationAllocationLimitReached() {
841 return (PromotedSpaceSize() + PromotedExternalMemorySize()) 841 return (PromotedSpaceSize() + PromotedExternalMemorySize())
842 > old_gen_allocation_limit_; 842 > old_gen_allocation_limit_;
843 } 843 }
844 844
845 // Can be called when the embedding application is idle. 845 // Can be called when the embedding application is idle.
846 static bool IdleNotification() { 846 static bool IdleNotification();
847 static const int kIdlesBeforeCollection = 7;
848 static int number_idle_notifications = 0;
849 static int last_gc_count = gc_count_;
850
851 bool finished = false;
852
853 if (last_gc_count == gc_count_) {
854 number_idle_notifications++;
855 } else {
856 number_idle_notifications = 0;
857 last_gc_count = gc_count_;
858 }
859
860 if (number_idle_notifications >= kIdlesBeforeCollection) {
861 // The first time through we collect without forcing compaction.
862 // The second time through we force compaction and quit.
863 bool force_compaction =
864 number_idle_notifications > kIdlesBeforeCollection;
865 CollectAllGarbage(force_compaction);
866 last_gc_count = gc_count_;
867 if (force_compaction) {
868 number_idle_notifications = 0;
869 finished = true;
870 }
871 }
872
873 // Uncommit unused memory in new space.
874 Heap::UncommitFromSpace();
875 return finished;
876 }
877 847
878 // Declare all the root indices. 848 // Declare all the root indices.
879 enum RootListIndex { 849 enum RootListIndex {
880 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, 850 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
881 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) 851 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
882 #undef ROOT_INDEX_DECLARATION 852 #undef ROOT_INDEX_DECLARATION
883 853
884 // Utility type maps 854 // Utility type maps
885 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, 855 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
886 STRUCT_LIST(DECLARE_STRUCT_MAP) 856 STRUCT_LIST(DECLARE_STRUCT_MAP)
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 int marked_count_; 1499 int marked_count_;
1530 1500
1531 // The count from the end of the previous full GC. Will be zero if there 1501 // The count from the end of the previous full GC. Will be zero if there
1532 // was no previous full GC. 1502 // was no previous full GC.
1533 int previous_marked_count_; 1503 int previous_marked_count_;
1534 }; 1504 };
1535 1505
1536 } } // namespace v8::internal 1506 } } // namespace v8::internal
1537 1507
1538 #endif // V8_HEAP_H_ 1508 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698