OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_H_ | 5 #ifndef V8_HEAP_H_ |
6 #define V8_HEAP_H_ | 6 #define V8_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 case LO_SPACE: | 649 case LO_SPACE: |
650 UNREACHABLE(); | 650 UNREACHABLE(); |
651 } | 651 } |
652 return NULL; | 652 return NULL; |
653 } | 653 } |
654 | 654 |
655 bool always_allocate() { return always_allocate_scope_depth_ != 0; } | 655 bool always_allocate() { return always_allocate_scope_depth_ != 0; } |
656 Address always_allocate_scope_depth_address() { | 656 Address always_allocate_scope_depth_address() { |
657 return reinterpret_cast<Address>(&always_allocate_scope_depth_); | 657 return reinterpret_cast<Address>(&always_allocate_scope_depth_); |
658 } | 658 } |
659 bool linear_allocation() { | |
660 return linear_allocation_scope_depth_ != 0; | |
661 } | |
662 | 659 |
663 Address* NewSpaceAllocationTopAddress() { | 660 Address* NewSpaceAllocationTopAddress() { |
664 return new_space_.allocation_top_address(); | 661 return new_space_.allocation_top_address(); |
665 } | 662 } |
666 Address* NewSpaceAllocationLimitAddress() { | 663 Address* NewSpaceAllocationLimitAddress() { |
667 return new_space_.allocation_limit_address(); | 664 return new_space_.allocation_limit_address(); |
668 } | 665 } |
669 | 666 |
670 Address* OldPointerSpaceAllocationTopAddress() { | 667 Address* OldPointerSpaceAllocationTopAddress() { |
671 return old_pointer_space_->allocation_top_address(); | 668 return old_pointer_space_->allocation_top_address(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 return true; | 966 return true; |
970 #else | 967 #else |
971 #ifdef VERIFY_HEAP | 968 #ifdef VERIFY_HEAP |
972 return FLAG_verify_heap; | 969 return FLAG_verify_heap; |
973 #else | 970 #else |
974 return false; | 971 return false; |
975 #endif | 972 #endif |
976 #endif | 973 #endif |
977 } | 974 } |
978 | 975 |
| 976 // Number of "runtime allocations" done so far. |
| 977 uint32_t allocations_count() { return allocations_count_; } |
| 978 |
| 979 // Returns deterministic "time" value in ms. Works only with |
| 980 // FLAG_verify_predictable. |
| 981 double synthetic_time() { return allocations_count_ / 100.0; } |
| 982 |
979 // Print short heap statistics. | 983 // Print short heap statistics. |
980 void PrintShortHeapStatistics(); | 984 void PrintShortHeapStatistics(); |
981 | 985 |
982 // Write barrier support for address[offset] = o. | 986 // Write barrier support for address[offset] = o. |
983 INLINE(void RecordWrite(Address address, int offset)); | 987 INLINE(void RecordWrite(Address address, int offset)); |
984 | 988 |
985 // Write barrier support for address[start : start + len[ = o. | 989 // Write barrier support for address[start : start + len[ = o. |
986 INLINE(void RecordWrites(Address address, int start, int len)); | 990 INLINE(void RecordWrites(Address address, int start, int len)); |
987 | 991 |
988 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 992 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 | 1433 |
1430 void InitializeWeakObjectToCodeTable() { | 1434 void InitializeWeakObjectToCodeTable() { |
1431 set_weak_object_to_code_table(undefined_value()); | 1435 set_weak_object_to_code_table(undefined_value()); |
1432 } | 1436 } |
1433 | 1437 |
1434 void EnsureWeakObjectToCodeTable(); | 1438 void EnsureWeakObjectToCodeTable(); |
1435 | 1439 |
1436 static void FatalProcessOutOfMemory(const char* location, | 1440 static void FatalProcessOutOfMemory(const char* location, |
1437 bool take_snapshot = false); | 1441 bool take_snapshot = false); |
1438 | 1442 |
| 1443 // This event is triggered after successful allocation of a new object made |
| 1444 // by runtime. Allocations of target space for object evacuation do not |
| 1445 // trigger the event. In order to track ALL allocations one must turn off |
| 1446 // FLAG_inline_new and FLAG_use_allocation_folding. |
| 1447 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); |
| 1448 |
| 1449 // This event is triggered after object is moved to a new place. |
| 1450 inline void OnMoveEvent(HeapObject* target, |
| 1451 HeapObject* source, |
| 1452 int size_in_bytes); |
| 1453 |
1439 protected: | 1454 protected: |
1440 // Methods made available to tests. | 1455 // Methods made available to tests. |
1441 | 1456 |
1442 // Allocates a JS Map in the heap. | 1457 // Allocates a JS Map in the heap. |
1443 MUST_USE_RESULT AllocationResult AllocateMap( | 1458 MUST_USE_RESULT AllocationResult AllocateMap( |
1444 InstanceType instance_type, | 1459 InstanceType instance_type, |
1445 int instance_size, | 1460 int instance_size, |
1446 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1461 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
1447 | 1462 |
1448 // Allocates and initializes a new JavaScript object based on a | 1463 // Allocates and initializes a new JavaScript object based on a |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 int old_space_growing_factor_; | 1533 int old_space_growing_factor_; |
1519 | 1534 |
1520 // For keeping track of how much data has survived | 1535 // For keeping track of how much data has survived |
1521 // scavenge since last new space expansion. | 1536 // scavenge since last new space expansion. |
1522 int survived_since_last_expansion_; | 1537 int survived_since_last_expansion_; |
1523 | 1538 |
1524 // For keeping track on when to flush RegExp code. | 1539 // For keeping track on when to flush RegExp code. |
1525 int sweep_generation_; | 1540 int sweep_generation_; |
1526 | 1541 |
1527 int always_allocate_scope_depth_; | 1542 int always_allocate_scope_depth_; |
1528 int linear_allocation_scope_depth_; | |
1529 | 1543 |
1530 // For keeping track of context disposals. | 1544 // For keeping track of context disposals. |
1531 int contexts_disposed_; | 1545 int contexts_disposed_; |
1532 | 1546 |
1533 int global_ic_age_; | 1547 int global_ic_age_; |
1534 | 1548 |
1535 bool flush_monomorphic_ics_; | 1549 bool flush_monomorphic_ics_; |
1536 | 1550 |
1537 int scan_on_scavenge_pages_; | 1551 int scan_on_scavenge_pages_; |
1538 | 1552 |
1539 NewSpace new_space_; | 1553 NewSpace new_space_; |
1540 OldSpace* old_pointer_space_; | 1554 OldSpace* old_pointer_space_; |
1541 OldSpace* old_data_space_; | 1555 OldSpace* old_data_space_; |
1542 OldSpace* code_space_; | 1556 OldSpace* code_space_; |
1543 MapSpace* map_space_; | 1557 MapSpace* map_space_; |
1544 CellSpace* cell_space_; | 1558 CellSpace* cell_space_; |
1545 PropertyCellSpace* property_cell_space_; | 1559 PropertyCellSpace* property_cell_space_; |
1546 LargeObjectSpace* lo_space_; | 1560 LargeObjectSpace* lo_space_; |
1547 HeapState gc_state_; | 1561 HeapState gc_state_; |
1548 int gc_post_processing_depth_; | 1562 int gc_post_processing_depth_; |
1549 Address new_space_top_after_last_gc_; | 1563 Address new_space_top_after_last_gc_; |
1550 | 1564 |
1551 // Returns the amount of external memory registered since last global gc. | 1565 // Returns the amount of external memory registered since last global gc. |
1552 int64_t PromotedExternalMemorySize(); | 1566 int64_t PromotedExternalMemorySize(); |
1553 | 1567 |
1554 unsigned int ms_count_; // how many mark-sweep collections happened | 1568 // How many "runtime allocations" happened. |
1555 unsigned int gc_count_; // how many gc happened | 1569 uint32_t allocations_count_; |
| 1570 |
| 1571 // Running hash over allocations performed. |
| 1572 uint32_t raw_allocations_hash_; |
| 1573 |
| 1574 // Countdown counter, dumps allocation hash when 0. |
| 1575 uint32_t dump_allocations_hash_countdown_; |
| 1576 |
| 1577 // How many mark-sweep collections happened. |
| 1578 unsigned int ms_count_; |
| 1579 |
| 1580 // How many gc happened. |
| 1581 unsigned int gc_count_; |
1556 | 1582 |
1557 // For post mortem debugging. | 1583 // For post mortem debugging. |
1558 static const int kRememberedUnmappedPages = 128; | 1584 static const int kRememberedUnmappedPages = 128; |
1559 int remembered_unmapped_pages_index_; | 1585 int remembered_unmapped_pages_index_; |
1560 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; | 1586 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; |
1561 | 1587 |
1562 // Total length of the strings we failed to flatten since the last GC. | 1588 // Total length of the strings we failed to flatten since the last GC. |
1563 int unflattened_strings_length_; | 1589 int unflattened_strings_length_; |
1564 | 1590 |
1565 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1591 #define ROOT_ACCESSOR(type, name, camel_name) \ |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 | 2105 |
2080 void set_weak_object_to_code_table(Object* value) { | 2106 void set_weak_object_to_code_table(Object* value) { |
2081 ASSERT(!InNewSpace(value)); | 2107 ASSERT(!InNewSpace(value)); |
2082 weak_object_to_code_table_ = value; | 2108 weak_object_to_code_table_ = value; |
2083 } | 2109 } |
2084 | 2110 |
2085 Object** weak_object_to_code_table_address() { | 2111 Object** weak_object_to_code_table_address() { |
2086 return &weak_object_to_code_table_; | 2112 return &weak_object_to_code_table_; |
2087 } | 2113 } |
2088 | 2114 |
| 2115 inline void UpdateAllocationsHash(HeapObject* object); |
| 2116 inline void UpdateAllocationsHash(uint32_t value); |
| 2117 inline void PrintAlloctionsHash(); |
| 2118 |
2089 static const int kInitialStringTableSize = 2048; | 2119 static const int kInitialStringTableSize = 2048; |
2090 static const int kInitialEvalCacheSize = 64; | 2120 static const int kInitialEvalCacheSize = 64; |
2091 static const int kInitialNumberStringCacheSize = 256; | 2121 static const int kInitialNumberStringCacheSize = 256; |
2092 | 2122 |
2093 // Object counts and used memory by InstanceType | 2123 // Object counts and used memory by InstanceType |
2094 size_t object_counts_[OBJECT_STATS_COUNT]; | 2124 size_t object_counts_[OBJECT_STATS_COUNT]; |
2095 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 2125 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
2096 size_t object_sizes_[OBJECT_STATS_COUNT]; | 2126 size_t object_sizes_[OBJECT_STATS_COUNT]; |
2097 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; | 2127 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; |
2098 | 2128 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2810 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2781 | 2811 |
2782 private: | 2812 private: |
2783 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2813 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2784 }; | 2814 }; |
2785 #endif // DEBUG | 2815 #endif // DEBUG |
2786 | 2816 |
2787 } } // namespace v8::internal | 2817 } } // namespace v8::internal |
2788 | 2818 |
2789 #endif // V8_HEAP_H_ | 2819 #endif // V8_HEAP_H_ |
OLD | NEW |