OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 Loading... |
33 #include <stdlib.h> | 33 #include <stdlib.h> |
34 | 34 |
35 #include "v8.h" | 35 #include "v8.h" |
36 | 36 |
37 #include "api.h" | 37 #include "api.h" |
38 #include "factory.h" | 38 #include "factory.h" |
39 #include "objects.h" | 39 #include "objects.h" |
40 #include "cctest.h" | 40 #include "cctest.h" |
41 #include "zone-inl.h" | 41 #include "zone-inl.h" |
42 | 42 |
43 // Adapted from http://en.wikipedia.org/wiki/Multiply-with-carry | |
44 class RandomNumberGenerator { | |
45 public: | |
46 RandomNumberGenerator() { | |
47 init(); | |
48 } | |
49 | |
50 void init(uint32_t seed = 0x5688c73e) { | |
51 static const uint32_t phi = 0x9e3779b9; | |
52 c = 362436; | |
53 i = kQSize-1; | |
54 Q[0] = seed; | |
55 Q[1] = seed + phi; | |
56 Q[2] = seed + phi + phi; | |
57 for (unsigned j = 3; j < kQSize; j++) { | |
58 Q[j] = Q[j - 3] ^ Q[j - 2] ^ phi ^ j; | |
59 } | |
60 } | |
61 | |
62 uint32_t next() { | |
63 uint64_t a = 18782; | |
64 uint32_t r = 0xfffffffe; | |
65 i = (i + 1) & (kQSize-1); | |
66 uint64_t t = a * Q[i] + c; | |
67 c = (t >> 32); | |
68 uint32_t x = static_cast<uint32_t>(t + c); | |
69 if (x < c) { | |
70 x++; | |
71 c++; | |
72 } | |
73 return (Q[i] = r - x); | |
74 } | |
75 | |
76 uint32_t next(int max) { | |
77 return next() % max; | |
78 } | |
79 | |
80 bool next(double threshold) { | |
81 ASSERT(threshold >= 0.0 && threshold <= 1.0); | |
82 if (threshold == 1.0) return true; | |
83 if (threshold == 0.0) return false; | |
84 uint32_t value = next() % 100000; | |
85 return threshold > static_cast<double>(value)/100000.0; | |
86 } | |
87 | |
88 private: | |
89 static const uint32_t kQSize = 4096; | |
90 uint32_t Q[kQSize]; | |
91 uint32_t c; | |
92 uint32_t i; | |
93 }; | |
94 | |
95 | 43 |
96 using namespace v8::internal; | 44 using namespace v8::internal; |
97 | 45 |
98 | 46 |
99 static const int DEEP_DEPTH = 8 * 1024; | 47 static const int DEEP_DEPTH = 8 * 1024; |
100 static const int SUPER_DEEP_DEPTH = 80 * 1024; | 48 static const int SUPER_DEEP_DEPTH = 80 * 1024; |
101 | 49 |
102 | 50 |
103 class Resource: public v8::String::ExternalStringResource, | 51 class Resource: public v8::String::ExternalStringResource, |
104 public ZoneObject { | 52 public ZoneObject { |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 CheckCanonicalEquivalence(c, test); | 1297 CheckCanonicalEquivalence(c, test); |
1350 continue; | 1298 continue; |
1351 } | 1299 } |
1352 if (upper != c && lower != c) { | 1300 if (upper != c && lower != c) { |
1353 CheckCanonicalEquivalence(c, test); | 1301 CheckCanonicalEquivalence(c, test); |
1354 continue; | 1302 continue; |
1355 } | 1303 } |
1356 CHECK_EQ(Min(upper, lower), test); | 1304 CHECK_EQ(Min(upper, lower), test); |
1357 } | 1305 } |
1358 } | 1306 } |
OLD | NEW |