| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return Type::Intersect(t1, t2, region_); | 119 return Type::Intersect(t1, t2, region_); |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 Region* region_; | 123 Region* region_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 | 126 |
| 127 // Testing auxiliaries (breaking the Type abstraction). | 127 // Testing auxiliaries (breaking the Type abstraction). |
| 128 struct ZoneRep { | 128 struct ZoneRep { |
| 129 static bool IsTagged(ZoneType* t, int tag) { | 129 static bool IsTagged(Type* t, int tag) { |
| 130 return !IsBitset(t) | 130 return !IsBitset(t) |
| 131 && reinterpret_cast<intptr_t>(AsTagged(t)->at(0)) == tag; | 131 && reinterpret_cast<intptr_t>(AsTagged(t)->at(0)) == tag; |
| 132 } | 132 } |
| 133 static bool IsBitset(ZoneType* t) { | 133 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } |
| 134 return reinterpret_cast<intptr_t>(t) & 1; | 134 static bool IsClass(Type* t) { return IsTagged(t, 0); } |
| 135 } | 135 static bool IsConstant(Type* t) { return IsTagged(t, 1); } |
| 136 static bool IsClass(ZoneType* t) { return IsTagged(t, 0); } | 136 static bool IsUnion(Type* t) { return IsTagged(t, 2); } |
| 137 static bool IsConstant(ZoneType* t) { return IsTagged(t, 1); } | |
| 138 static bool IsUnion(ZoneType* t) { return IsTagged(t, 2); } | |
| 139 | 137 |
| 140 static ZoneList<void*>* AsTagged(ZoneType* t) { | 138 static ZoneList<void*>* AsTagged(Type* t) { |
| 141 return reinterpret_cast<ZoneList<void*>*>(t); | 139 return reinterpret_cast<ZoneList<void*>*>(t); |
| 142 } | 140 } |
| 143 static int AsBitset(ZoneType* t) { | 141 static int AsBitset(Type* t) { |
| 144 return reinterpret_cast<intptr_t>(t) >> 1; | 142 return reinterpret_cast<intptr_t>(t) >> 1; |
| 145 } | 143 } |
| 146 static Map* AsClass(ZoneType* t) { | 144 static Map* AsClass(Type* t) { |
| 147 return *reinterpret_cast<Map**>(AsTagged(t)->at(1)); | 145 return *reinterpret_cast<Map**>(AsTagged(t)->at(1)); |
| 148 } | 146 } |
| 149 static Object* AsConstant(ZoneType* t) { | 147 static Object* AsConstant(Type* t) { |
| 150 return *reinterpret_cast<Object**>(AsTagged(t)->at(1)); | 148 return *reinterpret_cast<Object**>(AsTagged(t)->at(1)); |
| 151 } | 149 } |
| 152 static ZoneList<ZoneType*>* AsUnion(ZoneType* t) { | 150 static ZoneList<Type*>* AsUnion(Type* t) { |
| 153 return reinterpret_cast<ZoneList<ZoneType*>*>(AsTagged(t)); | 151 return reinterpret_cast<ZoneList<Type*>*>(AsTagged(t)); |
| 154 } | 152 } |
| 155 | 153 |
| 156 static Zone* Region(Zone* zone, Isolate* isolate) { return zone; } | 154 static Zone* Region(Zone* zone, Isolate* isolate) { return zone; } |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 | 157 |
| 160 struct HeapRep { | 158 struct HeapRep { |
| 161 static bool IsBitset(Handle<Type> t) { return t->IsSmi(); } | 159 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } |
| 162 static bool IsClass(Handle<Type> t) { return t->IsMap(); } | 160 static bool IsClass(Handle<HeapType> t) { return t->IsMap(); } |
| 163 static bool IsConstant(Handle<Type> t) { return t->IsBox(); } | 161 static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); } |
| 164 static bool IsUnion(Handle<Type> t) { return t->IsFixedArray(); } | 162 static bool IsUnion(Handle<HeapType> t) { return t->IsFixedArray(); } |
| 165 | 163 |
| 166 static int AsBitset(Handle<Type> t) { return Smi::cast(*t)->value(); } | 164 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } |
| 167 static Map* AsClass(Handle<Type> t) { return Map::cast(*t); } | 165 static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); } |
| 168 static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); } | 166 static Object* AsConstant(Handle<HeapType> t) { |
| 169 static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); } | 167 return Box::cast(*t)->value(); |
| 168 } |
| 169 static FixedArray* AsUnion(Handle<HeapType> t) { |
| 170 return FixedArray::cast(*t); |
| 171 } |
| 170 | 172 |
| 171 static Isolate* Region(Zone* zone, Isolate* isolate) { return isolate; } | 173 static Isolate* Region(Zone* zone, Isolate* isolate) { return isolate; } |
| 172 }; | 174 }; |
| 173 | 175 |
| 174 | 176 |
| 175 template<class Type, class TypeHandle, class Region, class Rep> | 177 template<class Type, class TypeHandle, class Region, class Rep> |
| 176 struct Tests : Rep { | 178 struct Tests : Rep { |
| 177 Isolate* isolate; | 179 Isolate* isolate; |
| 178 HandleScope scope; | 180 HandleScope scope; |
| 179 Zone zone; | 181 Zone zone; |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 T.Union(T.ArrayConstant1, T.ObjectConstant2))), | 750 T.Union(T.ArrayConstant1, T.ObjectConstant2))), |
| 749 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 751 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 750 CheckEqual( | 752 CheckEqual( |
| 751 T.Intersect( | 753 T.Intersect( |
| 752 T.Union(T.ObjectConstant2, T.ArrayConstant1), | 754 T.Union(T.ObjectConstant2, T.ArrayConstant1), |
| 753 T.Union(T.ObjectConstant1, T.ArrayConstant2)), | 755 T.Union(T.ObjectConstant1, T.ArrayConstant2)), |
| 754 T.ArrayConstant1); | 756 T.ArrayConstant1); |
| 755 } | 757 } |
| 756 }; | 758 }; |
| 757 | 759 |
| 758 typedef Tests<ZoneType, ZoneType*, Zone, ZoneRep> ZoneTests; | 760 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
| 759 typedef Tests<Type, Handle<Type>, Isolate, HeapRep> HeapTests; | 761 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
| 760 | 762 |
| 761 | 763 |
| 762 TEST(Bitset) { | 764 TEST(Bitset) { |
| 763 CcTest::InitializeVM(); | 765 CcTest::InitializeVM(); |
| 764 ZoneTests().Bitset(); | 766 ZoneTests().Bitset(); |
| 765 HeapTests().Bitset(); | 767 HeapTests().Bitset(); |
| 766 } | 768 } |
| 767 | 769 |
| 768 | 770 |
| 769 TEST(Class) { | 771 TEST(Class) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 799 ZoneTests().Union(); | 801 ZoneTests().Union(); |
| 800 HeapTests().Union(); | 802 HeapTests().Union(); |
| 801 } | 803 } |
| 802 | 804 |
| 803 | 805 |
| 804 TEST(Intersect) { | 806 TEST(Intersect) { |
| 805 CcTest::InitializeVM(); | 807 CcTest::InitializeVM(); |
| 806 ZoneTests().Intersect(); | 808 ZoneTests().Intersect(); |
| 807 HeapTests().Intersect(); | 809 HeapTests().Intersect(); |
| 808 } | 810 } |
| OLD | NEW |