From ba24c3a79ff41d059a7aebb576e215f5483f631a Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 8 Nov 2013 10:55:01 +0000 Subject: [PATCH] Removed dead function V8::FillHeapNumberWithRandom. Removed a useless test case along the way. R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/65143007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17584 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/assembler.cc | 8 ---- src/assembler.h | 2 - src/serialize.cc | 5 --- src/v8.cc | 24 ----------- src/v8.h | 2 - test/cctest/test-random.cc | 100 --------------------------------------------- 6 files changed, 141 deletions(-) delete mode 100644 test/cctest/test-random.cc diff --git a/src/assembler.cc b/src/assembler.cc index eb88922..c06e15b 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -1053,14 +1053,6 @@ ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) { } -ExternalReference ExternalReference::fill_heap_number_with_random_function( - Isolate* isolate) { - return ExternalReference(Redirect( - isolate, - FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); -} - - ExternalReference ExternalReference::delete_handle_scope_extensions( Isolate* isolate) { return ExternalReference(Redirect( diff --git a/src/assembler.h b/src/assembler.h index ee51f23..8ec3ad7 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -715,8 +715,6 @@ class ExternalReference BASE_EMBEDDED { Isolate* isolate); static ExternalReference flush_icache_function(Isolate* isolate); static ExternalReference perform_gc_function(Isolate* isolate); - static ExternalReference fill_heap_number_with_random_function( - Isolate* isolate); static ExternalReference random_uint32_function(Isolate* isolate); static ExternalReference transcendental_cache_array_address(Isolate* isolate); static ExternalReference delete_handle_scope_extensions(Isolate* isolate); diff --git a/src/serialize.cc b/src/serialize.cc index 4c89bcf..89d6b14 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -297,11 +297,6 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { RUNTIME_ENTRY, 1, "Runtime::PerformGC"); - Add(ExternalReference::fill_heap_number_with_random_function( - isolate).address(), - RUNTIME_ENTRY, - 2, - "V8::FillHeapNumberWithRandom"); Add(ExternalReference::random_uint32_function(isolate).address(), RUNTIME_ENTRY, 3, diff --git a/src/v8.cc b/src/v8.cc index fc6c56d..c35230d 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -171,30 +171,6 @@ void V8::FireCallCompletedCallback(Isolate* isolate) { } -// Use a union type to avoid type-aliasing optimizations in GCC. -typedef union { - double double_value; - uint64_t uint64_t_value; -} double_int_union; - - -Object* V8::FillHeapNumberWithRandom(Object* heap_number, - Context* context) { - double_int_union r; - uint64_t random_bits = Random(context); - // Convert 32 random bits to 0.(32 random bits) in a double - // by computing: - // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). - static const double binary_million = 1048576.0; - r.double_value = binary_million; - r.uint64_t_value |= random_bits; - r.double_value -= binary_million; - - HeapNumber::cast(heap_number)->set_value(r.double_value); - return heap_number; -} - - void V8::InitializeOncePerProcessImpl() { FlagList::EnforceFlagImplications(); if (FLAG_stress_compaction) { diff --git a/src/v8.h b/src/v8.h index 5848f74..01362ab 100644 --- a/src/v8.h +++ b/src/v8.h @@ -97,8 +97,6 @@ class V8 : public AllStatic { static void SetFunctionEntryHook(FunctionEntryHook entry_hook); // Random number generation support. Not cryptographically safe. static uint32_t Random(Context* context); - static Object* FillHeapNumberWithRandom(Object* heap_number, - Context* context); static void AddCallCompletedCallback(CallCompletedCallback callback); static void RemoveCallCompletedCallback(CallCompletedCallback callback); diff --git a/test/cctest/test-random.cc b/test/cctest/test-random.cc deleted file mode 100644 index ea1f36f..0000000 --- a/test/cctest/test-random.cc +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2012 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. - -#include "v8.h" - -#include "cctest.h" -#include "compiler.h" -#include "execution.h" -#include "isolate.h" - - -using namespace v8::internal; - - -void SetSeeds(Handle seeds, uint32_t state0, uint32_t state1) { - for (int i = 0; i < 4; i++) { - seeds->set(i, static_cast(state0 >> (i * kBitsPerByte))); - seeds->set(i + 4, static_cast(state1 >> (i * kBitsPerByte))); - } -} - - -void TestSeeds(Handle fun, - Handle context, - uint32_t state0, - uint32_t state1) { - bool has_pending_exception; - Handle global(context->global_object()); - Handle seeds(context->random_seed()); - - SetSeeds(seeds, state0, state1); - Handle value = Execution::Call( - context->GetIsolate(), fun, global, 0, NULL, &has_pending_exception); - CHECK(value->IsHeapNumber()); - CHECK(fun->IsOptimized()); - double crankshaft_value = HeapNumber::cast(*value)->value(); - - SetSeeds(seeds, state0, state1); - V8::FillHeapNumberWithRandom(*value, *context); - double runtime_value = HeapNumber::cast(*value)->value(); - CHECK_EQ(runtime_value, crankshaft_value); -} - - -TEST(CrankshaftRandom) { - v8::V8::Initialize(); - // Skip test if crankshaft is disabled. - if (!CcTest::i_isolate()->use_crankshaft()) return; - v8::Isolate* v8_isolate = CcTest::isolate(); - v8::HandleScope scope(v8_isolate); - v8::Context::Scope context_scope(v8::Context::New(v8_isolate)); - - i::Isolate* isolate = reinterpret_cast(v8_isolate); - Handle context(isolate->context()); - Handle global(context->global_object()); - Handle seeds(context->random_seed()); - bool has_pending_exception; - - CompileRun("function f() { return Math.random(); }"); - - Object* string = CcTest::i_isolate()->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("f"))->ToObjectChecked(); - MaybeObject* fun_object = - context->global_object()->GetProperty(String::cast(string)); - Handle fun(JSFunction::cast(fun_object->ToObjectChecked())); - - // Optimize function. - Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); - Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); - if (!fun->IsOptimized()) fun->MarkForLazyRecompilation(); - - // Test with some random values. - TestSeeds(fun, context, 0xC0C0AFFE, 0x31415926); - TestSeeds(fun, context, 0x01020304, 0xFFFFFFFF); - TestSeeds(fun, context, 0x00000001, 0x00000001); -} -- 2.7.4