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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 V(object_symbol, "object") \ | 202 V(object_symbol, "object") \ |
203 V(prototype_symbol, "prototype") \ | 203 V(prototype_symbol, "prototype") \ |
204 V(string_symbol, "string") \ | 204 V(string_symbol, "string") \ |
205 V(String_symbol, "String") \ | 205 V(String_symbol, "String") \ |
206 V(Date_symbol, "Date") \ | 206 V(Date_symbol, "Date") \ |
207 V(this_symbol, "this") \ | 207 V(this_symbol, "this") \ |
208 V(to_string_symbol, "toString") \ | 208 V(to_string_symbol, "toString") \ |
209 V(char_at_symbol, "CharAt") \ | 209 V(char_at_symbol, "CharAt") \ |
210 V(undefined_symbol, "undefined") \ | 210 V(undefined_symbol, "undefined") \ |
211 V(value_of_symbol, "valueOf") \ | 211 V(value_of_symbol, "valueOf") \ |
| 212 V(stack_symbol, "stack") \ |
212 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ | 213 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ |
213 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ | 214 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ |
214 V(KeyedLoadElementMonomorphic_symbol, \ | 215 V(KeyedLoadElementMonomorphic_symbol, \ |
215 "KeyedLoadElementMonomorphic") \ | 216 "KeyedLoadElementMonomorphic") \ |
216 V(KeyedStoreElementMonomorphic_symbol, \ | 217 V(KeyedStoreElementMonomorphic_symbol, \ |
217 "KeyedStoreElementMonomorphic") \ | 218 "KeyedStoreElementMonomorphic") \ |
218 V(KeyedStoreAndGrowElementMonomorphic_symbol, \ | 219 V(KeyedStoreAndGrowElementMonomorphic_symbol, \ |
219 "KeyedStoreAndGrowElementMonomorphic") \ | 220 "KeyedStoreAndGrowElementMonomorphic") \ |
220 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ | 221 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ |
221 V(illegal_access_symbol, "illegal access") \ | 222 V(illegal_access_symbol, "illegal access") \ |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // separate from old space strings. | 429 // separate from old space strings. |
429 List<Object*> new_space_strings_; | 430 List<Object*> new_space_strings_; |
430 List<Object*> old_space_strings_; | 431 List<Object*> old_space_strings_; |
431 | 432 |
432 Heap* heap_; | 433 Heap* heap_; |
433 | 434 |
434 DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); | 435 DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); |
435 }; | 436 }; |
436 | 437 |
437 | 438 |
| 439 // The stack property of an error object is implemented as a getter that |
| 440 // formats the attached raw stack trace into a string. This raw stack trace |
| 441 // keeps code and function objects alive until the getter is called the first |
| 442 // time. To release those objects, we call the getter after each GC for |
| 443 // newly tenured error objects that are kept in a list. |
| 444 class ErrorObjectList { |
| 445 public: |
| 446 inline void Add(JSObject* object); |
| 447 |
| 448 inline void Iterate(ObjectVisitor* v); |
| 449 |
| 450 void TearDown(); |
| 451 |
| 452 void RemoveUnmarked(Heap* heap); |
| 453 |
| 454 void DeferredFormatStackTrace(Isolate* isolate); |
| 455 |
| 456 void UpdateReferences(); |
| 457 |
| 458 void UpdateReferencesInNewSpace(Heap* heap); |
| 459 |
| 460 private: |
| 461 static const int kBudgetPerGC = 16; |
| 462 |
| 463 ErrorObjectList() : nested_(false) { } |
| 464 |
| 465 friend class Heap; |
| 466 |
| 467 List<Object*> list_; |
| 468 bool nested_; |
| 469 |
| 470 DISALLOW_COPY_AND_ASSIGN(ErrorObjectList); |
| 471 }; |
| 472 |
| 473 |
438 enum ArrayStorageAllocationMode { | 474 enum ArrayStorageAllocationMode { |
439 DONT_INITIALIZE_ARRAY_ELEMENTS, | 475 DONT_INITIALIZE_ARRAY_ELEMENTS, |
440 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 476 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
441 }; | 477 }; |
442 | 478 |
443 class Heap { | 479 class Heap { |
444 public: | 480 public: |
445 // Configure heap size before setup. Return false if the heap has been | 481 // Configure heap size before setup. Return false if the heap has been |
446 // set up already. | 482 // set up already. |
447 bool ConfigureHeap(int max_semispace_size, | 483 bool ConfigureHeap(int max_semispace_size, |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 bool AdvanceSweepers(int step_size) { | 1610 bool AdvanceSweepers(int step_size) { |
1575 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); | 1611 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); |
1576 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); | 1612 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); |
1577 return sweeping_complete; | 1613 return sweeping_complete; |
1578 } | 1614 } |
1579 | 1615 |
1580 ExternalStringTable* external_string_table() { | 1616 ExternalStringTable* external_string_table() { |
1581 return &external_string_table_; | 1617 return &external_string_table_; |
1582 } | 1618 } |
1583 | 1619 |
| 1620 ErrorObjectList* error_object_list() { |
| 1621 return &error_object_list_; |
| 1622 } |
| 1623 |
1584 // Returns the current sweep generation. | 1624 // Returns the current sweep generation. |
1585 int sweep_generation() { | 1625 int sweep_generation() { |
1586 return sweep_generation_; | 1626 return sweep_generation_; |
1587 } | 1627 } |
1588 | 1628 |
1589 inline Isolate* isolate(); | 1629 inline Isolate* isolate(); |
1590 | 1630 |
1591 inline void CallGlobalGCPrologueCallback() { | 1631 inline void CallGlobalGCPrologueCallback() { |
1592 if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_(); | 1632 if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_(); |
1593 } | 1633 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 | 2194 |
2155 // Shared state read by the scavenge collector and set by ScavengeObject. | 2195 // Shared state read by the scavenge collector and set by ScavengeObject. |
2156 PromotionQueue promotion_queue_; | 2196 PromotionQueue promotion_queue_; |
2157 | 2197 |
2158 // Flag is set when the heap has been configured. The heap can be repeatedly | 2198 // Flag is set when the heap has been configured. The heap can be repeatedly |
2159 // configured through the API until it is set up. | 2199 // configured through the API until it is set up. |
2160 bool configured_; | 2200 bool configured_; |
2161 | 2201 |
2162 ExternalStringTable external_string_table_; | 2202 ExternalStringTable external_string_table_; |
2163 | 2203 |
| 2204 ErrorObjectList error_object_list_; |
| 2205 |
2164 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; | 2206 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
2165 | 2207 |
2166 MemoryChunk* chunks_queued_for_free_; | 2208 MemoryChunk* chunks_queued_for_free_; |
2167 | 2209 |
2168 Mutex* relocation_mutex_; | 2210 Mutex* relocation_mutex_; |
2169 | 2211 |
2170 friend class Factory; | 2212 friend class Factory; |
2171 friend class GCTracer; | 2213 friend class GCTracer; |
2172 friend class DisallowAllocationFailure; | 2214 friend class DisallowAllocationFailure; |
2173 friend class AlwaysAllocateScope; | 2215 friend class AlwaysAllocateScope; |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 2870 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
2829 | 2871 |
2830 private: | 2872 private: |
2831 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2873 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2832 }; | 2874 }; |
2833 #endif // DEBUG || LIVE_OBJECT_LIST | 2875 #endif // DEBUG || LIVE_OBJECT_LIST |
2834 | 2876 |
2835 } } // namespace v8::internal | 2877 } } // namespace v8::internal |
2836 | 2878 |
2837 #endif // V8_HEAP_H_ | 2879 #endif // V8_HEAP_H_ |
OLD | NEW |