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

Side by Side Diff: src/heap.h

Issue 2084017: Version 2.2.11... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 7 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/globals.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // Helper function that governs the promotion policy from new space to 974 // Helper function that governs the promotion policy from new space to
975 // old. If the object's old address lies below the new space's age 975 // old. If the object's old address lies below the new space's age
976 // mark or if we've already filled the bottom 1/16th of the to space, 976 // mark or if we've already filled the bottom 1/16th of the to space,
977 // we try to promote this object. 977 // we try to promote this object.
978 static inline bool ShouldBePromoted(Address old_address, int object_size); 978 static inline bool ShouldBePromoted(Address old_address, int object_size);
979 979
980 static int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; } 980 static int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; }
981 981
982 static void ClearJSFunctionResultCaches(); 982 static void ClearJSFunctionResultCaches();
983 983
984 static GCTracer* tracer() { return tracer_; }
985
984 private: 986 private:
985 static int reserved_semispace_size_; 987 static int reserved_semispace_size_;
986 static int max_semispace_size_; 988 static int max_semispace_size_;
987 static int initial_semispace_size_; 989 static int initial_semispace_size_;
988 static int max_old_generation_size_; 990 static int max_old_generation_size_;
989 static size_t code_range_size_; 991 static size_t code_range_size_;
990 992
991 // For keeping track of how much data has survived 993 // For keeping track of how much data has survived
992 // scavenge since last new space expansion. 994 // scavenge since last new space expansion.
993 static int survived_since_last_expansion_; 995 static int survived_since_last_expansion_;
(...skipping 19 matching lines...) Expand all
1013 static LargeObjectSpace* lo_space_; 1015 static LargeObjectSpace* lo_space_;
1014 static HeapState gc_state_; 1016 static HeapState gc_state_;
1015 1017
1016 // Returns the size of object residing in non new spaces. 1018 // Returns the size of object residing in non new spaces.
1017 static int PromotedSpaceSize(); 1019 static int PromotedSpaceSize();
1018 1020
1019 // Returns the amount of external memory registered since last global gc. 1021 // Returns the amount of external memory registered since last global gc.
1020 static int PromotedExternalMemorySize(); 1022 static int PromotedExternalMemorySize();
1021 1023
1022 static int mc_count_; // how many mark-compact collections happened 1024 static int mc_count_; // how many mark-compact collections happened
1025 static int ms_count_; // how many mark-sweep collections happened
1023 static int gc_count_; // how many gc happened 1026 static int gc_count_; // how many gc happened
1024 1027
1025 // Total length of the strings we failed to flatten since the last GC. 1028 // Total length of the strings we failed to flatten since the last GC.
1026 static int unflattened_strings_length_; 1029 static int unflattened_strings_length_;
1027 1030
1028 #define ROOT_ACCESSOR(type, name, camel_name) \ 1031 #define ROOT_ACCESSOR(type, name, camel_name) \
1029 static inline void set_##name(type* value) { \ 1032 static inline void set_##name(type* value) { \
1030 roots_[k##camel_name##RootIndex] = value; \ 1033 roots_[k##camel_name##RootIndex] = value; \
1031 } 1034 }
1032 ROOT_LIST(ROOT_ACCESSOR) 1035 ROOT_LIST(ROOT_ACCESSOR)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // Initializes a function with a shared part and prototype. 1219 // Initializes a function with a shared part and prototype.
1217 // Returns the function. 1220 // Returns the function.
1218 // Note: this code was factored out of AllocateFunction such that 1221 // Note: this code was factored out of AllocateFunction such that
1219 // other parts of the VM could use it. Specifically, a function that creates 1222 // other parts of the VM could use it. Specifically, a function that creates
1220 // instances of type JS_FUNCTION_TYPE benefit from the use of this function. 1223 // instances of type JS_FUNCTION_TYPE benefit from the use of this function.
1221 // Please note this does not perform a garbage collection. 1224 // Please note this does not perform a garbage collection.
1222 static inline Object* InitializeFunction(JSFunction* function, 1225 static inline Object* InitializeFunction(JSFunction* function,
1223 SharedFunctionInfo* shared, 1226 SharedFunctionInfo* shared,
1224 Object* prototype); 1227 Object* prototype);
1225 1228
1229 static GCTracer* tracer_;
1230
1226 1231
1227 // Initializes the number to string cache based on the max semispace size. 1232 // Initializes the number to string cache based on the max semispace size.
1228 static Object* InitializeNumberStringCache(); 1233 static Object* InitializeNumberStringCache();
1229 // Flush the number to string cache. 1234 // Flush the number to string cache.
1230 static void FlushNumberStringCache(); 1235 static void FlushNumberStringCache();
1231 1236
1232 static const int kInitialSymbolTableSize = 2048; 1237 static const int kInitialSymbolTableSize = 2048;
1233 static const int kInitialEvalCacheSize = 64; 1238 static const int kInitialEvalCacheSize = 64;
1234 1239
1235 friend class Factory; 1240 friend class Factory;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 ~DisableAssertNoAllocation() { } 1627 ~DisableAssertNoAllocation() { }
1623 }; 1628 };
1624 1629
1625 #endif 1630 #endif
1626 1631
1627 // GCTracer collects and prints ONE line after each garbage collector 1632 // GCTracer collects and prints ONE line after each garbage collector
1628 // invocation IFF --trace_gc is used. 1633 // invocation IFF --trace_gc is used.
1629 1634
1630 class GCTracer BASE_EMBEDDED { 1635 class GCTracer BASE_EMBEDDED {
1631 public: 1636 public:
1632 // Time spent while in the external scope counts towards the 1637 class Scope BASE_EMBEDDED {
1633 // external time in the tracer and will be reported separately.
1634 class ExternalScope BASE_EMBEDDED {
1635 public: 1638 public:
1636 explicit ExternalScope(GCTracer* tracer) : tracer_(tracer) { 1639 enum ScopeId {
1640 EXTERNAL,
1641 MC_MARK,
1642 MC_SWEEP,
1643 MC_COMPACT,
1644 kNumberOfScopes
1645 };
1646
1647 Scope(GCTracer* tracer, ScopeId scope)
1648 : tracer_(tracer),
1649 scope_(scope) {
1637 start_time_ = OS::TimeCurrentMillis(); 1650 start_time_ = OS::TimeCurrentMillis();
1638 } 1651 }
1639 ~ExternalScope() { 1652
1640 tracer_->external_time_ += OS::TimeCurrentMillis() - start_time_; 1653 ~Scope() {
1654 ASSERT((0 <= scope_) && (scope_ < kNumberOfScopes));
1655 tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_;
1641 } 1656 }
1642 1657
1643 private: 1658 private:
1644 GCTracer* tracer_; 1659 GCTracer* tracer_;
1660 ScopeId scope_;
1645 double start_time_; 1661 double start_time_;
1646 }; 1662 };
1647 1663
1648 GCTracer(); 1664 GCTracer();
1649 ~GCTracer(); 1665 ~GCTracer();
1650 1666
1651 // Sets the collector. 1667 // Sets the collector.
1652 void set_collector(GarbageCollector collector) { collector_ = collector; } 1668 void set_collector(GarbageCollector collector) { collector_ = collector; }
1653 1669
1654 // Sets the GC count. 1670 // Sets the GC count.
1655 void set_gc_count(int count) { gc_count_ = count; } 1671 void set_gc_count(int count) { gc_count_ = count; }
1656 1672
1657 // Sets the full GC count. 1673 // Sets the full GC count.
1658 void set_full_gc_count(int count) { full_gc_count_ = count; } 1674 void set_full_gc_count(int count) { full_gc_count_ = count; }
1659 1675
1660 // Sets the flag that this is a compacting full GC. 1676 // Sets the flag that this is a compacting full GC.
1661 void set_is_compacting() { is_compacting_ = true; } 1677 void set_is_compacting() { is_compacting_ = true; }
1662 bool is_compacting() const { return is_compacting_; } 1678 bool is_compacting() const { return is_compacting_; }
1663 1679
1664 // Increment and decrement the count of marked objects. 1680 // Increment and decrement the count of marked objects.
1665 void increment_marked_count() { ++marked_count_; } 1681 void increment_marked_count() { ++marked_count_; }
1666 void decrement_marked_count() { --marked_count_; } 1682 void decrement_marked_count() { --marked_count_; }
1667 1683
1668 int marked_count() { return marked_count_; } 1684 int marked_count() { return marked_count_; }
1669 1685
1686 void increment_promoted_objects_size(int object_size) {
1687 promoted_objects_size_ += object_size;
1688 }
1689
1690 // Returns maximum GC pause.
1691 static int get_max_gc_pause() { return max_gc_pause_; }
1692
1693 // Returns maximum size of objects alive after GC.
1694 static int get_max_alive_after_gc() { return max_alive_after_gc_; }
1695
1696 // Returns minimal interval between two subsequent collections.
1697 static int get_min_in_mutator() { return min_in_mutator_; }
1698
1670 private: 1699 private:
1671 // Returns a string matching the collector. 1700 // Returns a string matching the collector.
1672 const char* CollectorString(); 1701 const char* CollectorString();
1673 1702
1674 // Returns size of object in heap (in MB). 1703 // Returns size of object in heap (in MB).
1675 double SizeOfHeapObjects() { 1704 double SizeOfHeapObjects() {
1676 return (static_cast<double>(Heap::SizeOfObjects())) / MB; 1705 return (static_cast<double>(Heap::SizeOfObjects())) / MB;
1677 } 1706 }
1678 1707
1679 double start_time_; // Timestamp set in the constructor. 1708 double start_time_; // Timestamp set in the constructor.
1680 double start_size_; // Size of objects in heap set in constructor. 1709 int start_size_; // Size of objects in heap set in constructor.
1681 GarbageCollector collector_; // Type of collector. 1710 GarbageCollector collector_; // Type of collector.
1682 1711
1683 // Keep track of the amount of time spent in external callbacks.
1684 double external_time_;
1685
1686 // A count (including this one, eg, the first collection is 1) of the 1712 // A count (including this one, eg, the first collection is 1) of the
1687 // number of garbage collections. 1713 // number of garbage collections.
1688 int gc_count_; 1714 int gc_count_;
1689 1715
1690 // A count (including this one) of the number of full garbage collections. 1716 // A count (including this one) of the number of full garbage collections.
1691 int full_gc_count_; 1717 int full_gc_count_;
1692 1718
1693 // True if the current GC is a compacting full collection, false 1719 // True if the current GC is a compacting full collection, false
1694 // otherwise. 1720 // otherwise.
1695 bool is_compacting_; 1721 bool is_compacting_;
1696 1722
1697 // True if the *previous* full GC cwas a compacting collection (will be 1723 // True if the *previous* full GC cwas a compacting collection (will be
1698 // false if there has not been a previous full GC). 1724 // false if there has not been a previous full GC).
1699 bool previous_has_compacted_; 1725 bool previous_has_compacted_;
1700 1726
1701 // On a full GC, a count of the number of marked objects. Incremented 1727 // On a full GC, a count of the number of marked objects. Incremented
1702 // when an object is marked and decremented when an object's mark bit is 1728 // when an object is marked and decremented when an object's mark bit is
1703 // cleared. Will be zero on a scavenge collection. 1729 // cleared. Will be zero on a scavenge collection.
1704 int marked_count_; 1730 int marked_count_;
1705 1731
1706 // The count from the end of the previous full GC. Will be zero if there 1732 // The count from the end of the previous full GC. Will be zero if there
1707 // was no previous full GC. 1733 // was no previous full GC.
1708 int previous_marked_count_; 1734 int previous_marked_count_;
1735
1736 // Amounts of time spent in different scopes during GC.
1737 double scopes_[Scope::kNumberOfScopes];
1738
1739 // Total amount of space either wasted or contained in one of free lists
1740 // before the current GC.
1741 int in_free_list_or_wasted_before_gc_;
1742
1743 // Difference between space used in the heap at the beginning of the current
1744 // collection and the end of the previous collection.
1745 int allocated_since_last_gc_;
1746
1747 // Amount of time spent in mutator that is time elapsed between end of the
1748 // previous collection and the beginning of the current one.
1749 double spent_in_mutator_;
1750
1751 // Size of objects promoted during the current collection.
1752 int promoted_objects_size_;
1753
1754 // Maximum GC pause.
1755 static int max_gc_pause_;
1756
1757 // Maximum size of objects alive after GC.
1758 static int max_alive_after_gc_;
1759
1760 // Minimal interval between two subsequent collections.
1761 static int min_in_mutator_;
1762
1763 // Size of objects alive after last GC.
1764 static int alive_after_last_gc_;
1765
1766 static double last_gc_end_timestamp_;
1709 }; 1767 };
1710 1768
1711 1769
1712 class TranscendentalCache { 1770 class TranscendentalCache {
1713 public: 1771 public:
1714 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; 1772 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches};
1715 1773
1716 explicit TranscendentalCache(Type t); 1774 explicit TranscendentalCache(Type t);
1717 1775
1718 // Returns a heap number with f(input), where f is a math function specified 1776 // Returns a heap number with f(input), where f is a math function specified
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 1893
1836 // To speed up scavenge collections new space string are kept 1894 // To speed up scavenge collections new space string are kept
1837 // separate from old space strings. 1895 // separate from old space strings.
1838 static List<Object*> new_space_strings_; 1896 static List<Object*> new_space_strings_;
1839 static List<Object*> old_space_strings_; 1897 static List<Object*> old_space_strings_;
1840 }; 1898 };
1841 1899
1842 } } // namespace v8::internal 1900 } } // namespace v8::internal
1843 1901
1844 #endif // V8_HEAP_H_ 1902 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698