| 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_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
| 6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 V(ToNumber) \ | 48 V(ToNumber) \ |
| 49 V(NonNumberToNumber) \ | 49 V(NonNumberToNumber) \ |
| 50 V(ToString) \ | 50 V(ToString) \ |
| 51 V(ToName) \ | 51 V(ToName) \ |
| 52 V(ToObject) \ | 52 V(ToObject) \ |
| 53 V(VectorStoreICTrampoline) \ | 53 V(VectorStoreICTrampoline) \ |
| 54 V(VectorKeyedStoreICTrampoline) \ | 54 V(VectorKeyedStoreICTrampoline) \ |
| 55 V(VectorStoreIC) \ | 55 V(VectorStoreIC) \ |
| 56 V(VectorKeyedStoreIC) \ | 56 V(VectorKeyedStoreIC) \ |
| 57 /* HydrogenCodeStubs */ \ | 57 /* HydrogenCodeStubs */ \ |
| 58 V(ArrayNArgumentsConstructor) \ | |
| 59 V(BinaryOpIC) \ | 58 V(BinaryOpIC) \ |
| 60 V(BinaryOpWithAllocationSite) \ | 59 V(BinaryOpWithAllocationSite) \ |
| 61 V(CreateAllocationSite) \ | 60 V(CreateAllocationSite) \ |
| 62 V(CreateWeakCell) \ | 61 V(CreateWeakCell) \ |
| 63 V(ElementsTransitionAndStore) \ | 62 V(ElementsTransitionAndStore) \ |
| 64 V(FastArrayPush) \ | 63 V(FastArrayPush) \ |
| 65 V(FastCloneRegExp) \ | 64 V(FastCloneRegExp) \ |
| 66 V(FastCloneShallowArray) \ | 65 V(FastCloneShallowArray) \ |
| 67 V(FastFunctionBind) \ | 66 V(FastFunctionBind) \ |
| 68 V(FastNewClosure) \ | 67 V(FastNewClosure) \ |
| 69 V(FastNewContext) \ | 68 V(FastNewContext) \ |
| 70 V(FastNewObject) \ | 69 V(FastNewObject) \ |
| 71 V(FastNewRestParameter) \ | 70 V(FastNewRestParameter) \ |
| 72 V(FastNewSloppyArguments) \ | 71 V(FastNewSloppyArguments) \ |
| 73 V(FastNewStrictArguments) \ | 72 V(FastNewStrictArguments) \ |
| 74 V(GrowArrayElements) \ | 73 V(GrowArrayElements) \ |
| 75 V(InternalArrayNArgumentsConstructor) \ | |
| 76 V(KeyedLoadGeneric) \ | 74 V(KeyedLoadGeneric) \ |
| 77 V(LoadGlobalViaContext) \ | 75 V(LoadGlobalViaContext) \ |
| 78 V(LoadScriptContextField) \ | 76 V(LoadScriptContextField) \ |
| 79 V(LoadDictionaryElement) \ | 77 V(LoadDictionaryElement) \ |
| 80 V(NameDictionaryLookup) \ | 78 V(NameDictionaryLookup) \ |
| 81 V(NumberToString) \ | 79 V(NumberToString) \ |
| 82 V(Typeof) \ | 80 V(Typeof) \ |
| 83 V(RegExpConstructResult) \ | 81 V(RegExpConstructResult) \ |
| 84 V(StoreFastElement) \ | 82 V(StoreFastElement) \ |
| 85 V(StoreGlobalViaContext) \ | 83 V(StoreGlobalViaContext) \ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 96 V(AllocateUint32x4) \ | 94 V(AllocateUint32x4) \ |
| 97 V(AllocateBool32x4) \ | 95 V(AllocateBool32x4) \ |
| 98 V(AllocateInt16x8) \ | 96 V(AllocateInt16x8) \ |
| 99 V(AllocateUint16x8) \ | 97 V(AllocateUint16x8) \ |
| 100 V(AllocateBool16x8) \ | 98 V(AllocateBool16x8) \ |
| 101 V(AllocateInt8x16) \ | 99 V(AllocateInt8x16) \ |
| 102 V(AllocateUint8x16) \ | 100 V(AllocateUint8x16) \ |
| 103 V(AllocateBool8x16) \ | 101 V(AllocateBool8x16) \ |
| 104 V(ArrayNoArgumentConstructor) \ | 102 V(ArrayNoArgumentConstructor) \ |
| 105 V(ArraySingleArgumentConstructor) \ | 103 V(ArraySingleArgumentConstructor) \ |
| 104 V(ArrayNArgumentsConstructor) \ |
| 106 V(StringLength) \ | 105 V(StringLength) \ |
| 107 V(Add) \ | 106 V(Add) \ |
| 108 V(Subtract) \ | 107 V(Subtract) \ |
| 109 V(Multiply) \ | 108 V(Multiply) \ |
| 110 V(Divide) \ | 109 V(Divide) \ |
| 111 V(Modulus) \ | 110 V(Modulus) \ |
| 112 V(ShiftRight) \ | 111 V(ShiftRight) \ |
| 113 V(ShiftRightLogical) \ | 112 V(ShiftRightLogical) \ |
| 114 V(ShiftLeft) \ | 113 V(ShiftLeft) \ |
| 115 V(BitwiseAnd) \ | 114 V(BitwiseAnd) \ |
| (...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 return ArgumentCountBits::decode(minor_key_); | 1299 return ArgumentCountBits::decode(minor_key_); |
| 1301 } | 1300 } |
| 1302 | 1301 |
| 1303 void GenerateDispatchToArrayStub(MacroAssembler* masm, | 1302 void GenerateDispatchToArrayStub(MacroAssembler* masm, |
| 1304 AllocationSiteOverrideMode mode); | 1303 AllocationSiteOverrideMode mode); |
| 1305 | 1304 |
| 1306 void PrintName(std::ostream& os) const override; // NOLINT | 1305 void PrintName(std::ostream& os) const override; // NOLINT |
| 1307 | 1306 |
| 1308 class ArgumentCountBits : public BitField<ArgumentCountKey, 0, 2> {}; | 1307 class ArgumentCountBits : public BitField<ArgumentCountKey, 0, 2> {}; |
| 1309 | 1308 |
| 1310 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructor); | 1309 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayNArgumentsConstructor); |
| 1311 DEFINE_PLATFORM_CODE_STUB(ArrayConstructor, PlatformCodeStub); | 1310 DEFINE_PLATFORM_CODE_STUB(ArrayConstructor, PlatformCodeStub); |
| 1312 }; | 1311 }; |
| 1313 | 1312 |
| 1314 | 1313 |
| 1315 class InternalArrayConstructorStub: public PlatformCodeStub { | 1314 class InternalArrayConstructorStub: public PlatformCodeStub { |
| 1316 public: | 1315 public: |
| 1317 explicit InternalArrayConstructorStub(Isolate* isolate); | 1316 explicit InternalArrayConstructorStub(Isolate* isolate); |
| 1318 | 1317 |
| 1319 private: | 1318 private: |
| 1320 void GenerateCase(MacroAssembler* masm, ElementsKind kind); | 1319 void GenerateCase(MacroAssembler* masm, ElementsKind kind); |
| 1321 | 1320 |
| 1322 DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructor); | 1321 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayNArgumentsConstructor); |
| 1323 DEFINE_PLATFORM_CODE_STUB(InternalArrayConstructor, PlatformCodeStub); | 1322 DEFINE_PLATFORM_CODE_STUB(InternalArrayConstructor, PlatformCodeStub); |
| 1324 }; | 1323 }; |
| 1325 | 1324 |
| 1326 | 1325 |
| 1327 class MathPowStub: public PlatformCodeStub { | 1326 class MathPowStub: public PlatformCodeStub { |
| 1328 public: | 1327 public: |
| 1329 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK }; | 1328 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK }; |
| 1330 | 1329 |
| 1331 MathPowStub(Isolate* isolate, ExponentType exponent_type) | 1330 MathPowStub(Isolate* isolate, ExponentType exponent_type) |
| 1332 : PlatformCodeStub(isolate) { | 1331 : PlatformCodeStub(isolate) { |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 \ | 2799 \ |
| 2801 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ | 2800 void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
| 2802 void GenerateAssembly(CodeStubAssembler* assembler) const override; \ | 2801 void GenerateAssembly(CodeStubAssembler* assembler) const override; \ |
| 2803 \ | 2802 \ |
| 2804 DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate##Type); \ | 2803 DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate##Type); \ |
| 2805 DEFINE_CODE_STUB(Allocate##Type, TurboFanCodeStub); \ | 2804 DEFINE_CODE_STUB(Allocate##Type, TurboFanCodeStub); \ |
| 2806 }; | 2805 }; |
| 2807 SIMD128_TYPES(SIMD128_ALLOC_STUB) | 2806 SIMD128_TYPES(SIMD128_ALLOC_STUB) |
| 2808 #undef SIMD128_ALLOC_STUB | 2807 #undef SIMD128_ALLOC_STUB |
| 2809 | 2808 |
| 2810 class ArrayConstructorStubBase : public HydrogenCodeStub { | |
| 2811 public: | |
| 2812 ArrayConstructorStubBase(Isolate* isolate, | |
| 2813 ElementsKind kind, | |
| 2814 AllocationSiteOverrideMode override_mode) | |
| 2815 : HydrogenCodeStub(isolate) { | |
| 2816 // It only makes sense to override local allocation site behavior | |
| 2817 // if there is a difference between the global allocation site policy | |
| 2818 // for an ElementsKind and the desired usage of the stub. | |
| 2819 DCHECK(override_mode != DISABLE_ALLOCATION_SITES || | |
| 2820 AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); | |
| 2821 set_sub_minor_key(ElementsKindBits::encode(kind) | | |
| 2822 AllocationSiteOverrideModeBits::encode(override_mode)); | |
| 2823 } | |
| 2824 | |
| 2825 ElementsKind elements_kind() const { | |
| 2826 return ElementsKindBits::decode(sub_minor_key()); | |
| 2827 } | |
| 2828 | |
| 2829 AllocationSiteOverrideMode override_mode() const { | |
| 2830 return AllocationSiteOverrideModeBits::decode(sub_minor_key()); | |
| 2831 } | |
| 2832 | |
| 2833 static void GenerateStubsAheadOfTime(Isolate* isolate); | |
| 2834 | |
| 2835 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | |
| 2836 static const int kConstructor = 0; | |
| 2837 static const int kAllocationSite = 1; | |
| 2838 | |
| 2839 protected: | |
| 2840 std::ostream& BasePrintName(std::ostream& os, | |
| 2841 const char* name) const; // NOLINT | |
| 2842 | |
| 2843 private: | |
| 2844 // Ensure data fits within available bits. | |
| 2845 STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1); | |
| 2846 | |
| 2847 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; | |
| 2848 class AllocationSiteOverrideModeBits: public | |
| 2849 BitField<AllocationSiteOverrideMode, 8, 1> {}; // NOLINT | |
| 2850 | |
| 2851 DEFINE_CODE_STUB_BASE(ArrayConstructorStubBase, HydrogenCodeStub); | |
| 2852 }; | |
| 2853 | |
| 2854 class CommonArrayConstructorStub : public TurboFanCodeStub { | 2809 class CommonArrayConstructorStub : public TurboFanCodeStub { |
| 2855 protected: | 2810 protected: |
| 2856 CommonArrayConstructorStub(Isolate* isolate, ElementsKind kind, | 2811 CommonArrayConstructorStub(Isolate* isolate, ElementsKind kind, |
| 2857 AllocationSiteOverrideMode override_mode) | 2812 AllocationSiteOverrideMode override_mode) |
| 2858 : TurboFanCodeStub(isolate) { | 2813 : TurboFanCodeStub(isolate) { |
| 2859 // It only makes sense to override local allocation site behavior | 2814 // It only makes sense to override local allocation site behavior |
| 2860 // if there is a difference between the global allocation site policy | 2815 // if there is a difference between the global allocation site policy |
| 2861 // for an ElementsKind and the desired usage of the stub. | 2816 // for an ElementsKind and the desired usage of the stub. |
| 2862 DCHECK(override_mode != DISABLE_ALLOCATION_SITES || | 2817 DCHECK(override_mode != DISABLE_ALLOCATION_SITES || |
| 2863 AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); | 2818 AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2874 | 2829 |
| 2875 public: | 2830 public: |
| 2876 ElementsKind elements_kind() const { | 2831 ElementsKind elements_kind() const { |
| 2877 return ElementsKindBits::decode(sub_minor_key()); | 2832 return ElementsKindBits::decode(sub_minor_key()); |
| 2878 } | 2833 } |
| 2879 | 2834 |
| 2880 AllocationSiteOverrideMode override_mode() const { | 2835 AllocationSiteOverrideMode override_mode() const { |
| 2881 return AllocationSiteOverrideModeBits::decode(sub_minor_key()); | 2836 return AllocationSiteOverrideModeBits::decode(sub_minor_key()); |
| 2882 } | 2837 } |
| 2883 | 2838 |
| 2839 static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2840 |
| 2884 private: | 2841 private: |
| 2885 // Ensure data fits within available bits. | 2842 // Ensure data fits within available bits. |
| 2886 STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1); | 2843 STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1); |
| 2887 | 2844 |
| 2888 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; | 2845 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; |
| 2889 class AllocationSiteOverrideModeBits | 2846 class AllocationSiteOverrideModeBits |
| 2890 : public BitField<AllocationSiteOverrideMode, 8, 1> {}; // NOLINT | 2847 : public BitField<AllocationSiteOverrideMode, 8, 1> {}; // NOLINT |
| 2891 }; | 2848 }; |
| 2892 | 2849 |
| 2893 class ArrayNoArgumentConstructorStub : public CommonArrayConstructorStub { | 2850 class ArrayNoArgumentConstructorStub : public CommonArrayConstructorStub { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2950 private: | 2907 private: |
| 2951 void PrintName(std::ostream& os) const override { // NOLINT | 2908 void PrintName(std::ostream& os) const override { // NOLINT |
| 2952 os << "InternalArraySingleArgumentConstructorStub"; | 2909 os << "InternalArraySingleArgumentConstructorStub"; |
| 2953 } | 2910 } |
| 2954 | 2911 |
| 2955 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArraySingleArgumentConstructor); | 2912 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArraySingleArgumentConstructor); |
| 2956 DEFINE_TURBOFAN_CODE_STUB(InternalArraySingleArgumentConstructor, | 2913 DEFINE_TURBOFAN_CODE_STUB(InternalArraySingleArgumentConstructor, |
| 2957 CommonArrayConstructorStub); | 2914 CommonArrayConstructorStub); |
| 2958 }; | 2915 }; |
| 2959 | 2916 |
| 2960 class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase { | 2917 class ArrayNArgumentsConstructorStub : public PlatformCodeStub { |
| 2961 public: | 2918 public: |
| 2962 ArrayNArgumentsConstructorStub( | 2919 explicit ArrayNArgumentsConstructorStub(Isolate* isolate) |
| 2963 Isolate* isolate, | 2920 : PlatformCodeStub(isolate) {} |
| 2964 ElementsKind kind, | 2921 |
| 2965 AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) | 2922 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2966 : ArrayConstructorStubBase(isolate, kind, override_mode) { | 2923 return ArrayNArgumentsConstructorDescriptor(isolate()); |
| 2967 } | 2924 } |
| 2968 | 2925 |
| 2969 private: | 2926 private: |
| 2970 void PrintName(std::ostream& os) const override { // NOLINT | 2927 DEFINE_PLATFORM_CODE_STUB(ArrayNArgumentsConstructor, PlatformCodeStub); |
| 2971 BasePrintName(os, "ArrayNArgumentsConstructorStub"); | |
| 2972 } | |
| 2973 | |
| 2974 DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructor); | |
| 2975 DEFINE_HYDROGEN_CODE_STUB(ArrayNArgumentsConstructor, | |
| 2976 ArrayConstructorStubBase); | |
| 2977 }; | 2928 }; |
| 2978 | 2929 |
| 2979 | |
| 2980 class InternalArrayConstructorStubBase : public HydrogenCodeStub { | |
| 2981 public: | |
| 2982 InternalArrayConstructorStubBase(Isolate* isolate, ElementsKind kind) | |
| 2983 : HydrogenCodeStub(isolate) { | |
| 2984 set_sub_minor_key(ElementsKindBits::encode(kind)); | |
| 2985 } | |
| 2986 | |
| 2987 static void GenerateStubsAheadOfTime(Isolate* isolate); | |
| 2988 | |
| 2989 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | |
| 2990 static const int kConstructor = 0; | |
| 2991 | |
| 2992 ElementsKind elements_kind() const { | |
| 2993 return ElementsKindBits::decode(sub_minor_key()); | |
| 2994 } | |
| 2995 | |
| 2996 private: | |
| 2997 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; | |
| 2998 | |
| 2999 DEFINE_CODE_STUB_BASE(InternalArrayConstructorStubBase, HydrogenCodeStub); | |
| 3000 }; | |
| 3001 | |
| 3002 | |
| 3003 class InternalArrayNArgumentsConstructorStub : public | |
| 3004 InternalArrayConstructorStubBase { | |
| 3005 public: | |
| 3006 InternalArrayNArgumentsConstructorStub(Isolate* isolate, ElementsKind kind) | |
| 3007 : InternalArrayConstructorStubBase(isolate, kind) { } | |
| 3008 | |
| 3009 DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructor); | |
| 3010 DEFINE_HYDROGEN_CODE_STUB(InternalArrayNArgumentsConstructor, | |
| 3011 InternalArrayConstructorStubBase); | |
| 3012 }; | |
| 3013 | |
| 3014 | |
| 3015 class StoreElementStub : public PlatformCodeStub { | 2930 class StoreElementStub : public PlatformCodeStub { |
| 3016 public: | 2931 public: |
| 3017 StoreElementStub(Isolate* isolate, ElementsKind elements_kind, | 2932 StoreElementStub(Isolate* isolate, ElementsKind elements_kind, |
| 3018 KeyedAccessStoreMode mode) | 2933 KeyedAccessStoreMode mode) |
| 3019 : PlatformCodeStub(isolate) { | 2934 : PlatformCodeStub(isolate) { |
| 3020 // TODO(jkummerow): Rename this stub to StoreSlowElementStub, | 2935 // TODO(jkummerow): Rename this stub to StoreSlowElementStub, |
| 3021 // drop elements_kind parameter. | 2936 // drop elements_kind parameter. |
| 3022 DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind); | 2937 DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind); |
| 3023 minor_key_ = ElementsKindBits::encode(elements_kind) | | 2938 minor_key_ = ElementsKindBits::encode(elements_kind) | |
| 3024 CommonStoreModeBits::encode(mode); | 2939 CommonStoreModeBits::encode(mode); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 #undef DEFINE_HYDROGEN_CODE_STUB | 3179 #undef DEFINE_HYDROGEN_CODE_STUB |
| 3265 #undef DEFINE_CODE_STUB | 3180 #undef DEFINE_CODE_STUB |
| 3266 #undef DEFINE_CODE_STUB_BASE | 3181 #undef DEFINE_CODE_STUB_BASE |
| 3267 | 3182 |
| 3268 extern Representation RepresentationFromType(Type* type); | 3183 extern Representation RepresentationFromType(Type* type); |
| 3269 | 3184 |
| 3270 } // namespace internal | 3185 } // namespace internal |
| 3271 } // namespace v8 | 3186 } // namespace v8 |
| 3272 | 3187 |
| 3273 #endif // V8_CODE_STUBS_H_ | 3188 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |