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

Side by Side Diff: test/cctest/cctest.h

Issue 22343003: Rollback of r16040 in trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Remove .rej file Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/version.cc ('k') | test/cctest/test-global-handles.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // Helper function that simulates a full old-space in the heap. 293 // Helper function that simulates a full old-space in the heap.
294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { 294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
295 int old_linear_size = static_cast<int>(space->limit() - space->top()); 295 int old_linear_size = static_cast<int>(space->limit() - space->top());
296 space->Free(space->top(), old_linear_size); 296 space->Free(space->top(), old_linear_size);
297 space->SetTop(space->limit(), space->limit()); 297 space->SetTop(space->limit(), space->limit());
298 space->ResetFreeList(); 298 space->ResetFreeList();
299 space->ClearStats(); 299 space->ClearStats();
300 } 300 }
301 301
302 302
303 // Adapted from http://en.wikipedia.org/wiki/Multiply-with-carry
304 class RandomNumberGenerator {
305 public:
306 RandomNumberGenerator() {
307 init();
308 }
309
310 void init(uint32_t seed = 0x5688c73e) {
311 static const uint32_t phi = 0x9e3779b9;
312 c = 362436;
313 i = kQSize-1;
314 Q[0] = seed;
315 Q[1] = seed + phi;
316 Q[2] = seed + phi + phi;
317 for (unsigned j = 3; j < kQSize; j++) {
318 Q[j] = Q[j - 3] ^ Q[j - 2] ^ phi ^ j;
319 }
320 }
321
322 uint32_t next() {
323 uint64_t a = 18782;
324 uint32_t r = 0xfffffffe;
325 i = (i + 1) & (kQSize-1);
326 uint64_t t = a * Q[i] + c;
327 c = (t >> 32);
328 uint32_t x = static_cast<uint32_t>(t + c);
329 if (x < c) {
330 x++;
331 c++;
332 }
333 return (Q[i] = r - x);
334 }
335
336 uint32_t next(int max) {
337 return next() % max;
338 }
339
340 bool next(double threshold) {
341 ASSERT(threshold >= 0.0 && threshold <= 1.0);
342 if (threshold == 1.0) return true;
343 if (threshold == 0.0) return false;
344 uint32_t value = next() % 100000;
345 return threshold > static_cast<double>(value)/100000.0;
346 }
347
348 private:
349 static const uint32_t kQSize = 4096;
350 uint32_t Q[kQSize];
351 uint32_t c;
352 uint32_t i;
353 };
354
355
356 #endif // ifndef CCTEST_H_ 303 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/version.cc ('k') | test/cctest/test-global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698