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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ValueVector integers; // "Integer" values used for range limits. | 148 ValueVector integers; // "Integer" values used for range limits. |
149 | 149 |
150 Type* Of(Handle<i::Object> value) { return Type::Of(value, zone_); } | 150 Type* Of(Handle<i::Object> value) { return Type::Of(value, zone_); } |
151 | 151 |
152 Type* Constant(Handle<i::Object> value) { | 152 Type* Constant(Handle<i::Object> value) { |
153 return Type::Constant(value, zone_); | 153 return Type::Constant(value, zone_); |
154 } | 154 } |
155 | 155 |
156 Type* Range(double min, double max) { return Type::Range(min, max, zone_); } | 156 Type* Range(double min, double max) { return Type::Range(min, max, zone_); } |
157 | 157 |
158 Type* Context(Type* outer) { return Type::Context(outer, zone_); } | |
159 | |
160 Type* Array1(Type* element) { return Type::Array(element, zone_); } | 158 Type* Array1(Type* element) { return Type::Array(element, zone_); } |
161 | 159 |
162 Type* Function0(Type* result, Type* receiver) { | 160 Type* Function0(Type* result, Type* receiver) { |
163 return Type::Function(result, receiver, 0, zone_); | 161 return Type::Function(result, receiver, 0, zone_); |
164 } | 162 } |
165 | 163 |
166 Type* Function1(Type* result, Type* receiver, Type* arg) { | 164 Type* Function1(Type* result, Type* receiver, Type* arg) { |
167 Type* type = Type::Function(result, receiver, 1, zone_); | 165 Type* type = Type::Function(result, receiver, 1, zone_); |
168 type->AsFunction()->InitParameter(0, arg); | 166 type->AsFunction()->InitParameter(0, arg); |
169 return type; | 167 return type; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 return Type::Constant(values[i], zone_); | 213 return Type::Constant(values[i], zone_); |
216 } | 214 } |
217 case 2: { // range | 215 case 2: { // range |
218 int i = rng_->NextInt(static_cast<int>(integers.size())); | 216 int i = rng_->NextInt(static_cast<int>(integers.size())); |
219 int j = rng_->NextInt(static_cast<int>(integers.size())); | 217 int j = rng_->NextInt(static_cast<int>(integers.size())); |
220 double min = integers[i]->Number(); | 218 double min = integers[i]->Number(); |
221 double max = integers[j]->Number(); | 219 double max = integers[j]->Number(); |
222 if (min > max) std::swap(min, max); | 220 if (min > max) std::swap(min, max); |
223 return Type::Range(min, max, zone_); | 221 return Type::Range(min, max, zone_); |
224 } | 222 } |
225 case 3: { // context | 223 case 3: { // array |
226 int depth = rng_->NextInt(3); | |
227 Type* type = Type::Internal(); | |
228 for (int i = 0; i < depth; ++i) type = Type::Context(type, zone_); | |
229 return type; | |
230 } | |
231 case 4: { // array | |
232 Type* element = Fuzz(depth / 2); | 224 Type* element = Fuzz(depth / 2); |
233 return Type::Array(element, zone_); | 225 return Type::Array(element, zone_); |
234 } | 226 } |
235 case 5: | 227 case 4: |
236 case 6: { // function | 228 case 5: { // function |
237 Type* result = Fuzz(depth / 2); | 229 Type* result = Fuzz(depth / 2); |
238 Type* receiver = Fuzz(depth / 2); | 230 Type* receiver = Fuzz(depth / 2); |
239 int arity = rng_->NextInt(3); | 231 int arity = rng_->NextInt(3); |
240 Type* type = Type::Function(result, receiver, arity, zone_); | 232 Type* type = Type::Function(result, receiver, arity, zone_); |
241 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | 233 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { |
242 Type* parameter = Fuzz(depth / 2); | 234 Type* parameter = Fuzz(depth / 2); |
243 type->AsFunction()->InitParameter(i, parameter); | 235 type->AsFunction()->InitParameter(i, parameter); |
244 } | 236 } |
245 return type; | 237 return type; |
246 } | 238 } |
(...skipping 15 matching lines...) Expand all Loading... |
262 private: | 254 private: |
263 Zone* zone_; | 255 Zone* zone_; |
264 v8::base::RandomNumberGenerator* rng_; | 256 v8::base::RandomNumberGenerator* rng_; |
265 }; | 257 }; |
266 | 258 |
267 | 259 |
268 } // namespace internal | 260 } // namespace internal |
269 } // namespace v8 | 261 } // namespace v8 |
270 | 262 |
271 #endif | 263 #endif |
OLD | NEW |