OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 21 matching lines...) Expand all Loading... |
32 #include "src/v8.h" | 32 #include "src/v8.h" |
33 | 33 |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 | 37 |
38 template<class Type, class TypeHandle, class Region> | 38 template<class Type, class TypeHandle, class Region> |
39 class Types { | 39 class Types { |
40 public: | 40 public: |
41 Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng) | 41 Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng) |
42 : region_(region), rng_(rng) { | 42 : region_(region), isolate_(isolate), rng_(rng) { |
43 #define DECLARE_TYPE(name, value) \ | 43 #define DECLARE_TYPE(name, value) \ |
44 name = Type::name(region); \ | 44 name = Type::name(region); \ |
45 types.push_back(name); | 45 types.push_back(name); |
46 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 46 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
47 #undef DECLARE_TYPE | 47 #undef DECLARE_TYPE |
48 | 48 |
49 SignedSmall = Type::SignedSmall(region); | 49 SignedSmall = Type::SignedSmall(region); |
50 UnsignedSmall = Type::UnsignedSmall(region); | 50 UnsignedSmall = Type::UnsignedSmall(region); |
51 | 51 |
52 object_map = isolate->factory()->NewMap( | 52 object_map = isolate->factory()->NewMap( |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 TypeHandle result = Fuzz(depth / 2); | 297 TypeHandle result = Fuzz(depth / 2); |
298 TypeHandle receiver = Fuzz(depth / 2); | 298 TypeHandle receiver = Fuzz(depth / 2); |
299 int arity = rng_->NextInt(3); | 299 int arity = rng_->NextInt(3); |
300 TypeHandle type = Type::Function(result, receiver, arity, region_); | 300 TypeHandle type = Type::Function(result, receiver, arity, region_); |
301 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | 301 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { |
302 TypeHandle parameter = Fuzz(depth / 2); | 302 TypeHandle parameter = Fuzz(depth / 2); |
303 type->AsFunction()->InitParameter(i, parameter); | 303 type->AsFunction()->InitParameter(i, parameter); |
304 } | 304 } |
305 return type; | 305 return type; |
306 } | 306 } |
| 307 case 8: { // simd |
| 308 static const int num_simd_types = |
| 309 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) +1 |
| 310 SIMD128_TYPES(COUNT_SIMD_TYPE) |
| 311 #undef COUNT_SIMD_TYPE |
| 312 ; |
| 313 TypeHandle (*simd_constructors[num_simd_types])(Isolate*, Region*) = { |
| 314 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \ |
| 315 &Type::Name, |
| 316 SIMD128_TYPES(COUNT_SIMD_TYPE) |
| 317 #undef COUNT_SIMD_TYPE |
| 318 }; |
| 319 return simd_constructors[rng_->NextInt(num_simd_types)]( |
| 320 isolate_, region_); |
| 321 } |
307 default: { // union | 322 default: { // union |
308 int n = rng_->NextInt(10); | 323 int n = rng_->NextInt(10); |
309 TypeHandle type = None; | 324 TypeHandle type = None; |
310 for (int i = 0; i < n; ++i) { | 325 for (int i = 0; i < n; ++i) { |
311 TypeHandle operand = Fuzz(depth - 1); | 326 TypeHandle operand = Fuzz(depth - 1); |
312 type = Type::Union(type, operand, region_); | 327 type = Type::Union(type, operand, region_); |
313 } | 328 } |
314 return type; | 329 return type; |
315 } | 330 } |
316 } | 331 } |
317 UNREACHABLE(); | 332 UNREACHABLE(); |
318 } | 333 } |
319 | 334 |
320 Region* region() { return region_; } | 335 Region* region() { return region_; } |
321 | 336 |
322 private: | 337 private: |
323 Region* region_; | 338 Region* region_; |
| 339 Isolate* isolate_; |
324 v8::base::RandomNumberGenerator* rng_; | 340 v8::base::RandomNumberGenerator* rng_; |
325 }; | 341 }; |
326 | 342 |
327 | 343 |
328 } } // namespace v8::internal | 344 } } // namespace v8::internal |
329 | 345 |
330 #endif | 346 #endif |
OLD | NEW |