Reviewers: jochen,

Message:
PTAL

Description:
Properly seed the RNG for cctest/test-types.

This was broken since r21879, as the RandomNumberGenerator constructor
does no longer look at FLAG_random_seed implicitly.

TEST=cctest/test-types

Please review this at https://codereview.chromium.org/370973002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+15, -36 lines):
  M src/arguments.h
  M test/cctest/test-types.cc


Index: src/arguments.h
diff --git a/src/arguments.h b/src/arguments.h
index 320b6ad6d7d89a264e6593cdb5e0b8556f503da2..fce930fbabd85c53320ab8c251d3ed65f88a85ed 100644
--- a/src/arguments.h
+++ b/src/arguments.h
@@ -6,6 +6,7 @@
 #define V8_ARGUMENTS_H_

 #include "src/allocation.h"
+#include "src/isolate.h"

 namespace v8 {
 namespace internal {
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_;
 };




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to