| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 }; | 898 }; |
| 899 | 899 |
| 900 | 900 |
| 901 class ToBooleanStub: public CodeStub { | 901 class ToBooleanStub: public CodeStub { |
| 902 public: | 902 public: |
| 903 enum Type { | 903 enum Type { |
| 904 UNDEFINED, | 904 UNDEFINED, |
| 905 BOOLEAN, | 905 BOOLEAN, |
| 906 NULL_TYPE, | 906 NULL_TYPE, |
| 907 SMI, | 907 SMI, |
| 908 UNDETECTABLE, | |
| 909 SPEC_OBJECT, | 908 SPEC_OBJECT, |
| 910 STRING, | 909 STRING, |
| 911 HEAP_NUMBER, | 910 HEAP_NUMBER, |
| 912 INTERNAL_OBJECT, | 911 INTERNAL_OBJECT, |
| 913 NUMBER_OF_TYPES | 912 NUMBER_OF_TYPES |
| 914 }; | 913 }; |
| 915 | 914 |
| 915 // At most 8 different types can be distinguished, because the Code object |
| 916 // only has room for a single byte to hold a set of these types. :-P |
| 917 STATIC_ASSERT(NUMBER_OF_TYPES <= 8); |
| 918 |
| 916 class Types { | 919 class Types { |
| 917 public: | 920 public: |
| 918 Types() {} | 921 Types() {} |
| 919 explicit Types(int bits) : set_(bits) {} | 922 explicit Types(byte bits) : set_(bits) {} |
| 920 | 923 |
| 921 bool IsEmpty() const { return set_.IsEmpty(); } | 924 bool IsEmpty() const { return set_.IsEmpty(); } |
| 922 bool Contains(Type type) const { return set_.Contains(type); } | 925 bool Contains(Type type) const { return set_.Contains(type); } |
| 923 void Add(Type type) { set_.Add(type); } | 926 void Add(Type type) { set_.Add(type); } |
| 924 int ToInt() const { return set_.ToIntegral(); } | 927 byte ToByte() const { return set_.ToIntegral(); } |
| 925 void Print(StringStream* stream); | 928 void Print(StringStream* stream); |
| 926 void TraceTransition(Types to); | 929 void TraceTransition(Types to); |
| 927 bool Record(Handle<Object> object); | 930 bool Record(Handle<Object> object); |
| 928 | 931 |
| 929 private: | 932 private: |
| 930 EnumSet<Type> set_; | 933 EnumSet<Type, byte> set_; |
| 931 }; | 934 }; |
| 932 | 935 |
| 933 explicit ToBooleanStub(Register tos, Types types = Types()) | 936 explicit ToBooleanStub(Register tos, Types types = Types()) |
| 934 : tos_(tos), types_(types) { } | 937 : tos_(tos), types_(types) { } |
| 935 | 938 |
| 936 void Generate(MacroAssembler* masm); | 939 void Generate(MacroAssembler* masm); |
| 937 virtual int GetCodeKind() { return Code::TO_BOOLEAN_IC; } | 940 virtual int GetCodeKind() { return Code::TO_BOOLEAN_IC; } |
| 938 virtual void PrintName(StringStream* stream); | 941 virtual void PrintName(StringStream* stream); |
| 939 | 942 |
| 940 private: | 943 private: |
| 941 Major MajorKey() { return ToBoolean; } | 944 Major MajorKey() { return ToBoolean; } |
| 942 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToInt(); } | 945 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToByte(); } |
| 946 |
| 947 virtual void FinishCode(Code* code) { |
| 948 code->set_to_boolean_state(types_.ToByte()); |
| 949 } |
| 943 | 950 |
| 944 void CheckOddball(MacroAssembler* masm, | 951 void CheckOddball(MacroAssembler* masm, |
| 945 Type type, | 952 Type type, |
| 946 Handle<Object> value, | 953 Handle<Object> value, |
| 947 bool result, | 954 bool result, |
| 948 Label* patch); | 955 Label* patch); |
| 949 void GenerateTypeTransition(MacroAssembler* masm); | 956 void GenerateTypeTransition(MacroAssembler* masm); |
| 950 | 957 |
| 951 Register tos_; | 958 Register tos_; |
| 952 Types types_; | 959 Types types_; |
| 953 }; | 960 }; |
| 954 | 961 |
| 955 } } // namespace v8::internal | 962 } } // namespace v8::internal |
| 956 | 963 |
| 957 #endif // V8_CODE_STUBS_H_ | 964 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |