| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 UNREACHABLE(); | 169 UNREACHABLE(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 Region* region_; | 173 Region* region_; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 | 176 |
| 177 // Testing auxiliaries (breaking the Type abstraction). | 177 // Testing auxiliaries (breaking the Type abstraction). |
| 178 struct ZoneRep { | 178 struct ZoneRep { |
| 179 struct Struct { int tag; int length; void* args[1]; }; | 179 typedef void* Struct; |
| 180 | 180 |
| 181 static bool IsStruct(Type* t, int tag) { | 181 static bool IsStruct(Type* t, int tag) { |
| 182 return !IsBitset(t) && AsStruct(t)->tag == tag; | 182 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; |
| 183 } | 183 } |
| 184 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } | 184 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } |
| 185 static bool IsClass(Type* t) { return IsStruct(t, 0); } | 185 static bool IsClass(Type* t) { return IsStruct(t, 0); } |
| 186 static bool IsConstant(Type* t) { return IsStruct(t, 1); } | 186 static bool IsConstant(Type* t) { return IsStruct(t, 1); } |
| 187 static bool IsUnion(Type* t) { return IsStruct(t, 2); } | 187 static bool IsUnion(Type* t) { return IsStruct(t, 2); } |
| 188 | 188 |
| 189 static Struct* AsStruct(Type* t) { | 189 static Struct* AsStruct(Type* t) { |
| 190 return reinterpret_cast<Struct*>(t); | 190 return reinterpret_cast<Struct*>(t); |
| 191 } | 191 } |
| 192 static int AsBitset(Type* t) { | 192 static int AsBitset(Type* t) { |
| 193 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); | 193 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); |
| 194 } | 194 } |
| 195 static Map* AsClass(Type* t) { | 195 static Map* AsClass(Type* t) { |
| 196 return *static_cast<Map**>(AsStruct(t)->args[1]); | 196 return *static_cast<Map**>(AsStruct(t)[3]); |
| 197 } | 197 } |
| 198 static Object* AsConstant(Type* t) { | 198 static Object* AsConstant(Type* t) { |
| 199 return *static_cast<Object**>(AsStruct(t)->args[1]); | 199 return *static_cast<Object**>(AsStruct(t)[3]); |
| 200 } | 200 } |
| 201 static Struct* AsUnion(Type* t) { | 201 static Struct* AsUnion(Type* t) { |
| 202 return AsStruct(t); | 202 return AsStruct(t); |
| 203 } | 203 } |
| 204 static int Length(Struct* structured) { return structured->length; } | 204 static int Length(Struct* structured) { |
| 205 return static_cast<int>(reinterpret_cast<intptr_t>(structured[1])); |
| 206 } |
| 205 | 207 |
| 206 static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; } | 208 static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; } |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 | 211 |
| 210 struct HeapRep { | 212 struct HeapRep { |
| 211 typedef FixedArray Struct; | 213 typedef FixedArray Struct; |
| 212 | 214 |
| 213 static bool IsStruct(Handle<HeapType> t, int tag) { | 215 static bool IsStruct(Handle<HeapType> t, int tag) { |
| 214 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; | 216 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 ZoneTests().Intersect(); | 887 ZoneTests().Intersect(); |
| 886 HeapTests().Intersect(); | 888 HeapTests().Intersect(); |
| 887 } | 889 } |
| 888 | 890 |
| 889 | 891 |
| 890 TEST(Convert) { | 892 TEST(Convert) { |
| 891 CcTest::InitializeVM(); | 893 CcTest::InitializeVM(); |
| 892 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 894 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
| 893 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 895 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
| 894 } | 896 } |
| OLD | NEW |