| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 526 |
| 527 // Returns the amount of memory currently committed for the heap. | 527 // Returns the amount of memory currently committed for the heap. |
| 528 intptr_t CommittedMemory(); | 528 intptr_t CommittedMemory(); |
| 529 | 529 |
| 530 // Returns the amount of executable memory currently committed for the heap. | 530 // Returns the amount of executable memory currently committed for the heap. |
| 531 intptr_t CommittedMemoryExecutable(); | 531 intptr_t CommittedMemoryExecutable(); |
| 532 | 532 |
| 533 // Returns the amount of phyical memory currently committed for the heap. | 533 // Returns the amount of phyical memory currently committed for the heap. |
| 534 size_t CommittedPhysicalMemory(); | 534 size_t CommittedPhysicalMemory(); |
| 535 | 535 |
| 536 // Returns the maximum amount of memory ever committed for the heap. |
| 537 intptr_t MaximumCommittedMemory() { return maximum_committed_; } |
| 538 |
| 539 // Updates the maximum committed memory for the heap. Should be called |
| 540 // whenever a space grows. |
| 541 void UpdateMaximumCommitted(); |
| 542 |
| 536 // Returns the available bytes in space w/o growing. | 543 // Returns the available bytes in space w/o growing. |
| 537 // Heap doesn't guarantee that it can allocate an object that requires | 544 // Heap doesn't guarantee that it can allocate an object that requires |
| 538 // all available bytes. Check MaxHeapObjectSize() instead. | 545 // all available bytes. Check MaxHeapObjectSize() instead. |
| 539 intptr_t Available(); | 546 intptr_t Available(); |
| 540 | 547 |
| 541 // Returns of size of all objects residing in the heap. | 548 // Returns of size of all objects residing in the heap. |
| 542 intptr_t SizeOfObjects(); | 549 intptr_t SizeOfObjects(); |
| 543 | 550 |
| 544 // Return the starting address and a mask for the new space. And-masking an | 551 // Return the starting address and a mask for the new space. And-masking an |
| 545 // address with the mask will result in the start address of the new space | 552 // address with the mask will result in the start address of the new space |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 // failed. | 624 // failed. |
| 618 // Please note this does not perform a garbage collection. | 625 // Please note this does not perform a garbage collection. |
| 619 MUST_USE_RESULT MaybeObject* AllocateJSObject( | 626 MUST_USE_RESULT MaybeObject* AllocateJSObject( |
| 620 JSFunction* constructor, | 627 JSFunction* constructor, |
| 621 PretenureFlag pretenure = NOT_TENURED); | 628 PretenureFlag pretenure = NOT_TENURED); |
| 622 | 629 |
| 623 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( | 630 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( |
| 624 JSFunction* constructor, | 631 JSFunction* constructor, |
| 625 Handle<AllocationSite> allocation_site); | 632 Handle<AllocationSite> allocation_site); |
| 626 | 633 |
| 627 MUST_USE_RESULT MaybeObject* AllocateJSGeneratorObject( | |
| 628 JSFunction* function); | |
| 629 | |
| 630 MUST_USE_RESULT MaybeObject* AllocateJSModule(Context* context, | 634 MUST_USE_RESULT MaybeObject* AllocateJSModule(Context* context, |
| 631 ScopeInfo* scope_info); | 635 ScopeInfo* scope_info); |
| 632 | 636 |
| 633 // Allocate a JSArray with no elements | 637 // Allocate a JSArray with no elements |
| 634 MUST_USE_RESULT MaybeObject* AllocateEmptyJSArray( | 638 MUST_USE_RESULT MaybeObject* AllocateEmptyJSArray( |
| 635 ElementsKind elements_kind, | 639 ElementsKind elements_kind, |
| 636 PretenureFlag pretenure = NOT_TENURED) { | 640 PretenureFlag pretenure = NOT_TENURED) { |
| 637 return AllocateJSArrayAndStorage(elements_kind, 0, 0, | 641 return AllocateJSArrayAndStorage(elements_kind, 0, 0, |
| 638 DONT_INITIALIZE_ARRAY_ELEMENTS, | 642 DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 639 pretenure); | 643 pretenure); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 661 int length, | 665 int length, |
| 662 PretenureFlag pretenure = NOT_TENURED); | 666 PretenureFlag pretenure = NOT_TENURED); |
| 663 | 667 |
| 664 // Returns a deep copy of the JavaScript object. | 668 // Returns a deep copy of the JavaScript object. |
| 665 // Properties and elements are copied too. | 669 // Properties and elements are copied too. |
| 666 // Returns failure if allocation failed. | 670 // Returns failure if allocation failed. |
| 667 // Optionally takes an AllocationSite to be appended in an AllocationMemento. | 671 // Optionally takes an AllocationSite to be appended in an AllocationMemento. |
| 668 MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source, | 672 MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source, |
| 669 AllocationSite* site = NULL); | 673 AllocationSite* site = NULL); |
| 670 | 674 |
| 671 // Allocates the function prototype. | |
| 672 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
| 673 // failed. | |
| 674 // Please note this does not perform a garbage collection. | |
| 675 MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function); | |
| 676 | |
| 677 // Allocates a JS ArrayBuffer object. | 675 // Allocates a JS ArrayBuffer object. |
| 678 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 676 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 679 // failed. | 677 // failed. |
| 680 // Please note this does not perform a garbage collection. | 678 // Please note this does not perform a garbage collection. |
| 681 MUST_USE_RESULT MaybeObject* AllocateJSArrayBuffer(); | 679 MUST_USE_RESULT MaybeObject* AllocateJSArrayBuffer(); |
| 682 | 680 |
| 683 // Allocates a Harmony proxy or function proxy. | 681 // Allocates a Harmony proxy or function proxy. |
| 684 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 682 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 685 // failed. | 683 // failed. |
| 686 // Please note this does not perform a garbage collection. | 684 // Please note this does not perform a garbage collection. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 // Please note this function does not perform a garbage collection. | 731 // Please note this function does not perform a garbage collection. |
| 734 MUST_USE_RESULT MaybeObject* AllocateMap( | 732 MUST_USE_RESULT MaybeObject* AllocateMap( |
| 735 InstanceType instance_type, | 733 InstanceType instance_type, |
| 736 int instance_size, | 734 int instance_size, |
| 737 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 735 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
| 738 | 736 |
| 739 // Allocates a partial map for bootstrapping. | 737 // Allocates a partial map for bootstrapping. |
| 740 MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, | 738 MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, |
| 741 int instance_size); | 739 int instance_size); |
| 742 | 740 |
| 743 // Allocate a map for the specified function | |
| 744 MUST_USE_RESULT MaybeObject* AllocateInitialMap(JSFunction* fun); | |
| 745 | |
| 746 // Allocates an empty code cache. | 741 // Allocates an empty code cache. |
| 747 MUST_USE_RESULT MaybeObject* AllocateCodeCache(); | 742 MUST_USE_RESULT MaybeObject* AllocateCodeCache(); |
| 748 | 743 |
| 749 // Allocates a serialized scope info. | 744 // Allocates a serialized scope info. |
| 750 MUST_USE_RESULT MaybeObject* AllocateScopeInfo(int length); | 745 MUST_USE_RESULT MaybeObject* AllocateScopeInfo(int length); |
| 751 | 746 |
| 752 // Allocates an External object for v8's external API. | 747 // Allocates an External object for v8's external API. |
| 753 MUST_USE_RESULT MaybeObject* AllocateExternal(void* value); | 748 MUST_USE_RESULT MaybeObject* AllocateExternal(void* value); |
| 754 | 749 |
| 755 // Allocates an empty PolymorphicCodeCache. | 750 // Allocates an empty PolymorphicCodeCache. |
| 756 MUST_USE_RESULT MaybeObject* AllocatePolymorphicCodeCache(); | 751 MUST_USE_RESULT MaybeObject* AllocatePolymorphicCodeCache(); |
| 757 | 752 |
| 758 // Allocates a pre-tenured empty AccessorPair. | 753 // Allocates a pre-tenured empty AccessorPair. |
| 759 MUST_USE_RESULT MaybeObject* AllocateAccessorPair(); | 754 MUST_USE_RESULT MaybeObject* AllocateAccessorPair(); |
| 760 | 755 |
| 761 // Allocates an empty TypeFeedbackInfo. | 756 // Allocates an empty TypeFeedbackInfo. |
| 762 MUST_USE_RESULT MaybeObject* AllocateTypeFeedbackInfo(); | 757 MUST_USE_RESULT MaybeObject* AllocateTypeFeedbackInfo(); |
| 763 | 758 |
| 764 // Allocates an AliasedArgumentsEntry. | 759 // Allocates an AliasedArgumentsEntry. |
| 765 MUST_USE_RESULT MaybeObject* AllocateAliasedArgumentsEntry(int slot); | 760 MUST_USE_RESULT MaybeObject* AllocateAliasedArgumentsEntry(int slot); |
| 766 | 761 |
| 767 // Clear the Instanceof cache (used when a prototype changes). | 762 // Clear the Instanceof cache (used when a prototype changes). |
| 768 inline void ClearInstanceofCache(); | 763 inline void ClearInstanceofCache(); |
| 769 | 764 |
| 765 // Iterates the whole code space to clear all ICs of the given kind. |
| 766 void ClearAllICsByKind(Code::Kind kind); |
| 767 |
| 770 // For use during bootup. | 768 // For use during bootup. |
| 771 void RepairFreeListsAfterBoot(); | 769 void RepairFreeListsAfterBoot(); |
| 772 | 770 |
| 773 // Allocates and fully initializes a String. There are two String | 771 // Allocates and fully initializes a String. There are two String |
| 774 // encodings: ASCII and two byte. One should choose between the three string | 772 // encodings: ASCII and two byte. One should choose between the three string |
| 775 // allocation functions based on the encoding of the string buffer used to | 773 // allocation functions based on the encoding of the string buffer used to |
| 776 // initialized the string. | 774 // initialized the string. |
| 777 // - ...FromAscii initializes the string from a buffer that is ASCII | 775 // - ...FromAscii initializes the string from a buffer that is ASCII |
| 778 // encoded (it does not check that the buffer is ASCII encoded) and the | 776 // encoded (it does not check that the buffer is ASCII encoded) and the |
| 779 // result will be ASCII encoded. | 777 // result will be ASCII encoded. |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 | 1803 |
| 1806 // ObjectStats are kept in two arrays, counts and sizes. Related stats are | 1804 // ObjectStats are kept in two arrays, counts and sizes. Related stats are |
| 1807 // stored in a contiguous linear buffer. Stats groups are stored one after | 1805 // stored in a contiguous linear buffer. Stats groups are stored one after |
| 1808 // another. | 1806 // another. |
| 1809 enum { | 1807 enum { |
| 1810 FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1, | 1808 FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1, |
| 1811 FIRST_FIXED_ARRAY_SUB_TYPE = | 1809 FIRST_FIXED_ARRAY_SUB_TYPE = |
| 1812 FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS, | 1810 FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS, |
| 1813 FIRST_CODE_AGE_SUB_TYPE = | 1811 FIRST_CODE_AGE_SUB_TYPE = |
| 1814 FIRST_FIXED_ARRAY_SUB_TYPE + LAST_FIXED_ARRAY_SUB_TYPE + 1, | 1812 FIRST_FIXED_ARRAY_SUB_TYPE + LAST_FIXED_ARRAY_SUB_TYPE + 1, |
| 1815 OBJECT_STATS_COUNT = FIRST_CODE_AGE_SUB_TYPE + Code::kLastCodeAge + 1 | 1813 OBJECT_STATS_COUNT = FIRST_CODE_AGE_SUB_TYPE + Code::kCodeAgeCount + 1 |
| 1816 }; | 1814 }; |
| 1817 | 1815 |
| 1818 void RecordObjectStats(InstanceType type, size_t size) { | 1816 void RecordObjectStats(InstanceType type, size_t size) { |
| 1819 ASSERT(type <= LAST_TYPE); | 1817 ASSERT(type <= LAST_TYPE); |
| 1820 object_counts_[type]++; | 1818 object_counts_[type]++; |
| 1821 object_sizes_[type] += size; | 1819 object_sizes_[type] += size; |
| 1822 } | 1820 } |
| 1823 | 1821 |
| 1824 void RecordCodeSubTypeStats(int code_sub_type, int code_age, size_t size) { | 1822 void RecordCodeSubTypeStats(int code_sub_type, int code_age, size_t size) { |
| 1825 ASSERT(code_sub_type < Code::NUMBER_OF_KINDS); | 1823 int code_sub_type_index = FIRST_CODE_KIND_SUB_TYPE + code_sub_type; |
| 1826 ASSERT(code_age < Code::kLastCodeAge); | 1824 int code_age_index = |
| 1827 object_counts_[FIRST_CODE_KIND_SUB_TYPE + code_sub_type]++; | 1825 FIRST_CODE_AGE_SUB_TYPE + code_age - Code::kFirstCodeAge; |
| 1828 object_sizes_[FIRST_CODE_KIND_SUB_TYPE + code_sub_type] += size; | 1826 ASSERT(code_sub_type_index >= FIRST_CODE_KIND_SUB_TYPE && |
| 1829 object_counts_[FIRST_CODE_AGE_SUB_TYPE + code_age]++; | 1827 code_sub_type_index < FIRST_CODE_AGE_SUB_TYPE); |
| 1830 object_sizes_[FIRST_CODE_AGE_SUB_TYPE + code_age] += size; | 1828 ASSERT(code_age_index >= FIRST_CODE_AGE_SUB_TYPE && |
| 1829 code_age_index < OBJECT_STATS_COUNT); |
| 1830 object_counts_[code_sub_type_index]++; |
| 1831 object_sizes_[code_sub_type_index] += size; |
| 1832 object_counts_[code_age_index]++; |
| 1833 object_sizes_[code_age_index] += size; |
| 1831 } | 1834 } |
| 1832 | 1835 |
| 1833 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { | 1836 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { |
| 1834 ASSERT(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); | 1837 ASSERT(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); |
| 1835 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; | 1838 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; |
| 1836 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; | 1839 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; |
| 1837 } | 1840 } |
| 1838 | 1841 |
| 1839 void CheckpointObjectStats(); | 1842 void CheckpointObjectStats(); |
| 1840 | 1843 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 Isolate* isolate_; | 1884 Isolate* isolate_; |
| 1882 | 1885 |
| 1883 Object* roots_[kRootListLength]; | 1886 Object* roots_[kRootListLength]; |
| 1884 | 1887 |
| 1885 intptr_t code_range_size_; | 1888 intptr_t code_range_size_; |
| 1886 int reserved_semispace_size_; | 1889 int reserved_semispace_size_; |
| 1887 int max_semispace_size_; | 1890 int max_semispace_size_; |
| 1888 int initial_semispace_size_; | 1891 int initial_semispace_size_; |
| 1889 intptr_t max_old_generation_size_; | 1892 intptr_t max_old_generation_size_; |
| 1890 intptr_t max_executable_size_; | 1893 intptr_t max_executable_size_; |
| 1894 intptr_t maximum_committed_; |
| 1891 | 1895 |
| 1892 // For keeping track of how much data has survived | 1896 // For keeping track of how much data has survived |
| 1893 // scavenge since last new space expansion. | 1897 // scavenge since last new space expansion. |
| 1894 int survived_since_last_expansion_; | 1898 int survived_since_last_expansion_; |
| 1895 | 1899 |
| 1896 // For keeping track on when to flush RegExp code. | 1900 // For keeping track on when to flush RegExp code. |
| 1897 int sweep_generation_; | 1901 int sweep_generation_; |
| 1898 | 1902 |
| 1899 int always_allocate_scope_depth_; | 1903 int always_allocate_scope_depth_; |
| 1900 int linear_allocation_scope_depth_; | 1904 int linear_allocation_scope_depth_; |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3074 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3071 | 3075 |
| 3072 private: | 3076 private: |
| 3073 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3077 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3074 }; | 3078 }; |
| 3075 #endif // DEBUG | 3079 #endif // DEBUG |
| 3076 | 3080 |
| 3077 } } // namespace v8::internal | 3081 } } // namespace v8::internal |
| 3078 | 3082 |
| 3079 #endif // V8_HEAP_H_ | 3083 #endif // V8_HEAP_H_ |
| OLD | NEW |