| 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 659 |
| 660 // Allocates and initializes a new global object based on a constructor. | 660 // Allocates and initializes a new global object based on a constructor. |
| 661 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 661 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 662 // failed. | 662 // failed. |
| 663 // Please note this does not perform a garbage collection. | 663 // Please note this does not perform a garbage collection. |
| 664 MUST_USE_RESULT MaybeObject* AllocateGlobalObject(JSFunction* constructor); | 664 MUST_USE_RESULT MaybeObject* AllocateGlobalObject(JSFunction* constructor); |
| 665 | 665 |
| 666 // Returns a deep copy of the JavaScript object. | 666 // Returns a deep copy of the JavaScript object. |
| 667 // Properties and elements are copied too. | 667 // Properties and elements are copied too. |
| 668 // Returns failure if allocation failed. | 668 // Returns failure if allocation failed. |
| 669 MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source); | 669 // Optionally takes an AllocationSite to be appended in an AllocationMemento. |
| 670 | 670 MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source, |
| 671 MUST_USE_RESULT MaybeObject* CopyJSObjectWithAllocationSite( | 671 AllocationSite* site = NULL); |
| 672 JSObject* source, AllocationSite* site); | |
| 673 | 672 |
| 674 // Allocates the function prototype. | 673 // Allocates the function prototype. |
| 675 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 674 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 676 // failed. | 675 // failed. |
| 677 // Please note this does not perform a garbage collection. | 676 // Please note this does not perform a garbage collection. |
| 678 MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function); | 677 MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function); |
| 679 | 678 |
| 680 // Allocates a JS ArrayBuffer object. | 679 // Allocates a JS ArrayBuffer object. |
| 681 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 680 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 682 // failed. | 681 // failed. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 // A cache is used for ASCII codes. | 857 // A cache is used for ASCII codes. |
| 859 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 858 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 860 // failed. Please note this does not perform a garbage collection. | 859 // failed. Please note this does not perform a garbage collection. |
| 861 MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode( | 860 MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode( |
| 862 uint16_t code); | 861 uint16_t code); |
| 863 | 862 |
| 864 // Allocate a byte array of the specified length | 863 // Allocate a byte array of the specified length |
| 865 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 864 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 866 // failed. | 865 // failed. |
| 867 // Please note this does not perform a garbage collection. | 866 // Please note this does not perform a garbage collection. |
| 868 MUST_USE_RESULT MaybeObject* AllocateByteArray(int length, | 867 MUST_USE_RESULT MaybeObject* AllocateByteArray( |
| 869 PretenureFlag pretenure); | 868 int length, |
| 870 | 869 PretenureFlag pretenure = NOT_TENURED); |
| 871 // Allocate a non-tenured byte array of the specified length | |
| 872 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
| 873 // failed. | |
| 874 // Please note this does not perform a garbage collection. | |
| 875 MUST_USE_RESULT MaybeObject* AllocateByteArray(int length); | |
| 876 | 870 |
| 877 // Allocates an external array of the specified length and type. | 871 // Allocates an external array of the specified length and type. |
| 878 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 872 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 879 // failed. | 873 // failed. |
| 880 // Please note this does not perform a garbage collection. | 874 // Please note this does not perform a garbage collection. |
| 881 MUST_USE_RESULT MaybeObject* AllocateExternalArray( | 875 MUST_USE_RESULT MaybeObject* AllocateExternalArray( |
| 882 int length, | 876 int length, |
| 883 ExternalArrayType array_type, | 877 ExternalArrayType array_type, |
| 884 void* external_pointer, | 878 void* external_pointer, |
| 885 PretenureFlag pretenure); | 879 PretenureFlag pretenure); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 906 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, | 900 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, |
| 907 PretenureFlag pretenure); | 901 PretenureFlag pretenure); |
| 908 | 902 |
| 909 // Allocate a tenured AllocationSite. It's payload is null | 903 // Allocate a tenured AllocationSite. It's payload is null |
| 910 MUST_USE_RESULT MaybeObject* AllocateAllocationSite(); | 904 MUST_USE_RESULT MaybeObject* AllocateAllocationSite(); |
| 911 | 905 |
| 912 // Allocates a fixed array initialized with undefined values | 906 // Allocates a fixed array initialized with undefined values |
| 913 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 907 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 914 // failed. | 908 // failed. |
| 915 // Please note this does not perform a garbage collection. | 909 // Please note this does not perform a garbage collection. |
| 916 MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length, | 910 MUST_USE_RESULT MaybeObject* AllocateFixedArray( |
| 917 PretenureFlag pretenure); | 911 int length, |
| 918 // Allocates a fixed array initialized with undefined values | 912 PretenureFlag pretenure = NOT_TENURED); |
| 919 MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length); | |
| 920 | 913 |
| 921 // Allocates an uninitialized fixed array. It must be filled by the caller. | 914 // Allocates an uninitialized fixed array. It must be filled by the caller. |
| 922 // | 915 // |
| 923 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 916 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 924 // failed. | 917 // failed. |
| 925 // Please note this does not perform a garbage collection. | 918 // Please note this does not perform a garbage collection. |
| 926 MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length); | 919 MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length); |
| 927 | 920 |
| 928 // Move len elements within a given array from src_index index to dst_index | 921 // Move len elements within a given array from src_index index to dst_index |
| 929 // index. | 922 // index. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( | 1031 MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( |
| 1039 Object* callee, int length); | 1032 Object* callee, int length); |
| 1040 | 1033 |
| 1041 // Same as NewNumberFromDouble, but may return a preallocated/immutable | 1034 // Same as NewNumberFromDouble, but may return a preallocated/immutable |
| 1042 // number object (e.g., minus_zero_value_, nan_value_) | 1035 // number object (e.g., minus_zero_value_, nan_value_) |
| 1043 MUST_USE_RESULT MaybeObject* NumberFromDouble( | 1036 MUST_USE_RESULT MaybeObject* NumberFromDouble( |
| 1044 double value, PretenureFlag pretenure = NOT_TENURED); | 1037 double value, PretenureFlag pretenure = NOT_TENURED); |
| 1045 | 1038 |
| 1046 // Allocated a HeapNumber from value. | 1039 // Allocated a HeapNumber from value. |
| 1047 MUST_USE_RESULT MaybeObject* AllocateHeapNumber( | 1040 MUST_USE_RESULT MaybeObject* AllocateHeapNumber( |
| 1048 double value, | 1041 double value, PretenureFlag pretenure = NOT_TENURED); |
| 1049 PretenureFlag pretenure); | |
| 1050 // pretenure = NOT_TENURED | |
| 1051 MUST_USE_RESULT MaybeObject* AllocateHeapNumber(double value); | |
| 1052 | 1042 |
| 1053 // Converts an int into either a Smi or a HeapNumber object. | 1043 // Converts an int into either a Smi or a HeapNumber object. |
| 1054 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 1044 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 1055 // failed. | 1045 // failed. |
| 1056 // Please note this does not perform a garbage collection. | 1046 // Please note this does not perform a garbage collection. |
| 1057 MUST_USE_RESULT inline MaybeObject* NumberFromInt32( | 1047 MUST_USE_RESULT inline MaybeObject* NumberFromInt32( |
| 1058 int32_t value, PretenureFlag pretenure = NOT_TENURED); | 1048 int32_t value, PretenureFlag pretenure = NOT_TENURED); |
| 1059 | 1049 |
| 1060 // Converts an int into either a Smi or a HeapNumber object. | 1050 // Converts an int into either a Smi or a HeapNumber object. |
| 1061 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 1051 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 const char** reason); | 2050 const char** reason); |
| 2061 | 2051 |
| 2062 // Performs garbage collection | 2052 // Performs garbage collection |
| 2063 // Returns whether there is a chance another major GC could | 2053 // Returns whether there is a chance another major GC could |
| 2064 // collect more garbage. | 2054 // collect more garbage. |
| 2065 bool PerformGarbageCollection(GarbageCollector collector, | 2055 bool PerformGarbageCollection(GarbageCollector collector, |
| 2066 GCTracer* tracer); | 2056 GCTracer* tracer); |
| 2067 | 2057 |
| 2068 inline void UpdateOldSpaceLimits(); | 2058 inline void UpdateOldSpaceLimits(); |
| 2069 | 2059 |
| 2060 // Selects the proper allocation space depending on the given object |
| 2061 // size, pretenuring decision, and preferred old-space. |
| 2062 static AllocationSpace SelectSpace(int object_size, |
| 2063 AllocationSpace preferred_old_space, |
| 2064 PretenureFlag pretenure) { |
| 2065 ASSERT(preferred_old_space == OLD_POINTER_SPACE || |
| 2066 preferred_old_space == OLD_DATA_SPACE); |
| 2067 if (object_size > Page::kMaxNonCodeHeapObjectSize) return LO_SPACE; |
| 2068 return (pretenure == TENURED) ? preferred_old_space : NEW_SPACE; |
| 2069 } |
| 2070 |
| 2070 // Allocate an uninitialized object in map space. The behavior is identical | 2071 // Allocate an uninitialized object in map space. The behavior is identical |
| 2071 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't | 2072 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't |
| 2072 // have to test the allocation space argument and (b) can reduce code size | 2073 // have to test the allocation space argument and (b) can reduce code size |
| 2073 // (since both AllocateRaw and AllocateRawMap are inlined). | 2074 // (since both AllocateRaw and AllocateRawMap are inlined). |
| 2074 MUST_USE_RESULT inline MaybeObject* AllocateRawMap(); | 2075 MUST_USE_RESULT inline MaybeObject* AllocateRawMap(); |
| 2075 | 2076 |
| 2076 // Allocate an uninitialized object in the simple cell space. | 2077 // Allocate an uninitialized object in the simple cell space. |
| 2077 MUST_USE_RESULT inline MaybeObject* AllocateRawCell(); | 2078 MUST_USE_RESULT inline MaybeObject* AllocateRawCell(); |
| 2078 | 2079 |
| 2079 // Allocate an uninitialized object in the global property cell space. | 2080 // Allocate an uninitialized object in the global property cell space. |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3024 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3024 | 3025 |
| 3025 private: | 3026 private: |
| 3026 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3027 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3027 }; | 3028 }; |
| 3028 #endif // DEBUG | 3029 #endif // DEBUG |
| 3029 | 3030 |
| 3030 } } // namespace v8::internal | 3031 } } // namespace v8::internal |
| 3031 | 3032 |
| 3032 #endif // V8_HEAP_H_ | 3033 #endif // V8_HEAP_H_ |
| OLD | NEW |