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 3935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3946 MathPowStub stub(MathPowStub::INTEGER); | 3946 MathPowStub stub(MathPowStub::INTEGER); |
3947 __ CallStub(&stub); | 3947 __ CallStub(&stub); |
3948 } else { | 3948 } else { |
3949 ASSERT(exponent_type.IsDouble()); | 3949 ASSERT(exponent_type.IsDouble()); |
3950 MathPowStub stub(MathPowStub::DOUBLE); | 3950 MathPowStub stub(MathPowStub::DOUBLE); |
3951 __ CallStub(&stub); | 3951 __ CallStub(&stub); |
3952 } | 3952 } |
3953 } | 3953 } |
3954 | 3954 |
3955 | 3955 |
3956 void LCodeGen::DoRandom(LRandom* instr) { | |
3957 // Assert that the register size is indeed the size of each seed. | |
3958 static const int kSeedSize = sizeof(uint32_t); | |
3959 STATIC_ASSERT(kPointerSize == kSeedSize); | |
3960 | |
3961 // Load native context | |
3962 Register global_object = ToRegister(instr->global_object()); | |
3963 Register native_context = global_object; | |
3964 __ ldr(native_context, FieldMemOperand( | |
3965 global_object, GlobalObject::kNativeContextOffset)); | |
3966 | |
3967 // Load state (FixedArray of the native context's random seeds) | |
3968 static const int kRandomSeedOffset = | |
3969 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; | |
3970 Register state = native_context; | |
3971 __ ldr(state, FieldMemOperand(native_context, kRandomSeedOffset)); | |
3972 | |
3973 // Load state[0]. | |
3974 Register state0 = ToRegister(instr->scratch()); | |
3975 __ ldr(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); | |
3976 // Load state[1]. | |
3977 Register state1 = ToRegister(instr->scratch2()); | |
3978 __ ldr(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); | |
3979 | |
3980 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) | |
3981 Register scratch3 = ToRegister(instr->scratch3()); | |
3982 Register scratch4 = scratch0(); | |
3983 __ and_(scratch3, state0, Operand(0xFFFF)); | |
3984 __ mov(scratch4, Operand(18273)); | |
3985 __ mul(scratch3, scratch3, scratch4); | |
3986 __ add(state0, scratch3, Operand(state0, LSR, 16)); | |
3987 // Save state[0]. | |
3988 __ str(state0, FieldMemOperand(state, ByteArray::kHeaderSize)); | |
3989 | |
3990 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16) | |
3991 __ and_(scratch3, state1, Operand(0xFFFF)); | |
3992 __ mov(scratch4, Operand(36969)); | |
3993 __ mul(scratch3, scratch3, scratch4); | |
3994 __ add(state1, scratch3, Operand(state1, LSR, 16)); | |
3995 // Save state[1]. | |
3996 __ str(state1, FieldMemOperand(state, ByteArray::kHeaderSize + kSeedSize)); | |
3997 | |
3998 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) | |
3999 Register random = scratch4; | |
4000 __ and_(random, state1, Operand(0x3FFFF)); | |
4001 __ add(random, random, Operand(state0, LSL, 14)); | |
4002 | |
4003 // 0x41300000 is the top half of 1.0 x 2^20 as a double. | |
4004 // Create this constant using mov/orr to avoid PC relative load. | |
4005 __ mov(scratch3, Operand(0x41000000)); | |
4006 __ orr(scratch3, scratch3, Operand(0x300000)); | |
4007 // Move 0x41300000xxxxxxxx (x = random bits) to VFP. | |
4008 DwVfpRegister result = ToDoubleRegister(instr->result()); | |
4009 __ vmov(result, random, scratch3); | |
4010 // Move 0x4130000000000000 to VFP. | |
4011 __ mov(scratch4, Operand::Zero()); | |
4012 DwVfpRegister scratch5 = double_scratch0(); | |
4013 __ vmov(scratch5, scratch4, scratch3); | |
4014 __ vsub(result, result, scratch5); | |
4015 } | |
4016 | |
4017 | |
4018 void LCodeGen::DoMathExp(LMathExp* instr) { | 3956 void LCodeGen::DoMathExp(LMathExp* instr) { |
4019 DwVfpRegister input = ToDoubleRegister(instr->value()); | 3957 DwVfpRegister input = ToDoubleRegister(instr->value()); |
4020 DwVfpRegister result = ToDoubleRegister(instr->result()); | 3958 DwVfpRegister result = ToDoubleRegister(instr->result()); |
4021 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); | 3959 DwVfpRegister double_scratch1 = ToDoubleRegister(instr->double_temp()); |
4022 DwVfpRegister double_scratch2 = double_scratch0(); | 3960 DwVfpRegister double_scratch2 = double_scratch0(); |
4023 Register temp1 = ToRegister(instr->temp1()); | 3961 Register temp1 = ToRegister(instr->temp1()); |
4024 Register temp2 = ToRegister(instr->temp2()); | 3962 Register temp2 = ToRegister(instr->temp2()); |
4025 | 3963 |
4026 MathExpGenerator::EmitMathExp( | 3964 MathExpGenerator::EmitMathExp( |
4027 masm(), input, result, double_scratch1, double_scratch2, | 3965 masm(), input, result, double_scratch1, double_scratch2, |
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5875 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5938 __ ldr(result, FieldMemOperand(scratch, | 5876 __ ldr(result, FieldMemOperand(scratch, |
5939 FixedArray::kHeaderSize - kPointerSize)); | 5877 FixedArray::kHeaderSize - kPointerSize)); |
5940 __ bind(&done); | 5878 __ bind(&done); |
5941 } | 5879 } |
5942 | 5880 |
5943 | 5881 |
5944 #undef __ | 5882 #undef __ |
5945 | 5883 |
5946 } } // namespace v8::internal | 5884 } } // namespace v8::internal |
OLD | NEW |