Commit 5f721c3f authored by whesse@chromium.org's avatar whesse@chromium.org

Speed up V8 random number generator, reverting part of 8490.

Return to previous random number generator, but mix more bits into
output to hide hidden state better.  Keep the multithreading fix that
moves the PNG into isolate.

BUG=
TEST=

Review URL: http://codereview.chromium.org/7250005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8524 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 57c29c1f
......@@ -332,8 +332,8 @@ class HashMap;
V(int, bad_char_shift_table, kUC16AlphabetSize) \
V(int, good_suffix_shift_table, (kBMMaxShift + 1)) \
V(int, suffix_table, (kBMMaxShift + 1)) \
V(uint32_t, random_seed, 4) \
V(uint32_t, private_random_seed, 4) \
V(uint32_t, random_seed, 2) \
V(uint32_t, private_random_seed, 2) \
ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
......
......@@ -101,7 +101,7 @@ void V8::TearDown() {
static void seed_random(uint32_t* state) {
for (int i = 0; i < 4; ++i) {
for (int i = 0; i < 2; ++i) {
state[i] = FLAG_random_seed;
while (state[i] == 0) {
state[i] = random();
......@@ -119,10 +119,8 @@ static uint32_t random_base(uint32_t* state) {
// Mix the bits. Never replaces state[i] with 0 if it is nonzero.
state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16);
state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16);
state[2] = 23208 * (state[2] & 0xFFFF) + (state[2] >> 16);
state[3] = 27753 * (state[3] & 0xFFFF) + (state[3] >> 16);
return ((state[2] ^ state[3]) << 16) + ((state[0] ^ state[1]) & 0xFFFF);
return (state[0] << 14) + (state[1] & 0x3FFFF);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment