| 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SPEC_OBJECT, | 908 SPEC_OBJECT, |
| 909 STRING, | 909 STRING, |
| 910 HEAP_NUMBER, | 910 HEAP_NUMBER, |
| 911 INTERNAL_OBJECT, | |
| 912 NUMBER_OF_TYPES | 911 NUMBER_OF_TYPES |
| 913 }; | 912 }; |
| 914 | 913 |
| 915 // At most 8 different types can be distinguished, because the Code object | 914 // 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 | 915 // only has room for a single byte to hold a set of these types. :-P |
| 917 STATIC_ASSERT(NUMBER_OF_TYPES <= 8); | 916 STATIC_ASSERT(NUMBER_OF_TYPES <= 8); |
| 918 | 917 |
| 919 class Types { | 918 class Types { |
| 920 public: | 919 public: |
| 921 Types() {} | 920 Types() {} |
| 922 explicit Types(byte bits) : set_(bits) {} | 921 explicit Types(byte bits) : set_(bits) {} |
| 923 | 922 |
| 924 bool IsEmpty() const { return set_.IsEmpty(); } | 923 bool IsEmpty() const { return set_.IsEmpty(); } |
| 925 bool IsAll() const { return ToByte() == ((1 << NUMBER_OF_TYPES) - 1); } | |
| 926 bool Contains(Type type) const { return set_.Contains(type); } | 924 bool Contains(Type type) const { return set_.Contains(type); } |
| 927 void Add(Type type) { set_.Add(type); } | 925 void Add(Type type) { set_.Add(type); } |
| 928 byte ToByte() const { return set_.ToIntegral(); } | 926 byte ToByte() const { return set_.ToIntegral(); } |
| 929 void Print(StringStream* stream) const; | 927 void Print(StringStream* stream) const; |
| 930 void TraceTransition(Types to) const; | 928 void TraceTransition(Types to) const; |
| 931 bool Record(Handle<Object> object); | 929 bool Record(Handle<Object> object); |
| 932 bool NeedsMap() const; | 930 bool NeedsMap() const; |
| 931 bool CanBeUndetectable() const; |
| 933 | 932 |
| 934 private: | 933 private: |
| 935 EnumSet<Type, byte> set_; | 934 EnumSet<Type, byte> set_; |
| 936 }; | 935 }; |
| 937 | 936 |
| 938 static Types no_types() { return Types(); } | 937 static Types no_types() { return Types(); } |
| 939 static Types all_types() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 938 static Types all_types() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
| 940 | 939 |
| 941 explicit ToBooleanStub(Register tos, Types types = Types()) | 940 explicit ToBooleanStub(Register tos, Types types = Types()) |
| 942 : tos_(tos), types_(types) { } | 941 : tos_(tos), types_(types) { } |
| 943 | 942 |
| 944 void Generate(MacroAssembler* masm); | 943 void Generate(MacroAssembler* masm); |
| 945 virtual int GetCodeKind() { return Code::TO_BOOLEAN_IC; } | 944 virtual int GetCodeKind() { return Code::TO_BOOLEAN_IC; } |
| 946 virtual void PrintName(StringStream* stream); | 945 virtual void PrintName(StringStream* stream); |
| 947 | 946 |
| 948 private: | 947 private: |
| 949 Major MajorKey() { return ToBoolean; } | 948 Major MajorKey() { return ToBoolean; } |
| 950 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToByte(); } | 949 int MinorKey() { return (tos_.code() << NUMBER_OF_TYPES) | types_.ToByte(); } |
| 951 | 950 |
| 952 virtual void FinishCode(Code* code) { | 951 virtual void FinishCode(Code* code) { |
| 953 code->set_to_boolean_state(types_.ToByte()); | 952 code->set_to_boolean_state(types_.ToByte()); |
| 954 } | 953 } |
| 955 | 954 |
| 956 void CheckOddball(MacroAssembler* masm, | 955 void CheckOddball(MacroAssembler* masm, |
| 957 Type type, | 956 Type type, |
| 958 Heap::RootListIndex value, | 957 Heap::RootListIndex value, |
| 959 bool result, | 958 bool result); |
| 960 Label* patch); | |
| 961 void GenerateTypeTransition(MacroAssembler* masm); | 959 void GenerateTypeTransition(MacroAssembler* masm); |
| 962 | 960 |
| 963 Register tos_; | 961 Register tos_; |
| 964 Types types_; | 962 Types types_; |
| 965 }; | 963 }; |
| 966 | 964 |
| 967 } } // namespace v8::internal | 965 } } // namespace v8::internal |
| 968 | 966 |
| 969 #endif // V8_CODE_STUBS_H_ | 967 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |