Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: test/cctest/types-fuzz.h

Issue 759013003: Avoid number range holes in bitset types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Another rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 36
37 template<class Type, class TypeHandle, class Region> 37 template<class Type, class TypeHandle, class Region>
38 class Types { 38 class Types {
39 public: 39 public:
40 Types(Region* region, Isolate* isolate) 40 Types(Region* region, Isolate* isolate)
41 : region_(region), rng_(isolate->random_number_generator()) { 41 : region_(region), rng_(isolate->random_number_generator()) {
42 #define DECLARE_TYPE(name, value) \ 42 #define DECLARE_TYPE(name, value) \
43 name = Type::name(region); \ 43 name = Type::name(region); \
44 if (SmiValuesAre31Bits() || \ 44 types.push_back(name);
45 (!Type::name(region)->Equals(Type::OtherSigned32()) && \
46 !Type::name(region)->Equals(Type::OtherUnsigned31()))) { \
47 /* Hack: Avoid generating those empty bitset types. */ \
48 types.push_back(name); \
49 }
50 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) 45 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
51 #undef DECLARE_TYPE 46 #undef DECLARE_TYPE
52 47
53 object_map = isolate->factory()->NewMap( 48 object_map = isolate->factory()->NewMap(
54 JS_OBJECT_TYPE, JSObject::kHeaderSize); 49 JS_OBJECT_TYPE, JSObject::kHeaderSize);
55 array_map = isolate->factory()->NewMap( 50 array_map = isolate->factory()->NewMap(
56 JS_ARRAY_TYPE, JSArray::kSize); 51 JS_ARRAY_TYPE, JSArray::kSize);
57 number_map = isolate->factory()->NewMap( 52 number_map = isolate->factory()->NewMap(
58 HEAP_NUMBER_TYPE, HeapNumber::kSize); 53 HEAP_NUMBER_TYPE, HeapNumber::kSize);
59 uninitialized_map = isolate->factory()->uninitialized_map(); 54 uninitialized_map = isolate->factory()->uninitialized_map();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 Handle<i::Map> uninitialized_map; 121 Handle<i::Map> uninitialized_map;
127 122
128 Handle<i::Smi> smi; 123 Handle<i::Smi> smi;
129 Handle<i::HeapNumber> signed32; 124 Handle<i::HeapNumber> signed32;
130 Handle<i::JSObject> object1; 125 Handle<i::JSObject> object1;
131 Handle<i::JSObject> object2; 126 Handle<i::JSObject> object2;
132 Handle<i::JSArray> array; 127 Handle<i::JSArray> array;
133 Handle<i::Oddball> uninitialized; 128 Handle<i::Oddball> uninitialized;
134 129
135 #define DECLARE_TYPE(name, value) TypeHandle name; 130 #define DECLARE_TYPE(name, value) TypeHandle name;
136 BITSET_TYPE_LIST(DECLARE_TYPE) 131 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
137 #undef DECLARE_TYPE 132 #undef DECLARE_TYPE
138 133
139 TypeHandle ObjectClass; 134 TypeHandle ObjectClass;
140 TypeHandle ArrayClass; 135 TypeHandle ArrayClass;
141 TypeHandle NumberClass; 136 TypeHandle NumberClass;
142 TypeHandle UninitializedClass; 137 TypeHandle UninitializedClass;
143 138
144 TypeHandle SmiConstant; 139 TypeHandle SmiConstant;
145 TypeHandle Signed32Constant; 140 TypeHandle Signed32Constant;
146 TypeHandle ObjectConstant1; 141 TypeHandle ObjectConstant1;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 case 0: { // bitset 226 case 0: { // bitset
232 #define COUNT_BITSET_TYPES(type, value) + 1 227 #define COUNT_BITSET_TYPES(type, value) + 1
233 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); 228 int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES);
234 #undef COUNT_BITSET_TYPES 229 #undef COUNT_BITSET_TYPES
235 // Pick a bunch of named bitsets and return their intersection. 230 // Pick a bunch of named bitsets and return their intersection.
236 TypeHandle result = Type::Any(region_); 231 TypeHandle result = Type::Any(region_);
237 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { 232 for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) {
238 int j = rng_->NextInt(n); 233 int j = rng_->NextInt(n);
239 #define PICK_BITSET_TYPE(type, value) \ 234 #define PICK_BITSET_TYPE(type, value) \
240 if (j-- == 0) { \ 235 if (j-- == 0) { \
241 if (!SmiValuesAre31Bits() && \
242 (Type::type(region_)->Equals(Type::OtherSigned32()) || \
243 Type::type(region_)->Equals(Type::OtherUnsigned31()))) { \
244 /* Hack: Avoid generating those empty bitset types. */ \
245 continue; \
246 } \
247 TypeHandle tmp = Type::Intersect( \ 236 TypeHandle tmp = Type::Intersect( \
248 result, Type::type(region_), region_); \ 237 result, Type::type(region_), region_); \
249 if (tmp->Is(Type::None()) && i != 0) { \ 238 if (tmp->Is(Type::None()) && i != 0) { \
250 break; \ 239 break; \
251 } else { \ 240 } else { \
252 result = tmp; \ 241 result = tmp; \
253 continue; \ 242 continue; \
254 } \ 243 } \
255 } 244 }
256 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) 245 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 302
314 private: 303 private:
315 Region* region_; 304 Region* region_;
316 v8::base::RandomNumberGenerator* rng_; 305 v8::base::RandomNumberGenerator* rng_;
317 }; 306 };
318 307
319 308
320 } } // namespace v8::internal 309 } } // namespace v8::internal
321 310
322 #endif 311 #endif
OLDNEW
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698