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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 47 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
48 #undef DECLARE_TYPE | 48 #undef DECLARE_TYPE |
49 | 49 |
50 SignedSmall = Type::SignedSmall(); | 50 SignedSmall = Type::SignedSmall(); |
51 UnsignedSmall = Type::UnsignedSmall(); | 51 UnsignedSmall = Type::UnsignedSmall(); |
52 | 52 |
53 object_map = isolate->factory()->NewMap( | 53 object_map = isolate->factory()->NewMap( |
54 JS_OBJECT_TYPE, JSObject::kHeaderSize); | 54 JS_OBJECT_TYPE, JSObject::kHeaderSize); |
55 | 55 |
56 smi = handle(Smi::FromInt(666), isolate); | 56 smi = handle(Smi::FromInt(666), isolate); |
| 57 boxed_smi = isolate->factory()->NewHeapNumber(666); |
57 signed32 = isolate->factory()->NewHeapNumber(0x40000000); | 58 signed32 = isolate->factory()->NewHeapNumber(0x40000000); |
| 59 float1 = isolate->factory()->NewHeapNumber(1.53); |
| 60 float2 = isolate->factory()->NewHeapNumber(0.53); |
| 61 // float3 is identical to float1 in order to test that OtherNumberConstant |
| 62 // types are equal by double value and not by handle pointer value. |
| 63 float3 = isolate->factory()->NewHeapNumber(1.53); |
58 object1 = isolate->factory()->NewJSObjectFromMap(object_map); | 64 object1 = isolate->factory()->NewJSObjectFromMap(object_map); |
59 object2 = isolate->factory()->NewJSObjectFromMap(object_map); | 65 object2 = isolate->factory()->NewJSObjectFromMap(object_map); |
60 array = isolate->factory()->NewJSArray(20); | 66 array = isolate->factory()->NewJSArray(20); |
61 uninitialized = isolate->factory()->uninitialized_value(); | 67 uninitialized = isolate->factory()->uninitialized_value(); |
62 SmiConstant = Type::Constant(smi, zone); | 68 SmiConstant = Type::NewConstant(smi, zone); |
63 Signed32Constant = Type::Constant(signed32, zone); | 69 Signed32Constant = Type::NewConstant(signed32, zone); |
64 | 70 |
65 ObjectConstant1 = Type::Constant(object1, zone); | 71 ObjectConstant1 = Type::Constant(object1, zone); |
66 ObjectConstant2 = Type::Constant(object2, zone); | 72 ObjectConstant2 = Type::Constant(object2, zone); |
67 ArrayConstant = Type::Constant(array, zone); | 73 ArrayConstant = Type::Constant(array, zone); |
68 UninitializedConstant = Type::Constant(uninitialized, zone); | 74 UninitializedConstant = Type::Constant(uninitialized, zone); |
69 | 75 |
70 values.push_back(smi); | 76 values.push_back(smi); |
| 77 values.push_back(boxed_smi); |
71 values.push_back(signed32); | 78 values.push_back(signed32); |
72 values.push_back(object1); | 79 values.push_back(object1); |
73 values.push_back(object2); | 80 values.push_back(object2); |
74 values.push_back(array); | 81 values.push_back(array); |
75 values.push_back(uninitialized); | 82 values.push_back(uninitialized); |
| 83 values.push_back(float1); |
| 84 values.push_back(float2); |
| 85 values.push_back(float3); |
76 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { | 86 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { |
77 types.push_back(Type::Constant(*it, zone)); | 87 types.push_back(Type::NewConstant(*it, zone)); |
78 } | 88 } |
79 | 89 |
80 integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); | 90 integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); |
81 integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); | 91 integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); |
82 integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); | 92 integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); |
83 integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); | 93 integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); |
84 for (int i = 0; i < 10; ++i) { | 94 for (int i = 0; i < 10; ++i) { |
85 double x = rng_->NextInt(); | 95 double x = rng_->NextInt(); |
86 integers.push_back(isolate->factory()->NewNumber(x)); | 96 integers.push_back(isolate->factory()->NewNumber(x)); |
87 x *= rng_->NextInt(); | 97 x *= rng_->NextInt(); |
88 if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); | 98 if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); |
89 } | 99 } |
90 | 100 |
91 Integer = Type::Range(-V8_INFINITY, +V8_INFINITY, zone); | 101 Integer = Type::Range(-V8_INFINITY, +V8_INFINITY, zone); |
92 | 102 |
93 for (int i = 0; i < 30; ++i) { | 103 for (int i = 0; i < 30; ++i) { |
94 types.push_back(Fuzz()); | 104 types.push_back(Fuzz()); |
95 } | 105 } |
96 } | 106 } |
97 | 107 |
98 Handle<i::Map> object_map; | 108 Handle<i::Map> object_map; |
99 | 109 |
100 Handle<i::Smi> smi; | 110 Handle<i::Smi> smi; |
| 111 Handle<i::HeapNumber> boxed_smi; |
101 Handle<i::HeapNumber> signed32; | 112 Handle<i::HeapNumber> signed32; |
| 113 Handle<i::HeapNumber> float1; |
| 114 Handle<i::HeapNumber> float2; |
| 115 Handle<i::HeapNumber> float3; |
102 Handle<i::JSObject> object1; | 116 Handle<i::JSObject> object1; |
103 Handle<i::JSObject> object2; | 117 Handle<i::JSObject> object2; |
104 Handle<i::JSArray> array; | 118 Handle<i::JSArray> array; |
105 Handle<i::Oddball> uninitialized; | 119 Handle<i::Oddball> uninitialized; |
106 | 120 |
107 #define DECLARE_TYPE(name, value) Type* name; | 121 #define DECLARE_TYPE(name, value) Type* name; |
108 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 122 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
109 #undef DECLARE_TYPE | 123 #undef DECLARE_TYPE |
110 | 124 |
111 Type* SignedSmall; | 125 Type* SignedSmall; |
(...skipping 10 matching lines...) Expand all Loading... |
122 | 136 |
123 typedef std::vector<Type*> TypeVector; | 137 typedef std::vector<Type*> TypeVector; |
124 typedef std::vector<Handle<i::Object> > ValueVector; | 138 typedef std::vector<Handle<i::Object> > ValueVector; |
125 | 139 |
126 TypeVector types; | 140 TypeVector types; |
127 ValueVector values; | 141 ValueVector values; |
128 ValueVector integers; // "Integer" values used for range limits. | 142 ValueVector integers; // "Integer" values used for range limits. |
129 | 143 |
130 Type* Of(Handle<i::Object> value) { return Type::Of(value, zone_); } | 144 Type* Of(Handle<i::Object> value) { return Type::Of(value, zone_); } |
131 | 145 |
| 146 Type* NewConstant(Handle<i::Object> value) { |
| 147 return Type::NewConstant(value, zone_); |
| 148 } |
| 149 |
132 Type* Constant(Handle<i::Object> value) { | 150 Type* Constant(Handle<i::Object> value) { |
133 return Type::Constant(value, zone_); | 151 return Type::Constant(value, zone_); |
134 } | 152 } |
135 | 153 |
136 Type* Range(double min, double max) { return Type::Range(min, max, zone_); } | 154 Type* Range(double min, double max) { return Type::Range(min, max, zone_); } |
137 | 155 |
138 Type* Union(Type* t1, Type* t2) { return Type::Union(t1, t2, zone_); } | 156 Type* Union(Type* t1, Type* t2) { return Type::Union(t1, t2, zone_); } |
139 | 157 |
140 Type* Intersect(Type* t1, Type* t2) { return Type::Intersect(t1, t2, zone_); } | 158 Type* Intersect(Type* t1, Type* t2) { return Type::Intersect(t1, t2, zone_); } |
141 | 159 |
(...skipping 21 matching lines...) Expand all Loading... |
163 continue; \ | 181 continue; \ |
164 } \ | 182 } \ |
165 } | 183 } |
166 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 184 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
167 #undef PICK_BITSET_TYPE | 185 #undef PICK_BITSET_TYPE |
168 } | 186 } |
169 return result; | 187 return result; |
170 } | 188 } |
171 case 1: { // constant | 189 case 1: { // constant |
172 int i = rng_->NextInt(static_cast<int>(values.size())); | 190 int i = rng_->NextInt(static_cast<int>(values.size())); |
173 return Type::Constant(values[i], zone_); | 191 return Type::NewConstant(values[i], zone_); |
174 } | 192 } |
175 case 2: { // range | 193 case 2: { // range |
176 int i = rng_->NextInt(static_cast<int>(integers.size())); | 194 int i = rng_->NextInt(static_cast<int>(integers.size())); |
177 int j = rng_->NextInt(static_cast<int>(integers.size())); | 195 int j = rng_->NextInt(static_cast<int>(integers.size())); |
178 double min = integers[i]->Number(); | 196 double min = integers[i]->Number(); |
179 double max = integers[j]->Number(); | 197 double max = integers[j]->Number(); |
180 if (min > max) std::swap(min, max); | 198 if (min > max) std::swap(min, max); |
181 return Type::Range(min, max, zone_); | 199 return Type::Range(min, max, zone_); |
182 } | 200 } |
183 default: { // union | 201 default: { // union |
(...skipping 14 matching lines...) Expand all Loading... |
198 private: | 216 private: |
199 Zone* zone_; | 217 Zone* zone_; |
200 v8::base::RandomNumberGenerator* rng_; | 218 v8::base::RandomNumberGenerator* rng_; |
201 }; | 219 }; |
202 | 220 |
203 } // namespace compiler | 221 } // namespace compiler |
204 } // namespace internal | 222 } // namespace internal |
205 } // namespace v8 | 223 } // namespace v8 |
206 | 224 |
207 #endif | 225 #endif |
OLD | NEW |