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_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
11 #include "src/assert-scope.h" | 11 #include "src/assert-scope.h" |
12 #include "src/counters.h" | 12 #include "src/counters.h" |
13 #include "src/globals.h" | 13 #include "src/globals.h" |
| 14 #include "src/heap/gc-idle-time-handler.h" |
14 #include "src/heap/gc-tracer.h" | 15 #include "src/heap/gc-tracer.h" |
15 #include "src/heap/incremental-marking.h" | 16 #include "src/heap/incremental-marking.h" |
16 #include "src/heap/mark-compact.h" | 17 #include "src/heap/mark-compact.h" |
17 #include "src/heap/objects-visiting.h" | 18 #include "src/heap/objects-visiting.h" |
18 #include "src/heap/spaces.h" | 19 #include "src/heap/spaces.h" |
19 #include "src/heap/store-buffer.h" | 20 #include "src/heap/store-buffer.h" |
20 #include "src/list.h" | 21 #include "src/list.h" |
21 #include "src/splay-tree-inl.h" | 22 #include "src/splay-tree-inl.h" |
22 | 23 |
23 namespace v8 { | 24 namespace v8 { |
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 // the code that belongs to the allocation site and derive the lifetime | 1922 // the code that belongs to the allocation site and derive the lifetime |
1922 // of the allocation site. | 1923 // of the allocation site. |
1923 unsigned int maximum_size_scavenges_; | 1924 unsigned int maximum_size_scavenges_; |
1924 | 1925 |
1925 // TODO(hpayer): Allocation site pretenuring may make this method obsolete. | 1926 // TODO(hpayer): Allocation site pretenuring may make this method obsolete. |
1926 // Re-visit incremental marking heuristics. | 1927 // Re-visit incremental marking heuristics. |
1927 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } | 1928 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } |
1928 | 1929 |
1929 void SelectScavengingVisitorsTable(); | 1930 void SelectScavengingVisitorsTable(); |
1930 | 1931 |
1931 void StartIdleRound() { mark_sweeps_since_idle_round_started_ = 0; } | 1932 void AdvanceIdleIncrementalMarking(intptr_t step_size); |
1932 | |
1933 void FinishIdleRound() { | |
1934 mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound; | |
1935 scavenges_since_last_idle_round_ = 0; | |
1936 } | |
1937 | |
1938 bool EnoughGarbageSinceLastIdleRound() { | |
1939 return (scavenges_since_last_idle_round_ >= kIdleScavengeThreshold); | |
1940 } | |
1941 | |
1942 // Estimates how many milliseconds a Mark-Sweep would take to complete. | |
1943 // In idle notification handler we assume that this function will return: | |
1944 // - a number less than 10 for small heaps, which are less than 8Mb. | |
1945 // - a number greater than 10 for large heaps, which are greater than 32Mb. | |
1946 int TimeMarkSweepWouldTakeInMs() { | |
1947 // Rough estimate of how many megabytes of heap can be processed in 1 ms. | |
1948 static const int kMbPerMs = 2; | |
1949 | |
1950 int heap_size_mb = static_cast<int>(SizeOfObjects() / MB); | |
1951 return heap_size_mb / kMbPerMs; | |
1952 } | |
1953 | |
1954 void AdvanceIdleIncrementalMarking(int idle_time_in_ms); | |
1955 | 1933 |
1956 void ClearObjectStats(bool clear_last_time_stats = false); | 1934 void ClearObjectStats(bool clear_last_time_stats = false); |
1957 | 1935 |
1958 void set_weak_object_to_code_table(Object* value) { | 1936 void set_weak_object_to_code_table(Object* value) { |
1959 DCHECK(!InNewSpace(value)); | 1937 DCHECK(!InNewSpace(value)); |
1960 weak_object_to_code_table_ = value; | 1938 weak_object_to_code_table_ = value; |
1961 } | 1939 } |
1962 | 1940 |
1963 Object** weak_object_to_code_table_address() { | 1941 Object** weak_object_to_code_table_address() { |
1964 return &weak_object_to_code_table_; | 1942 return &weak_object_to_code_table_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 double sweeping_time_; | 1975 double sweeping_time_; |
1998 | 1976 |
1999 MarkCompactCollector mark_compact_collector_; | 1977 MarkCompactCollector mark_compact_collector_; |
2000 | 1978 |
2001 StoreBuffer store_buffer_; | 1979 StoreBuffer store_buffer_; |
2002 | 1980 |
2003 Marking marking_; | 1981 Marking marking_; |
2004 | 1982 |
2005 IncrementalMarking incremental_marking_; | 1983 IncrementalMarking incremental_marking_; |
2006 | 1984 |
2007 int number_idle_notifications_; | 1985 GCIdleTimeHandler gc_idle_time_handler_; |
2008 unsigned int last_idle_notification_gc_count_; | |
2009 bool last_idle_notification_gc_count_init_; | |
2010 | |
2011 int mark_sweeps_since_idle_round_started_; | |
2012 unsigned int gc_count_at_last_idle_gc_; | 1986 unsigned int gc_count_at_last_idle_gc_; |
2013 int scavenges_since_last_idle_round_; | |
2014 | 1987 |
2015 // These two counters are monotomically increasing and never reset. | 1988 // These two counters are monotomically increasing and never reset. |
2016 size_t full_codegen_bytes_generated_; | 1989 size_t full_codegen_bytes_generated_; |
2017 size_t crankshaft_codegen_bytes_generated_; | 1990 size_t crankshaft_codegen_bytes_generated_; |
2018 | 1991 |
2019 // If the --deopt_every_n_garbage_collections flag is set to a positive value, | 1992 // If the --deopt_every_n_garbage_collections flag is set to a positive value, |
2020 // this variable holds the number of garbage collections since the last | 1993 // this variable holds the number of garbage collections since the last |
2021 // deoptimization triggered by garbage collection. | 1994 // deoptimization triggered by garbage collection. |
2022 int gcs_since_last_deopt_; | 1995 int gcs_since_last_deopt_; |
2023 | 1996 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2493 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2521 | 2494 |
2522 private: | 2495 private: |
2523 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2496 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2524 }; | 2497 }; |
2525 #endif // DEBUG | 2498 #endif // DEBUG |
2526 } | 2499 } |
2527 } // namespace v8::internal | 2500 } // namespace v8::internal |
2528 | 2501 |
2529 #endif // V8_HEAP_HEAP_H_ | 2502 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |