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

Side by Side Diff: test/cctest/test-types.cc

Issue 231443002: Improve reproducibility of test runs. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Address nit Created 6 years, 8 months 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-strtod.cc ('k') | test/mjsunit/mjsunit.status » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <list> 28 #include <list>
29 29
30 #include "cctest.h" 30 #include "cctest.h"
31 #include "types.h" 31 #include "types.h"
32 #include "utils/random-number-generator.h"
32 33
33 using namespace v8::internal; 34 using namespace v8::internal;
34 35
35 template<class Type, class TypeHandle, class Region> 36 template<class Type, class TypeHandle, class Region>
36 class Types { 37 class Types {
37 public: 38 public:
38 Types(Region* region, Isolate* isolate) : 39 Types(Region* region, Isolate* isolate) :
39 Representation(Type::Representation(region)), 40 Representation(Type::Representation(region)),
40 Semantic(Type::Semantic(region)), 41 Semantic(Type::Semantic(region)),
41 None(Type::None(region)), 42 None(Type::None(region)),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 types.push_back(Fuzz()); 106 types.push_back(Fuzz());
106 } 107 }
107 108
108 objects.push_back(smi); 109 objects.push_back(smi);
109 objects.push_back(signed32); 110 objects.push_back(signed32);
110 objects.push_back(object1); 111 objects.push_back(object1);
111 objects.push_back(object2); 112 objects.push_back(object2);
112 objects.push_back(array); 113 objects.push_back(array);
113 } 114 }
114 115
116 RandomNumberGenerator rng;
117
115 TypeHandle Representation; 118 TypeHandle Representation;
116 TypeHandle Semantic; 119 TypeHandle Semantic;
117 TypeHandle None; 120 TypeHandle None;
118 TypeHandle Any; 121 TypeHandle Any;
119 TypeHandle Boolean; 122 TypeHandle Boolean;
120 TypeHandle Null; 123 TypeHandle Null;
121 TypeHandle Undefined; 124 TypeHandle Undefined;
122 TypeHandle Number; 125 TypeHandle Number;
123 TypeHandle SignedSmall; 126 TypeHandle SignedSmall;
124 TypeHandle Signed32; 127 TypeHandle Signed32;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { 176 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) {
174 return Type::Intersect(t1, t2, region_); 177 return Type::Intersect(t1, t2, region_);
175 } 178 }
176 179
177 template<class Type2, class TypeHandle2> 180 template<class Type2, class TypeHandle2>
178 TypeHandle Convert(TypeHandle2 t) { 181 TypeHandle Convert(TypeHandle2 t) {
179 return Type::template Convert<Type2>(t, region_); 182 return Type::template Convert<Type2>(t, region_);
180 } 183 }
181 184
182 TypeHandle Fuzz(int depth = 5) { 185 TypeHandle Fuzz(int depth = 5) {
183 switch (rand() % (depth == 0 ? 3 : 20)) { 186 switch (rng.NextInt(depth == 0 ? 3 : 20)) {
184 case 0: { // bitset 187 case 0: { // bitset
185 int n = 0 188 int n = 0
186 #define COUNT_BITSET_TYPES(type, value) + 1 189 #define COUNT_BITSET_TYPES(type, value) + 1
187 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) 190 BITSET_TYPE_LIST(COUNT_BITSET_TYPES)
188 #undef COUNT_BITSET_TYPES 191 #undef COUNT_BITSET_TYPES
189 ; 192 ;
190 int i = rand() % n; 193 int i = rng.NextInt(n);
191 #define PICK_BITSET_TYPE(type, value) \ 194 #define PICK_BITSET_TYPE(type, value) \
192 if (i-- == 0) return Type::type(region_); 195 if (i-- == 0) return Type::type(region_);
193 BITSET_TYPE_LIST(PICK_BITSET_TYPE) 196 BITSET_TYPE_LIST(PICK_BITSET_TYPE)
194 #undef PICK_BITSET_TYPE 197 #undef PICK_BITSET_TYPE
195 UNREACHABLE(); 198 UNREACHABLE();
196 } 199 }
197 case 1: // class 200 case 1: // class
198 switch (rand() % 2) { 201 switch (rng.NextInt(2)) {
199 case 0: return ObjectClass; 202 case 0: return ObjectClass;
200 case 1: return ArrayClass; 203 case 1: return ArrayClass;
201 } 204 }
202 UNREACHABLE(); 205 UNREACHABLE();
203 case 2: // constant 206 case 2: // constant
204 switch (rand() % 6) { 207 switch (rng.NextInt(6)) {
205 case 0: return SmiConstant; 208 case 0: return SmiConstant;
206 case 1: return Signed32Constant; 209 case 1: return Signed32Constant;
207 case 2: return ObjectConstant1; 210 case 2: return ObjectConstant1;
208 case 3: return ObjectConstant2; 211 case 3: return ObjectConstant2;
209 case 4: return ArrayConstant1; 212 case 4: return ArrayConstant1;
210 case 5: return ArrayConstant2; 213 case 5: return ArrayConstant2;
211 } 214 }
212 UNREACHABLE(); 215 UNREACHABLE();
213 default: { // union 216 default: { // union
214 int n = rand() % 10; 217 int n = rng.NextInt(10);
215 TypeHandle type = None; 218 TypeHandle type = None;
216 for (int i = 0; i < n; ++i) { 219 for (int i = 0; i < n; ++i) {
217 type = Type::Union(type, Fuzz(depth - 1), region_); 220 type = Type::Union(type, Fuzz(depth - 1), region_);
218 } 221 }
219 return type; 222 return type;
220 } 223 }
221 } 224 }
222 UNREACHABLE(); 225 UNREACHABLE();
223 } 226 }
224 227
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 ZoneTests().Intersect(); 1100 ZoneTests().Intersect();
1098 HeapTests().Intersect(); 1101 HeapTests().Intersect();
1099 } 1102 }
1100 1103
1101 1104
1102 TEST(Convert) { 1105 TEST(Convert) {
1103 CcTest::InitializeVM(); 1106 CcTest::InitializeVM();
1104 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 1107 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
1105 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 1108 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
1106 } 1109 }
OLDNEW
« no previous file with comments | « test/cctest/test-strtod.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698