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/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // testing machinery is restructured in such a way that we don't have to come up | 322 // testing machinery is restructured in such a way that we don't have to come up |
323 // with a CompilationInfo out of thin air, although we only need a few parts of | 323 // with a CompilationInfo out of thin air, although we only need a few parts of |
324 // it. | 324 // it. |
325 struct FakeStubForTesting : public CodeStub { | 325 struct FakeStubForTesting : public CodeStub { |
326 explicit FakeStubForTesting(Isolate* isolate) : CodeStub(isolate) {} | 326 explicit FakeStubForTesting(Isolate* isolate) : CodeStub(isolate) {} |
327 | 327 |
328 // Only used by pipeline.cc's GetDebugName in DEBUG mode. | 328 // Only used by pipeline.cc's GetDebugName in DEBUG mode. |
329 Major MajorKey() const override { return CodeStub::NoCache; } | 329 Major MajorKey() const override { return CodeStub::NoCache; } |
330 | 330 |
331 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { | 331 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
332 UNREACHABLE(); | 332 return ContextOnlyDescriptor(isolate()); |
333 return CallInterfaceDescriptor(); | |
334 } | 333 } |
335 | 334 |
336 Handle<Code> GenerateCode() override { | 335 Handle<Code> GenerateCode() override { |
337 UNREACHABLE(); | 336 UNREACHABLE(); |
338 return Handle<Code>(); | 337 return Handle<Code>(); |
339 } | 338 } |
340 }; | 339 }; |
341 | 340 |
342 | 341 |
343 #define DEFINE_CODE_STUB_BASE(NAME, SUPER) \ | 342 #define DEFINE_CODE_STUB_BASE(NAME, SUPER) \ |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 Code::StubType GetStubType() const override { return Code::FAST; } | 1270 Code::StubType GetStubType() const override { return Code::FAST; } |
1272 | 1271 |
1273 private: | 1272 private: |
1274 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | 1273 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
1275 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; | 1274 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
1276 | 1275 |
1277 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); | 1276 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); |
1278 }; | 1277 }; |
1279 | 1278 |
1280 | 1279 |
| 1280 // Register and parameter access methods are specified here instead of in |
| 1281 // the CallInterfaceDescriptor because the stub uses a different descriptor |
| 1282 // if FLAG_vector_stores is on. |
| 1283 class StoreTransitionHelper { |
| 1284 public: |
| 1285 static Register ReceiverRegister() { |
| 1286 return StoreTransitionDescriptor::ReceiverRegister(); |
| 1287 } |
| 1288 |
| 1289 static Register NameRegister() { |
| 1290 return StoreTransitionDescriptor::NameRegister(); |
| 1291 } |
| 1292 |
| 1293 static Register ValueRegister() { |
| 1294 return StoreTransitionDescriptor::ValueRegister(); |
| 1295 } |
| 1296 |
| 1297 static Register SlotRegister() { |
| 1298 DCHECK(FLAG_vector_stores); |
| 1299 return VectorStoreTransitionDescriptor::SlotRegister(); |
| 1300 } |
| 1301 |
| 1302 static Register VectorRegister() { |
| 1303 DCHECK(FLAG_vector_stores); |
| 1304 return VectorStoreTransitionDescriptor::VectorRegister(); |
| 1305 } |
| 1306 |
| 1307 static Register MapRegister() { |
| 1308 return FLAG_vector_stores ? VectorStoreTransitionDescriptor::MapRegister() |
| 1309 : StoreTransitionDescriptor::MapRegister(); |
| 1310 } |
| 1311 |
| 1312 static int ReceiverIndex() { |
| 1313 return StoreTransitionDescriptor::kReceiverIndex; |
| 1314 } |
| 1315 |
| 1316 static int NameIndex() { return StoreTransitionDescriptor::kReceiverIndex; } |
| 1317 |
| 1318 static int ValueIndex() { return StoreTransitionDescriptor::kValueIndex; } |
| 1319 |
| 1320 static int SlotIndex() { |
| 1321 DCHECK(FLAG_vector_stores); |
| 1322 return VectorStoreTransitionDescriptor::kSlotIndex; |
| 1323 } |
| 1324 |
| 1325 static int VectorIndex() { |
| 1326 DCHECK(FLAG_vector_stores); |
| 1327 return VectorStoreTransitionDescriptor::kVectorIndex; |
| 1328 } |
| 1329 |
| 1330 static int MapIndex() { |
| 1331 if (FLAG_vector_stores) { |
| 1332 return VectorStoreTransitionDescriptor::kMapIndex; |
| 1333 } |
| 1334 return StoreTransitionDescriptor::kMapIndex; |
| 1335 } |
| 1336 |
| 1337 // Some platforms push Slot, Vector, Map on the stack instead of in |
| 1338 // registers. |
| 1339 static bool UsesStackArgs() { return MapRegister().is(no_reg); } |
| 1340 }; |
| 1341 |
| 1342 |
1281 class StoreTransitionStub : public HandlerStub { | 1343 class StoreTransitionStub : public HandlerStub { |
1282 public: | 1344 public: |
1283 enum StoreMode { | 1345 enum StoreMode { |
1284 StoreMapOnly, | 1346 StoreMapOnly, |
1285 StoreMapAndValue, | 1347 StoreMapAndValue, |
1286 ExtendStorageAndStoreMapAndValue | 1348 ExtendStorageAndStoreMapAndValue |
1287 }; | 1349 }; |
1288 | 1350 |
1289 explicit StoreTransitionStub(Isolate* isolate) : HandlerStub(isolate) { | 1351 explicit StoreTransitionStub(Isolate* isolate) : HandlerStub(isolate) { |
1290 set_sub_minor_key(StoreModeBits::encode(StoreMapOnly)); | 1352 set_sub_minor_key(StoreModeBits::encode(StoreMapOnly)); |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); } | 2661 bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); } |
2600 | 2662 |
2601 ElementsKind elements_kind() const { | 2663 ElementsKind elements_kind() const { |
2602 return ElementsKindBits::decode(sub_minor_key()); | 2664 return ElementsKindBits::decode(sub_minor_key()); |
2603 } | 2665 } |
2604 | 2666 |
2605 KeyedAccessStoreMode store_mode() const { | 2667 KeyedAccessStoreMode store_mode() const { |
2606 return StoreModeBits::decode(sub_minor_key()); | 2668 return StoreModeBits::decode(sub_minor_key()); |
2607 } | 2669 } |
2608 | 2670 |
| 2671 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2672 if (FLAG_vector_stores) { |
| 2673 return VectorStoreICDescriptor(isolate()); |
| 2674 } |
| 2675 return StoreDescriptor(isolate()); |
| 2676 } |
| 2677 |
2609 private: | 2678 private: |
2610 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; | 2679 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
2611 class StoreModeBits: public BitField<KeyedAccessStoreMode, 8, 4> {}; | 2680 class StoreModeBits: public BitField<KeyedAccessStoreMode, 8, 4> {}; |
2612 class IsJSArrayBits: public BitField<bool, 12, 1> {}; | 2681 class IsJSArrayBits: public BitField<bool, 12, 1> {}; |
2613 | 2682 |
2614 DEFINE_CALL_INTERFACE_DESCRIPTOR(Store); | |
2615 DEFINE_HYDROGEN_CODE_STUB(StoreFastElement, HydrogenCodeStub); | 2683 DEFINE_HYDROGEN_CODE_STUB(StoreFastElement, HydrogenCodeStub); |
2616 }; | 2684 }; |
2617 | 2685 |
2618 | 2686 |
2619 class TransitionElementsKindStub : public HydrogenCodeStub { | 2687 class TransitionElementsKindStub : public HydrogenCodeStub { |
2620 public: | 2688 public: |
2621 TransitionElementsKindStub(Isolate* isolate, | 2689 TransitionElementsKindStub(Isolate* isolate, |
2622 ElementsKind from_kind, | 2690 ElementsKind from_kind, |
2623 ElementsKind to_kind, | 2691 ElementsKind to_kind, |
2624 bool is_js_array) : HydrogenCodeStub(isolate) { | 2692 bool is_js_array) : HydrogenCodeStub(isolate) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 }; | 2890 }; |
2823 | 2891 |
2824 | 2892 |
2825 class StoreElementStub : public PlatformCodeStub { | 2893 class StoreElementStub : public PlatformCodeStub { |
2826 public: | 2894 public: |
2827 StoreElementStub(Isolate* isolate, ElementsKind elements_kind) | 2895 StoreElementStub(Isolate* isolate, ElementsKind elements_kind) |
2828 : PlatformCodeStub(isolate) { | 2896 : PlatformCodeStub(isolate) { |
2829 minor_key_ = ElementsKindBits::encode(elements_kind); | 2897 minor_key_ = ElementsKindBits::encode(elements_kind); |
2830 } | 2898 } |
2831 | 2899 |
| 2900 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2901 if (FLAG_vector_stores) { |
| 2902 return VectorStoreICDescriptor(isolate()); |
| 2903 } |
| 2904 return StoreDescriptor(isolate()); |
| 2905 } |
| 2906 |
2832 private: | 2907 private: |
2833 ElementsKind elements_kind() const { | 2908 ElementsKind elements_kind() const { |
2834 return ElementsKindBits::decode(minor_key_); | 2909 return ElementsKindBits::decode(minor_key_); |
2835 } | 2910 } |
2836 | 2911 |
2837 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; | 2912 class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; |
2838 | 2913 |
2839 DEFINE_CALL_INTERFACE_DESCRIPTOR(Store); | |
2840 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); | 2914 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); |
2841 }; | 2915 }; |
2842 | 2916 |
2843 | 2917 |
2844 class ToBooleanStub: public HydrogenCodeStub { | 2918 class ToBooleanStub: public HydrogenCodeStub { |
2845 public: | 2919 public: |
2846 enum Type { | 2920 enum Type { |
2847 UNDEFINED, | 2921 UNDEFINED, |
2848 BOOLEAN, | 2922 BOOLEAN, |
2849 NULL_TYPE, | 2923 NULL_TYPE, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 StoreModeBits::encode(store_mode)); | 3018 StoreModeBits::encode(store_mode)); |
2945 } | 3019 } |
2946 | 3020 |
2947 ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); } | 3021 ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); } |
2948 ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); } | 3022 ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); } |
2949 bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); } | 3023 bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); } |
2950 KeyedAccessStoreMode store_mode() const { | 3024 KeyedAccessStoreMode store_mode() const { |
2951 return StoreModeBits::decode(sub_minor_key()); | 3025 return StoreModeBits::decode(sub_minor_key()); |
2952 } | 3026 } |
2953 | 3027 |
| 3028 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; |
| 3029 |
2954 private: | 3030 private: |
2955 class FromBits : public BitField<ElementsKind, 0, 8> {}; | 3031 class FromBits : public BitField<ElementsKind, 0, 8> {}; |
2956 class ToBits : public BitField<ElementsKind, 8, 8> {}; | 3032 class ToBits : public BitField<ElementsKind, 8, 8> {}; |
2957 class IsJSArrayBits : public BitField<bool, 16, 1> {}; | 3033 class IsJSArrayBits : public BitField<bool, 16, 1> {}; |
2958 class StoreModeBits : public BitField<KeyedAccessStoreMode, 17, 4> {}; | 3034 class StoreModeBits : public BitField<KeyedAccessStoreMode, 17, 4> {}; |
2959 | 3035 |
2960 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreTransition); | |
2961 DEFINE_HYDROGEN_CODE_STUB(ElementsTransitionAndStore, HydrogenCodeStub); | 3036 DEFINE_HYDROGEN_CODE_STUB(ElementsTransitionAndStore, HydrogenCodeStub); |
2962 }; | 3037 }; |
2963 | 3038 |
2964 | 3039 |
2965 class StoreArrayLiteralElementStub : public PlatformCodeStub { | 3040 class StoreArrayLiteralElementStub : public PlatformCodeStub { |
2966 public: | 3041 public: |
2967 explicit StoreArrayLiteralElementStub(Isolate* isolate) | 3042 explicit StoreArrayLiteralElementStub(Isolate* isolate) |
2968 : PlatformCodeStub(isolate) { } | 3043 : PlatformCodeStub(isolate) { } |
2969 | 3044 |
2970 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreArrayLiteralElement); | 3045 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreArrayLiteralElement); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 #undef DEFINE_PLATFORM_CODE_STUB | 3150 #undef DEFINE_PLATFORM_CODE_STUB |
3076 #undef DEFINE_HANDLER_CODE_STUB | 3151 #undef DEFINE_HANDLER_CODE_STUB |
3077 #undef DEFINE_HYDROGEN_CODE_STUB | 3152 #undef DEFINE_HYDROGEN_CODE_STUB |
3078 #undef DEFINE_CODE_STUB | 3153 #undef DEFINE_CODE_STUB |
3079 #undef DEFINE_CODE_STUB_BASE | 3154 #undef DEFINE_CODE_STUB_BASE |
3080 | 3155 |
3081 extern Representation RepresentationFromType(Type* type); | 3156 extern Representation RepresentationFromType(Type* type); |
3082 } } // namespace v8::internal | 3157 } } // namespace v8::internal |
3083 | 3158 |
3084 #endif // V8_CODE_STUBS_H_ | 3159 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |