Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "src/hydrogen-types.h" | 7 #include "src/hydrogen-types.h" |
| 8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
| 9 #include "src/ostreams.h" | |
| 9 #include "src/types.h" | 10 #include "src/types.h" |
| 10 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
| 11 | 12 |
| 12 using namespace v8::internal; | 13 using namespace v8::internal; |
| 13 | 14 |
| 14 // Testing auxiliaries (breaking the Type abstraction). | 15 // Testing auxiliaries (breaking the Type abstraction). |
| 15 struct ZoneRep { | 16 struct ZoneRep { |
| 16 typedef void* Struct; | 17 typedef void* Struct; |
| 17 | 18 |
| 18 static bool IsStruct(Type* t, int tag) { | 19 static bool IsStruct(Type* t, int tag) { |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1312 CheckEqual(union_type, type); | 1313 CheckEqual(union_type, type); |
| 1313 } | 1314 } |
| 1314 | 1315 |
| 1315 // Commutativity: Union(T1, T2) = Union(T2, T1) | 1316 // Commutativity: Union(T1, T2) = Union(T2, T1) |
| 1316 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1317 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1317 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1318 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1318 TypeHandle type1 = *it1; | 1319 TypeHandle type1 = *it1; |
| 1319 TypeHandle type2 = *it2; | 1320 TypeHandle type2 = *it2; |
| 1320 TypeHandle union12 = T.Union(type1, type2); | 1321 TypeHandle union12 = T.Union(type1, type2); |
| 1321 TypeHandle union21 = T.Union(type2, type1); | 1322 TypeHandle union21 = T.Union(type2, type1); |
| 1323 OFStream os(stdout); | |
|
rossberg
2014/08/05 15:07:53
Yeah, I don't like committing this. Either all tes
neis
2014/08/05 17:01:10
Done.
| |
| 1324 type1->PrintTo(os); | |
| 1325 os << " \\/ "; | |
| 1326 type2->PrintTo(os); | |
| 1327 os << " = "; | |
| 1328 union12->PrintTo(os); | |
| 1329 os << "\n"; | |
| 1322 CheckEqual(union12, union21); | 1330 CheckEqual(union12, union21); |
| 1323 } | 1331 } |
| 1324 } | 1332 } |
| 1325 | 1333 |
| 1326 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) | 1334 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) |
| 1327 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1335 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1328 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1336 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1329 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1337 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1330 TypeHandle type1 = *it1; | 1338 TypeHandle type1 = *it1; |
| 1331 TypeHandle type2 = *it2; | 1339 TypeHandle type2 = *it2; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1540 CheckEqual(intersect_type, type); | 1548 CheckEqual(intersect_type, type); |
| 1541 } | 1549 } |
| 1542 | 1550 |
| 1543 // Commutativity: Intersect(T1, T2) = Intersect(T2, T1) | 1551 // Commutativity: Intersect(T1, T2) = Intersect(T2, T1) |
| 1544 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1552 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1545 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1553 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1546 TypeHandle type1 = *it1; | 1554 TypeHandle type1 = *it1; |
| 1547 TypeHandle type2 = *it2; | 1555 TypeHandle type2 = *it2; |
| 1548 TypeHandle intersect12 = T.Intersect(type1, type2); | 1556 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1549 TypeHandle intersect21 = T.Intersect(type2, type1); | 1557 TypeHandle intersect21 = T.Intersect(type2, type1); |
| 1558 OFStream os(stdout); | |
| 1559 type1->PrintTo(os); | |
| 1560 os << " /\\ "; | |
| 1561 type2->PrintTo(os); | |
| 1562 os << " = "; | |
| 1563 intersect12->PrintTo(os); | |
| 1564 os << "\n"; | |
| 1550 CheckEqual(intersect12, intersect21); | 1565 CheckEqual(intersect12, intersect21); |
| 1551 } | 1566 } |
| 1552 } | 1567 } |
| 1553 | 1568 |
| 1554 // Associativity: | 1569 // Associativity: |
| 1555 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) | 1570 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) |
| 1556 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1571 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1557 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1572 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1558 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1573 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1559 TypeHandle type1 = *it1; | 1574 TypeHandle type1 = *it1; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1944 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 1959 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
| 1945 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 1960 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
| 1946 } | 1961 } |
| 1947 | 1962 |
| 1948 | 1963 |
| 1949 TEST(HTypeFromType) { | 1964 TEST(HTypeFromType) { |
| 1950 CcTest::InitializeVM(); | 1965 CcTest::InitializeVM(); |
| 1951 ZoneTests().HTypeFromType(); | 1966 ZoneTests().HTypeFromType(); |
| 1952 HeapTests().HTypeFromType(); | 1967 HeapTests().HTypeFromType(); |
| 1953 } | 1968 } |
| OLD | NEW |