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

Side by Side Diff: src/mips/lithium-codegen-mips.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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/mips/lithium-mips.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 3833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 MathPowStub stub(MathPowStub::INTEGER); 3844 MathPowStub stub(MathPowStub::INTEGER);
3845 __ CallStub(&stub); 3845 __ CallStub(&stub);
3846 } else { 3846 } else {
3847 ASSERT(exponent_type.IsDouble()); 3847 ASSERT(exponent_type.IsDouble());
3848 MathPowStub stub(MathPowStub::DOUBLE); 3848 MathPowStub stub(MathPowStub::DOUBLE);
3849 __ CallStub(&stub); 3849 __ CallStub(&stub);
3850 } 3850 }
3851 } 3851 }
3852 3852
3853 3853
3854 void LCodeGen::DoRandom(LRandom* instr) {
3855 // Assert that the register size is indeed the size of each seed.
3856 static const int kSeedSize = sizeof(uint32_t);
3857 STATIC_ASSERT(kPointerSize == kSeedSize);
3858
3859 // Load native context.
3860 Register global_object = ToRegister(instr->global_object());
3861 Register native_context = global_object;
3862 __ lw(native_context, FieldMemOperand(
3863 global_object, GlobalObject::kNativeContextOffset));
3864
3865 // Load state (FixedArray of the native context's random seeds).
3866 static const int kRandomSeedOffset =
3867 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize;
3868 Register state = native_context;
3869 __ lw(state, FieldMemOperand(native_context, kRandomSeedOffset));
3870
3871 // Load state[0].
3872 Register state0 = ToRegister(instr->scratch());
3873 __ lw(state0, FieldMemOperand(state, ByteArray::kHeaderSize));
3874 // Load state[1].
3875 Register state1 = ToRegister(instr->scratch2());
3876 __ lw(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize));
3877
3878 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16)
3879 Register scratch3 = ToRegister(instr->scratch3());
3880 Register scratch4 = scratch0();
3881 __ And(scratch3, state0, Operand(0xFFFF));
3882 __ li(scratch4, Operand(18273));
3883 __ Mul(scratch3, scratch3, scratch4);
3884 __ srl(state0, state0, 16);
3885 __ Addu(state0, scratch3, state0);
3886 // Save state[0].
3887 __ sw(state0, FieldMemOperand(state, ByteArray::kHeaderSize));
3888
3889 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16)
3890 __ And(scratch3, state1, Operand(0xFFFF));
3891 __ li(scratch4, Operand(36969));
3892 __ Mul(scratch3, scratch3, scratch4);
3893 __ srl(state1, state1, 16),
3894 __ Addu(state1, scratch3, state1);
3895 // Save state[1].
3896 __ sw(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize));
3897
3898 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF)
3899 Register random = scratch4;
3900 __ And(random, state1, Operand(0x3FFFF));
3901 __ sll(state0, state0, 14);
3902 __ Addu(random, random, state0);
3903
3904 // 0x41300000 is the top half of 1.0 x 2^20 as a double.
3905 __ li(scratch3, Operand(0x41300000));
3906 // Move 0x41300000xxxxxxxx (x = random bits in v0) to FPU.
3907 DoubleRegister result = ToDoubleRegister(instr->result());
3908 __ Move(result, random, scratch3);
3909 // Move 0x4130000000000000 to FPU.
3910 DoubleRegister scratch5 = double_scratch0();
3911 __ Move(scratch5, zero_reg, scratch3);
3912 __ sub_d(result, result, scratch5);
3913 }
3914
3915
3854 void LCodeGen::DoMathExp(LMathExp* instr) { 3916 void LCodeGen::DoMathExp(LMathExp* instr) {
3855 DoubleRegister input = ToDoubleRegister(instr->value()); 3917 DoubleRegister input = ToDoubleRegister(instr->value());
3856 DoubleRegister result = ToDoubleRegister(instr->result()); 3918 DoubleRegister result = ToDoubleRegister(instr->result());
3857 DoubleRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); 3919 DoubleRegister double_scratch1 = ToDoubleRegister(instr->double_temp());
3858 DoubleRegister double_scratch2 = double_scratch0(); 3920 DoubleRegister double_scratch2 = double_scratch0();
3859 Register temp1 = ToRegister(instr->temp1()); 3921 Register temp1 = ToRegister(instr->temp1());
3860 Register temp2 = ToRegister(instr->temp2()); 3922 Register temp2 = ToRegister(instr->temp2());
3861 3923
3862 MathExpGenerator::EmitMathExp( 3924 MathExpGenerator::EmitMathExp(
3863 masm(), input, result, double_scratch1, double_scratch2, 3925 masm(), input, result, double_scratch1, double_scratch2,
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
5845 __ Subu(scratch, result, scratch); 5907 __ Subu(scratch, result, scratch);
5846 __ lw(result, FieldMemOperand(scratch, 5908 __ lw(result, FieldMemOperand(scratch,
5847 FixedArray::kHeaderSize - kPointerSize)); 5909 FixedArray::kHeaderSize - kPointerSize));
5848 __ bind(&done); 5910 __ bind(&done);
5849 } 5911 }
5850 5912
5851 5913
5852 #undef __ 5914 #undef __
5853 5915
5854 } } // namespace v8::internal 5916 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698