Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: src/code-stubs.h

Issue 1202973003: Expand ToBoolean stub so it can handle more types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 HEAP_NUMBER, 2730 HEAP_NUMBER,
2731 NUMBER_OF_TYPES 2731 NUMBER_OF_TYPES
2732 }; 2732 };
2733 2733
2734 enum ResultMode { 2734 enum ResultMode {
2735 RESULT_AS_SMI, // For Smi(1) on truthy value, Smi(0) otherwise. 2735 RESULT_AS_SMI, // For Smi(1) on truthy value, Smi(0) otherwise.
2736 RESULT_AS_ODDBALL, // For {true} on truthy value, {false} otherwise. 2736 RESULT_AS_ODDBALL, // For {true} on truthy value, {false} otherwise.
2737 RESULT_AS_INVERSE_ODDBALL // For {false} on truthy value, {true} otherwise. 2737 RESULT_AS_INVERSE_ODDBALL // For {false} on truthy value, {true} otherwise.
2738 }; 2738 };
2739 2739
2740 // At most 8 different types can be distinguished, because the Code object 2740 // At most 16 different types can be distinguished, because the Code object
2741 // only has room for a single byte to hold a set of these types. :-P 2741 // only has room for two bytes to hold a set of these types. :-P
2742 STATIC_ASSERT(NUMBER_OF_TYPES <= 8); 2742 STATIC_ASSERT(NUMBER_OF_TYPES <= 16);
2743 2743
2744 class Types : public EnumSet<Type, byte> { 2744 class Types : public EnumSet<Type, uint16_t> {
2745 public: 2745 public:
2746 Types() : EnumSet<Type, byte>(0) {} 2746 Types() : EnumSet<Type, uint16_t>(0) {}
2747 explicit Types(byte bits) : EnumSet<Type, byte>(bits) {} 2747 explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {}
2748 2748
2749 byte ToByte() const { return ToIntegral(); }
2750 bool UpdateStatus(Handle<Object> object); 2749 bool UpdateStatus(Handle<Object> object);
2751 bool NeedsMap() const; 2750 bool NeedsMap() const;
2752 bool CanBeUndetectable() const; 2751 bool CanBeUndetectable() const;
2753 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } 2752 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); }
2754 2753
2755 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } 2754 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); }
2756 }; 2755 };
2757 2756
2758 ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types()) 2757 ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types())
2759 : HydrogenCodeStub(isolate) { 2758 : HydrogenCodeStub(isolate) {
2760 set_sub_minor_key(TypesBits::encode(types.ToByte()) | 2759 set_sub_minor_key(TypesBits::encode(types.ToIntegral()) |
2761 ResultModeBits::encode(mode)); 2760 ResultModeBits::encode(mode));
2762 } 2761 }
2763 2762
2764 ToBooleanStub(Isolate* isolate, ExtraICState state) 2763 ToBooleanStub(Isolate* isolate, ExtraICState state)
2765 : HydrogenCodeStub(isolate) { 2764 : HydrogenCodeStub(isolate) {
2766 set_sub_minor_key(TypesBits::encode(static_cast<byte>(state)) | 2765 set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state)) |
2767 ResultModeBits::encode(RESULT_AS_SMI)); 2766 ResultModeBits::encode(RESULT_AS_SMI));
2768 } 2767 }
2769 2768
2770 bool UpdateStatus(Handle<Object> object); 2769 bool UpdateStatus(Handle<Object> object);
2771 Types types() const { return Types(TypesBits::decode(sub_minor_key())); } 2770 Types types() const { return Types(TypesBits::decode(sub_minor_key())); }
2772 ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); } 2771 ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); }
2773 2772
2774 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } 2773 Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; }
2775 void PrintState(std::ostream& os) const override; // NOLINT 2774 void PrintState(std::ostream& os) const override; // NOLINT
2776 2775
(...skipping 12 matching lines...) Expand all
2789 return MONOMORPHIC; 2788 return MONOMORPHIC;
2790 } 2789 }
2791 } 2790 }
2792 2791
2793 private: 2792 private:
2794 ToBooleanStub(Isolate* isolate, InitializationState init_state) 2793 ToBooleanStub(Isolate* isolate, InitializationState init_state)
2795 : HydrogenCodeStub(isolate, init_state) { 2794 : HydrogenCodeStub(isolate, init_state) {
2796 set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI)); 2795 set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI));
2797 } 2796 }
2798 2797
2799 class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {}; 2798 class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {};
2800 class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {}; 2799 class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
2801 2800
2802 DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean); 2801 DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean);
2803 DEFINE_HYDROGEN_CODE_STUB(ToBoolean, HydrogenCodeStub); 2802 DEFINE_HYDROGEN_CODE_STUB(ToBoolean, HydrogenCodeStub);
2804 }; 2803 };
2805 2804
2806 2805
2807 std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& t); 2806 std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& t);
2808 2807
2809 2808
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 2959
2961 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR 2960 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR
2962 #undef DEFINE_PLATFORM_CODE_STUB 2961 #undef DEFINE_PLATFORM_CODE_STUB
2963 #undef DEFINE_HANDLER_CODE_STUB 2962 #undef DEFINE_HANDLER_CODE_STUB
2964 #undef DEFINE_HYDROGEN_CODE_STUB 2963 #undef DEFINE_HYDROGEN_CODE_STUB
2965 #undef DEFINE_CODE_STUB 2964 #undef DEFINE_CODE_STUB
2966 #undef DEFINE_CODE_STUB_BASE 2965 #undef DEFINE_CODE_STUB_BASE
2967 } } // namespace v8::internal 2966 } } // namespace v8::internal
2968 2967
2969 #endif // V8_CODE_STUBS_H_ 2968 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « no previous file | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698