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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
969 return true; | 969 return true; |
970 #else | 970 #else |
971 #ifdef VERIFY_HEAP | 971 #ifdef VERIFY_HEAP |
972 return FLAG_verify_heap; | 972 return FLAG_verify_heap; |
973 #else | 973 #else |
974 return false; | 974 return false; |
975 #endif | 975 #endif |
976 #endif | 976 #endif |
977 } | 977 } |
978 | 978 |
979 // Number of allocations done so far. | |
Hannes Payer (out of office)
2014/06/09 15:23:51
"runtime allocations"
Igor Sheludko
2014/06/10 08:22:54
Done.
| |
980 uint32_t allocations_count() { return allocations_count_; } | |
981 | |
979 // Print short heap statistics. | 982 // Print short heap statistics. |
980 void PrintShortHeapStatistics(); | 983 void PrintShortHeapStatistics(); |
981 | 984 |
982 // Write barrier support for address[offset] = o. | 985 // Write barrier support for address[offset] = o. |
983 INLINE(void RecordWrite(Address address, int offset)); | 986 INLINE(void RecordWrite(Address address, int offset)); |
984 | 987 |
985 // Write barrier support for address[start : start + len[ = o. | 988 // Write barrier support for address[start : start + len[ = o. |
986 INLINE(void RecordWrites(Address address, int start, int len)); | 989 INLINE(void RecordWrites(Address address, int start, int len)); |
987 | 990 |
988 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 991 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 | 1432 |
1430 void InitializeWeakObjectToCodeTable() { | 1433 void InitializeWeakObjectToCodeTable() { |
1431 set_weak_object_to_code_table(undefined_value()); | 1434 set_weak_object_to_code_table(undefined_value()); |
1432 } | 1435 } |
1433 | 1436 |
1434 void EnsureWeakObjectToCodeTable(); | 1437 void EnsureWeakObjectToCodeTable(); |
1435 | 1438 |
1436 static void FatalProcessOutOfMemory(const char* location, | 1439 static void FatalProcessOutOfMemory(const char* location, |
1437 bool take_snapshot = false); | 1440 bool take_snapshot = false); |
1438 | 1441 |
1442 // This event is triggered after each successful allocation made by runtime. | |
1443 // It could be allocation either of new object or of a target space for object | |
1444 // evacuation. In order to track ALL allocations one must turn off | |
1445 // FLAG_inline_new and FLAG_use_allocation_folding. | |
1446 inline void OnAllocationEvent(HeapObject* object, int size_in_bytes); | |
1447 | |
1439 protected: | 1448 protected: |
1440 // Methods made available to tests. | 1449 // Methods made available to tests. |
1441 | 1450 |
1442 // Allocates a JS Map in the heap. | 1451 // Allocates a JS Map in the heap. |
1443 MUST_USE_RESULT AllocationResult AllocateMap( | 1452 MUST_USE_RESULT AllocationResult AllocateMap( |
1444 InstanceType instance_type, | 1453 InstanceType instance_type, |
1445 int instance_size, | 1454 int instance_size, |
1446 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1455 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
1447 | 1456 |
1448 // Allocates and initializes a new JavaScript object based on a | 1457 // Allocates and initializes a new JavaScript object based on a |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 CellSpace* cell_space_; | 1553 CellSpace* cell_space_; |
1545 PropertyCellSpace* property_cell_space_; | 1554 PropertyCellSpace* property_cell_space_; |
1546 LargeObjectSpace* lo_space_; | 1555 LargeObjectSpace* lo_space_; |
1547 HeapState gc_state_; | 1556 HeapState gc_state_; |
1548 int gc_post_processing_depth_; | 1557 int gc_post_processing_depth_; |
1549 Address new_space_top_after_last_gc_; | 1558 Address new_space_top_after_last_gc_; |
1550 | 1559 |
1551 // Returns the amount of external memory registered since last global gc. | 1560 // Returns the amount of external memory registered since last global gc. |
1552 int64_t PromotedExternalMemorySize(); | 1561 int64_t PromotedExternalMemorySize(); |
1553 | 1562 |
1563 uint32_t allocations_count_; // how many allocations happened | |
Hannes Payer (out of office)
2014/06/09 15:23:51
Style guide: Each comment should start in a new li
Igor Sheludko
2014/06/10 08:22:54
Done.
| |
1564 uint32_t raw_allocations_hash_; // running hash over allocations performed | |
1565 uint32_t dump_allocations_hash_countdown_; // dump allocation hash when 0 | |
1566 | |
1554 unsigned int ms_count_; // how many mark-sweep collections happened | 1567 unsigned int ms_count_; // how many mark-sweep collections happened |
1555 unsigned int gc_count_; // how many gc happened | 1568 unsigned int gc_count_; // how many gc happened |
1556 | 1569 |
1557 // For post mortem debugging. | 1570 // For post mortem debugging. |
1558 static const int kRememberedUnmappedPages = 128; | 1571 static const int kRememberedUnmappedPages = 128; |
1559 int remembered_unmapped_pages_index_; | 1572 int remembered_unmapped_pages_index_; |
1560 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; | 1573 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; |
1561 | 1574 |
1562 // Total length of the strings we failed to flatten since the last GC. | 1575 // Total length of the strings we failed to flatten since the last GC. |
1563 int unflattened_strings_length_; | 1576 int unflattened_strings_length_; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2079 | 2092 |
2080 void set_weak_object_to_code_table(Object* value) { | 2093 void set_weak_object_to_code_table(Object* value) { |
2081 ASSERT(!InNewSpace(value)); | 2094 ASSERT(!InNewSpace(value)); |
2082 weak_object_to_code_table_ = value; | 2095 weak_object_to_code_table_ = value; |
2083 } | 2096 } |
2084 | 2097 |
2085 Object** weak_object_to_code_table_address() { | 2098 Object** weak_object_to_code_table_address() { |
2086 return &weak_object_to_code_table_; | 2099 return &weak_object_to_code_table_; |
2087 } | 2100 } |
2088 | 2101 |
2102 inline void UpdateAllocationsHash(uint32_t value); | |
2103 inline void PrintAlloctionsHash(); | |
2104 | |
2089 static const int kInitialStringTableSize = 2048; | 2105 static const int kInitialStringTableSize = 2048; |
2090 static const int kInitialEvalCacheSize = 64; | 2106 static const int kInitialEvalCacheSize = 64; |
2091 static const int kInitialNumberStringCacheSize = 256; | 2107 static const int kInitialNumberStringCacheSize = 256; |
2092 | 2108 |
2093 // Object counts and used memory by InstanceType | 2109 // Object counts and used memory by InstanceType |
2094 size_t object_counts_[OBJECT_STATS_COUNT]; | 2110 size_t object_counts_[OBJECT_STATS_COUNT]; |
2095 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 2111 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
2096 size_t object_sizes_[OBJECT_STATS_COUNT]; | 2112 size_t object_sizes_[OBJECT_STATS_COUNT]; |
2097 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; | 2113 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; |
2098 | 2114 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2780 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2796 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2781 | 2797 |
2782 private: | 2798 private: |
2783 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2799 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2784 }; | 2800 }; |
2785 #endif // DEBUG | 2801 #endif // DEBUG |
2786 | 2802 |
2787 } } // namespace v8::internal | 2803 } } // namespace v8::internal |
2788 | 2804 |
2789 #endif // V8_HEAP_H_ | 2805 #endif // V8_HEAP_H_ |
OLD | NEW |