From: yangguo@chromium.org Date: Fri, 9 Mar 2012 09:51:34 +0000 (+0000) Subject: Simplify V8::FillHeapNumberWithRandom. X-Git-Tag: upstream/4.7.83~17153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f1846173c3bdc3f7309d1afdb30649c09e1a615;p=platform%2Fupstream%2Fv8.git Simplify V8::FillHeapNumberWithRandom. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/9592047 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10975 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/v8.cc b/src/v8.cc index 003c75c..98b3038 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -223,19 +223,17 @@ typedef union { Object* V8::FillHeapNumberWithRandom(Object* heap_number, Context* context) { + double_int_union r; uint64_t random_bits = Random(context); - // Make a double* from address (heap_number + sizeof(double)). - double_int_union* r = reinterpret_cast( - reinterpret_cast(heap_number) + - HeapNumber::kValueOffset - kHeapObjectTag); // 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)). - const double binary_million = 1048576.0; - r->double_value = binary_million; - r->uint64_t_value |= random_bits; - r->double_value -= binary_million; + 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; }