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/types.h" | 9 #include "src/types.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 CheckSub(T.InternalizedString, T.String); | 1011 CheckSub(T.InternalizedString, T.String); |
1012 CheckSub(T.InternalizedString, T.UniqueName); | 1012 CheckSub(T.InternalizedString, T.UniqueName); |
1013 CheckSub(T.InternalizedString, T.Name); | 1013 CheckSub(T.InternalizedString, T.Name); |
1014 CheckSub(T.Symbol, T.UniqueName); | 1014 CheckSub(T.Symbol, T.UniqueName); |
1015 CheckSub(T.Symbol, T.Name); | 1015 CheckSub(T.Symbol, T.Name); |
1016 CheckUnordered(T.String, T.UniqueName); | 1016 CheckUnordered(T.String, T.UniqueName); |
1017 CheckUnordered(T.String, T.Symbol); | 1017 CheckUnordered(T.String, T.Symbol); |
1018 CheckUnordered(T.InternalizedString, T.Symbol); | 1018 CheckUnordered(T.InternalizedString, T.Symbol); |
1019 | 1019 |
1020 CheckSub(T.Object, T.Receiver); | 1020 CheckSub(T.Object, T.Receiver); |
1021 CheckSub(T.Array, T.Object); | |
1022 CheckSub(T.Proxy, T.Receiver); | 1021 CheckSub(T.Proxy, T.Receiver); |
| 1022 CheckSub(T.OtherObject, T.Object); |
| 1023 CheckSub(T.Undetectable, T.Object); |
| 1024 CheckSub(T.DetectableObject, T.Object); |
| 1025 CheckSub(T.GlobalObject, T.DetectableObject); |
| 1026 CheckSub(T.OtherObject, T.DetectableObject); |
| 1027 CheckSub(T.GlobalObject, T.Object); |
| 1028 CheckSub(T.GlobalObject, T.Receiver); |
| 1029 |
1023 CheckUnordered(T.Object, T.Proxy); | 1030 CheckUnordered(T.Object, T.Proxy); |
1024 | 1031 CheckUnordered(T.GlobalObject, T.OtherObject); |
| 1032 CheckUnordered(T.DetectableObject, T.Undetectable); |
1025 | 1033 |
1026 // Subtyping between concrete structural types | 1034 // Subtyping between concrete structural types |
1027 | 1035 |
1028 CheckSub(T.ObjectClass, T.Object); | 1036 CheckSub(T.ObjectClass, T.Object); |
1029 CheckSub(T.ArrayClass, T.Object); | 1037 CheckSub(T.ArrayClass, T.OtherObject); |
1030 CheckSub(T.ArrayClass, T.Array); | |
1031 CheckSub(T.UninitializedClass, T.Internal); | 1038 CheckSub(T.UninitializedClass, T.Internal); |
1032 CheckUnordered(T.ObjectClass, T.ArrayClass); | 1039 CheckUnordered(T.ObjectClass, T.ArrayClass); |
1033 CheckUnordered(T.UninitializedClass, T.Null); | 1040 CheckUnordered(T.UninitializedClass, T.Null); |
1034 CheckUnordered(T.UninitializedClass, T.Undefined); | 1041 CheckUnordered(T.UninitializedClass, T.Undefined); |
1035 | 1042 |
1036 CheckSub(T.SmiConstant, T.SignedSmall); | 1043 CheckSub(T.SmiConstant, T.SignedSmall); |
1037 CheckSub(T.SmiConstant, T.Signed32); | 1044 CheckSub(T.SmiConstant, T.Signed32); |
1038 CheckSub(T.SmiConstant, T.Number); | 1045 CheckSub(T.SmiConstant, T.Number); |
1039 CheckSub(T.ObjectConstant1, T.Object); | 1046 CheckSub(T.ObjectConstant1, T.Object); |
1040 CheckSub(T.ObjectConstant2, T.Object); | 1047 CheckSub(T.ObjectConstant2, T.Object); |
1041 CheckSub(T.ArrayConstant, T.Object); | 1048 CheckSub(T.ArrayConstant, T.Object); |
1042 CheckSub(T.ArrayConstant, T.Array); | 1049 CheckSub(T.ArrayConstant, T.OtherObject); |
| 1050 CheckSub(T.ArrayConstant, T.Receiver); |
1043 CheckSub(T.UninitializedConstant, T.Internal); | 1051 CheckSub(T.UninitializedConstant, T.Internal); |
1044 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); | 1052 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); |
1045 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); | 1053 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); |
1046 CheckUnordered(T.UninitializedConstant, T.Null); | 1054 CheckUnordered(T.UninitializedConstant, T.Null); |
1047 CheckUnordered(T.UninitializedConstant, T.Undefined); | 1055 CheckUnordered(T.UninitializedConstant, T.Undefined); |
1048 | 1056 |
1049 CheckUnordered(T.ObjectConstant1, T.ObjectClass); | 1057 CheckUnordered(T.ObjectConstant1, T.ObjectClass); |
1050 CheckUnordered(T.ObjectConstant2, T.ObjectClass); | 1058 CheckUnordered(T.ObjectConstant2, T.ObjectClass); |
1051 CheckUnordered(T.ObjectConstant1, T.ArrayClass); | 1059 CheckUnordered(T.ObjectConstant1, T.ArrayClass); |
1052 CheckUnordered(T.ObjectConstant2, T.ArrayClass); | 1060 CheckUnordered(T.ObjectConstant2, T.ArrayClass); |
1053 CheckUnordered(T.ArrayConstant, T.ObjectClass); | 1061 CheckUnordered(T.ArrayConstant, T.ObjectClass); |
1054 | 1062 |
1055 CheckSub(T.NumberArray, T.Array); | 1063 CheckSub(T.NumberArray, T.OtherObject); |
| 1064 CheckSub(T.NumberArray, T.Receiver); |
1056 CheckSub(T.NumberArray, T.Object); | 1065 CheckSub(T.NumberArray, T.Object); |
1057 CheckUnordered(T.StringArray, T.AnyArray); | 1066 CheckUnordered(T.StringArray, T.AnyArray); |
1058 | 1067 |
1059 CheckSub(T.MethodFunction, T.Object); | 1068 CheckSub(T.MethodFunction, T.Object); |
1060 CheckSub(T.NumberFunction1, T.Object); | 1069 CheckSub(T.NumberFunction1, T.Object); |
1061 CheckUnordered(T.SignedFunction1, T.NumberFunction1); | 1070 CheckUnordered(T.SignedFunction1, T.NumberFunction1); |
1062 CheckUnordered(T.NumberFunction1, T.NumberFunction2); | 1071 CheckUnordered(T.NumberFunction1, T.NumberFunction2); |
1063 } | 1072 } |
1064 | 1073 |
1065 void NowIs() { | 1074 void NowIs() { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 CheckOverlap(T.String, T.Name); | 1343 CheckOverlap(T.String, T.Name); |
1335 CheckOverlap(T.InternalizedString, T.String); | 1344 CheckOverlap(T.InternalizedString, T.String); |
1336 CheckOverlap(T.InternalizedString, T.UniqueName); | 1345 CheckOverlap(T.InternalizedString, T.UniqueName); |
1337 CheckOverlap(T.InternalizedString, T.Name); | 1346 CheckOverlap(T.InternalizedString, T.Name); |
1338 CheckOverlap(T.Symbol, T.UniqueName); | 1347 CheckOverlap(T.Symbol, T.UniqueName); |
1339 CheckOverlap(T.Symbol, T.Name); | 1348 CheckOverlap(T.Symbol, T.Name); |
1340 CheckOverlap(T.String, T.UniqueName); | 1349 CheckOverlap(T.String, T.UniqueName); |
1341 CheckDisjoint(T.String, T.Symbol); | 1350 CheckDisjoint(T.String, T.Symbol); |
1342 CheckDisjoint(T.InternalizedString, T.Symbol); | 1351 CheckDisjoint(T.InternalizedString, T.Symbol); |
1343 CheckOverlap(T.Object, T.Receiver); | 1352 CheckOverlap(T.Object, T.Receiver); |
1344 CheckOverlap(T.Array, T.Object); | 1353 CheckOverlap(T.OtherObject, T.Object); |
| 1354 CheckOverlap(T.GlobalObject, T.Object); |
1345 CheckOverlap(T.Proxy, T.Receiver); | 1355 CheckOverlap(T.Proxy, T.Receiver); |
1346 CheckDisjoint(T.Object, T.Proxy); | 1356 CheckDisjoint(T.Object, T.Proxy); |
1347 | 1357 |
1348 // Structural types | 1358 // Structural types |
1349 CheckOverlap(T.ObjectClass, T.Object); | 1359 CheckOverlap(T.ObjectClass, T.Object); |
1350 CheckOverlap(T.ArrayClass, T.Object); | 1360 CheckOverlap(T.ArrayClass, T.Object); |
1351 CheckOverlap(T.ObjectClass, T.ObjectClass); | 1361 CheckOverlap(T.ObjectClass, T.ObjectClass); |
1352 CheckOverlap(T.ArrayClass, T.ArrayClass); | 1362 CheckOverlap(T.ArrayClass, T.ArrayClass); |
1353 CheckDisjoint(T.ObjectClass, T.ArrayClass); | 1363 CheckDisjoint(T.ObjectClass, T.ArrayClass); |
1354 CheckOverlap(T.SmiConstant, T.SignedSmall); | 1364 CheckOverlap(T.SmiConstant, T.SignedSmall); |
1355 CheckOverlap(T.SmiConstant, T.Signed32); | 1365 CheckOverlap(T.SmiConstant, T.Signed32); |
1356 CheckOverlap(T.SmiConstant, T.Number); | 1366 CheckOverlap(T.SmiConstant, T.Number); |
1357 CheckOverlap(T.ObjectConstant1, T.Object); | 1367 CheckOverlap(T.ObjectConstant1, T.Object); |
1358 CheckOverlap(T.ObjectConstant2, T.Object); | 1368 CheckOverlap(T.ObjectConstant2, T.Object); |
1359 CheckOverlap(T.ArrayConstant, T.Object); | 1369 CheckOverlap(T.ArrayConstant, T.Object); |
1360 CheckOverlap(T.ArrayConstant, T.Array); | 1370 CheckOverlap(T.ArrayConstant, T.Receiver); |
1361 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); | 1371 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); |
1362 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); | 1372 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); |
1363 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); | 1373 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); |
1364 CheckDisjoint(T.ObjectConstant1, T.ArrayClass); | 1374 CheckOverlap(T.ObjectConstant1, T.ArrayClass); |
1365 CheckDisjoint(T.ObjectConstant2, T.ArrayClass); | 1375 CheckOverlap(T.ObjectConstant2, T.ArrayClass); |
1366 CheckDisjoint(T.ArrayConstant, T.ObjectClass); | 1376 CheckOverlap(T.ArrayConstant, T.ObjectClass); |
1367 CheckOverlap(T.NumberArray, T.Array); | 1377 CheckOverlap(T.NumberArray, T.Receiver); |
1368 CheckDisjoint(T.NumberArray, T.AnyArray); | 1378 CheckDisjoint(T.NumberArray, T.AnyArray); |
1369 CheckDisjoint(T.NumberArray, T.StringArray); | 1379 CheckDisjoint(T.NumberArray, T.StringArray); |
1370 CheckOverlap(T.MethodFunction, T.Object); | 1380 CheckOverlap(T.MethodFunction, T.Object); |
1371 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); | 1381 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); |
1372 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); | 1382 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); |
1373 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); | 1383 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); |
1374 CheckDisjoint(T.SignedFunction1, T.MethodFunction); | 1384 CheckDisjoint(T.SignedFunction1, T.MethodFunction); |
1375 CheckOverlap(T.ObjectConstant1, T.ObjectClass); // !!! | 1385 CheckOverlap(T.ObjectConstant1, T.ObjectClass); // !!! |
1376 CheckOverlap(T.ObjectConstant2, T.ObjectClass); // !!! | 1386 CheckOverlap(T.ObjectConstant2, T.ObjectClass); // !!! |
1377 CheckOverlap(T.NumberClass, T.Intersect(T.Number, T.Tagged)); // !!! | 1387 CheckOverlap(T.NumberClass, T.Intersect(T.Number, T.Tagged)); // !!! |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 TypeHandle union23 = T.Union(type2, type3); | 1514 TypeHandle union23 = T.Union(type2, type3); |
1505 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); | 1515 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); |
1506 } | 1516 } |
1507 } | 1517 } |
1508 } | 1518 } |
1509 } | 1519 } |
1510 | 1520 |
1511 void Union4() { | 1521 void Union4() { |
1512 // Class-class | 1522 // Class-class |
1513 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); | 1523 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); |
1514 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); | 1524 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.OtherObject); |
1515 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array); | 1525 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Receiver); |
1516 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); | 1526 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); |
1517 | 1527 |
1518 // Constant-constant | 1528 // Constant-constant |
1519 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); | 1529 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); |
1520 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); | 1530 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
1521 CheckUnordered( | 1531 CheckUnordered( |
1522 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); | 1532 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); |
1523 CheckOverlap( | 1533 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
1524 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); | |
1525 CheckDisjoint( | 1534 CheckDisjoint( |
1526 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); | 1535 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); |
1527 CheckOverlap( | 1536 CheckOverlap( |
1528 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass); // !!! | 1537 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass); // !!! |
1529 | 1538 |
1530 // Bitset-array | 1539 // Bitset-array |
1531 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array))); | 1540 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Receiver))); |
1532 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); | 1541 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); |
1533 | 1542 |
1534 CheckEqual(T.Union(T.AnyArray, T.Array), T.Array); | 1543 CheckEqual(T.Union(T.AnyArray, T.Receiver), T.Receiver); |
1535 CheckUnordered(T.Union(T.AnyArray, T.String), T.Array); | 1544 CheckEqual(T.Union(T.AnyArray, T.OtherObject), T.OtherObject); |
| 1545 CheckUnordered(T.Union(T.AnyArray, T.String), T.Receiver); |
1536 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); | 1546 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); |
1537 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); | 1547 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); |
1538 | 1548 |
1539 // Bitset-function | 1549 // Bitset-function |
1540 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Object))); | 1550 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Object))); |
1541 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); | 1551 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); |
1542 | 1552 |
1543 CheckEqual(T.Union(T.MethodFunction, T.Object), T.Object); | 1553 CheckEqual(T.Union(T.MethodFunction, T.Object), T.Object); |
1544 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Object); | 1554 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Object); |
1545 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); | 1555 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); |
1546 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); | 1556 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); |
1547 | 1557 |
1548 // Bitset-class | 1558 // Bitset-class |
1549 CheckSub(T.Union(T.ObjectClass, T.SignedSmall), | 1559 CheckSub(T.Union(T.ObjectClass, T.SignedSmall), |
1550 T.Union(T.Object, T.Number)); | 1560 T.Union(T.Object, T.Number)); |
1551 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); | 1561 CheckSub(T.Union(T.ObjectClass, T.OtherObject), T.Object); |
1552 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); | 1562 CheckUnordered(T.Union(T.ObjectClass, T.String), T.OtherObject); |
1553 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); | 1563 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); |
1554 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); | 1564 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); |
1555 | 1565 |
1556 // Bitset-constant | 1566 // Bitset-constant |
1557 CheckSub( | 1567 CheckSub( |
1558 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); | 1568 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); |
1559 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); | 1569 CheckSub(T.Union(T.ObjectConstant1, T.OtherObject), T.Object); |
1560 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); | 1570 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.OtherObject); |
1561 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); | 1571 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); |
1562 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); | 1572 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); |
1563 | 1573 |
1564 // Class-constant | 1574 // Class-constant |
1565 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); | 1575 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); |
1566 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); | 1576 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); |
1567 CheckSub( | 1577 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), |
1568 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); | 1578 T.Union(T.Receiver, T.Object)); |
1569 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); | 1579 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); |
1570 CheckDisjoint( | 1580 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); |
1571 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); | |
1572 CheckOverlap( | 1581 CheckOverlap( |
1573 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); // !!! | 1582 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); // !!! |
1574 | 1583 |
1575 // Bitset-union | 1584 // Bitset-union |
1576 CheckSub( | 1585 CheckSub( |
1577 T.NaN, | 1586 T.NaN, |
1578 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); | 1587 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); |
1579 CheckSub( | 1588 CheckSub( |
1580 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Signed32), | 1589 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Signed32), |
1581 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); | 1590 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); |
(...skipping 14 matching lines...) Expand all Loading... |
1596 CheckEqual( | 1605 CheckEqual( |
1597 T.Union( | 1606 T.Union( |
1598 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), | 1607 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), |
1599 T.Union( | 1608 T.Union( |
1600 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); | 1609 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); |
1601 | 1610 |
1602 // Array-union | 1611 // Array-union |
1603 CheckEqual( | 1612 CheckEqual( |
1604 T.Union(T.AnyArray, T.Union(T.NumberArray, T.AnyArray)), | 1613 T.Union(T.AnyArray, T.Union(T.NumberArray, T.AnyArray)), |
1605 T.Union(T.AnyArray, T.NumberArray)); | 1614 T.Union(T.AnyArray, T.NumberArray)); |
1606 CheckSub(T.Union(T.AnyArray, T.NumberArray), T.Array); | 1615 CheckSub(T.Union(T.AnyArray, T.NumberArray), T.OtherObject); |
1607 | 1616 |
1608 // Function-union | 1617 // Function-union |
1609 CheckEqual( | 1618 CheckEqual( |
1610 T.Union(T.NumberFunction1, T.NumberFunction2), | 1619 T.Union(T.NumberFunction1, T.NumberFunction2), |
1611 T.Union(T.NumberFunction2, T.NumberFunction1)); | 1620 T.Union(T.NumberFunction2, T.NumberFunction1)); |
1612 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Object); | 1621 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Object); |
1613 | 1622 |
1614 // Union-union | 1623 // Union-union |
1615 CheckEqual( | 1624 CheckEqual( |
1616 T.Union( | 1625 T.Union( |
1617 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1626 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
1618 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1627 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
1619 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1628 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1620 CheckEqual(T.Union(T.Union(T.Number, T.ArrayClass), | 1629 CheckEqual(T.Union(T.Union(T.Number, T.ArrayClass), |
1621 T.Union(T.SignedSmall, T.Array)), | 1630 T.Union(T.SignedSmall, T.Receiver)), |
1622 T.Union(T.Number, T.Array)); | 1631 T.Union(T.Number, T.Receiver)); |
1623 } | 1632 } |
1624 | 1633 |
1625 void Intersect() { | 1634 void Intersect() { |
1626 // Identity: Intersect(T, Any) = T | 1635 // Identity: Intersect(T, Any) = T |
1627 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1636 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1628 TypeHandle type = *it; | 1637 TypeHandle type = *it; |
1629 TypeHandle intersect_type = T.Intersect(type, T.Any); | 1638 TypeHandle intersect_type = T.Intersect(type, T.Any); |
1630 CheckEqual(intersect_type, type); | 1639 CheckEqual(intersect_type, type); |
1631 } | 1640 } |
1632 | 1641 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 TypeHandle type3 = *it3; | 1765 TypeHandle type3 = *it3; |
1757 TypeHandle intersect23 = T.Intersect(type2, type3); | 1766 TypeHandle intersect23 = T.Intersect(type2, type3); |
1758 CHECK(!(type1->Is(type2) && type1->Is(type3)) || | 1767 CHECK(!(type1->Is(type2) && type1->Is(type3)) || |
1759 type1->Is(intersect23)); | 1768 type1->Is(intersect23)); |
1760 } | 1769 } |
1761 } | 1770 } |
1762 } | 1771 } |
1763 | 1772 |
1764 // Bitset-class | 1773 // Bitset-class |
1765 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); | 1774 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); |
1766 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.Array)), T.None); | |
1767 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.Number)), T.None); | 1775 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.Number)), T.None); |
1768 | 1776 |
1769 // Bitset-array | 1777 // Bitset-array |
1770 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); | 1778 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); |
1771 CheckEqual(T.Semantic(T.Intersect(T.AnyArray, T.Proxy)), T.None); | 1779 CheckEqual(T.Semantic(T.Intersect(T.AnyArray, T.Proxy)), T.None); |
1772 | 1780 |
1773 // Bitset-function | 1781 // Bitset-function |
1774 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); | 1782 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); |
1775 CheckEqual(T.Semantic(T.Intersect(T.NumberFunction1, T.Proxy)), T.None); | 1783 CheckEqual(T.Semantic(T.Intersect(T.NumberFunction1, T.Proxy)), T.None); |
1776 | 1784 |
1777 // Bitset-union | 1785 // Bitset-union |
1778 CheckEqual( | 1786 CheckEqual( |
1779 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), | 1787 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), |
1780 T.Union(T.ObjectConstant1, T.ObjectClass)); | 1788 T.Union(T.ObjectConstant1, T.ObjectClass)); |
1781 CheckEqual(T.Semantic(T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), | 1789 CheckEqual(T.Semantic(T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), |
1782 T.Number)), | 1790 T.Number)), |
1783 T.None); | 1791 T.None); |
1784 | 1792 |
1785 // Class-constant | 1793 // Class-constant |
1786 CHECK(T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); // !!! | 1794 CHECK(T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); // !!! |
1787 CHECK(!T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); | 1795 CHECK(T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); |
1788 | 1796 |
1789 // Array-union | 1797 // Array-union |
1790 CheckEqual( | 1798 CheckEqual( |
1791 T.Intersect(T.NumberArray, T.Union(T.NumberArray, T.ArrayClass)), | 1799 T.Intersect(T.NumberArray, T.Union(T.NumberArray, T.ArrayClass)), |
1792 T.NumberArray); | 1800 T.NumberArray); |
1793 CheckEqual( | 1801 CheckEqual( |
1794 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), | 1802 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), |
1795 T.AnyArray); | 1803 T.AnyArray); |
1796 CHECK( | 1804 CHECK( |
1797 !T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.NumberArray) | 1805 !T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.NumberArray) |
(...skipping 29 matching lines...) Expand all Loading... |
1827 CheckEqual( | 1835 CheckEqual( |
1828 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), | 1836 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), |
1829 T.SmiConstant); | 1837 T.SmiConstant); |
1830 CHECK( | 1838 CHECK( |
1831 T.Intersect( | 1839 T.Intersect( |
1832 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) | 1840 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) |
1833 ->IsInhabited()); // !!! | 1841 ->IsInhabited()); // !!! |
1834 | 1842 |
1835 // Union-union | 1843 // Union-union |
1836 CheckEqual(T.Intersect(T.Union(T.Number, T.ArrayClass), | 1844 CheckEqual(T.Intersect(T.Union(T.Number, T.ArrayClass), |
1837 T.Union(T.SignedSmall, T.Array)), | 1845 T.Union(T.SignedSmall, T.Receiver)), |
1838 T.Union(T.SignedSmall, T.ArrayClass)); | 1846 T.Union(T.SignedSmall, T.ArrayClass)); |
1839 CheckEqual( | 1847 CheckEqual(T.Intersect(T.Union(T.Number, T.ObjectClass), |
1840 T.Intersect( | 1848 T.Union(T.Signed32, T.OtherObject)), |
1841 T.Union(T.Number, T.ObjectClass), | 1849 T.Union(T.Signed32, T.ObjectClass)); |
1842 T.Union(T.Signed32, T.Array)), | |
1843 T.Signed32); | |
1844 CheckEqual( | 1850 CheckEqual( |
1845 T.Intersect( | 1851 T.Intersect( |
1846 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1852 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
1847 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1853 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
1848 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1854 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1849 CheckEqual( | 1855 CheckEqual( |
1850 T.Intersect( | 1856 T.Intersect( |
1851 T.Union( | 1857 T.Union( |
1852 T.ArrayClass, | 1858 T.ArrayClass, |
1853 T.Union(T.ObjectConstant2, T.ObjectConstant1)), | 1859 T.Union(T.ObjectConstant2, T.ObjectConstant1)), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1957 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1952 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1958 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1953 TypeHandle type1 = *it1; | 1959 TypeHandle type1 = *it1; |
1954 TypeHandle type2 = *it2; | 1960 TypeHandle type2 = *it2; |
1955 HType htype1 = HType::FromType<Type>(type1); | 1961 HType htype1 = HType::FromType<Type>(type1); |
1956 HType htype2 = HType::FromType<Type>(type2); | 1962 HType htype2 = HType::FromType<Type>(type2); |
1957 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); | 1963 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); |
1958 } | 1964 } |
1959 } | 1965 } |
1960 } | 1966 } |
| 1967 |
| 1968 void GlobalObjectType() { |
| 1969 i::Handle<i::Context> context1 = v8::Utils::OpenHandle( |
| 1970 *v8::Context::New(reinterpret_cast<v8::Isolate*>(isolate))); |
| 1971 Handle<i::GlobalObject> global_object1(context1->global_object()); |
| 1972 TypeHandle GlobalObjectConstant1 = |
| 1973 Type::Constant(global_object1, Rep::ToRegion(&zone, isolate)); |
| 1974 |
| 1975 i::Handle<i::Context> context2 = v8::Utils::OpenHandle( |
| 1976 *v8::Context::New(reinterpret_cast<v8::Isolate*>(isolate))); |
| 1977 Handle<i::GlobalObject> global_object2(context2->global_object()); |
| 1978 TypeHandle GlobalObjectConstant2 = |
| 1979 Type::Constant(global_object2, Rep::ToRegion(&zone, isolate)); |
| 1980 |
| 1981 CheckSub(GlobalObjectConstant1, T.DetectableObject); |
| 1982 CheckSub(GlobalObjectConstant2, T.DetectableObject); |
| 1983 CheckSub(GlobalObjectConstant1, T.GlobalObject); |
| 1984 CheckSub(GlobalObjectConstant2, T.GlobalObject); |
| 1985 CheckSub(GlobalObjectConstant1, T.Object); |
| 1986 CheckSub(GlobalObjectConstant2, T.Object); |
| 1987 |
| 1988 CheckUnordered(T.GlobalObject, T.OtherObject); |
| 1989 CheckUnordered(GlobalObjectConstant1, T.OtherObject); |
| 1990 CheckUnordered(GlobalObjectConstant2, T.OtherObject); |
| 1991 CheckUnordered(GlobalObjectConstant1, GlobalObjectConstant2); |
| 1992 |
| 1993 CheckDisjoint(T.GlobalObject, T.ObjectClass); |
| 1994 CheckDisjoint(GlobalObjectConstant1, T.ObjectClass); |
| 1995 CheckDisjoint(GlobalObjectConstant2, T.ArrayClass); |
| 1996 |
| 1997 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.GlobalObject); |
| 1998 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), GlobalObjectConstant1); |
| 1999 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), GlobalObjectConstant2); |
| 2000 |
| 2001 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.GlobalObject); |
| 2002 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), |
| 2003 GlobalObjectConstant1); |
| 2004 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), |
| 2005 GlobalObjectConstant2); |
| 2006 |
| 2007 CheckUnordered(T.Union(T.ObjectClass, T.String), T.GlobalObject); |
| 2008 |
| 2009 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), |
| 2010 T.Union(T.GlobalObject, T.Object)); |
| 2011 |
| 2012 CheckDisjoint(T.Union(GlobalObjectConstant1, T.ArrayClass), |
| 2013 GlobalObjectConstant2); |
| 2014 |
| 2015 CheckEqual(T.Union(T.Union(T.Number, GlobalObjectConstant1), |
| 2016 T.Union(T.SignedSmall, T.GlobalObject)), |
| 2017 T.Union(T.Number, T.GlobalObject)); |
| 2018 |
| 2019 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.GlobalObject)), T.None); |
| 2020 |
| 2021 CHECK(!T.Intersect(T.ArrayClass, GlobalObjectConstant2)->IsInhabited()); |
| 2022 |
| 2023 CheckEqual(T.Intersect(T.Union(T.Number, T.OtherObject), |
| 2024 T.Union(T.Signed32, T.GlobalObject)), |
| 2025 T.Signed32); |
| 2026 } |
1961 }; | 2027 }; |
1962 | 2028 |
1963 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 2029 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
1964 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | 2030 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
1965 | 2031 |
1966 | 2032 |
1967 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } | 2033 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } |
1968 | 2034 |
1969 | 2035 |
1970 TEST(IsSomeType_heap) { HeapTests().IsSomeType(); } | 2036 TEST(IsSomeType_heap) { HeapTests().IsSomeType(); } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 } | 2191 } |
2126 | 2192 |
2127 | 2193 |
2128 TEST(Convert_heap) { HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); } | 2194 TEST(Convert_heap) { HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); } |
2129 | 2195 |
2130 | 2196 |
2131 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } | 2197 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } |
2132 | 2198 |
2133 | 2199 |
2134 TEST(HTypeFromType_heap) { HeapTests().HTypeFromType(); } | 2200 TEST(HTypeFromType_heap) { HeapTests().HTypeFromType(); } |
| 2201 |
| 2202 |
| 2203 TEST(GlobalObjectType_zone) { ZoneTests().GlobalObjectType(); } |
| 2204 |
| 2205 |
| 2206 TEST(GlobalObjectType_heap) { HeapTests().GlobalObjectType(); } |
OLD | NEW |