Revision: 17584
Author: [email protected]
Date: Fri Nov 8 10:55:01 2013 UTC
Log: Removed dead function V8::FillHeapNumberWithRandom.
Removed a useless test case along the way.
[email protected]
Review URL: https://codereview.chromium.org/65143007
http://code.google.com/p/v8/source/detail?r=17584
Deleted:
/branches/bleeding_edge/test/cctest/test-random.cc
Modified:
/branches/bleeding_edge/src/assembler.cc
/branches/bleeding_edge/src/assembler.h
/branches/bleeding_edge/src/serialize.cc
/branches/bleeding_edge/src/v8.cc
/branches/bleeding_edge/src/v8.h
=======================================
--- /branches/bleeding_edge/test/cctest/test-random.cc Thu Sep 19 09:17:13
2013 UTC
+++ /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<ByteArray> seeds, uint32_t state0, uint32_t state1) {
- for (int i = 0; i < 4; i++) {
- seeds->set(i, static_cast<byte>(state0 >> (i * kBitsPerByte)));
- seeds->set(i + 4, static_cast<byte>(state1 >> (i * kBitsPerByte)));
- }
-}
-
-
-void TestSeeds(Handle<JSFunction> fun,
- Handle<Context> context,
- uint32_t state0,
- uint32_t state1) {
- bool has_pending_exception;
- Handle<JSObject> global(context->global_object());
- Handle<ByteArray> seeds(context->random_seed());
-
- SetSeeds(seeds, state0, state1);
- Handle<Object> 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<i::Isolate*>(v8_isolate);
- Handle<Context> context(isolate->context());
- Handle<JSObject> global(context->global_object());
- Handle<ByteArray> 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<JSFunction> 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);
-}
=======================================
--- /branches/bleeding_edge/src/assembler.cc Thu Nov 7 16:35:27 2013 UTC
+++ /branches/bleeding_edge/src/assembler.cc Fri Nov 8 10:55:01 2013 UTC
@@ -1051,14 +1051,6 @@
return
ExternalReference(Redirect(isolate,
FUNCTION_ADDR(Runtime::PerformGC)));
}
-
-
-ExternalReference ExternalReference::fill_heap_number_with_random_function(
- Isolate* isolate) {
- return ExternalReference(Redirect(
- isolate,
- FUNCTION_ADDR(V8::FillHeapNumberWithRandom)));
-}
ExternalReference ExternalReference::delete_handle_scope_extensions(
=======================================
--- /branches/bleeding_edge/src/assembler.h Tue Nov 5 10:14:48 2013 UTC
+++ /branches/bleeding_edge/src/assembler.h Fri Nov 8 10:55:01 2013 UTC
@@ -715,8 +715,6 @@
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);
=======================================
--- /branches/bleeding_edge/src/serialize.cc Thu Nov 7 07:37:28 2013 UTC
+++ /branches/bleeding_edge/src/serialize.cc Fri Nov 8 10:55:01 2013 UTC
@@ -297,11 +297,6 @@
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,
=======================================
--- /branches/bleeding_edge/src/v8.cc Thu Nov 7 16:25:20 2013 UTC
+++ /branches/bleeding_edge/src/v8.cc Fri Nov 8 10:55:01 2013 UTC
@@ -169,30 +169,6 @@
}
handle_scope_implementer->DecrementCallDepth();
}
-
-
-// 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() {
=======================================
--- /branches/bleeding_edge/src/v8.h Wed Oct 2 09:01:40 2013 UTC
+++ /branches/bleeding_edge/src/v8.h Fri Nov 8 10:55:01 2013 UTC
@@ -97,8 +97,6 @@
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);
--
--
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/groups/opt_out.