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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 80513004: Revert 17963, 17962 and 17955: Random number generator in JS changes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove Yang's changes, too Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4149 matching lines...) Expand 10 before | Expand all | Expand 10 after
4160 MathPowStub stub(MathPowStub::INTEGER); 4160 MathPowStub stub(MathPowStub::INTEGER);
4161 __ CallStub(&stub); 4161 __ CallStub(&stub);
4162 } else { 4162 } else {
4163 ASSERT(exponent_type.IsDouble()); 4163 ASSERT(exponent_type.IsDouble());
4164 MathPowStub stub(MathPowStub::DOUBLE); 4164 MathPowStub stub(MathPowStub::DOUBLE);
4165 __ CallStub(&stub); 4165 __ CallStub(&stub);
4166 } 4166 }
4167 } 4167 }
4168 4168
4169 4169
4170 void LCodeGen::DoRandom(LRandom* instr) {
4171 CpuFeatureScope scope(masm(), SSE2);
4172
4173 // Assert that the register size is indeed the size of each seed.
4174 static const int kSeedSize = sizeof(uint32_t);
4175 STATIC_ASSERT(kPointerSize == kSeedSize);
4176
4177 // Load native context
4178 Register global_object = ToRegister(instr->global_object());
4179 Register native_context = global_object;
4180 __ mov(native_context, FieldOperand(
4181 global_object, GlobalObject::kNativeContextOffset));
4182
4183 // Load state (FixedArray of the native context's random seeds)
4184 static const int kRandomSeedOffset =
4185 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize;
4186 Register state = native_context;
4187 __ mov(state, FieldOperand(native_context, kRandomSeedOffset));
4188
4189 // Load state[0].
4190 Register state0 = ToRegister(instr->scratch());
4191 __ mov(state0, FieldOperand(state, ByteArray::kHeaderSize));
4192 // Load state[1].
4193 Register state1 = ToRegister(instr->scratch2());
4194 __ mov(state1, FieldOperand(state, ByteArray::kHeaderSize + kSeedSize));
4195
4196 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16)
4197 Register scratch3 = ToRegister(instr->scratch3());
4198 __ movzx_w(scratch3, state0);
4199 __ imul(scratch3, scratch3, 18273);
4200 __ shr(state0, 16);
4201 __ add(state0, scratch3);
4202 // Save state[0].
4203 __ mov(FieldOperand(state, ByteArray::kHeaderSize), state0);
4204
4205 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16)
4206 __ movzx_w(scratch3, state1);
4207 __ imul(scratch3, scratch3, 36969);
4208 __ shr(state1, 16);
4209 __ add(state1, scratch3);
4210 // Save state[1].
4211 __ mov(FieldOperand(state, ByteArray::kHeaderSize + kSeedSize), state1);
4212
4213 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF)
4214 Register random = state0;
4215 __ shl(random, 14);
4216 __ and_(state1, Immediate(0x3FFFF));
4217 __ add(random, state1);
4218
4219 // Convert 32 random bits in random to 0.(32 random bits) in a double
4220 // by computing:
4221 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
4222 XMMRegister result = ToDoubleRegister(instr->result());
4223 XMMRegister scratch4 = double_scratch0();
4224 __ mov(scratch3, Immediate(0x49800000)); // 1.0 x 2^20 as single.
4225 __ movd(scratch4, scratch3);
4226 __ movd(result, random);
4227 __ cvtss2sd(scratch4, scratch4);
4228 __ xorps(result, scratch4);
4229 __ subsd(result, scratch4);
4230 }
4231
4232
4170 void LCodeGen::DoMathLog(LMathLog* instr) { 4233 void LCodeGen::DoMathLog(LMathLog* instr) {
4171 CpuFeatureScope scope(masm(), SSE2); 4234 CpuFeatureScope scope(masm(), SSE2);
4172 ASSERT(instr->value()->Equals(instr->result())); 4235 ASSERT(instr->value()->Equals(instr->result()));
4173 XMMRegister input_reg = ToDoubleRegister(instr->value()); 4236 XMMRegister input_reg = ToDoubleRegister(instr->value());
4174 XMMRegister xmm_scratch = double_scratch0(); 4237 XMMRegister xmm_scratch = double_scratch0();
4175 Label positive, done, zero; 4238 Label positive, done, zero;
4176 __ xorps(xmm_scratch, xmm_scratch); 4239 __ xorps(xmm_scratch, xmm_scratch);
4177 __ ucomisd(input_reg, xmm_scratch); 4240 __ ucomisd(input_reg, xmm_scratch);
4178 __ j(above, &positive, Label::kNear); 4241 __ j(above, &positive, Label::kNear);
4179 __ j(equal, &zero, Label::kNear); 4242 __ j(equal, &zero, Label::kNear);
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
6413 FixedArray::kHeaderSize - kPointerSize)); 6476 FixedArray::kHeaderSize - kPointerSize));
6414 __ bind(&done); 6477 __ bind(&done);
6415 } 6478 }
6416 6479
6417 6480
6418 #undef __ 6481 #undef __
6419 6482
6420 } } // namespace v8::internal 6483 } } // namespace v8::internal
6421 6484
6422 #endif // V8_TARGET_ARCH_IA32 6485 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« 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