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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { | 118 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { |
119 return Type::Intersect(t1, t2, region_); | 119 return Type::Intersect(t1, t2, region_); |
120 } | 120 } |
121 | 121 |
122 template<class Type2, class TypeHandle2> | 122 template<class Type2, class TypeHandle2> |
123 TypeHandle Convert(TypeHandle2 t) { | 123 TypeHandle Convert(TypeHandle2 t) { |
124 return Type::template Convert<Type2>(t, region_); | 124 return Type::template Convert<Type2>(t, region_); |
125 } | 125 } |
126 | 126 |
127 TypeHandle Fuzz(int depth = 5) { | 127 TypeHandle Fuzz(int depth = 5) { |
128 switch (random() % (depth == 0 ? 3 : 20)) { | 128 switch (rand() % (depth == 0 ? 3 : 20)) { |
129 case 0: { // bitset | 129 case 0: { // bitset |
130 int n = 0 | 130 int n = 0 |
131 #define COUNT_BITSET_TYPES(type, value) + 1 | 131 #define COUNT_BITSET_TYPES(type, value) + 1 |
132 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) | 132 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) |
133 #undef COUNT_BITSET_TYPES | 133 #undef COUNT_BITSET_TYPES |
134 ; | 134 ; |
135 int i = random() % n; | 135 int i = rand() % n; |
136 #define PICK_BITSET_TYPE(type, value) \ | 136 #define PICK_BITSET_TYPE(type, value) \ |
137 if (i-- == 0) return Type::type(region_); | 137 if (i-- == 0) return Type::type(region_); |
138 BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 138 BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
139 #undef PICK_BITSET_TYPE | 139 #undef PICK_BITSET_TYPE |
140 UNREACHABLE(); | 140 UNREACHABLE(); |
141 } | 141 } |
142 case 1: // class | 142 case 1: // class |
143 switch (random() % 2) { | 143 switch (rand() % 2) { |
144 case 0: return ObjectClass; | 144 case 0: return ObjectClass; |
145 case 1: return ArrayClass; | 145 case 1: return ArrayClass; |
146 } | 146 } |
147 UNREACHABLE(); | 147 UNREACHABLE(); |
148 case 2: // constant | 148 case 2: // constant |
149 switch (random() % 6) { | 149 switch (rand() % 6) { |
150 case 0: return SmiConstant; | 150 case 0: return SmiConstant; |
151 case 1: return Signed32Constant; | 151 case 1: return Signed32Constant; |
152 case 2: return ObjectConstant1; | 152 case 2: return ObjectConstant1; |
153 case 3: return ObjectConstant2; | 153 case 3: return ObjectConstant2; |
154 case 4: return ArrayConstant1; | 154 case 4: return ArrayConstant1; |
155 case 5: return ArrayConstant2; | 155 case 5: return ArrayConstant2; |
156 } | 156 } |
157 UNREACHABLE(); | 157 UNREACHABLE(); |
158 default: { // union | 158 default: { // union |
159 int n = random() % 10; | 159 int n = rand() % 10; |
160 TypeHandle type = None; | 160 TypeHandle type = None; |
161 for (int i = 0; i < n; ++i) { | 161 for (int i = 0; i < n; ++i) { |
162 type = Type::Union(type, Fuzz(depth - 1), region_); | 162 type = Type::Union(type, Fuzz(depth - 1), region_); |
163 } | 163 } |
164 return type; | 164 return type; |
165 } | 165 } |
166 } | 166 } |
167 UNREACHABLE(); | 167 UNREACHABLE(); |
168 } | 168 } |
169 | 169 |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 ZoneTests().Intersect(); | 867 ZoneTests().Intersect(); |
868 HeapTests().Intersect(); | 868 HeapTests().Intersect(); |
869 } | 869 } |
870 | 870 |
871 | 871 |
872 TEST(Convert) { | 872 TEST(Convert) { |
873 CcTest::InitializeVM(); | 873 CcTest::InitializeVM(); |
874 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 874 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
875 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 875 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
876 } | 876 } |
OLD | NEW |