| OLD | NEW | 
|     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 3855 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3866     MathPowStub stub(MathPowStub::INTEGER); |  3866     MathPowStub stub(MathPowStub::INTEGER); | 
|  3867     __ CallStub(&stub); |  3867     __ CallStub(&stub); | 
|  3868   } else { |  3868   } else { | 
|  3869     ASSERT(exponent_type.IsDouble()); |  3869     ASSERT(exponent_type.IsDouble()); | 
|  3870     MathPowStub stub(MathPowStub::DOUBLE); |  3870     MathPowStub stub(MathPowStub::DOUBLE); | 
|  3871     __ CallStub(&stub); |  3871     __ CallStub(&stub); | 
|  3872   } |  3872   } | 
|  3873 } |  3873 } | 
|  3874  |  3874  | 
|  3875  |  3875  | 
|  3876 void LCodeGen::DoRandom(LRandom* instr) { |  | 
|  3877   // Assert that the register size is indeed the size of each seed. |  | 
|  3878   static const int kSeedSize = sizeof(uint32_t); |  | 
|  3879   STATIC_ASSERT(kPointerSize == kSeedSize); |  | 
|  3880  |  | 
|  3881   // Load native context. |  | 
|  3882   Register global_object = ToRegister(instr->global_object()); |  | 
|  3883   Register native_context = global_object; |  | 
|  3884   __ lw(native_context, FieldMemOperand( |  | 
|  3885           global_object, GlobalObject::kNativeContextOffset)); |  | 
|  3886  |  | 
|  3887   // Load state (FixedArray of the native context's random seeds). |  | 
|  3888   static const int kRandomSeedOffset = |  | 
|  3889       FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; |  | 
|  3890   Register state = native_context; |  | 
|  3891   __ lw(state, FieldMemOperand(native_context, kRandomSeedOffset)); |  | 
|  3892  |  | 
|  3893   // Load state[0]. |  | 
|  3894   Register state0 = ToRegister(instr->scratch()); |  | 
|  3895   __ lw(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); |  | 
|  3896   // Load state[1]. |  | 
|  3897   Register state1 = ToRegister(instr->scratch2()); |  | 
|  3898   __ lw(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); |  | 
|  3899  |  | 
|  3900   // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) |  | 
|  3901   Register scratch3 = ToRegister(instr->scratch3()); |  | 
|  3902   Register scratch4 = scratch0(); |  | 
|  3903   __ And(scratch3, state0, Operand(0xFFFF)); |  | 
|  3904   __ li(scratch4, Operand(18273)); |  | 
|  3905   __ Mul(scratch3, scratch3, scratch4); |  | 
|  3906   __ srl(state0, state0, 16); |  | 
|  3907   __ Addu(state0, scratch3, state0); |  | 
|  3908   // Save state[0]. |  | 
|  3909   __ sw(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); |  | 
|  3910  |  | 
|  3911   // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16) |  | 
|  3912   __ And(scratch3, state1, Operand(0xFFFF)); |  | 
|  3913   __ li(scratch4, Operand(36969)); |  | 
|  3914   __ Mul(scratch3, scratch3, scratch4); |  | 
|  3915   __ srl(state1, state1, 16), |  | 
|  3916   __ Addu(state1, scratch3, state1); |  | 
|  3917   // Save state[1]. |  | 
|  3918   __ sw(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); |  | 
|  3919  |  | 
|  3920   // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) |  | 
|  3921   Register random = scratch4; |  | 
|  3922   __ And(random, state1, Operand(0x3FFFF)); |  | 
|  3923   __ sll(state0, state0, 14); |  | 
|  3924   __ Addu(random, random, state0); |  | 
|  3925  |  | 
|  3926   // 0x41300000 is the top half of 1.0 x 2^20 as a double. |  | 
|  3927   __ li(scratch3, Operand(0x41300000)); |  | 
|  3928   // Move 0x41300000xxxxxxxx (x = random bits in v0) to FPU. |  | 
|  3929   DoubleRegister result = ToDoubleRegister(instr->result()); |  | 
|  3930   __ Move(result, random, scratch3); |  | 
|  3931   // Move 0x4130000000000000 to FPU. |  | 
|  3932   DoubleRegister scratch5 = double_scratch0(); |  | 
|  3933   __ Move(scratch5, zero_reg, scratch3); |  | 
|  3934   __ sub_d(result, result, scratch5); |  | 
|  3935 } |  | 
|  3936  |  | 
|  3937  |  | 
|  3938 void LCodeGen::DoMathExp(LMathExp* instr) { |  3876 void LCodeGen::DoMathExp(LMathExp* instr) { | 
|  3939   DoubleRegister input = ToDoubleRegister(instr->value()); |  3877   DoubleRegister input = ToDoubleRegister(instr->value()); | 
|  3940   DoubleRegister result = ToDoubleRegister(instr->result()); |  3878   DoubleRegister result = ToDoubleRegister(instr->result()); | 
|  3941   DoubleRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); |  3879   DoubleRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); | 
|  3942   DoubleRegister double_scratch2 = double_scratch0(); |  3880   DoubleRegister double_scratch2 = double_scratch0(); | 
|  3943   Register temp1 = ToRegister(instr->temp1()); |  3881   Register temp1 = ToRegister(instr->temp1()); | 
|  3944   Register temp2 = ToRegister(instr->temp2()); |  3882   Register temp2 = ToRegister(instr->temp2()); | 
|  3945  |  3883  | 
|  3946   MathExpGenerator::EmitMathExp( |  3884   MathExpGenerator::EmitMathExp( | 
|  3947       masm(), input, result, double_scratch1, double_scratch2, |  3885       masm(), input, result, double_scratch1, double_scratch2, | 
| (...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5929   __ Subu(scratch, result, scratch); |  5867   __ Subu(scratch, result, scratch); | 
|  5930   __ lw(result, FieldMemOperand(scratch, |  5868   __ lw(result, FieldMemOperand(scratch, | 
|  5931                                 FixedArray::kHeaderSize - kPointerSize)); |  5869                                 FixedArray::kHeaderSize - kPointerSize)); | 
|  5932   __ bind(&done); |  5870   __ bind(&done); | 
|  5933 } |  5871 } | 
|  5934  |  5872  | 
|  5935  |  5873  | 
|  5936 #undef __ |  5874 #undef __ | 
|  5937  |  5875  | 
|  5938 } }  // namespace v8::internal |  5876 } }  // namespace v8::internal | 
| OLD | NEW |