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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 }; | 90 }; |
91 | 91 |
92 | 92 |
93 template<class Type, class TypeHandle, class Region> | 93 template<class Type, class TypeHandle, class Region> |
94 class Types { | 94 class Types { |
95 public: | 95 public: |
96 Types(Region* region, Isolate* isolate) | 96 Types(Region* region, Isolate* isolate) |
97 : region_(region), rng_(isolate->random_number_generator()) { | 97 : region_(region), rng_(isolate->random_number_generator()) { |
98 #define DECLARE_TYPE(name, value) \ | 98 #define DECLARE_TYPE(name, value) \ |
99 name = Type::name(region); \ | 99 name = Type::name(region); \ |
100 if (SmiValuesAre31Bits() || \ | 100 types.push_back(name); |
101 (!Type::name(region)->Equals(Type::OtherSigned32()) && \ | |
102 !Type::name(region)->Equals(Type::OtherUnsigned31()))) { \ | |
103 /* Hack: Avoid generating those empty bitset types. */ \ | |
104 types.push_back(name); \ | |
105 } | |
106 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) | 101 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
107 #undef DECLARE_TYPE | 102 #undef DECLARE_TYPE |
108 | 103 |
109 object_map = isolate->factory()->NewMap( | 104 object_map = isolate->factory()->NewMap( |
110 JS_OBJECT_TYPE, JSObject::kHeaderSize); | 105 JS_OBJECT_TYPE, JSObject::kHeaderSize); |
111 array_map = isolate->factory()->NewMap( | 106 array_map = isolate->factory()->NewMap( |
112 JS_ARRAY_TYPE, JSArray::kSize); | 107 JS_ARRAY_TYPE, JSArray::kSize); |
113 number_map = isolate->factory()->NewMap( | 108 number_map = isolate->factory()->NewMap( |
114 HEAP_NUMBER_TYPE, HeapNumber::kSize); | 109 HEAP_NUMBER_TYPE, HeapNumber::kSize); |
115 uninitialized_map = isolate->factory()->uninitialized_map(); | 110 uninitialized_map = isolate->factory()->uninitialized_map(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 case 0: { // bitset | 277 case 0: { // bitset |
283 #define COUNT_BITSET_TYPES(type, value) + 1 | 278 #define COUNT_BITSET_TYPES(type, value) + 1 |
284 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); | 279 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); |
285 #undef COUNT_BITSET_TYPES | 280 #undef COUNT_BITSET_TYPES |
286 // Pick a bunch of named bitsets and return their intersection. | 281 // Pick a bunch of named bitsets and return their intersection. |
287 TypeHandle result = Type::Any(region_); | 282 TypeHandle result = Type::Any(region_); |
288 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { | 283 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { |
289 int j = rng_->NextInt(n); | 284 int j = rng_->NextInt(n); |
290 #define PICK_BITSET_TYPE(type, value) \ | 285 #define PICK_BITSET_TYPE(type, value) \ |
291 if (j-- == 0) { \ | 286 if (j-- == 0) { \ |
292 if (!SmiValuesAre31Bits() && \ | |
293 (Type::type(region_)->Equals(Type::OtherSigned32()) || \ | |
294 Type::type(region_)->Equals(Type::OtherUnsigned31()))) { \ | |
295 /* Hack: Avoid generating those empty bitset types. */ \ | |
296 continue; \ | |
297 } \ | |
298 TypeHandle tmp = Type::Intersect( \ | 287 TypeHandle tmp = Type::Intersect( \ |
299 result, Type::type(region_), region_); \ | 288 result, Type::type(region_), region_); \ |
300 if (tmp->Is(Type::None()) && i != 0) { \ | 289 if (tmp->Is(Type::None()) && i != 0) { \ |
301 break; \ | 290 break; \ |
302 } else { \ | 291 } { \ |
303 result = tmp; \ | 292 result = tmp; \ |
304 continue; \ | 293 continue; \ |
305 } \ | 294 } \ |
306 } | 295 } |
307 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 296 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
308 #undef PICK_BITSET_TYPE | 297 #undef PICK_BITSET_TYPE |
309 } | 298 } |
310 return result; | 299 return result; |
311 } | 300 } |
312 case 1: { // class | 301 case 1: { // class |
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 } | 2172 } |
2184 | 2173 |
2185 | 2174 |
2186 TEST(NowOf) { | 2175 TEST(NowOf) { |
2187 CcTest::InitializeVM(); | 2176 CcTest::InitializeVM(); |
2188 ZoneTests().NowOf(); | 2177 ZoneTests().NowOf(); |
2189 HeapTests().NowOf(); | 2178 HeapTests().NowOf(); |
2190 } | 2179 } |
2191 | 2180 |
2192 | 2181 |
2193 TEST(MinMax) { | |
2194 CcTest::InitializeVM(); | |
2195 ZoneTests().MinMax(); | |
2196 HeapTests().MinMax(); | |
2197 } | |
2198 | |
2199 | |
2200 TEST(BitsetGlb) { | 2182 TEST(BitsetGlb) { |
2201 CcTest::InitializeVM(); | 2183 CcTest::InitializeVM(); |
2202 ZoneTests().BitsetGlb(); | 2184 ZoneTests().BitsetGlb(); |
2203 HeapTests().BitsetGlb(); | 2185 HeapTests().BitsetGlb(); |
2204 } | 2186 } |
2205 | 2187 |
2206 | 2188 |
2207 TEST(BitsetLub) { | 2189 TEST(BitsetLub) { |
2208 CcTest::InitializeVM(); | 2190 CcTest::InitializeVM(); |
2209 ZoneTests().BitsetLub(); | 2191 ZoneTests().BitsetLub(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 2284 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
2303 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 2285 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
2304 } | 2286 } |
2305 | 2287 |
2306 | 2288 |
2307 TEST(HTypeFromType) { | 2289 TEST(HTypeFromType) { |
2308 CcTest::InitializeVM(); | 2290 CcTest::InitializeVM(); |
2309 ZoneTests().HTypeFromType(); | 2291 ZoneTests().HTypeFromType(); |
2310 HeapTests().HTypeFromType(); | 2292 HeapTests().HTypeFromType(); |
2311 } | 2293 } |
OLD | NEW |