Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: src/ia32/lithium-codegen-ia32.cc

Issue 68723002: Implement Math.random() purely in JavaScript. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments only Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index fd70b7717bb493d50b1d19b8befe23a6ca156f82..fe7dc5495c72162ccde2f3d4b32bccf251a302b1 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -4200,69 +4200,6 @@ void LCodeGen::DoPower(LPower* instr) {
}
-void LCodeGen::DoRandom(LRandom* instr) {
- CpuFeatureScope scope(masm(), SSE2);
-
- // Assert that the register size is indeed the size of each seed.
- static const int kSeedSize = sizeof(uint32_t);
- STATIC_ASSERT(kPointerSize == kSeedSize);
-
- // Load native context
- Register global_object = ToRegister(instr->global_object());
- Register native_context = global_object;
- __ mov(native_context, FieldOperand(
- global_object, GlobalObject::kNativeContextOffset));
-
- // Load state (FixedArray of the native context's random seeds)
- static const int kRandomSeedOffset =
- FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize;
- Register state = native_context;
- __ mov(state, FieldOperand(native_context, kRandomSeedOffset));
-
- // Load state[0].
- Register state0 = ToRegister(instr->scratch());
- __ mov(state0, FieldOperand(state, ByteArray::kHeaderSize));
- // Load state[1].
- Register state1 = ToRegister(instr->scratch2());
- __ mov(state1, FieldOperand(state, ByteArray::kHeaderSize + kSeedSize));
-
- // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16)
- Register scratch3 = ToRegister(instr->scratch3());
- __ movzx_w(scratch3, state0);
- __ imul(scratch3, scratch3, 18273);
- __ shr(state0, 16);
- __ add(state0, scratch3);
- // Save state[0].
- __ mov(FieldOperand(state, ByteArray::kHeaderSize), state0);
-
- // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16)
- __ movzx_w(scratch3, state1);
- __ imul(scratch3, scratch3, 36969);
- __ shr(state1, 16);
- __ add(state1, scratch3);
- // Save state[1].
- __ mov(FieldOperand(state, ByteArray::kHeaderSize + kSeedSize), state1);
-
- // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF)
- Register random = state0;
- __ shl(random, 14);
- __ and_(state1, Immediate(0x3FFFF));
- __ add(random, state1);
-
- // Convert 32 random bits in random to 0.(32 random bits) in a double
- // by computing:
- // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
- XMMRegister result = ToDoubleRegister(instr->result());
- XMMRegister scratch4 = double_scratch0();
- __ mov(scratch3, Immediate(0x49800000)); // 1.0 x 2^20 as single.
- __ movd(scratch4, scratch3);
- __ movd(result, random);
- __ cvtss2sd(scratch4, scratch4);
- __ xorps(result, scratch4);
- __ subsd(result, scratch4);
-}
-
-
void LCodeGen::DoMathLog(LMathLog* instr) {
CpuFeatureScope scope(masm(), SSE2);
ASSERT(instr->value()->Equals(instr->result()));
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698