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

Side by Side Diff: src/arm/lithium-codegen-arm.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/arm/lithium-arm.cc ('k') | src/assembler.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 3916 matching lines...) Expand 10 before | Expand all | Expand 10 after
3927 MathPowStub stub(MathPowStub::INTEGER); 3927 MathPowStub stub(MathPowStub::INTEGER);
3928 __ CallStub(&stub); 3928 __ CallStub(&stub);
3929 } else { 3929 } else {
3930 ASSERT(exponent_type.IsDouble()); 3930 ASSERT(exponent_type.IsDouble());
3931 MathPowStub stub(MathPowStub::DOUBLE); 3931 MathPowStub stub(MathPowStub::DOUBLE);
3932 __ CallStub(&stub); 3932 __ CallStub(&stub);
3933 } 3933 }
3934 } 3934 }
3935 3935
3936 3936
3937 void LCodeGen::DoRandom(LRandom* instr) {
3938 // Assert that the register size is indeed the size of each seed.
3939 static const int kSeedSize = sizeof(uint32_t);
3940 STATIC_ASSERT(kPointerSize == kSeedSize);
3941
3942 // Load native context
3943 Register global_object = ToRegister(instr->global_object());
3944 Register native_context = global_object;
3945 __ ldr(native_context, FieldMemOperand(
3946 global_object, GlobalObject::kNativeContextOffset));
3947
3948 // Load state (FixedArray of the native context's random seeds)
3949 static const int kRandomSeedOffset =
3950 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize;
3951 Register state = native_context;
3952 __ ldr(state, FieldMemOperand(native_context, kRandomSeedOffset));
3953
3954 // Load state[0].
3955 Register state0 = ToRegister(instr->scratch());
3956 __ ldr(state0, FieldMemOperand(state, ByteArray::kHeaderSize));
3957 // Load state[1].
3958 Register state1 = ToRegister(instr->scratch2());
3959 __ ldr(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize));
3960
3961 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16)
3962 Register scratch3 = ToRegister(instr->scratch3());
3963 Register scratch4 = scratch0();
3964 __ and_(scratch3, state0, Operand(0xFFFF));
3965 __ mov(scratch4, Operand(18273));
3966 __ mul(scratch3, scratch3, scratch4);
3967 __ add(state0, scratch3, Operand(state0, LSR, 16));
3968 // Save state[0].
3969 __ str(state0, FieldMemOperand(state, ByteArray::kHeaderSize));
3970
3971 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16)
3972 __ and_(scratch3, state1, Operand(0xFFFF));
3973 __ mov(scratch4, Operand(36969));
3974 __ mul(scratch3, scratch3, scratch4);
3975 __ add(state1, scratch3, Operand(state1, LSR, 16));
3976 // Save state[1].
3977 __ str(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize));
3978
3979 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF)
3980 Register random = scratch4;
3981 __ and_(random, state1, Operand(0x3FFFF));
3982 __ add(random, random, Operand(state0, LSL, 14));
3983
3984 // 0x41300000 is the top half of 1.0 x 2^20 as a double.
3985 // Create this constant using mov/orr to avoid PC relative load.
3986 __ mov(scratch3, Operand(0x41000000));
3987 __ orr(scratch3, scratch3, Operand(0x300000));
3988 // Move 0x41300000xxxxxxxx (x = random bits) to VFP.
3989 DwVfpRegister result = ToDoubleRegister(instr->result());
3990 __ vmov(result, random, scratch3);
3991 // Move 0x4130000000000000 to VFP.
3992 __ mov(scratch4, Operand::Zero());
3993 DwVfpRegister scratch5 = double_scratch0();
3994 __ vmov(scratch5, scratch4, scratch3);
3995 __ vsub(result, result, scratch5);
3996 }
3997
3998
3937 void LCodeGen::DoMathExp(LMathExp* instr) { 3999 void LCodeGen::DoMathExp(LMathExp* instr) {
3938 DwVfpRegister input = ToDoubleRegister(instr->value()); 4000 DwVfpRegister input = ToDoubleRegister(instr->value());
3939 DwVfpRegister result = ToDoubleRegister(instr->result()); 4001 DwVfpRegister result = ToDoubleRegister(instr->result());
3940 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); 4002 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp());
3941 DwVfpRegister double_scratch2 = double_scratch0(); 4003 DwVfpRegister double_scratch2 = double_scratch0();
3942 Register temp1 = ToRegister(instr->temp1()); 4004 Register temp1 = ToRegister(instr->temp1());
3943 Register temp2 = ToRegister(instr->temp2()); 4005 Register temp2 = ToRegister(instr->temp2());
3944 4006
3945 MathExpGenerator::EmitMathExp( 4007 MathExpGenerator::EmitMathExp(
3946 masm(), input, result, double_scratch1, double_scratch2, 4008 masm(), input, result, double_scratch1, double_scratch2,
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
5856 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); 5918 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index));
5857 __ ldr(result, FieldMemOperand(scratch, 5919 __ ldr(result, FieldMemOperand(scratch,
5858 FixedArray::kHeaderSize - kPointerSize)); 5920 FixedArray::kHeaderSize - kPointerSize));
5859 __ bind(&done); 5921 __ bind(&done);
5860 } 5922 }
5861 5923
5862 5924
5863 #undef __ 5925 #undef __
5864 5926
5865 } } // namespace v8::internal 5927 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698