| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef V8_TEST_CCTEST_TYPES_H_ | 28 #ifndef V8_TEST_CCTEST_TYPES_H_ |
| 29 #define V8_TEST_CCTEST_TYPES_H_ | 29 #define V8_TEST_CCTEST_TYPES_H_ |
| 30 | 30 |
| 31 #include "src/base/utils/random-number-generator.h" | 31 #include "src/base/utils/random-number-generator.h" |
| 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> | |
| 39 class Types { | 38 class Types { |
| 40 public: | 39 public: |
| 41 Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng) | 40 Types(Zone* zone, Isolate* isolate, v8::base::RandomNumberGenerator* rng) |
| 42 : region_(region), isolate_(isolate), rng_(rng) { | 41 : zone_(zone), isolate_(isolate), rng_(rng) { |
| 43 #define DECLARE_TYPE(name, value) \ | 42 #define DECLARE_TYPE(name, value) \ |
| 44 name = Type::name(region); \ | 43 name = Type::name(); \ |
| 45 types.push_back(name); | 44 types.push_back(name); |
| 46 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 45 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
| 47 #undef DECLARE_TYPE | 46 #undef DECLARE_TYPE |
| 48 | 47 |
| 49 SignedSmall = Type::SignedSmall(region); | 48 SignedSmall = Type::SignedSmall(); |
| 50 UnsignedSmall = Type::UnsignedSmall(region); | 49 UnsignedSmall = Type::UnsignedSmall(); |
| 51 | 50 |
| 52 object_map = isolate->factory()->NewMap( | 51 object_map = isolate->factory()->NewMap( |
| 53 JS_OBJECT_TYPE, JSObject::kHeaderSize); | 52 JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 54 array_map = isolate->factory()->NewMap( | 53 array_map = isolate->factory()->NewMap( |
| 55 JS_ARRAY_TYPE, JSArray::kSize); | 54 JS_ARRAY_TYPE, JSArray::kSize); |
| 56 number_map = isolate->factory()->NewMap( | 55 number_map = isolate->factory()->NewMap( |
| 57 HEAP_NUMBER_TYPE, HeapNumber::kSize); | 56 HEAP_NUMBER_TYPE, HeapNumber::kSize); |
| 58 uninitialized_map = isolate->factory()->uninitialized_map(); | 57 uninitialized_map = isolate->factory()->uninitialized_map(); |
| 59 ObjectClass = Type::Class(object_map, region); | 58 ObjectClass = Type::Class(object_map, zone); |
| 60 ArrayClass = Type::Class(array_map, region); | 59 ArrayClass = Type::Class(array_map, zone); |
| 61 NumberClass = Type::Class(number_map, region); | 60 NumberClass = Type::Class(number_map, zone); |
| 62 UninitializedClass = Type::Class(uninitialized_map, region); | 61 UninitializedClass = Type::Class(uninitialized_map, zone); |
| 63 | 62 |
| 64 maps.push_back(object_map); | 63 maps.push_back(object_map); |
| 65 maps.push_back(array_map); | 64 maps.push_back(array_map); |
| 66 maps.push_back(uninitialized_map); | 65 maps.push_back(uninitialized_map); |
| 67 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) { | 66 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) { |
| 68 types.push_back(Type::Class(*it, region)); | 67 types.push_back(Type::Class(*it, zone)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 smi = handle(Smi::FromInt(666), isolate); | 70 smi = handle(Smi::FromInt(666), isolate); |
| 72 signed32 = isolate->factory()->NewHeapNumber(0x40000000); | 71 signed32 = isolate->factory()->NewHeapNumber(0x40000000); |
| 73 object1 = isolate->factory()->NewJSObjectFromMap(object_map); | 72 object1 = isolate->factory()->NewJSObjectFromMap(object_map); |
| 74 object2 = isolate->factory()->NewJSObjectFromMap(object_map); | 73 object2 = isolate->factory()->NewJSObjectFromMap(object_map); |
| 75 array = isolate->factory()->NewJSArray(20); | 74 array = isolate->factory()->NewJSArray(20); |
| 76 uninitialized = isolate->factory()->uninitialized_value(); | 75 uninitialized = isolate->factory()->uninitialized_value(); |
| 77 SmiConstant = Type::Constant(smi, region); | 76 SmiConstant = Type::Constant(smi, zone); |
| 78 Signed32Constant = Type::Constant(signed32, region); | 77 Signed32Constant = Type::Constant(signed32, zone); |
| 79 | 78 |
| 80 ObjectConstant1 = Type::Constant(object1, region); | 79 ObjectConstant1 = Type::Constant(object1, zone); |
| 81 ObjectConstant2 = Type::Constant(object2, region); | 80 ObjectConstant2 = Type::Constant(object2, zone); |
| 82 ArrayConstant = Type::Constant(array, region); | 81 ArrayConstant = Type::Constant(array, zone); |
| 83 UninitializedConstant = Type::Constant(uninitialized, region); | 82 UninitializedConstant = Type::Constant(uninitialized, zone); |
| 84 | 83 |
| 85 values.push_back(smi); | 84 values.push_back(smi); |
| 86 values.push_back(signed32); | 85 values.push_back(signed32); |
| 87 values.push_back(object1); | 86 values.push_back(object1); |
| 88 values.push_back(object2); | 87 values.push_back(object2); |
| 89 values.push_back(array); | 88 values.push_back(array); |
| 90 values.push_back(uninitialized); | 89 values.push_back(uninitialized); |
| 91 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { | 90 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { |
| 92 types.push_back(Type::Constant(*it, region)); | 91 types.push_back(Type::Constant(*it, zone)); |
| 93 } | 92 } |
| 94 | 93 |
| 95 integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); | 94 integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); |
| 96 integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); | 95 integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); |
| 97 integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); | 96 integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); |
| 98 integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); | 97 integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); |
| 99 for (int i = 0; i < 10; ++i) { | 98 for (int i = 0; i < 10; ++i) { |
| 100 double x = rng_->NextInt(); | 99 double x = rng_->NextInt(); |
| 101 integers.push_back(isolate->factory()->NewNumber(x)); | 100 integers.push_back(isolate->factory()->NewNumber(x)); |
| 102 x *= rng_->NextInt(); | 101 x *= rng_->NextInt(); |
| 103 if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); | 102 if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); |
| 104 } | 103 } |
| 105 | 104 |
| 106 Integer = Type::Range(-V8_INFINITY, +V8_INFINITY, region); | 105 Integer = Type::Range(-V8_INFINITY, +V8_INFINITY, zone); |
| 107 | 106 |
| 108 NumberArray = Type::Array(Number, region); | 107 NumberArray = Type::Array(Number, zone); |
| 109 StringArray = Type::Array(String, region); | 108 StringArray = Type::Array(String, zone); |
| 110 AnyArray = Type::Array(Any, region); | 109 AnyArray = Type::Array(Any, zone); |
| 111 | 110 |
| 112 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, region); | 111 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, zone); |
| 113 NumberFunction1 = Type::Function(Number, Number, region); | 112 NumberFunction1 = Type::Function(Number, Number, zone); |
| 114 NumberFunction2 = Type::Function(Number, Number, Number, region); | 113 NumberFunction2 = Type::Function(Number, Number, Number, zone); |
| 115 MethodFunction = Type::Function(String, Object, 0, region); | 114 MethodFunction = Type::Function(String, Object, 0, zone); |
| 116 | 115 |
| 117 for (int i = 0; i < 30; ++i) { | 116 for (int i = 0; i < 30; ++i) { |
| 118 types.push_back(Fuzz()); | 117 types.push_back(Fuzz()); |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 | 120 |
| 122 Handle<i::Map> object_map; | 121 Handle<i::Map> object_map; |
| 123 Handle<i::Map> array_map; | 122 Handle<i::Map> array_map; |
| 124 Handle<i::Map> number_map; | 123 Handle<i::Map> number_map; |
| 125 Handle<i::Map> uninitialized_map; | 124 Handle<i::Map> uninitialized_map; |
| 126 | 125 |
| 127 Handle<i::Smi> smi; | 126 Handle<i::Smi> smi; |
| 128 Handle<i::HeapNumber> signed32; | 127 Handle<i::HeapNumber> signed32; |
| 129 Handle<i::JSObject> object1; | 128 Handle<i::JSObject> object1; |
| 130 Handle<i::JSObject> object2; | 129 Handle<i::JSObject> object2; |
| 131 Handle<i::JSArray> array; | 130 Handle<i::JSArray> array; |
| 132 Handle<i::Oddball> uninitialized; | 131 Handle<i::Oddball> uninitialized; |
| 133 | 132 |
| 134 #define DECLARE_TYPE(name, value) TypeHandle name; | 133 #define DECLARE_TYPE(name, value) Type* name; |
| 135 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 134 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
| 136 #undef DECLARE_TYPE | 135 #undef DECLARE_TYPE |
| 137 | 136 |
| 138 #define DECLARE_TYPE(name, value) TypeHandle Mask##name##ForTesting; | 137 #define DECLARE_TYPE(name, value) Type* Mask##name##ForTesting; |
| 139 MASK_BITSET_TYPE_LIST(DECLARE_TYPE) | 138 MASK_BITSET_TYPE_LIST(DECLARE_TYPE) |
| 140 #undef DECLARE_TYPE | 139 #undef DECLARE_TYPE |
| 141 TypeHandle SignedSmall; | 140 Type* SignedSmall; |
| 142 TypeHandle UnsignedSmall; | 141 Type* UnsignedSmall; |
| 143 | 142 |
| 144 TypeHandle ObjectClass; | 143 Type* ObjectClass; |
| 145 TypeHandle ArrayClass; | 144 Type* ArrayClass; |
| 146 TypeHandle NumberClass; | 145 Type* NumberClass; |
| 147 TypeHandle UninitializedClass; | 146 Type* UninitializedClass; |
| 148 | 147 |
| 149 TypeHandle SmiConstant; | 148 Type* SmiConstant; |
| 150 TypeHandle Signed32Constant; | 149 Type* Signed32Constant; |
| 151 TypeHandle ObjectConstant1; | 150 Type* ObjectConstant1; |
| 152 TypeHandle ObjectConstant2; | 151 Type* ObjectConstant2; |
| 153 TypeHandle ArrayConstant; | 152 Type* ArrayConstant; |
| 154 TypeHandle UninitializedConstant; | 153 Type* UninitializedConstant; |
| 155 | 154 |
| 156 TypeHandle Integer; | 155 Type* Integer; |
| 157 | 156 |
| 158 TypeHandle NumberArray; | 157 Type* NumberArray; |
| 159 TypeHandle StringArray; | 158 Type* StringArray; |
| 160 TypeHandle AnyArray; | 159 Type* AnyArray; |
| 161 | 160 |
| 162 TypeHandle SignedFunction1; | 161 Type* SignedFunction1; |
| 163 TypeHandle NumberFunction1; | 162 Type* NumberFunction1; |
| 164 TypeHandle NumberFunction2; | 163 Type* NumberFunction2; |
| 165 TypeHandle MethodFunction; | 164 Type* MethodFunction; |
| 166 | 165 |
| 167 typedef std::vector<TypeHandle> TypeVector; | 166 typedef std::vector<Type*> TypeVector; |
| 168 typedef std::vector<Handle<i::Map> > MapVector; | 167 typedef std::vector<Handle<i::Map> > MapVector; |
| 169 typedef std::vector<Handle<i::Object> > ValueVector; | 168 typedef std::vector<Handle<i::Object> > ValueVector; |
| 170 | 169 |
| 171 TypeVector types; | 170 TypeVector types; |
| 172 MapVector maps; | 171 MapVector maps; |
| 173 ValueVector values; | 172 ValueVector values; |
| 174 ValueVector integers; // "Integer" values used for range limits. | 173 ValueVector integers; // "Integer" values used for range limits. |
| 175 | 174 |
| 176 TypeHandle Of(Handle<i::Object> value) { | 175 Type* Of(Handle<i::Object> value) { return Type::Of(value, zone_); } |
| 177 return Type::Of(value, region_); | 176 |
| 177 Type* NowOf(Handle<i::Object> value) { return Type::NowOf(value, zone_); } |
| 178 |
| 179 Type* Class(Handle<i::Map> map) { return Type::Class(map, zone_); } |
| 180 |
| 181 Type* Constant(Handle<i::Object> value) { |
| 182 return Type::Constant(value, zone_); |
| 178 } | 183 } |
| 179 | 184 |
| 180 TypeHandle NowOf(Handle<i::Object> value) { | 185 Type* Range(double min, double max) { return Type::Range(min, max, zone_); } |
| 181 return Type::NowOf(value, region_); | 186 |
| 187 Type* Context(Type* outer) { return Type::Context(outer, zone_); } |
| 188 |
| 189 Type* Array1(Type* element) { return Type::Array(element, zone_); } |
| 190 |
| 191 Type* Function0(Type* result, Type* receiver) { |
| 192 return Type::Function(result, receiver, 0, zone_); |
| 182 } | 193 } |
| 183 | 194 |
| 184 TypeHandle Class(Handle<i::Map> map) { | 195 Type* Function1(Type* result, Type* receiver, Type* arg) { |
| 185 return Type::Class(map, region_); | 196 Type* type = Type::Function(result, receiver, 1, zone_); |
| 186 } | |
| 187 | |
| 188 TypeHandle Constant(Handle<i::Object> value) { | |
| 189 return Type::Constant(value, region_); | |
| 190 } | |
| 191 | |
| 192 TypeHandle Range(double min, double max) { | |
| 193 return Type::Range(min, max, region_); | |
| 194 } | |
| 195 | |
| 196 TypeHandle Context(TypeHandle outer) { | |
| 197 return Type::Context(outer, region_); | |
| 198 } | |
| 199 | |
| 200 TypeHandle Array1(TypeHandle element) { | |
| 201 return Type::Array(element, region_); | |
| 202 } | |
| 203 | |
| 204 TypeHandle Function0(TypeHandle result, TypeHandle receiver) { | |
| 205 return Type::Function(result, receiver, 0, region_); | |
| 206 } | |
| 207 | |
| 208 TypeHandle Function1(TypeHandle result, TypeHandle receiver, TypeHandle arg) { | |
| 209 TypeHandle type = Type::Function(result, receiver, 1, region_); | |
| 210 type->AsFunction()->InitParameter(0, arg); | 197 type->AsFunction()->InitParameter(0, arg); |
| 211 return type; | 198 return type; |
| 212 } | 199 } |
| 213 | 200 |
| 214 TypeHandle Function2(TypeHandle result, TypeHandle arg1, TypeHandle arg2) { | 201 Type* Function2(Type* result, Type* arg1, Type* arg2) { |
| 215 return Type::Function(result, arg1, arg2, region_); | 202 return Type::Function(result, arg1, arg2, zone_); |
| 216 } | 203 } |
| 217 | 204 |
| 218 TypeHandle Union(TypeHandle t1, TypeHandle t2) { | 205 Type* Union(Type* t1, Type* t2) { return Type::Union(t1, t2, zone_); } |
| 219 return Type::Union(t1, t2, region_); | |
| 220 } | |
| 221 | 206 |
| 222 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { | 207 Type* Intersect(Type* t1, Type* t2) { return Type::Intersect(t1, t2, zone_); } |
| 223 return Type::Intersect(t1, t2, region_); | |
| 224 } | |
| 225 | 208 |
| 226 TypeHandle Representation(TypeHandle t) { | 209 Type* Representation(Type* t) { return Type::Representation(t, zone_); } |
| 227 return Type::Representation(t, region_); | |
| 228 } | |
| 229 | 210 |
| 230 // TypeHandle Semantic(TypeHandle t) { return Intersect(t, | 211 // Type* Semantic(Type* t) { return Intersect(t, |
| 231 // MaskSemanticForTesting); } | 212 // MaskSemanticForTesting); } |
| 232 TypeHandle Semantic(TypeHandle t) { return Type::Semantic(t, region_); } | 213 Type* Semantic(Type* t) { return Type::Semantic(t, zone_); } |
| 233 | 214 |
| 234 template<class Type2, class TypeHandle2> | 215 Type* Random() { |
| 235 TypeHandle Convert(TypeHandle2 t) { | |
| 236 return Type::template Convert<Type2>(t, region_); | |
| 237 } | |
| 238 | |
| 239 TypeHandle Random() { | |
| 240 return types[rng_->NextInt(static_cast<int>(types.size()))]; | 216 return types[rng_->NextInt(static_cast<int>(types.size()))]; |
| 241 } | 217 } |
| 242 | 218 |
| 243 TypeHandle Fuzz(int depth = 4) { | 219 Type* Fuzz(int depth = 4) { |
| 244 switch (rng_->NextInt(depth == 0 ? 3 : 20)) { | 220 switch (rng_->NextInt(depth == 0 ? 3 : 20)) { |
| 245 case 0: { // bitset | 221 case 0: { // bitset |
| 246 #define COUNT_BITSET_TYPES(type, value) + 1 | 222 #define COUNT_BITSET_TYPES(type, value) + 1 |
| 247 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); | 223 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); |
| 248 #undef COUNT_BITSET_TYPES | 224 #undef COUNT_BITSET_TYPES |
| 249 // Pick a bunch of named bitsets and return their intersection. | 225 // Pick a bunch of named bitsets and return their intersection. |
| 250 TypeHandle result = Type::Any(region_); | 226 Type* result = Type::Any(); |
| 251 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { | 227 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { |
| 252 int j = rng_->NextInt(n); | 228 int j = rng_->NextInt(n); |
| 253 #define PICK_BITSET_TYPE(type, value) \ | 229 #define PICK_BITSET_TYPE(type, value) \ |
| 254 if (j-- == 0) { \ | 230 if (j-- == 0) { \ |
| 255 TypeHandle tmp = Type::Intersect( \ | 231 Type* tmp = Type::Intersect(result, Type::type(), zone_); \ |
| 256 result, Type::type(region_), region_); \ | 232 if (tmp->Is(Type::None()) && i != 0) { \ |
| 257 if (tmp->Is(Type::None()) && i != 0) { \ | 233 break; \ |
| 258 break; \ | 234 } else { \ |
| 259 } else { \ | 235 result = tmp; \ |
| 260 result = tmp; \ | 236 continue; \ |
| 261 continue; \ | 237 } \ |
| 262 } \ | 238 } |
| 263 } | |
| 264 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 239 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
| 265 #undef PICK_BITSET_TYPE | 240 #undef PICK_BITSET_TYPE |
| 266 } | 241 } |
| 267 return result; | 242 return result; |
| 268 } | 243 } |
| 269 case 1: { // class | 244 case 1: { // class |
| 270 int i = rng_->NextInt(static_cast<int>(maps.size())); | 245 int i = rng_->NextInt(static_cast<int>(maps.size())); |
| 271 return Type::Class(maps[i], region_); | 246 return Type::Class(maps[i], zone_); |
| 272 } | 247 } |
| 273 case 2: { // constant | 248 case 2: { // constant |
| 274 int i = rng_->NextInt(static_cast<int>(values.size())); | 249 int i = rng_->NextInt(static_cast<int>(values.size())); |
| 275 return Type::Constant(values[i], region_); | 250 return Type::Constant(values[i], zone_); |
| 276 } | 251 } |
| 277 case 3: { // range | 252 case 3: { // range |
| 278 int i = rng_->NextInt(static_cast<int>(integers.size())); | 253 int i = rng_->NextInt(static_cast<int>(integers.size())); |
| 279 int j = rng_->NextInt(static_cast<int>(integers.size())); | 254 int j = rng_->NextInt(static_cast<int>(integers.size())); |
| 280 double min = integers[i]->Number(); | 255 double min = integers[i]->Number(); |
| 281 double max = integers[j]->Number(); | 256 double max = integers[j]->Number(); |
| 282 if (min > max) std::swap(min, max); | 257 if (min > max) std::swap(min, max); |
| 283 return Type::Range(min, max, region_); | 258 return Type::Range(min, max, zone_); |
| 284 } | 259 } |
| 285 case 4: { // context | 260 case 4: { // context |
| 286 int depth = rng_->NextInt(3); | 261 int depth = rng_->NextInt(3); |
| 287 TypeHandle type = Type::Internal(region_); | 262 Type* type = Type::Internal(); |
| 288 for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); | 263 for (int i = 0; i < depth; ++i) type = Type::Context(type, zone_); |
| 289 return type; | 264 return type; |
| 290 } | 265 } |
| 291 case 5: { // array | 266 case 5: { // array |
| 292 TypeHandle element = Fuzz(depth / 2); | 267 Type* element = Fuzz(depth / 2); |
| 293 return Type::Array(element, region_); | 268 return Type::Array(element, zone_); |
| 294 } | 269 } |
| 295 case 6: | 270 case 6: |
| 296 case 7: { // function | 271 case 7: { // function |
| 297 TypeHandle result = Fuzz(depth / 2); | 272 Type* result = Fuzz(depth / 2); |
| 298 TypeHandle receiver = Fuzz(depth / 2); | 273 Type* receiver = Fuzz(depth / 2); |
| 299 int arity = rng_->NextInt(3); | 274 int arity = rng_->NextInt(3); |
| 300 TypeHandle type = Type::Function(result, receiver, arity, region_); | 275 Type* type = Type::Function(result, receiver, arity, zone_); |
| 301 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | 276 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { |
| 302 TypeHandle parameter = Fuzz(depth / 2); | 277 Type* parameter = Fuzz(depth / 2); |
| 303 type->AsFunction()->InitParameter(i, parameter); | 278 type->AsFunction()->InitParameter(i, parameter); |
| 304 } | 279 } |
| 305 return type; | 280 return type; |
| 306 } | 281 } |
| 307 case 8: { // simd | 282 case 8: { // simd |
| 308 static const int num_simd_types = | 283 static const int num_simd_types = |
| 309 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) +1 | 284 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) +1 |
| 310 SIMD128_TYPES(COUNT_SIMD_TYPE); | 285 SIMD128_TYPES(COUNT_SIMD_TYPE); |
| 311 #undef COUNT_SIMD_TYPE | 286 #undef COUNT_SIMD_TYPE |
| 312 TypeHandle (*simd_constructors[num_simd_types])(Isolate*, Region*) = { | 287 Type* (*simd_constructors[num_simd_types])(Isolate*, Zone*) = { |
| 313 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \ | 288 #define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \ |
| 314 &Type::Name, | 289 &Type::Name, |
| 315 SIMD128_TYPES(COUNT_SIMD_TYPE) | 290 SIMD128_TYPES(COUNT_SIMD_TYPE) |
| 316 #undef COUNT_SIMD_TYPE | 291 #undef COUNT_SIMD_TYPE |
| 317 }; | 292 }; |
| 318 return simd_constructors[rng_->NextInt(num_simd_types)]( | 293 return simd_constructors[rng_->NextInt(num_simd_types)](isolate_, |
| 319 isolate_, region_); | 294 zone_); |
| 320 } | 295 } |
| 321 default: { // union | 296 default: { // union |
| 322 int n = rng_->NextInt(10); | 297 int n = rng_->NextInt(10); |
| 323 TypeHandle type = None; | 298 Type* type = None; |
| 324 for (int i = 0; i < n; ++i) { | 299 for (int i = 0; i < n; ++i) { |
| 325 TypeHandle operand = Fuzz(depth - 1); | 300 Type* operand = Fuzz(depth - 1); |
| 326 type = Type::Union(type, operand, region_); | 301 type = Type::Union(type, operand, zone_); |
| 327 } | 302 } |
| 328 return type; | 303 return type; |
| 329 } | 304 } |
| 330 } | 305 } |
| 331 UNREACHABLE(); | 306 UNREACHABLE(); |
| 332 } | 307 } |
| 333 | 308 |
| 334 Region* region() { return region_; } | 309 Zone* zone() { return zone_; } |
| 335 | 310 |
| 336 private: | 311 private: |
| 337 Region* region_; | 312 Zone* zone_; |
| 338 Isolate* isolate_; | 313 Isolate* isolate_; |
| 339 v8::base::RandomNumberGenerator* rng_; | 314 v8::base::RandomNumberGenerator* rng_; |
| 340 }; | 315 }; |
| 341 | 316 |
| 342 | 317 |
| 343 } // namespace internal | 318 } // namespace internal |
| 344 } // namespace v8 | 319 } // namespace v8 |
| 345 | 320 |
| 346 #endif | 321 #endif |
| OLD | NEW |