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" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/globals.h" | 12 #include "src/globals.h" |
13 #include "src/ic/ic-state.h" | 13 #include "src/ic/ic-state.h" |
14 #include "src/interface-descriptors.h" | 14 #include "src/interface-descriptors.h" |
15 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
16 #include "src/ostreams.h" | 16 #include "src/ostreams.h" |
| 17 #include "src/type-hints.h" |
17 | 18 |
18 namespace v8 { | 19 namespace v8 { |
19 namespace internal { | 20 namespace internal { |
20 | 21 |
21 class ObjectLiteral; | 22 class ObjectLiteral; |
22 | 23 |
23 // List of code stubs used on all platforms. | 24 // List of code stubs used on all platforms. |
24 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 25 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
25 /* --- PlatformCodeStubs --- */ \ | 26 /* --- PlatformCodeStubs --- */ \ |
26 V(ArrayConstructor) \ | 27 V(ArrayConstructor) \ |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 816 |
816 // ES6 [[Get]] operation. | 817 // ES6 [[Get]] operation. |
817 class GetPropertyStub : public TurboFanCodeStub { | 818 class GetPropertyStub : public TurboFanCodeStub { |
818 public: | 819 public: |
819 explicit GetPropertyStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 820 explicit GetPropertyStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
820 | 821 |
821 DEFINE_CALL_INTERFACE_DESCRIPTOR(GetProperty); | 822 DEFINE_CALL_INTERFACE_DESCRIPTOR(GetProperty); |
822 DEFINE_TURBOFAN_CODE_STUB(GetProperty, TurboFanCodeStub); | 823 DEFINE_TURBOFAN_CODE_STUB(GetProperty, TurboFanCodeStub); |
823 }; | 824 }; |
824 | 825 |
825 enum StringAddFlags { | |
826 // Omit both parameter checks. | |
827 STRING_ADD_CHECK_NONE = 0, | |
828 // Check left parameter. | |
829 STRING_ADD_CHECK_LEFT = 1 << 0, | |
830 // Check right parameter. | |
831 STRING_ADD_CHECK_RIGHT = 1 << 1, | |
832 // Check both parameters. | |
833 STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT, | |
834 // Convert parameters when check fails (instead of throwing an exception). | |
835 STRING_ADD_CONVERT = 1 << 2, | |
836 STRING_ADD_CONVERT_LEFT = STRING_ADD_CHECK_LEFT | STRING_ADD_CONVERT, | |
837 STRING_ADD_CONVERT_RIGHT = STRING_ADD_CHECK_RIGHT | STRING_ADD_CONVERT | |
838 }; | |
839 | |
840 | |
841 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags); | |
842 | |
843 class NumberToStringStub final : public TurboFanCodeStub { | 826 class NumberToStringStub final : public TurboFanCodeStub { |
844 public: | 827 public: |
845 explicit NumberToStringStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | 828 explicit NumberToStringStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
846 | 829 |
847 DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); | 830 DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
848 DEFINE_TURBOFAN_CODE_STUB(NumberToString, TurboFanCodeStub); | 831 DEFINE_TURBOFAN_CODE_STUB(NumberToString, TurboFanCodeStub); |
849 }; | 832 }; |
850 | 833 |
851 class FastNewClosureStub : public TurboFanCodeStub { | 834 class FastNewClosureStub : public TurboFanCodeStub { |
852 public: | 835 public: |
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 | 2551 |
2569 class ElementsKindBits | 2552 class ElementsKindBits |
2570 : public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {}; | 2553 : public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {}; |
2571 | 2554 |
2572 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector); | 2555 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector); |
2573 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); | 2556 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); |
2574 }; | 2557 }; |
2575 | 2558 |
2576 class ToBooleanICStub : public HydrogenCodeStub { | 2559 class ToBooleanICStub : public HydrogenCodeStub { |
2577 public: | 2560 public: |
2578 enum Type { | |
2579 UNDEFINED, | |
2580 BOOLEAN, | |
2581 NULL_TYPE, | |
2582 SMI, | |
2583 SPEC_OBJECT, | |
2584 STRING, | |
2585 SYMBOL, | |
2586 HEAP_NUMBER, | |
2587 SIMD_VALUE, | |
2588 NUMBER_OF_TYPES | |
2589 }; | |
2590 | |
2591 // At most 16 different types can be distinguished, because the Code object | |
2592 // only has room for two bytes to hold a set of these types. :-P | |
2593 STATIC_ASSERT(NUMBER_OF_TYPES <= 16); | |
2594 | |
2595 class Types : public EnumSet<Type, uint16_t> { | |
2596 public: | |
2597 Types() : EnumSet<Type, uint16_t>(0) {} | |
2598 explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {} | |
2599 | |
2600 bool UpdateStatus(Isolate* isolate, Handle<Object> object); | |
2601 bool NeedsMap() const; | |
2602 bool CanBeUndetectable() const { | |
2603 return Contains(ToBooleanICStub::SPEC_OBJECT); | |
2604 } | |
2605 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } | |
2606 | |
2607 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } | |
2608 }; | |
2609 | |
2610 ToBooleanICStub(Isolate* isolate, ExtraICState state) | 2561 ToBooleanICStub(Isolate* isolate, ExtraICState state) |
2611 : HydrogenCodeStub(isolate) { | 2562 : HydrogenCodeStub(isolate) { |
2612 set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state))); | 2563 set_sub_minor_key(HintsBits::encode(static_cast<uint16_t>(state))); |
2613 } | 2564 } |
2614 | 2565 |
2615 bool UpdateStatus(Handle<Object> object); | 2566 bool UpdateStatus(Handle<Object> object); |
2616 Types types() const { return Types(TypesBits::decode(sub_minor_key())); } | 2567 ToBooleanHints hints() const { |
| 2568 return ToBooleanHints(HintsBits::decode(sub_minor_key())); |
| 2569 } |
2617 | 2570 |
2618 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } | 2571 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } |
2619 void PrintState(std::ostream& os) const override; // NOLINT | 2572 void PrintState(std::ostream& os) const override; // NOLINT |
2620 | 2573 |
2621 bool SometimesSetsUpAFrame() override { return false; } | 2574 bool SometimesSetsUpAFrame() override { return false; } |
2622 | 2575 |
2623 static Handle<Code> GetUninitialized(Isolate* isolate) { | 2576 static Handle<Code> GetUninitialized(Isolate* isolate) { |
2624 return ToBooleanICStub(isolate, UNINITIALIZED).GetCode(); | 2577 return ToBooleanICStub(isolate, UNINITIALIZED).GetCode(); |
2625 } | 2578 } |
2626 | 2579 |
2627 ExtraICState GetExtraICState() const override { return types().ToIntegral(); } | 2580 ExtraICState GetExtraICState() const override { return hints(); } |
2628 | 2581 |
2629 InlineCacheState GetICState() const { | 2582 InlineCacheState GetICState() const { |
2630 if (types().IsEmpty()) { | 2583 if (hints() == ToBooleanHint::kNone) { |
2631 return ::v8::internal::UNINITIALIZED; | 2584 return ::v8::internal::UNINITIALIZED; |
2632 } else { | 2585 } else { |
2633 return MONOMORPHIC; | 2586 return MONOMORPHIC; |
2634 } | 2587 } |
2635 } | 2588 } |
2636 | 2589 |
2637 private: | 2590 private: |
2638 ToBooleanICStub(Isolate* isolate, InitializationState init_state) | 2591 ToBooleanICStub(Isolate* isolate, InitializationState init_state) |
2639 : HydrogenCodeStub(isolate, init_state) {} | 2592 : HydrogenCodeStub(isolate, init_state) {} |
2640 | 2593 |
2641 class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {}; | 2594 static const int kNumHints = 9; |
| 2595 STATIC_ASSERT(static_cast<int>(ToBooleanHint::kAny) == |
| 2596 ((1 << kNumHints) - 1)); |
| 2597 class HintsBits : public BitField<uint16_t, 0, kNumHints> {}; |
2642 | 2598 |
2643 DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); | 2599 DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
2644 DEFINE_HYDROGEN_CODE_STUB(ToBooleanIC, HydrogenCodeStub); | 2600 DEFINE_HYDROGEN_CODE_STUB(ToBooleanIC, HydrogenCodeStub); |
2645 }; | 2601 }; |
2646 | 2602 |
2647 std::ostream& operator<<(std::ostream& os, const ToBooleanICStub::Types& t); | |
2648 | |
2649 class ElementsTransitionAndStoreStub : public TurboFanCodeStub { | 2603 class ElementsTransitionAndStoreStub : public TurboFanCodeStub { |
2650 public: | 2604 public: |
2651 ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, | 2605 ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, |
2652 ElementsKind to_kind, bool is_jsarray, | 2606 ElementsKind to_kind, bool is_jsarray, |
2653 KeyedAccessStoreMode store_mode) | 2607 KeyedAccessStoreMode store_mode) |
2654 : TurboFanCodeStub(isolate) { | 2608 : TurboFanCodeStub(isolate) { |
2655 minor_key_ = CommonStoreModeBits::encode(store_mode) | | 2609 minor_key_ = CommonStoreModeBits::encode(store_mode) | |
2656 FromBits::encode(from_kind) | ToBits::encode(to_kind) | | 2610 FromBits::encode(from_kind) | ToBits::encode(to_kind) | |
2657 IsJSArrayBits::encode(is_jsarray); | 2611 IsJSArrayBits::encode(is_jsarray); |
2658 } | 2612 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2761 }; | 2715 }; |
2762 | 2716 |
2763 | 2717 |
2764 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR | 2718 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
2765 #undef DEFINE_PLATFORM_CODE_STUB | 2719 #undef DEFINE_PLATFORM_CODE_STUB |
2766 #undef DEFINE_HANDLER_CODE_STUB | 2720 #undef DEFINE_HANDLER_CODE_STUB |
2767 #undef DEFINE_HYDROGEN_CODE_STUB | 2721 #undef DEFINE_HYDROGEN_CODE_STUB |
2768 #undef DEFINE_CODE_STUB | 2722 #undef DEFINE_CODE_STUB |
2769 #undef DEFINE_CODE_STUB_BASE | 2723 #undef DEFINE_CODE_STUB_BASE |
2770 | 2724 |
2771 extern Representation RepresentationFromMachineType(MachineType type); | |
2772 | |
2773 } // namespace internal | 2725 } // namespace internal |
2774 } // namespace v8 | 2726 } // namespace v8 |
2775 | 2727 |
2776 #endif // V8_CODE_STUBS_H_ | 2728 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |