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

Unified Diff: test/cctest/test-types.cc

Issue 370973002: Properly seed the RNG for cctest/test-types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arguments.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 7be18c5e7f1d2aa753f5998bb4daa6d6e499ee39..8120a6d94c39cdd014b637f7ab723c925c3d9aa1 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -1,34 +1,11 @@
// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include <vector>
-#include "src/base/utils/random-number-generator.h"
#include "src/hydrogen-types.h"
+#include "src/isolate-inl.h"
#include "src/types.h"
#include "test/cctest/cctest.h"
@@ -127,7 +104,8 @@ struct HeapRep {
template<class Type, class TypeHandle, class Region>
class Types {
public:
- Types(Region* region, Isolate* isolate) : region_(region) {
+ Types(Region* region, Isolate* isolate)
+ : region_(region), rng_(isolate->random_number_generator()) {
#define DECLARE_TYPE(name, value) \
name = Type::name(region); \
types.push_back(name);
@@ -274,18 +252,18 @@ class Types {
}
TypeHandle Random() {
- return types[rng_.NextInt(static_cast<int>(types.size()))];
+ return types[rng_->NextInt(static_cast<int>(types.size()))];
}
TypeHandle Fuzz(int depth = 5) {
- switch (rng_.NextInt(depth == 0 ? 3 : 20)) {
+ switch (rng_->NextInt(depth == 0 ? 3 : 20)) {
case 0: { // bitset
int n = 0
#define COUNT_BITSET_TYPES(type, value) + 1
BITSET_TYPE_LIST(COUNT_BITSET_TYPES)
#undef COUNT_BITSET_TYPES
;
- int i = rng_.NextInt(n);
+ int i = rng_->NextInt(n);
#define PICK_BITSET_TYPE(type, value) \
if (i-- == 0) return Type::type(region_);
BITSET_TYPE_LIST(PICK_BITSET_TYPE)
@@ -293,15 +271,15 @@ class Types {
UNREACHABLE();
}
case 1: { // class
- int i = rng_.NextInt(static_cast<int>(maps.size()));
+ int i = rng_->NextInt(static_cast<int>(maps.size()));
return Type::Class(maps[i], region_);
}
case 2: { // constant
- int i = rng_.NextInt(static_cast<int>(values.size()));
+ int i = rng_->NextInt(static_cast<int>(values.size()));
return Type::Constant(values[i], region_);
}
case 3: { // context
- int depth = rng_.NextInt(3);
+ int depth = rng_->NextInt(3);
TypeHandle type = Type::Internal(region_);
for (int i = 0; i < depth; ++i) type = Type::Context(type, region_);
return type;
@@ -315,7 +293,7 @@ class Types {
case 7: { // function
TypeHandle result = Fuzz(depth / 2);
TypeHandle receiver = Fuzz(depth / 2);
- int arity = rng_.NextInt(3);
+ int arity = rng_->NextInt(3);
TypeHandle type = Type::Function(result, receiver, arity, region_);
for (int i = 0; i < type->AsFunction()->Arity(); ++i) {
TypeHandle parameter = Fuzz(depth - 1);
@@ -323,7 +301,7 @@ class Types {
}
}
default: { // union
- int n = rng_.NextInt(10);
+ int n = rng_->NextInt(10);
TypeHandle type = None;
for (int i = 0; i < n; ++i) {
TypeHandle operand = Fuzz(depth - 1);
@@ -339,7 +317,7 @@ class Types {
private:
Region* region_;
- v8::base::RandomNumberGenerator rng_;
+ v8::base::RandomNumberGenerator* rng_;
};
« no previous file with comments | « src/arguments.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698