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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 int depth = rng_->NextInt(3); | 270 int depth = rng_->NextInt(3); |
271 TypeHandle type = Type::Internal(region_); | 271 TypeHandle type = Type::Internal(region_); |
272 for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); | 272 for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); |
273 return type; | 273 return type; |
274 } | 274 } |
275 case 4: { // array | 275 case 4: { // array |
276 TypeHandle element = Fuzz(depth / 2); | 276 TypeHandle element = Fuzz(depth / 2); |
277 return Type::Array(element, region_); | 277 return Type::Array(element, region_); |
278 } | 278 } |
279 case 5: | 279 case 5: |
280 case 6: | 280 case 6: { // function |
281 case 7: { // function | |
282 TypeHandle result = Fuzz(depth / 2); | 281 TypeHandle result = Fuzz(depth / 2); |
283 TypeHandle receiver = Fuzz(depth / 2); | 282 TypeHandle receiver = Fuzz(depth / 2); |
284 int arity = rng_->NextInt(3); | 283 int arity = rng_->NextInt(3); |
285 TypeHandle type = Type::Function(result, receiver, arity, region_); | 284 TypeHandle type = Type::Function(result, receiver, arity, region_); |
286 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | 285 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { |
287 TypeHandle parameter = Fuzz(depth - 1); | 286 TypeHandle parameter = Fuzz(depth / 2); |
288 type->AsFunction()->InitParameter(i, parameter); | 287 type->AsFunction()->InitParameter(i, parameter); |
289 } | 288 } |
| 289 return type; |
290 } | 290 } |
291 default: { // union | 291 default: { // union |
292 int n = rng_->NextInt(10); | 292 int n = rng_->NextInt(10); |
293 TypeHandle type = None; | 293 TypeHandle type = None; |
294 for (int i = 0; i < n; ++i) { | 294 for (int i = 0; i < n; ++i) { |
295 TypeHandle operand = Fuzz(depth - 1); | 295 TypeHandle operand = Fuzz(depth - 1); |
296 type = Type::Union(type, operand, region_); | 296 type = Type::Union(type, operand, region_); |
297 } | 297 } |
298 return type; | 298 return type; |
299 } | 299 } |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 1944 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
1945 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 1945 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
1946 } | 1946 } |
1947 | 1947 |
1948 | 1948 |
1949 TEST(HTypeFromType) { | 1949 TEST(HTypeFromType) { |
1950 CcTest::InitializeVM(); | 1950 CcTest::InitializeVM(); |
1951 ZoneTests().HTypeFromType(); | 1951 ZoneTests().HTypeFromType(); |
1952 HeapTests().HTypeFromType(); | 1952 HeapTests().HTypeFromType(); |
1953 } | 1953 } |
OLD | NEW |