| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 V(LoadScriptContextField) \ | 88 V(LoadScriptContextField) \ |
| 89 V(LoadDictionaryElement) \ | 89 V(LoadDictionaryElement) \ |
| 90 V(NameDictionaryLookup) \ | 90 V(NameDictionaryLookup) \ |
| 91 V(NumberToString) \ | 91 V(NumberToString) \ |
| 92 V(Typeof) \ | 92 V(Typeof) \ |
| 93 V(RegExpConstructResult) \ | 93 V(RegExpConstructResult) \ |
| 94 V(StoreFastElement) \ | 94 V(StoreFastElement) \ |
| 95 V(StoreGlobalViaContext) \ | 95 V(StoreGlobalViaContext) \ |
| 96 V(StoreScriptContextField) \ | 96 V(StoreScriptContextField) \ |
| 97 V(StringAdd) \ | 97 V(StringAdd) \ |
| 98 V(ToBoolean) \ | 98 V(ToBooleanIC) \ |
| 99 V(TransitionElementsKind) \ | 99 V(TransitionElementsKind) \ |
| 100 V(KeyedLoadIC) \ | 100 V(KeyedLoadIC) \ |
| 101 V(LoadIC) \ | 101 V(LoadIC) \ |
| 102 /* TurboFanCodeStubs */ \ | 102 /* TurboFanCodeStubs */ \ |
| 103 V(StringLength) \ | 103 V(StringLength) \ |
| 104 V(ToBoolean) \ |
| 104 /* IC Handler stubs */ \ | 105 /* IC Handler stubs */ \ |
| 105 V(ArrayBufferViewLoadField) \ | 106 V(ArrayBufferViewLoadField) \ |
| 106 V(LoadConstant) \ | 107 V(LoadConstant) \ |
| 107 V(LoadFastElement) \ | 108 V(LoadFastElement) \ |
| 108 V(LoadField) \ | 109 V(LoadField) \ |
| 109 V(KeyedLoadSloppyArguments) \ | 110 V(KeyedLoadSloppyArguments) \ |
| 110 V(KeyedStoreSloppyArguments) \ | 111 V(KeyedStoreSloppyArguments) \ |
| 111 V(StoreField) \ | 112 V(StoreField) \ |
| 112 V(StoreGlobal) \ | 113 V(StoreGlobal) \ |
| 113 V(StoreTransition) | 114 V(StoreTransition) |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 624 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 624 InlineCacheState GetICState() const override { return MONOMORPHIC; } | 625 InlineCacheState GetICState() const override { return MONOMORPHIC; } |
| 625 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } | 626 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
| 626 | 627 |
| 627 void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; | 628 void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; |
| 628 | 629 |
| 629 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); | 630 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
| 630 DEFINE_CODE_STUB(StringLength, TurboFanCodeStub); | 631 DEFINE_CODE_STUB(StringLength, TurboFanCodeStub); |
| 631 }; | 632 }; |
| 632 | 633 |
| 634 class ToBooleanStub final : public TurboFanCodeStub { |
| 635 public: |
| 636 explicit ToBooleanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 637 |
| 638 void GenerateAssembly(compiler::CodeStubAssembler* assembler) const final; |
| 639 |
| 640 DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean); |
| 641 DEFINE_CODE_STUB(ToBoolean, TurboFanCodeStub); |
| 642 }; |
| 633 | 643 |
| 634 enum StringAddFlags { | 644 enum StringAddFlags { |
| 635 // Omit both parameter checks. | 645 // Omit both parameter checks. |
| 636 STRING_ADD_CHECK_NONE = 0, | 646 STRING_ADD_CHECK_NONE = 0, |
| 637 // Check left parameter. | 647 // Check left parameter. |
| 638 STRING_ADD_CHECK_LEFT = 1 << 0, | 648 STRING_ADD_CHECK_LEFT = 1 << 0, |
| 639 // Check right parameter. | 649 // Check right parameter. |
| 640 STRING_ADD_CHECK_RIGHT = 1 << 1, | 650 STRING_ADD_CHECK_RIGHT = 1 << 1, |
| 641 // Check both parameters. | 651 // Check both parameters. |
| 642 STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT, | 652 STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT, |
| (...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 private: | 2639 private: |
| 2630 ElementsKind elements_kind() const { | 2640 ElementsKind elements_kind() const { |
| 2631 return ElementsKindBits::decode(minor_key_); | 2641 return ElementsKindBits::decode(minor_key_); |
| 2632 } | 2642 } |
| 2633 | 2643 |
| 2634 class ElementsKindBits : public BitField<ElementsKind, 3, 8> {}; | 2644 class ElementsKindBits : public BitField<ElementsKind, 3, 8> {}; |
| 2635 | 2645 |
| 2636 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); | 2646 DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); |
| 2637 }; | 2647 }; |
| 2638 | 2648 |
| 2639 | 2649 class ToBooleanICStub : public HydrogenCodeStub { |
| 2640 class ToBooleanStub: public HydrogenCodeStub { | |
| 2641 public: | 2650 public: |
| 2642 enum Type { | 2651 enum Type { |
| 2643 UNDEFINED, | 2652 UNDEFINED, |
| 2644 BOOLEAN, | 2653 BOOLEAN, |
| 2645 NULL_TYPE, | 2654 NULL_TYPE, |
| 2646 SMI, | 2655 SMI, |
| 2647 SPEC_OBJECT, | 2656 SPEC_OBJECT, |
| 2648 STRING, | 2657 STRING, |
| 2649 SYMBOL, | 2658 SYMBOL, |
| 2650 HEAP_NUMBER, | 2659 HEAP_NUMBER, |
| 2651 SIMD_VALUE, | 2660 SIMD_VALUE, |
| 2652 NUMBER_OF_TYPES | 2661 NUMBER_OF_TYPES |
| 2653 }; | 2662 }; |
| 2654 | 2663 |
| 2655 // At most 16 different types can be distinguished, because the Code object | 2664 // At most 16 different types can be distinguished, because the Code object |
| 2656 // only has room for two bytes to hold a set of these types. :-P | 2665 // only has room for two bytes to hold a set of these types. :-P |
| 2657 STATIC_ASSERT(NUMBER_OF_TYPES <= 16); | 2666 STATIC_ASSERT(NUMBER_OF_TYPES <= 16); |
| 2658 | 2667 |
| 2659 class Types : public EnumSet<Type, uint16_t> { | 2668 class Types : public EnumSet<Type, uint16_t> { |
| 2660 public: | 2669 public: |
| 2661 Types() : EnumSet<Type, uint16_t>(0) {} | 2670 Types() : EnumSet<Type, uint16_t>(0) {} |
| 2662 explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {} | 2671 explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {} |
| 2663 | 2672 |
| 2664 bool UpdateStatus(Handle<Object> object); | 2673 bool UpdateStatus(Handle<Object> object); |
| 2665 bool NeedsMap() const; | 2674 bool NeedsMap() const; |
| 2666 bool CanBeUndetectable() const { | 2675 bool CanBeUndetectable() const { |
| 2667 return Contains(ToBooleanStub::SPEC_OBJECT); | 2676 return Contains(ToBooleanICStub::SPEC_OBJECT); |
| 2668 } | 2677 } |
| 2669 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } | 2678 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
| 2670 | 2679 |
| 2671 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 2680 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
| 2672 }; | 2681 }; |
| 2673 | 2682 |
| 2674 ToBooleanStub(Isolate* isolate, ExtraICState state) | 2683 ToBooleanICStub(Isolate* isolate, ExtraICState state) |
| 2675 : HydrogenCodeStub(isolate) { | 2684 : HydrogenCodeStub(isolate) { |
| 2676 set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state))); | 2685 set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state))); |
| 2677 } | 2686 } |
| 2678 | 2687 |
| 2679 bool UpdateStatus(Handle<Object> object); | 2688 bool UpdateStatus(Handle<Object> object); |
| 2680 Types types() const { return Types(TypesBits::decode(sub_minor_key())); } | 2689 Types types() const { return Types(TypesBits::decode(sub_minor_key())); } |
| 2681 | 2690 |
| 2682 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } | 2691 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } |
| 2683 void PrintState(std::ostream& os) const override; // NOLINT | 2692 void PrintState(std::ostream& os) const override; // NOLINT |
| 2684 | 2693 |
| 2685 bool SometimesSetsUpAFrame() override { return false; } | 2694 bool SometimesSetsUpAFrame() override { return false; } |
| 2686 | 2695 |
| 2687 static Handle<Code> GetUninitialized(Isolate* isolate) { | 2696 static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 2688 return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); | 2697 return ToBooleanICStub(isolate, UNINITIALIZED).GetCode(); |
| 2689 } | 2698 } |
| 2690 | 2699 |
| 2691 ExtraICState GetExtraICState() const override { return types().ToIntegral(); } | 2700 ExtraICState GetExtraICState() const override { return types().ToIntegral(); } |
| 2692 | 2701 |
| 2693 InlineCacheState GetICState() const override { | 2702 InlineCacheState GetICState() const override { |
| 2694 if (types().IsEmpty()) { | 2703 if (types().IsEmpty()) { |
| 2695 return ::v8::internal::UNINITIALIZED; | 2704 return ::v8::internal::UNINITIALIZED; |
| 2696 } else { | 2705 } else { |
| 2697 return MONOMORPHIC; | 2706 return MONOMORPHIC; |
| 2698 } | 2707 } |
| 2699 } | 2708 } |
| 2700 | 2709 |
| 2701 private: | 2710 private: |
| 2702 ToBooleanStub(Isolate* isolate, InitializationState init_state) | 2711 ToBooleanICStub(Isolate* isolate, InitializationState init_state) |
| 2703 : HydrogenCodeStub(isolate, init_state) { | 2712 : HydrogenCodeStub(isolate, init_state) {} |
| 2704 } | |
| 2705 | 2713 |
| 2706 class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {}; | 2714 class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {}; |
| 2707 | 2715 |
| 2708 DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean); | 2716 DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean); |
| 2709 DEFINE_HYDROGEN_CODE_STUB(ToBoolean, HydrogenCodeStub); | 2717 DEFINE_HYDROGEN_CODE_STUB(ToBooleanIC, HydrogenCodeStub); |
| 2710 }; | 2718 }; |
| 2711 | 2719 |
| 2712 | 2720 std::ostream& operator<<(std::ostream& os, const ToBooleanICStub::Types& t); |
| 2713 std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& t); | |
| 2714 | |
| 2715 | 2721 |
| 2716 class ElementsTransitionAndStoreStub : public HydrogenCodeStub { | 2722 class ElementsTransitionAndStoreStub : public HydrogenCodeStub { |
| 2717 public: | 2723 public: |
| 2718 ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, | 2724 ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, |
| 2719 ElementsKind to_kind, bool is_jsarray, | 2725 ElementsKind to_kind, bool is_jsarray, |
| 2720 KeyedAccessStoreMode store_mode) | 2726 KeyedAccessStoreMode store_mode) |
| 2721 : HydrogenCodeStub(isolate) { | 2727 : HydrogenCodeStub(isolate) { |
| 2722 set_sub_minor_key(CommonStoreModeBits::encode(store_mode) | | 2728 set_sub_minor_key(CommonStoreModeBits::encode(store_mode) | |
| 2723 FromBits::encode(from_kind) | ToBits::encode(to_kind) | | 2729 FromBits::encode(from_kind) | ToBits::encode(to_kind) | |
| 2724 IsJSArrayBits::encode(is_jsarray)); | 2730 IsJSArrayBits::encode(is_jsarray)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2875 #undef DEFINE_HYDROGEN_CODE_STUB | 2881 #undef DEFINE_HYDROGEN_CODE_STUB |
| 2876 #undef DEFINE_CODE_STUB | 2882 #undef DEFINE_CODE_STUB |
| 2877 #undef DEFINE_CODE_STUB_BASE | 2883 #undef DEFINE_CODE_STUB_BASE |
| 2878 | 2884 |
| 2879 extern Representation RepresentationFromType(Type* type); | 2885 extern Representation RepresentationFromType(Type* type); |
| 2880 | 2886 |
| 2881 } // namespace internal | 2887 } // namespace internal |
| 2882 } // namespace v8 | 2888 } // namespace v8 |
| 2883 | 2889 |
| 2884 #endif // V8_CODE_STUBS_H_ | 2890 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |