| 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 3889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3900 MathPowStub stub(MathPowStub::INTEGER); | 3900 MathPowStub stub(MathPowStub::INTEGER); |
| 3901 __ CallStub(&stub); | 3901 __ CallStub(&stub); |
| 3902 } else { | 3902 } else { |
| 3903 ASSERT(exponent_type.IsDouble()); | 3903 ASSERT(exponent_type.IsDouble()); |
| 3904 MathPowStub stub(MathPowStub::DOUBLE); | 3904 MathPowStub stub(MathPowStub::DOUBLE); |
| 3905 __ CallStub(&stub); | 3905 __ CallStub(&stub); |
| 3906 } | 3906 } |
| 3907 } | 3907 } |
| 3908 | 3908 |
| 3909 | 3909 |
| 3910 void LCodeGen::DoRandom(LRandom* instr) { | |
| 3911 // Assert that the register size is indeed the size of each seed. | |
| 3912 static const int kSeedSize = sizeof(uint32_t); | |
| 3913 STATIC_ASSERT(kPointerSize == kSeedSize); | |
| 3914 | |
| 3915 // Load native context | |
| 3916 Register global_object = ToRegister(instr->global_object()); | |
| 3917 Register native_context = global_object; | |
| 3918 __ ldr(native_context, FieldMemOperand( | |
| 3919 global_object, GlobalObject::kNativeContextOffset)); | |
| 3920 | |
| 3921 // Load state (FixedArray of the native context's random seeds) | |
| 3922 static const int kRandomSeedOffset = | |
| 3923 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; | |
| 3924 Register state = native_context; | |
| 3925 __ ldr(state, FieldMemOperand(native_context, kRandomSeedOffset)); | |
| 3926 | |
| 3927 // Load state[0]. | |
| 3928 Register state0 = ToRegister(instr->scratch()); | |
| 3929 __ ldr(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); | |
| 3930 // Load state[1]. | |
| 3931 Register state1 = ToRegister(instr->scratch2()); | |
| 3932 __ ldr(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); | |
| 3933 | |
| 3934 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) | |
| 3935 Register scratch3 = ToRegister(instr->scratch3()); | |
| 3936 Register scratch4 = scratch0(); | |
| 3937 __ and_(scratch3, state0, Operand(0xFFFF)); | |
| 3938 __ mov(scratch4, Operand(18273)); | |
| 3939 __ mul(scratch3, scratch3, scratch4); | |
| 3940 __ add(state0, scratch3, Operand(state0, LSR, 16)); | |
| 3941 // Save state[0]. | |
| 3942 __ str(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); | |
| 3943 | |
| 3944 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16) | |
| 3945 __ and_(scratch3, state1, Operand(0xFFFF)); | |
| 3946 __ mov(scratch4, Operand(36969)); | |
| 3947 __ mul(scratch3, scratch3, scratch4); | |
| 3948 __ add(state1, scratch3, Operand(state1, LSR, 16)); | |
| 3949 // Save state[1]. | |
| 3950 __ str(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); | |
| 3951 | |
| 3952 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) | |
| 3953 Register random = scratch4; | |
| 3954 __ and_(random, state1, Operand(0x3FFFF)); | |
| 3955 __ add(random, random, Operand(state0, LSL, 14)); | |
| 3956 | |
| 3957 // 0x41300000 is the top half of 1.0 x 2^20 as a double. | |
| 3958 // Create this constant using mov/orr to avoid PC relative load. | |
| 3959 __ mov(scratch3, Operand(0x41000000)); | |
| 3960 __ orr(scratch3, scratch3, Operand(0x300000)); | |
| 3961 // Move 0x41300000xxxxxxxx (x = random bits) to VFP. | |
| 3962 DwVfpRegister result = ToDoubleRegister(instr->result()); | |
| 3963 __ vmov(result, random, scratch3); | |
| 3964 // Move 0x4130000000000000 to VFP. | |
| 3965 __ mov(scratch4, Operand::Zero()); | |
| 3966 DwVfpRegister scratch5 = double_scratch0(); | |
| 3967 __ vmov(scratch5, scratch4, scratch3); | |
| 3968 __ vsub(result, result, scratch5); | |
| 3969 } | |
| 3970 | |
| 3971 | |
| 3972 void LCodeGen::DoMathExp(LMathExp* instr) { | 3910 void LCodeGen::DoMathExp(LMathExp* instr) { |
| 3973 DwVfpRegister input = ToDoubleRegister(instr->value()); | 3911 DwVfpRegister input = ToDoubleRegister(instr->value()); |
| 3974 DwVfpRegister result = ToDoubleRegister(instr->result()); | 3912 DwVfpRegister result = ToDoubleRegister(instr->result()); |
| 3975 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); | 3913 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); |
| 3976 DwVfpRegister double_scratch2 = double_scratch0(); | 3914 DwVfpRegister double_scratch2 = double_scratch0(); |
| 3977 Register temp1 = ToRegister(instr->temp1()); | 3915 Register temp1 = ToRegister(instr->temp1()); |
| 3978 Register temp2 = ToRegister(instr->temp2()); | 3916 Register temp2 = ToRegister(instr->temp2()); |
| 3979 | 3917 |
| 3980 MathExpGenerator::EmitMathExp( | 3918 MathExpGenerator::EmitMathExp( |
| 3981 masm(), input, result, double_scratch1, double_scratch2, | 3919 masm(), input, result, double_scratch1, double_scratch2, |
| (...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5875 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5813 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5876 __ ldr(result, FieldMemOperand(scratch, | 5814 __ ldr(result, FieldMemOperand(scratch, |
| 5877 FixedArray::kHeaderSize - kPointerSize)); | 5815 FixedArray::kHeaderSize - kPointerSize)); |
| 5878 __ bind(&done); | 5816 __ bind(&done); |
| 5879 } | 5817 } |
| 5880 | 5818 |
| 5881 | 5819 |
| 5882 #undef __ | 5820 #undef __ |
| 5883 | 5821 |
| 5884 } } // namespace v8::internal | 5822 } } // namespace v8::internal |
| OLD | NEW |