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