| 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/crankshaft/hydrogen-types.h" | 7 #include "src/crankshaft/hydrogen-types.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| 11 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 11 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 12 // (disallowed) include: src/factory.h -> src/objects-inl.h | 12 // (disallowed) include: src/factory.h -> src/objects-inl.h |
| 13 #include "src/ast/ast-types.h" | 13 #include "src/ast/ast-types.h" |
| 14 #include "src/objects-inl.h" | 14 #include "src/objects-inl.h" |
| 15 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 15 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 16 // (disallowed) include: src/type-feedback-vector.h -> | 16 // (disallowed) include: src/type-feedback-vector.h -> |
| 17 // src/type-feedback-vector-inl.h | 17 // src/type-feedback-vector-inl.h |
| 18 #include "src/type-feedback-vector-inl.h" | 18 #include "src/type-feedback-vector-inl.h" |
| 19 #include "test/cctest/ast-types-fuzz.h" | 19 #include "test/cctest/ast-types-fuzz.h" |
| 20 #include "test/cctest/cctest.h" | 20 #include "test/cctest/cctest.h" |
| 21 | 21 |
| 22 using namespace v8::internal; | 22 using namespace v8::internal; |
| 23 | 23 |
| 24 namespace { |
| 25 |
| 24 // Testing auxiliaries (breaking the Type abstraction). | 26 // Testing auxiliaries (breaking the Type abstraction). |
| 25 | 27 |
| 26 static bool IsInteger(double x) { | 28 static bool IsInteger(double x) { |
| 27 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. | 29 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. |
| 28 } | 30 } |
| 29 | 31 |
| 30 static bool IsInteger(i::Object* x) { | 32 static bool IsInteger(i::Object* x) { |
| 31 return x->IsNumber() && IsInteger(x->Number()); | 33 return x->IsNumber() && IsInteger(x->Number()); |
| 32 } | 34 } |
| 33 | 35 |
| 34 typedef uint32_t bitset; | 36 typedef uint32_t bitset; |
| 35 | 37 |
| 36 struct Tests { | 38 struct Tests { |
| 37 typedef Types::TypeVector::iterator TypeIterator; | 39 typedef AstTypes::TypeVector::iterator TypeIterator; |
| 38 typedef Types::MapVector::iterator MapIterator; | 40 typedef AstTypes::MapVector::iterator MapIterator; |
| 39 typedef Types::ValueVector::iterator ValueIterator; | 41 typedef AstTypes::ValueVector::iterator ValueIterator; |
| 40 | 42 |
| 41 Isolate* isolate; | 43 Isolate* isolate; |
| 42 HandleScope scope; | 44 HandleScope scope; |
| 43 Zone zone; | 45 Zone zone; |
| 44 Types T; | 46 AstTypes T; |
| 45 | 47 |
| 46 Tests() | 48 Tests() |
| 47 : isolate(CcTest::InitIsolateOnce()), | 49 : isolate(CcTest::InitIsolateOnce()), |
| 48 scope(isolate), | 50 scope(isolate), |
| 49 zone(isolate->allocator()), | 51 zone(isolate->allocator()), |
| 50 T(&zone, isolate, isolate->random_number_generator()) {} | 52 T(&zone, isolate, isolate->random_number_generator()) {} |
| 51 | 53 |
| 52 bool IsBitset(AstType* type) { return type->IsBitsetForTesting(); } | 54 bool IsBitset(AstType* type) { return type->IsBitsetForTesting(); } |
| 53 bool IsUnion(AstType* type) { return type->IsUnionForTesting(); } | 55 bool IsUnion(AstType* type) { return type->IsUnionForTesting(); } |
| 54 AstBitsetType::bitset AsBitset(AstType* type) { | 56 AstBitsetType::bitset AsBitset(AstType* type) { |
| (...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 AstType* type1 = *it1; | 1840 AstType* type1 = *it1; |
| 1839 AstType* type2 = *it2; | 1841 AstType* type2 = *it2; |
| 1840 HType htype1 = HType::FromType(type1); | 1842 HType htype1 = HType::FromType(type1); |
| 1841 HType htype2 = HType::FromType(type2); | 1843 HType htype2 = HType::FromType(type2); |
| 1842 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); | 1844 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); |
| 1843 } | 1845 } |
| 1844 } | 1846 } |
| 1845 } | 1847 } |
| 1846 }; | 1848 }; |
| 1847 | 1849 |
| 1850 } // namespace |
| 1851 |
| 1848 TEST(AstIsSomeType_zone) { Tests().IsSomeType(); } | 1852 TEST(AstIsSomeType_zone) { Tests().IsSomeType(); } |
| 1849 | 1853 |
| 1850 TEST(AstPointwiseRepresentation_zone) { Tests().PointwiseRepresentation(); } | 1854 TEST(AstPointwiseRepresentation_zone) { Tests().PointwiseRepresentation(); } |
| 1851 | 1855 |
| 1852 TEST(AstBitsetType_zone) { Tests().Bitset(); } | 1856 TEST(AstBitsetType_zone) { Tests().Bitset(); } |
| 1853 | 1857 |
| 1854 TEST(AstClassType_zone) { Tests().Class(); } | 1858 TEST(AstClassType_zone) { Tests().Class(); } |
| 1855 | 1859 |
| 1856 TEST(AstConstantType_zone) { Tests().Constant(); } | 1860 TEST(AstConstantType_zone) { Tests().Constant(); } |
| 1857 | 1861 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 | 1895 |
| 1892 TEST(AstUnion4_zone) { Tests().Union4(); } | 1896 TEST(AstUnion4_zone) { Tests().Union4(); } |
| 1893 | 1897 |
| 1894 TEST(AstIntersect_zone) { Tests().Intersect(); } | 1898 TEST(AstIntersect_zone) { Tests().Intersect(); } |
| 1895 | 1899 |
| 1896 TEST(AstDistributivity_zone) { Tests().Distributivity(); } | 1900 TEST(AstDistributivity_zone) { Tests().Distributivity(); } |
| 1897 | 1901 |
| 1898 TEST(AstGetRange_zone) { Tests().GetRange(); } | 1902 TEST(AstGetRange_zone) { Tests().GetRange(); } |
| 1899 | 1903 |
| 1900 TEST(AstHTypeFromType_zone) { Tests().HTypeFromType(); } | 1904 TEST(AstHTypeFromType_zone) { Tests().HTypeFromType(); } |
| OLD | NEW |