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 "allocation.h" | 10 #include "allocation.h" |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 Address* OldDataSpaceAllocationTopAddress() { | 678 Address* OldDataSpaceAllocationTopAddress() { |
679 return old_data_space_->allocation_top_address(); | 679 return old_data_space_->allocation_top_address(); |
680 } | 680 } |
681 Address* OldDataSpaceAllocationLimitAddress() { | 681 Address* OldDataSpaceAllocationLimitAddress() { |
682 return old_data_space_->allocation_limit_address(); | 682 return old_data_space_->allocation_limit_address(); |
683 } | 683 } |
684 | 684 |
685 // Allocates and initializes a new JavaScript object based on a | 685 // Allocates and initializes a new JavaScript object based on a |
686 // constructor. | 686 // constructor. |
687 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
688 // failed. | |
689 // If allocation_site is non-null, then a memento is emitted after the object | 687 // If allocation_site is non-null, then a memento is emitted after the object |
690 // that points to the site. | 688 // that points to the site. |
691 // Please note this does not perform a garbage collection. | 689 // Please note this does not perform a garbage collection. |
692 MUST_USE_RESULT MaybeObject* AllocateJSObject( | 690 MUST_USE_RESULT AllocationResult AllocateJSObject( |
693 JSFunction* constructor, | 691 JSFunction* constructor, |
694 PretenureFlag pretenure = NOT_TENURED, | 692 PretenureFlag pretenure = NOT_TENURED, |
695 AllocationSite* allocation_site = NULL); | 693 AllocationSite* allocation_site = NULL); |
696 | 694 |
697 // Returns a deep copy of the JavaScript object. | 695 // Returns a deep copy of the JavaScript object. |
698 // Properties and elements are copied too. | 696 // Properties and elements are copied too. |
699 // Returns failure if allocation failed. | |
700 // Optionally takes an AllocationSite to be appended in an AllocationMemento. | 697 // Optionally takes an AllocationSite to be appended in an AllocationMemento. |
701 MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source, | 698 MUST_USE_RESULT AllocationResult CopyJSObject(JSObject* source, |
702 AllocationSite* site = NULL); | 699 AllocationSite* site = NULL); |
703 | 700 |
704 // Allocates and initializes a new JavaScript object based on a map. | 701 // Allocates and initializes a new JavaScript object based on a map. |
705 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
706 // failed. | |
707 // Passing an allocation site means that a memento will be created that | 702 // Passing an allocation site means that a memento will be created that |
708 // points to the site. | 703 // points to the site. The result may indicate allocation failure. |
709 // Please note this does not perform a garbage collection. | 704 // Please note this does not perform a garbage collection. |
710 MUST_USE_RESULT MaybeObject* AllocateJSObjectFromMap( | 705 MUST_USE_RESULT AllocationResult AllocateJSObjectFromMap( |
711 Map* map, | 706 Map* map, |
712 PretenureFlag pretenure = NOT_TENURED, | 707 PretenureFlag pretenure = NOT_TENURED, |
713 bool alloc_props = true, | 708 bool alloc_props = true, |
714 AllocationSite* allocation_site = NULL); | 709 AllocationSite* allocation_site = NULL); |
715 | 710 |
716 // Allocates a heap object based on the map. | 711 // Allocates a heap object based on the map. |
717 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
718 // failed. | |
719 // Please note this function does not perform a garbage collection. | 712 // Please note this function does not perform a garbage collection. |
720 MUST_USE_RESULT MaybeObject* Allocate(Map* map, AllocationSpace space, | 713 MUST_USE_RESULT AllocationResult Allocate( |
721 AllocationSite* allocation_site = NULL); | 714 Map* map, |
| 715 AllocationSpace space, |
| 716 AllocationSite* allocation_site = NULL); |
722 | 717 |
723 // Allocates a JS Map in the heap. | 718 // Allocates a JS Map in the heap. |
724 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
725 // failed. | |
726 // Please note this function does not perform a garbage collection. | 719 // Please note this function does not perform a garbage collection. |
727 MUST_USE_RESULT MaybeObject* AllocateMap( | 720 MUST_USE_RESULT AllocationResult AllocateMap( |
728 InstanceType instance_type, | 721 InstanceType instance_type, |
729 int instance_size, | 722 int instance_size, |
730 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 723 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
731 | 724 |
732 // Allocates a partial map for bootstrapping. | 725 // Allocates a partial map for bootstrapping. |
733 MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, | 726 MUST_USE_RESULT AllocationResult AllocatePartialMap( |
734 int instance_size); | 727 InstanceType instance_type, |
| 728 int instance_size); |
735 | 729 |
736 // Allocate a block of memory in the given space (filled with a filler). | 730 // Allocate a block of memory in the given space (filled with a filler). |
737 // Used as a fall-back for generated code when the space is full. | 731 // Used as a fall-back for generated code when the space is full. |
738 MUST_USE_RESULT MaybeObject* AllocateFillerObject(int size, | 732 MUST_USE_RESULT AllocationResult AllocateFillerObject(int size, |
739 bool double_align, | 733 bool double_align, |
740 AllocationSpace space); | 734 AllocationSpace space); |
741 | 735 |
742 // Clear the Instanceof cache (used when a prototype changes). | 736 // Clear the Instanceof cache (used when a prototype changes). |
743 inline void ClearInstanceofCache(); | 737 inline void ClearInstanceofCache(); |
744 | 738 |
745 // Iterates the whole code space to clear all ICs of the given kind. | 739 // Iterates the whole code space to clear all ICs of the given kind. |
746 void ClearAllICsByKind(Code::Kind kind); | 740 void ClearAllICsByKind(Code::Kind kind); |
747 | 741 |
748 // For use during bootup. | 742 // For use during bootup. |
749 void RepairFreeListsAfterBoot(); | 743 void RepairFreeListsAfterBoot(); |
750 | 744 |
751 // Allocates and fully initializes a String. There are two String | 745 // Allocates and fully initializes a String. There are two String |
752 // encodings: ASCII and two byte. One should choose between the three string | 746 // encodings: ASCII and two byte. One should choose between the three string |
753 // allocation functions based on the encoding of the string buffer used to | 747 // allocation functions based on the encoding of the string buffer used to |
754 // initialized the string. | 748 // initialized the string. |
755 // - ...FromAscii initializes the string from a buffer that is ASCII | 749 // - ...FromAscii initializes the string from a buffer that is ASCII |
756 // encoded (it does not check that the buffer is ASCII encoded) and the | 750 // encoded (it does not check that the buffer is ASCII encoded) and the |
757 // result will be ASCII encoded. | 751 // result will be ASCII encoded. |
758 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 | 752 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 |
759 // encoded. If the characters are all single-byte characters, the | 753 // encoded. If the characters are all single-byte characters, the |
760 // result will be ASCII encoded, otherwise it will converted to two | 754 // result will be ASCII encoded, otherwise it will converted to two |
761 // byte. | 755 // byte. |
762 // - ...FromTwoByte initializes the string from a buffer that is two-byte | 756 // - ...FromTwoByte initializes the string from a buffer that is two-byte |
763 // encoded. If the characters are all single-byte characters, the | 757 // encoded. If the characters are all single-byte characters, the |
764 // result will be converted to ASCII, otherwise it will be left as | 758 // result will be converted to ASCII, otherwise it will be left as |
765 // two-byte. | 759 // two-byte. |
766 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
767 // failed. | |
768 // Please note this does not perform a garbage collection. | 760 // Please note this does not perform a garbage collection. |
769 MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow( | 761 MUST_USE_RESULT AllocationResult AllocateStringFromUtf8Slow( |
770 Vector<const char> str, | 762 Vector<const char> str, |
771 int non_ascii_start, | 763 int non_ascii_start, |
772 PretenureFlag pretenure = NOT_TENURED); | 764 PretenureFlag pretenure = NOT_TENURED); |
773 MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte( | 765 MUST_USE_RESULT AllocationResult AllocateStringFromTwoByte( |
774 Vector<const uc16> str, | 766 Vector<const uc16> str, |
775 PretenureFlag pretenure = NOT_TENURED); | 767 PretenureFlag pretenure = NOT_TENURED); |
776 | 768 |
777 // Allocates an internalized string in old space based on the character | 769 // Allocates an internalized string in old space based on the character |
778 // stream. Returns Failure::RetryAfterGC(requested_bytes, space) if the | |
779 // allocation failed. | |
780 // Please note this function does not perform a garbage collection. | 770 // Please note this function does not perform a garbage collection. |
781 MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringFromUtf8( | 771 MUST_USE_RESULT inline AllocationResult AllocateInternalizedStringFromUtf8( |
782 Vector<const char> str, | 772 Vector<const char> str, |
783 int chars, | 773 int chars, |
784 uint32_t hash_field); | 774 uint32_t hash_field); |
785 | 775 |
786 MUST_USE_RESULT inline MaybeObject* AllocateOneByteInternalizedString( | 776 MUST_USE_RESULT inline AllocationResult AllocateOneByteInternalizedString( |
787 Vector<const uint8_t> str, | 777 Vector<const uint8_t> str, |
788 uint32_t hash_field); | 778 uint32_t hash_field); |
789 | 779 |
790 MUST_USE_RESULT inline MaybeObject* AllocateTwoByteInternalizedString( | 780 MUST_USE_RESULT inline AllocationResult AllocateTwoByteInternalizedString( |
791 Vector<const uc16> str, | 781 Vector<const uc16> str, |
792 uint32_t hash_field); | 782 uint32_t hash_field); |
793 | 783 |
794 template<typename T> | 784 template<typename T> |
795 static inline bool IsOneByte(T t, int chars); | 785 static inline bool IsOneByte(T t, int chars); |
796 | 786 |
797 template<typename T> | 787 template<typename T> |
798 MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringImpl( | 788 MUST_USE_RESULT inline AllocationResult AllocateInternalizedStringImpl( |
799 T t, int chars, uint32_t hash_field); | 789 T t, int chars, uint32_t hash_field); |
800 | 790 |
801 template<bool is_one_byte, typename T> | 791 template<bool is_one_byte, typename T> |
802 MUST_USE_RESULT MaybeObject* AllocateInternalizedStringImpl( | 792 MUST_USE_RESULT AllocationResult AllocateInternalizedStringImpl( |
803 T t, int chars, uint32_t hash_field); | 793 T t, int chars, uint32_t hash_field); |
804 | 794 |
805 // Allocate a byte array of the specified length | 795 // Allocate a byte array of the specified length |
806 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
807 // failed. | |
808 // Please note this does not perform a garbage collection. | 796 // Please note this does not perform a garbage collection. |
809 MUST_USE_RESULT MaybeObject* AllocateByteArray( | 797 MUST_USE_RESULT AllocationResult AllocateByteArray( |
810 int length, | 798 int length, |
811 PretenureFlag pretenure = NOT_TENURED); | 799 PretenureFlag pretenure = NOT_TENURED); |
812 | 800 |
813 // Allocates an external array of the specified length and type. | 801 // Allocates an external array of the specified length and type. |
814 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
815 // failed. | |
816 // Please note this does not perform a garbage collection. | 802 // Please note this does not perform a garbage collection. |
817 MUST_USE_RESULT MaybeObject* AllocateExternalArray( | 803 MUST_USE_RESULT AllocationResult AllocateExternalArray( |
818 int length, | 804 int length, |
819 ExternalArrayType array_type, | 805 ExternalArrayType array_type, |
820 void* external_pointer, | 806 void* external_pointer, |
821 PretenureFlag pretenure); | 807 PretenureFlag pretenure); |
822 | 808 |
823 // Allocates a fixed typed array of the specified length and type. | 809 // Allocates a fixed typed array of the specified length and type. |
824 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
825 // failed. | |
826 // Please note this does not perform a garbage collection. | 810 // Please note this does not perform a garbage collection. |
827 MUST_USE_RESULT MaybeObject* AllocateFixedTypedArray( | 811 MUST_USE_RESULT AllocationResult AllocateFixedTypedArray( |
828 int length, | 812 int length, |
829 ExternalArrayType array_type, | 813 ExternalArrayType array_type, |
830 PretenureFlag pretenure); | 814 PretenureFlag pretenure); |
831 | 815 |
832 // Allocate a symbol in old space. | 816 // Allocate a symbol in old space. |
833 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
834 // failed. | |
835 // Please note this does not perform a garbage collection. | 817 // Please note this does not perform a garbage collection. |
836 MUST_USE_RESULT MaybeObject* AllocateSymbol(); | 818 MUST_USE_RESULT AllocationResult AllocateSymbol(); |
837 MUST_USE_RESULT MaybeObject* AllocatePrivateSymbol(); | 819 MUST_USE_RESULT AllocationResult AllocatePrivateSymbol(); |
838 | 820 |
839 // Allocates a fixed array initialized with undefined values | 821 // Allocates a fixed array initialized with undefined values |
840 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
841 // failed. | |
842 // Please note this does not perform a garbage collection. | 822 // Please note this does not perform a garbage collection. |
843 MUST_USE_RESULT MaybeObject* AllocateFixedArray( | 823 MUST_USE_RESULT AllocationResult AllocateFixedArray( |
844 int length, | 824 int length, |
845 PretenureFlag pretenure = NOT_TENURED); | 825 PretenureFlag pretenure = NOT_TENURED); |
846 | 826 |
847 // Allocates an uninitialized fixed array. It must be filled by the caller. | 827 // Allocates an uninitialized fixed array. It must be filled by the caller. |
848 // | |
849 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
850 // failed. | |
851 // Please note this does not perform a garbage collection. | 828 // Please note this does not perform a garbage collection. |
852 MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length); | 829 MUST_USE_RESULT AllocationResult AllocateUninitializedFixedArray(int length); |
853 | 830 |
854 // Move len elements within a given array from src_index index to dst_index | 831 // Move len elements within a given array from src_index index to dst_index |
855 // index. | 832 // index. |
856 void MoveElements(FixedArray* array, int dst_index, int src_index, int len); | 833 void MoveElements(FixedArray* array, int dst_index, int src_index, int len); |
857 | 834 |
858 // Make a copy of src and return it. Returns | 835 // Make a copy of src and return it. Returns |
859 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 836 MUST_USE_RESULT inline AllocationResult CopyFixedArray(FixedArray* src); |
860 MUST_USE_RESULT inline MaybeObject* CopyFixedArray(FixedArray* src); | |
861 | 837 |
862 // Make a copy of src and return it. Returns | 838 // Make a copy of src and return it. Returns |
863 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 839 MUST_USE_RESULT AllocationResult CopyAndTenureFixedCOWArray(FixedArray* src); |
864 MUST_USE_RESULT MaybeObject* CopyAndTenureFixedCOWArray(FixedArray* src); | |
865 | 840 |
866 // Make a copy of src, set the map, and return the copy. Returns | 841 // Make a copy of src, set the map, and return the copy. Returns |
867 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 842 MUST_USE_RESULT AllocationResult CopyFixedArrayWithMap(FixedArray* src, |
868 MUST_USE_RESULT MaybeObject* CopyFixedArrayWithMap(FixedArray* src, Map* map); | 843 Map* map); |
869 | 844 |
870 // Make a copy of src and return it. Returns | 845 // Make a copy of src and return it. Returns |
871 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 846 MUST_USE_RESULT inline AllocationResult CopyFixedDoubleArray( |
872 MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray( | |
873 FixedDoubleArray* src); | 847 FixedDoubleArray* src); |
874 | 848 |
875 // Make a copy of src, set the map, and return the copy. Returns | 849 // Make a copy of src, set the map, and return the copy. Returns |
876 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 850 MUST_USE_RESULT AllocationResult CopyFixedDoubleArrayWithMap( |
877 MUST_USE_RESULT MaybeObject* CopyFixedDoubleArrayWithMap( | |
878 FixedDoubleArray* src, Map* map); | 851 FixedDoubleArray* src, Map* map); |
879 | 852 |
880 // Make a copy of src and return it. Returns | 853 // Make a copy of src and return it. Returns |
881 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 854 MUST_USE_RESULT inline AllocationResult CopyConstantPoolArray( |
882 MUST_USE_RESULT inline MaybeObject* CopyConstantPoolArray( | |
883 ConstantPoolArray* src); | 855 ConstantPoolArray* src); |
884 | 856 |
885 // Make a copy of src, set the map, and return the copy. Returns | 857 // Make a copy of src, set the map, and return the copy. Returns |
886 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | 858 MUST_USE_RESULT AllocationResult CopyConstantPoolArrayWithMap( |
887 MUST_USE_RESULT MaybeObject* CopyConstantPoolArrayWithMap( | |
888 ConstantPoolArray* src, Map* map); | 859 ConstantPoolArray* src, Map* map); |
889 | 860 |
890 MUST_USE_RESULT MaybeObject* AllocateConstantPoolArray( | 861 MUST_USE_RESULT AllocationResult AllocateConstantPoolArray( |
891 int number_of_int64_entries, | 862 int number_of_int64_entries, |
892 int number_of_code_ptr_entries, | 863 int number_of_code_ptr_entries, |
893 int number_of_heap_ptr_entries, | 864 int number_of_heap_ptr_entries, |
894 int number_of_int32_entries); | 865 int number_of_int32_entries); |
895 | 866 |
896 // Allocates a fixed double array with uninitialized values. Returns | 867 // Allocates a fixed double array with uninitialized values. Returns |
897 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. | |
898 // Please note this does not perform a garbage collection. | 868 // Please note this does not perform a garbage collection. |
899 MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedDoubleArray( | 869 MUST_USE_RESULT AllocationResult AllocateUninitializedFixedDoubleArray( |
900 int length, | 870 int length, |
901 PretenureFlag pretenure = NOT_TENURED); | 871 PretenureFlag pretenure = NOT_TENURED); |
902 | 872 |
903 // AllocateHashTable is identical to AllocateFixedArray except | 873 // AllocateHashTable is identical to AllocateFixedArray except |
904 // that the resulting object has hash_table_map as map. | 874 // that the resulting object has hash_table_map as map. |
905 MUST_USE_RESULT MaybeObject* AllocateHashTable( | 875 MUST_USE_RESULT AllocationResult AllocateHashTable( |
906 int length, PretenureFlag pretenure = NOT_TENURED); | 876 int length, PretenureFlag pretenure = NOT_TENURED); |
907 | 877 |
908 // Allocates a new utility object in the old generation. | 878 // Allocates a new utility object in the old generation. |
909 MUST_USE_RESULT MaybeObject* AllocateStruct(InstanceType type); | 879 MUST_USE_RESULT AllocationResult AllocateStruct(InstanceType type); |
910 | 880 |
911 // Sloppy mode arguments object size. | 881 // Sloppy mode arguments object size. |
912 static const int kSloppyArgumentsObjectSize = | 882 static const int kSloppyArgumentsObjectSize = |
913 JSObject::kHeaderSize + 2 * kPointerSize; | 883 JSObject::kHeaderSize + 2 * kPointerSize; |
914 // Strict mode arguments has no callee so it is smaller. | 884 // Strict mode arguments has no callee so it is smaller. |
915 static const int kStrictArgumentsObjectSize = | 885 static const int kStrictArgumentsObjectSize = |
916 JSObject::kHeaderSize + 1 * kPointerSize; | 886 JSObject::kHeaderSize + 1 * kPointerSize; |
917 // Indicies for direct access into argument objects. | 887 // Indicies for direct access into argument objects. |
918 static const int kArgumentsLengthIndex = 0; | 888 static const int kArgumentsLengthIndex = 0; |
919 // callee is only valid in sloppy mode. | 889 // callee is only valid in sloppy mode. |
920 static const int kArgumentsCalleeIndex = 1; | 890 static const int kArgumentsCalleeIndex = 1; |
921 | 891 |
922 // Allocates an arguments object - optionally with an elements array. | 892 // Allocates an arguments object - optionally with an elements array. |
923 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
924 // failed. | |
925 // Please note this does not perform a garbage collection. | 893 // Please note this does not perform a garbage collection. |
926 MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( | 894 MUST_USE_RESULT AllocationResult AllocateArgumentsObject( |
927 Object* callee, int length); | 895 Object* callee, int length); |
928 | 896 |
929 // Allocated a HeapNumber from value. | 897 // Allocated a HeapNumber from value. |
930 MUST_USE_RESULT MaybeObject* AllocateHeapNumber( | 898 MUST_USE_RESULT AllocationResult AllocateHeapNumber( |
931 double value, PretenureFlag pretenure = NOT_TENURED); | 899 double value, PretenureFlag pretenure = NOT_TENURED); |
932 | 900 |
933 // Converts an int into either a Smi or a HeapNumber object. | 901 // Allocates a new foreign object. |
934 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
935 // failed. | |
936 // Please note this does not perform a garbage collection. | 902 // Please note this does not perform a garbage collection. |
937 MUST_USE_RESULT inline MaybeObject* NumberFromUint32( | 903 MUST_USE_RESULT AllocationResult AllocateForeign( |
938 uint32_t value, PretenureFlag pretenure = NOT_TENURED); | |
939 | |
940 // Allocates a new foreign object. | |
941 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
942 // failed. | |
943 // Please note this does not perform a garbage collection. | |
944 MUST_USE_RESULT MaybeObject* AllocateForeign( | |
945 Address address, PretenureFlag pretenure = NOT_TENURED); | 904 Address address, PretenureFlag pretenure = NOT_TENURED); |
946 | 905 |
947 // Finalizes an external string by deleting the associated external | 906 // Finalizes an external string by deleting the associated external |
948 // data and clearing the resource pointer. | 907 // data and clearing the resource pointer. |
949 inline void FinalizeExternalString(String* string); | 908 inline void FinalizeExternalString(String* string); |
950 | 909 |
951 // Initialize a filler object to keep the ability to iterate over the heap | 910 // Initialize a filler object to keep the ability to iterate over the heap |
952 // when shortening objects. | 911 // when shortening objects. |
953 void CreateFillerObjectAt(Address addr, int size); | 912 void CreateFillerObjectAt(Address addr, int size); |
954 | 913 |
955 bool CanMoveObjectStart(HeapObject* object); | 914 bool CanMoveObjectStart(HeapObject* object); |
956 | 915 |
957 enum InvocationMode { FROM_GC, FROM_MUTATOR }; | 916 enum InvocationMode { FROM_GC, FROM_MUTATOR }; |
958 | 917 |
959 // Maintain marking consistency for IncrementalMarking. | 918 // Maintain marking consistency for IncrementalMarking. |
960 void AdjustLiveBytes(Address address, int by, InvocationMode mode); | 919 void AdjustLiveBytes(Address address, int by, InvocationMode mode); |
961 | 920 |
962 MUST_USE_RESULT MaybeObject* AllocateCode(int object_size, bool immovable); | 921 MUST_USE_RESULT AllocationResult AllocateCode(int object_size, |
| 922 bool immovable); |
963 | 923 |
964 MUST_USE_RESULT MaybeObject* CopyCode(Code* code); | 924 MUST_USE_RESULT AllocationResult CopyCode(Code* code); |
965 | 925 |
966 // Copy the code and scope info part of the code object, but insert | 926 // Copy the code and scope info part of the code object, but insert |
967 // the provided data as the relocation information. | 927 // the provided data as the relocation information. |
968 MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info); | 928 MUST_USE_RESULT AllocationResult CopyCode(Code* code, |
| 929 Vector<byte> reloc_info); |
969 | 930 |
970 // Finds the internalized copy for string in the string table. | 931 // Finds the internalized copy for string in the string table. |
971 // If not found, a new string is added to the table and returned. | 932 // If not found, a new string is added to the table and returned. |
972 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation | |
973 // failed. | |
974 // Please note this function does not perform a garbage collection. | 933 // Please note this function does not perform a garbage collection. |
975 MUST_USE_RESULT MaybeObject* InternalizeStringWithKey(HashTableKey* key); | 934 MUST_USE_RESULT AllocationResult InternalizeStringWithKey(HashTableKey* key); |
976 | 935 |
977 bool InternalizeStringIfExists(String* str, String** result); | 936 bool InternalizeStringIfExists(String* str, String** result); |
978 bool InternalizeTwoCharsStringIfExists(String* str, String** result); | 937 bool InternalizeTwoCharsStringIfExists(String* str, String** result); |
979 | 938 |
980 // Converts the given boolean condition to JavaScript boolean value. | 939 // Converts the given boolean condition to JavaScript boolean value. |
981 inline Object* ToBoolean(bool condition); | 940 inline Object* ToBoolean(bool condition); |
982 | 941 |
983 // Performs garbage collection operation. | 942 // Performs garbage collection operation. |
984 // Returns whether there is a chance that another major GC could | 943 // Returns whether there is a chance that another major GC could |
985 // collect more garbage. | 944 // collect more garbage. |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 ASSERT(preferred_old_space == OLD_POINTER_SPACE || | 1877 ASSERT(preferred_old_space == OLD_POINTER_SPACE || |
1919 preferred_old_space == OLD_DATA_SPACE); | 1878 preferred_old_space == OLD_DATA_SPACE); |
1920 if (object_size > Page::kMaxRegularHeapObjectSize) return LO_SPACE; | 1879 if (object_size > Page::kMaxRegularHeapObjectSize) return LO_SPACE; |
1921 return (pretenure == TENURED) ? preferred_old_space : NEW_SPACE; | 1880 return (pretenure == TENURED) ? preferred_old_space : NEW_SPACE; |
1922 } | 1881 } |
1923 | 1882 |
1924 // Allocate an uninitialized object. The memory is non-executable if the | 1883 // Allocate an uninitialized object. The memory is non-executable if the |
1925 // hardware and OS allow. This is the single choke-point for allocations | 1884 // hardware and OS allow. This is the single choke-point for allocations |
1926 // performed by the runtime and should not be bypassed (to extend this to | 1885 // performed by the runtime and should not be bypassed (to extend this to |
1927 // inlined allocations, use the Heap::DisableInlineAllocation() support). | 1886 // inlined allocations, use the Heap::DisableInlineAllocation() support). |
1928 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes, | 1887 MUST_USE_RESULT inline AllocationResult AllocateRaw( |
1929 AllocationSpace space, | 1888 int size_in_bytes, |
1930 AllocationSpace retry_space); | 1889 AllocationSpace space, |
| 1890 AllocationSpace retry_space); |
1931 | 1891 |
1932 // Allocate an uninitialized fixed array. | 1892 // Allocate an uninitialized fixed array. |
1933 MUST_USE_RESULT MaybeObject* AllocateRawFixedArray( | 1893 MUST_USE_RESULT AllocationResult AllocateRawFixedArray( |
1934 int length, PretenureFlag pretenure); | 1894 int length, PretenureFlag pretenure); |
1935 | 1895 |
1936 // Allocate an uninitialized fixed double array. | 1896 // Allocate an uninitialized fixed double array. |
1937 MUST_USE_RESULT MaybeObject* AllocateRawFixedDoubleArray( | 1897 MUST_USE_RESULT AllocationResult AllocateRawFixedDoubleArray( |
1938 int length, PretenureFlag pretenure); | 1898 int length, PretenureFlag pretenure); |
1939 | 1899 |
1940 // Allocate an initialized fixed array with the given filler value. | 1900 // Allocate an initialized fixed array with the given filler value. |
1941 MUST_USE_RESULT MaybeObject* AllocateFixedArrayWithFiller( | 1901 MUST_USE_RESULT AllocationResult AllocateFixedArrayWithFiller( |
1942 int length, PretenureFlag pretenure, Object* filler); | 1902 int length, PretenureFlag pretenure, Object* filler); |
1943 | 1903 |
1944 // Allocate and partially initializes a String. There are two String | 1904 // Allocate and partially initializes a String. There are two String |
1945 // encodings: ASCII and two byte. These functions allocate a string of the | 1905 // encodings: ASCII and two byte. These functions allocate a string of the |
1946 // given length and set its map and length fields. The characters of the | 1906 // given length and set its map and length fields. The characters of the |
1947 // string are uninitialized. | 1907 // string are uninitialized. |
1948 MUST_USE_RESULT MaybeObject* AllocateRawOneByteString( | 1908 MUST_USE_RESULT AllocationResult AllocateRawOneByteString( |
1949 int length, PretenureFlag pretenure); | 1909 int length, PretenureFlag pretenure); |
1950 MUST_USE_RESULT MaybeObject* AllocateRawTwoByteString( | 1910 MUST_USE_RESULT AllocationResult AllocateRawTwoByteString( |
1951 int length, PretenureFlag pretenure); | 1911 int length, PretenureFlag pretenure); |
1952 | 1912 |
1953 // Initializes a JSObject based on its map. | 1913 // Initializes a JSObject based on its map. |
1954 void InitializeJSObjectFromMap(JSObject* obj, | 1914 void InitializeJSObjectFromMap(JSObject* obj, |
1955 FixedArray* properties, | 1915 FixedArray* properties, |
1956 Map* map); | 1916 Map* map); |
1957 void InitializeAllocationMemento(AllocationMemento* memento, | 1917 void InitializeAllocationMemento(AllocationMemento* memento, |
1958 AllocationSite* allocation_site); | 1918 AllocationSite* allocation_site); |
1959 | 1919 |
1960 bool CreateInitialMaps(); | 1920 bool CreateInitialMaps(); |
1961 void CreateInitialObjects(); | 1921 void CreateInitialObjects(); |
1962 | 1922 |
1963 // These five Create*EntryStub functions are here and forced to not be inlined | 1923 // These five Create*EntryStub functions are here and forced to not be inlined |
1964 // because of a gcc-4.4 bug that assigns wrong vtable entries. | 1924 // because of a gcc-4.4 bug that assigns wrong vtable entries. |
1965 NO_INLINE(void CreateJSEntryStub()); | 1925 NO_INLINE(void CreateJSEntryStub()); |
1966 NO_INLINE(void CreateJSConstructEntryStub()); | 1926 NO_INLINE(void CreateJSConstructEntryStub()); |
1967 | 1927 |
1968 void CreateFixedStubs(); | 1928 void CreateFixedStubs(); |
1969 | 1929 |
1970 // Allocate empty fixed array. | 1930 // Allocate empty fixed array. |
1971 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray(); | 1931 MUST_USE_RESULT AllocationResult AllocateEmptyFixedArray(); |
1972 | 1932 |
1973 // Allocate empty external array of given type. | 1933 // Allocate empty external array of given type. |
1974 MUST_USE_RESULT MaybeObject* AllocateEmptyExternalArray( | 1934 MUST_USE_RESULT AllocationResult AllocateEmptyExternalArray( |
1975 ExternalArrayType array_type); | 1935 ExternalArrayType array_type); |
1976 | 1936 |
1977 // Allocate empty fixed typed array of given type. | 1937 // Allocate empty fixed typed array of given type. |
1978 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedTypedArray( | 1938 MUST_USE_RESULT AllocationResult AllocateEmptyFixedTypedArray( |
1979 ExternalArrayType array_type); | 1939 ExternalArrayType array_type); |
1980 | 1940 |
1981 // Allocate empty constant pool array. | 1941 // Allocate empty constant pool array. |
1982 MUST_USE_RESULT MaybeObject* AllocateEmptyConstantPoolArray(); | 1942 MUST_USE_RESULT AllocationResult AllocateEmptyConstantPoolArray(); |
1983 | 1943 |
1984 // Allocate a tenured simple cell. | 1944 // Allocate a tenured simple cell. |
1985 MUST_USE_RESULT MaybeObject* AllocateCell(Object* value); | 1945 MUST_USE_RESULT AllocationResult AllocateCell(Object* value); |
1986 | 1946 |
1987 // Allocate a tenured JS global property cell initialized with the hole. | 1947 // Allocate a tenured JS global property cell initialized with the hole. |
1988 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); | 1948 MUST_USE_RESULT AllocationResult AllocatePropertyCell(); |
1989 | 1949 |
1990 // Performs a minor collection in new generation. | 1950 // Performs a minor collection in new generation. |
1991 void Scavenge(); | 1951 void Scavenge(); |
1992 | 1952 |
1993 // Commits from space if it is uncommitted. | 1953 // Commits from space if it is uncommitted. |
1994 void EnsureFromSpaceIsCommitted(); | 1954 void EnsureFromSpaceIsCommitted(); |
1995 | 1955 |
1996 // Uncommit unused semi space. | 1956 // Uncommit unused semi space. |
1997 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } | 1957 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } |
1998 | 1958 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2818 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2859 | 2819 |
2860 private: | 2820 private: |
2861 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2821 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2862 }; | 2822 }; |
2863 #endif // DEBUG | 2823 #endif // DEBUG |
2864 | 2824 |
2865 } } // namespace v8::internal | 2825 } } // namespace v8::internal |
2866 | 2826 |
2867 #endif // V8_HEAP_H_ | 2827 #endif // V8_HEAP_H_ |
OLD | NEW |