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

Side by Side Diff: src/heap.h

Issue 3764011: Link all global contexts into a weak list. (Closed)
Patch Set: Created 10 years, 2 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 V(redeclaration_symbol, "redeclaration") \ 195 V(redeclaration_symbol, "redeclaration") \
196 V(failure_symbol, "<failure>") \ 196 V(failure_symbol, "<failure>") \
197 V(space_symbol, " ") \ 197 V(space_symbol, " ") \
198 V(exec_symbol, "exec") \ 198 V(exec_symbol, "exec") \
199 V(zero_symbol, "0") \ 199 V(zero_symbol, "0") \
200 V(global_eval_symbol, "GlobalEval") \ 200 V(global_eval_symbol, "GlobalEval") \
201 V(identity_hash_symbol, "v8::IdentityHash") \ 201 V(identity_hash_symbol, "v8::IdentityHash") \
202 V(closure_symbol, "(closure)") 202 V(closure_symbol, "(closure)")
203 203
204 204
205 // Forward declaration of the GCTracer class. 205 // Forward declarations.
206 class GCTracer; 206 class GCTracer;
207 class HeapStats; 207 class HeapStats;
208 class WeakObjectRetainer;
208 209
209 210
210 typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer); 211 typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer);
211 212
212 typedef bool (*DirtyRegionCallback)(Address start, 213 typedef bool (*DirtyRegionCallback)(Address start,
213 Address end, 214 Address end,
214 ObjectSlotCallback copy_object_func); 215 ObjectSlotCallback copy_object_func);
215 216
216 217
217 // The all static Heap captures the interface to the global object heap. 218 // The all static Heap captures the interface to the global object heap.
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 #define SYMBOL_ACCESSOR(name, str) static inline String* name() { \ 761 #define SYMBOL_ACCESSOR(name, str) static inline String* name() { \
761 return String::cast(roots_[k##name##RootIndex]); \ 762 return String::cast(roots_[k##name##RootIndex]); \
762 } 763 }
763 SYMBOL_LIST(SYMBOL_ACCESSOR) 764 SYMBOL_LIST(SYMBOL_ACCESSOR)
764 #undef SYMBOL_ACCESSOR 765 #undef SYMBOL_ACCESSOR
765 766
766 // The hidden_symbol is special because it is the empty string, but does 767 // The hidden_symbol is special because it is the empty string, but does
767 // not match the empty string. 768 // not match the empty string.
768 static String* hidden_symbol() { return hidden_symbol_; } 769 static String* hidden_symbol() { return hidden_symbol_; }
769 770
771 static void set_global_contexts_list(Object* object) {
772 global_contexts_list_ = object;
773 }
774 static Object* global_contexts_list() { return global_contexts_list_; }
775
770 // Iterates over all roots in the heap. 776 // Iterates over all roots in the heap.
771 static void IterateRoots(ObjectVisitor* v, VisitMode mode); 777 static void IterateRoots(ObjectVisitor* v, VisitMode mode);
772 // Iterates over all strong roots in the heap. 778 // Iterates over all strong roots in the heap.
773 static void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); 779 static void IterateStrongRoots(ObjectVisitor* v, VisitMode mode);
774 // Iterates over all the other roots in the heap. 780 // Iterates over all the other roots in the heap.
775 static void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); 781 static void IterateWeakRoots(ObjectVisitor* v, VisitMode mode);
776 782
777 enum ExpectedPageWatermarkState { 783 enum ExpectedPageWatermarkState {
778 WATERMARK_SHOULD_BE_VALID, 784 WATERMARK_SHOULD_BE_VALID,
779 WATERMARK_CAN_BE_INVALID 785 WATERMARK_CAN_BE_INVALID
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 static void public_set_empty_script(Script* script) { 869 static void public_set_empty_script(Script* script) {
864 roots_[kEmptyScriptRootIndex] = script; 870 roots_[kEmptyScriptRootIndex] = script;
865 } 871 }
866 872
867 // Update the next script id. 873 // Update the next script id.
868 static inline void SetLastScriptId(Object* last_script_id); 874 static inline void SetLastScriptId(Object* last_script_id);
869 875
870 // Generated code can embed this address to get access to the roots. 876 // Generated code can embed this address to get access to the roots.
871 static Object** roots_address() { return roots_; } 877 static Object** roots_address() { return roots_; }
872 878
879 // Get address of global contexts list for serialization support.
880 static Object** global_contexts_list_address() {
881 return &global_contexts_list_;
882 }
883
873 #ifdef DEBUG 884 #ifdef DEBUG
874 static void Print(); 885 static void Print();
875 static void PrintHandles(); 886 static void PrintHandles();
876 887
877 // Verify the heap is in its normal state before or after a GC. 888 // Verify the heap is in its normal state before or after a GC.
878 static void Verify(); 889 static void Verify();
879 890
880 // Report heap statistics. 891 // Report heap statistics.
881 static void ReportHeapStatistics(const char* title); 892 static void ReportHeapStatistics(const char* title);
882 static void ReportCodeStatistics(const char* title); 893 static void ReportCodeStatistics(const char* title);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 static void CheckNewSpaceExpansionCriteria(); 1055 static void CheckNewSpaceExpansionCriteria();
1045 1056
1046 static inline void IncrementYoungSurvivorsCounter(int survived) { 1057 static inline void IncrementYoungSurvivorsCounter(int survived) {
1047 young_survivors_after_last_gc_ = survived; 1058 young_survivors_after_last_gc_ = survived;
1048 survived_since_last_expansion_ += survived; 1059 survived_since_last_expansion_ += survived;
1049 } 1060 }
1050 1061
1051 static void UpdateNewSpaceReferencesInExternalStringTable( 1062 static void UpdateNewSpaceReferencesInExternalStringTable(
1052 ExternalStringTableUpdaterCallback updater_func); 1063 ExternalStringTableUpdaterCallback updater_func);
1053 1064
1065 static void ProcessWeakReferences(WeakObjectRetainer* retainer);
1066
1054 // Helper function that governs the promotion policy from new space to 1067 // Helper function that governs the promotion policy from new space to
1055 // old. If the object's old address lies below the new space's age 1068 // old. If the object's old address lies below the new space's age
1056 // mark or if we've already filled the bottom 1/16th of the to space, 1069 // mark or if we've already filled the bottom 1/16th of the to space,
1057 // we try to promote this object. 1070 // we try to promote this object.
1058 static inline bool ShouldBePromoted(Address old_address, int object_size); 1071 static inline bool ShouldBePromoted(Address old_address, int object_size);
1059 1072
1060 static int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; } 1073 static int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; }
1061 1074
1062 static void ClearJSFunctionResultCaches(); 1075 static void ClearJSFunctionResultCaches();
1063 1076
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1163
1151 // Caches the amount of external memory registered at the last global gc. 1164 // Caches the amount of external memory registered at the last global gc.
1152 static int amount_of_external_allocated_memory_at_last_global_gc_; 1165 static int amount_of_external_allocated_memory_at_last_global_gc_;
1153 1166
1154 // Indicates that an allocation has failed in the old generation since the 1167 // Indicates that an allocation has failed in the old generation since the
1155 // last GC. 1168 // last GC.
1156 static int old_gen_exhausted_; 1169 static int old_gen_exhausted_;
1157 1170
1158 static Object* roots_[kRootListLength]; 1171 static Object* roots_[kRootListLength];
1159 1172
1173 static Object* global_contexts_list_;
1174
1160 struct StringTypeTable { 1175 struct StringTypeTable {
1161 InstanceType type; 1176 InstanceType type;
1162 int size; 1177 int size;
1163 RootListIndex index; 1178 RootListIndex index;
1164 }; 1179 };
1165 1180
1166 struct ConstantSymbolTable { 1181 struct ConstantSymbolTable {
1167 const char* contents; 1182 const char* contents;
1168 RootListIndex index; 1183 RootListIndex index;
1169 }; 1184 };
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 2051
2037 // Notifies the table that only a prefix of the new list is valid. 2052 // Notifies the table that only a prefix of the new list is valid.
2038 inline static void ShrinkNewStrings(int position); 2053 inline static void ShrinkNewStrings(int position);
2039 2054
2040 // To speed up scavenge collections new space string are kept 2055 // To speed up scavenge collections new space string are kept
2041 // separate from old space strings. 2056 // separate from old space strings.
2042 static List<Object*> new_space_strings_; 2057 static List<Object*> new_space_strings_;
2043 static List<Object*> old_space_strings_; 2058 static List<Object*> old_space_strings_;
2044 }; 2059 };
2045 2060
2061
2062 // Abstract base class for checking whether a weak object should be retained.
2063 class WeakObjectRetainer {
2064 public:
2065 virtual ~WeakObjectRetainer() {}
2066
2067 // Return whether this object should be retained. If NULL is returned the
2068 // object has no references. Otherwise the address of the retained object
2069 // should be returned as in some GC situations the object has been moved.
2070 virtual Object* RetainAs(Object* object) = 0;
2071 };
2072
2073
2046 } } // namespace v8::internal 2074 } } // namespace v8::internal
2047 2075
2048 #endif // V8_HEAP_H_ 2076 #endif // V8_HEAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698