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

Side by Side Diff: src/heap.h

Issue 6614010: [Isolates] Merge 6700:7030 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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/handles-inl.h ('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 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_HEAP_H_ 28 #ifndef V8_HEAP_H_
29 #define V8_HEAP_H_ 29 #define V8_HEAP_H_
30 30
31 #include <math.h> 31 #include <math.h>
32 32
33 #include "globals.h"
34 #include "list.h"
33 #include "mark-compact.h" 35 #include "mark-compact.h"
34 #include "spaces.h" 36 #include "spaces.h"
35 #include "splay-tree-inl.h" 37 #include "splay-tree-inl.h"
36 #include "v8-counters.h" 38 #include "v8-counters.h"
37 39
38 namespace v8 { 40 namespace v8 {
39 namespace internal { 41 namespace internal {
40 42
41 // TODO(isolates): remove HEAP here 43 // TODO(isolates): remove HEAP here
42 #define HEAP (_inline_get_heap_()) 44 #define HEAP (_inline_get_heap_())
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 V(this_symbol, "this") \ 185 V(this_symbol, "this") \
184 V(to_string_symbol, "toString") \ 186 V(to_string_symbol, "toString") \
185 V(char_at_symbol, "CharAt") \ 187 V(char_at_symbol, "CharAt") \
186 V(undefined_symbol, "undefined") \ 188 V(undefined_symbol, "undefined") \
187 V(value_of_symbol, "valueOf") \ 189 V(value_of_symbol, "valueOf") \
188 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ 190 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \
189 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ 191 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \
190 V(KeyedLoadSpecialized_symbol, "KeyedLoadSpecialized") \ 192 V(KeyedLoadSpecialized_symbol, "KeyedLoadSpecialized") \
191 V(KeyedStoreSpecialized_symbol, "KeyedStoreSpecialized") \ 193 V(KeyedStoreSpecialized_symbol, "KeyedStoreSpecialized") \
192 V(KeyedLoadPixelArray_symbol, "KeyedLoadPixelArray") \ 194 V(KeyedLoadPixelArray_symbol, "KeyedLoadPixelArray") \
195 V(KeyedStorePixelArray_symbol, "KeyedStorePixelArray") \
193 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ 196 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \
194 V(illegal_access_symbol, "illegal access") \ 197 V(illegal_access_symbol, "illegal access") \
195 V(out_of_memory_symbol, "out-of-memory") \ 198 V(out_of_memory_symbol, "out-of-memory") \
196 V(illegal_execution_state_symbol, "illegal execution state") \ 199 V(illegal_execution_state_symbol, "illegal execution state") \
197 V(get_symbol, "get") \ 200 V(get_symbol, "get") \
198 V(set_symbol, "set") \ 201 V(set_symbol, "set") \
199 V(function_class_symbol, "Function") \ 202 V(function_class_symbol, "Function") \
200 V(illegal_argument_symbol, "illegal argument") \ 203 V(illegal_argument_symbol, "illegal argument") \
201 V(MakeReferenceError_symbol, "MakeReferenceError") \ 204 V(MakeReferenceError_symbol, "MakeReferenceError") \
202 V(MakeSyntaxError_symbol, "MakeSyntaxError") \ 205 V(MakeSyntaxError_symbol, "MakeSyntaxError") \
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 HeapState gc_state_; 1267 HeapState gc_state_;
1265 1268
1266 // Returns the size of object residing in non new spaces. 1269 // Returns the size of object residing in non new spaces.
1267 intptr_t PromotedSpaceSize(); 1270 intptr_t PromotedSpaceSize();
1268 1271
1269 // Returns the amount of external memory registered since last global gc. 1272 // Returns the amount of external memory registered since last global gc.
1270 int PromotedExternalMemorySize(); 1273 int PromotedExternalMemorySize();
1271 1274
1272 int mc_count_; // how many mark-compact collections happened 1275 int mc_count_; // how many mark-compact collections happened
1273 int ms_count_; // how many mark-sweep collections happened 1276 int ms_count_; // how many mark-sweep collections happened
1274 int gc_count_; // how many gc happened 1277 unsigned int gc_count_; // how many gc happened
1275 1278
1276 // Total length of the strings we failed to flatten since the last GC. 1279 // Total length of the strings we failed to flatten since the last GC.
1277 int unflattened_strings_length_; 1280 int unflattened_strings_length_;
1278 1281
1279 #define ROOT_ACCESSOR(type, name, camel_name) \ 1282 #define ROOT_ACCESSOR(type, name, camel_name) \
1280 inline void set_##name(type* value) { \ 1283 inline void set_##name(type* value) { \
1281 roots_[k##camel_name##RootIndex] = value; \ 1284 roots_[k##camel_name##RootIndex] = value; \
1282 } 1285 }
1283 ROOT_LIST(ROOT_ACCESSOR) 1286 ROOT_LIST(ROOT_ACCESSOR)
1284 #undef ROOT_ACCESSOR 1287 #undef ROOT_ACCESSOR
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 double last_gc_end_timestamp_; 1558 double last_gc_end_timestamp_;
1556 1559
1557 MarkCompactCollector mark_compact_collector_; 1560 MarkCompactCollector mark_compact_collector_;
1558 1561
1559 // This field contains the meaning of the WATERMARK_INVALIDATED flag. 1562 // This field contains the meaning of the WATERMARK_INVALIDATED flag.
1560 // Instead of clearing this flag from all pages we just flip 1563 // Instead of clearing this flag from all pages we just flip
1561 // its meaning at the beginning of a scavenge. 1564 // its meaning at the beginning of a scavenge.
1562 intptr_t page_watermark_invalidated_mark_; 1565 intptr_t page_watermark_invalidated_mark_;
1563 1566
1564 int number_idle_notifications_; 1567 int number_idle_notifications_;
1565 int last_idle_notification_gc_count_; 1568 unsigned int last_idle_notification_gc_count_;
1566 bool last_idle_notification_gc_count_init_; 1569 bool last_idle_notification_gc_count_init_;
1567 1570
1568 // Shared state read by the scavenge collector and set by ScavengeObject. 1571 // Shared state read by the scavenge collector and set by ScavengeObject.
1569 PromotionQueue promotion_queue_; 1572 PromotionQueue promotion_queue_;
1570 1573
1571 // Flag is set when the heap has been configured. The heap can be repeatedly 1574 // Flag is set when the heap has been configured. The heap can be repeatedly
1572 // configured through the API until it is setup. 1575 // configured through the API until it is setup.
1573 bool configured_; 1576 bool configured_;
1574 1577
1575 ExternalStringTable external_string_table_; 1578 ExternalStringTable external_string_table_;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 double start_time_; 2017 double start_time_;
2015 }; 2018 };
2016 2019
2017 explicit GCTracer(Heap* heap); 2020 explicit GCTracer(Heap* heap);
2018 ~GCTracer(); 2021 ~GCTracer();
2019 2022
2020 // Sets the collector. 2023 // Sets the collector.
2021 void set_collector(GarbageCollector collector) { collector_ = collector; } 2024 void set_collector(GarbageCollector collector) { collector_ = collector; }
2022 2025
2023 // Sets the GC count. 2026 // Sets the GC count.
2024 void set_gc_count(int count) { gc_count_ = count; } 2027 void set_gc_count(unsigned int count) { gc_count_ = count; }
2025 2028
2026 // Sets the full GC count. 2029 // Sets the full GC count.
2027 void set_full_gc_count(int count) { full_gc_count_ = count; } 2030 void set_full_gc_count(int count) { full_gc_count_ = count; }
2028 2031
2029 // Sets the flag that this is a compacting full GC. 2032 // Sets the flag that this is a compacting full GC.
2030 void set_is_compacting() { is_compacting_ = true; } 2033 void set_is_compacting() { is_compacting_ = true; }
2031 bool is_compacting() const { return is_compacting_; } 2034 bool is_compacting() const { return is_compacting_; }
2032 2035
2033 // Increment and decrement the count of marked objects. 2036 // Increment and decrement the count of marked objects.
2034 void increment_marked_count() { ++marked_count_; } 2037 void increment_marked_count() { ++marked_count_; }
(...skipping 13 matching lines...) Expand all
2048 double SizeOfHeapObjects() { 2051 double SizeOfHeapObjects() {
2049 return (static_cast<double>(HEAP->SizeOfObjects())) / MB; 2052 return (static_cast<double>(HEAP->SizeOfObjects())) / MB;
2050 } 2053 }
2051 2054
2052 double start_time_; // Timestamp set in the constructor. 2055 double start_time_; // Timestamp set in the constructor.
2053 intptr_t start_size_; // Size of objects in heap set in constructor. 2056 intptr_t start_size_; // Size of objects in heap set in constructor.
2054 GarbageCollector collector_; // Type of collector. 2057 GarbageCollector collector_; // Type of collector.
2055 2058
2056 // A count (including this one, eg, the first collection is 1) of the 2059 // A count (including this one, eg, the first collection is 1) of the
2057 // number of garbage collections. 2060 // number of garbage collections.
2058 int gc_count_; 2061 unsigned int gc_count_;
2059 2062
2060 // A count (including this one) of the number of full garbage collections. 2063 // A count (including this one) of the number of full garbage collections.
2061 int full_gc_count_; 2064 int full_gc_count_;
2062 2065
2063 // True if the current GC is a compacting full collection, false 2066 // True if the current GC is a compacting full collection, false
2064 // otherwise. 2067 // otherwise.
2065 bool is_compacting_; 2068 bool is_compacting_;
2066 2069
2067 // True if the *previous* full GC cwas a compacting collection (will be 2070 // True if the *previous* full GC cwas a compacting collection (will be
2068 // false if there has not been a previous full GC). 2071 // false if there has not been a previous full GC).
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 public: 2181 public:
2179 virtual ~WeakObjectRetainer() {} 2182 virtual ~WeakObjectRetainer() {}
2180 2183
2181 // Return whether this object should be retained. If NULL is returned the 2184 // Return whether this object should be retained. If NULL is returned the
2182 // object has no references. Otherwise the address of the retained object 2185 // object has no references. Otherwise the address of the retained object
2183 // should be returned as in some GC situations the object has been moved. 2186 // should be returned as in some GC situations the object has been moved.
2184 virtual Object* RetainAs(Object* object) = 0; 2187 virtual Object* RetainAs(Object* object) = 0;
2185 }; 2188 };
2186 2189
2187 2190
2191 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST)
2192 // Helper class for tracing paths to a search target Object from all roots.
2193 // The TracePathFrom() method can be used to trace paths from a specific
2194 // object to the search target object.
2195 class PathTracer : public ObjectVisitor {
2196 public:
2197 enum WhatToFind {
2198 FIND_ALL, // Will find all matches.
2199 FIND_FIRST // Will stop the search after first match.
2200 };
2201
2202 // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop
2203 // after the first match. If FIND_ALL is specified, then tracing will be
2204 // done for all matches.
2205 PathTracer(Object* search_target,
2206 WhatToFind what_to_find,
2207 VisitMode visit_mode)
2208 : search_target_(search_target),
2209 found_target_(false),
2210 found_target_in_trace_(false),
2211 what_to_find_(what_to_find),
2212 visit_mode_(visit_mode),
2213 object_stack_(20),
2214 no_alloc() {}
2215
2216 virtual void VisitPointers(Object** start, Object** end);
2217
2218 void Reset();
2219 void TracePathFrom(Object** root);
2220
2221 bool found() const { return found_target_; }
2222
2223 static Object* const kAnyGlobalObject;
2224
2225 protected:
2226 class MarkVisitor;
2227 class UnmarkVisitor;
2228
2229 void MarkRecursively(Object** p, MarkVisitor* mark_visitor);
2230 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor);
2231 virtual void ProcessResults();
2232
2233 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject.
2234 static const int kMarkTag = 2;
2235
2236 Object* search_target_;
2237 bool found_target_;
2238 bool found_target_in_trace_;
2239 WhatToFind what_to_find_;
2240 VisitMode visit_mode_;
2241 List<Object*> object_stack_;
2242
2243 AssertNoAllocation no_alloc; // i.e. no gc allowed.
2244
2245 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2246 };
2247 #endif // DEBUG || LIVE_OBJECT_LIST
2248
2249
2188 } } // namespace v8::internal 2250 } } // namespace v8::internal
2189 2251
2190 #undef HEAP 2252 #undef HEAP
2191 2253
2192 #endif // V8_HEAP_H_ 2254 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/handles-inl.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698