| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3525 | 3525 |
| 3526 void LCodeGen::DoMathCos(LMathCos* instr) { | 3526 void LCodeGen::DoMathCos(LMathCos* instr) { |
| 3527 ASSERT(ToDoubleRegister(instr->result()).is(d0)); | 3527 ASSERT(ToDoubleRegister(instr->result()).is(d0)); |
| 3528 TranscendentalCacheStub stub(TranscendentalCache::COS, | 3528 TranscendentalCacheStub stub(TranscendentalCache::COS, |
| 3529 TranscendentalCacheStub::UNTAGGED); | 3529 TranscendentalCacheStub::UNTAGGED); |
| 3530 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 3530 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 3531 ASSERT(ToDoubleRegister(instr->result()).Is(d0)); | 3531 ASSERT(ToDoubleRegister(instr->result()).Is(d0)); |
| 3532 } | 3532 } |
| 3533 | 3533 |
| 3534 | 3534 |
| 3535 void LCodeGen::DoRandom(LRandom* instr) { |
| 3536 class DeferredDoRandom: public LDeferredCode { |
| 3537 public: |
| 3538 DeferredDoRandom(LCodeGen* codegen, LRandom* instr) |
| 3539 : LDeferredCode(codegen), instr_(instr) { } |
| 3540 virtual void Generate() { codegen()->DoDeferredRandom(instr_); } |
| 3541 virtual LInstruction* instr() { return instr_; } |
| 3542 |
| 3543 private: |
| 3544 LRandom* instr_; |
| 3545 }; |
| 3546 |
| 3547 DeferredDoRandom* deferred = new(zone()) DeferredDoRandom(this, instr); |
| 3548 |
| 3549 // Having marked this instruction as a call we can use any registers. |
| 3550 ASSERT(instr->IsMarkedAsCall()); |
| 3551 ASSERT(ToDoubleRegister(instr->result()).is(d7)); |
| 3552 ASSERT(ToRegister(instr->global_object()).is(x0)); |
| 3553 |
| 3554 static const int kSeedSize = sizeof(uint32_t); |
| 3555 STATIC_ASSERT(kPointerSize == 2 * kSeedSize); |
| 3556 |
| 3557 Register global_object = x0; |
| 3558 __ Ldr(global_object, |
| 3559 FieldMemOperand(global_object, GlobalObject::kNativeContextOffset)); |
| 3560 static const int kRandomSeedOffset = |
| 3561 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; |
| 3562 __ Ldr(x1, FieldMemOperand(global_object, kRandomSeedOffset)); |
| 3563 // x1: FixedArray of the native context's random seeds |
| 3564 |
| 3565 // Load state[0]. |
| 3566 __ Ldr(w2, FieldMemOperand(x1, ByteArray::kHeaderSize)); |
| 3567 // If state[0] == 0, call runtime to initialize seeds. |
| 3568 __ Cbz(w2, deferred->entry()); |
| 3569 // Load state[1]. |
| 3570 __ Ldr(w3, FieldMemOperand(x1, ByteArray::kHeaderSize + kSeedSize)); |
| 3571 |
| 3572 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) |
| 3573 __ And(w4, w2, 0xFFFF); |
| 3574 __ Mov(w5, 18273); |
| 3575 __ Mul(w5, w5, w4); |
| 3576 __ Add(w2, w5, Operand(w2, LSR, 16)); |
| 3577 // Save state[0]. |
| 3578 __ Str(w2, FieldMemOperand(x1, ByteArray::kHeaderSize)); |
| 3579 |
| 3580 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16) |
| 3581 __ And(w4, w3, 0xFFFF); |
| 3582 __ Mov(w5, 36969); |
| 3583 __ Mul(w5, w5, w4); |
| 3584 __ Add(w3, w5, Operand(w3, LSR, 16)); |
| 3585 // Save state[1]. |
| 3586 __ Str(w3, FieldMemOperand(x1, ByteArray::kHeaderSize + kSeedSize)); |
| 3587 |
| 3588 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) |
| 3589 __ And(w3, w3, 0x3FFFF); |
| 3590 __ Add(w0, w3, Operand(w2, LSL, 14)); |
| 3591 |
| 3592 __ Bind(deferred->exit()); |
| 3593 // Interpret the 32 random bits as a 0.32 fixed point number, and convert to |
| 3594 // a double in the range 0.0 <= number < 1.0. |
| 3595 __ Ucvtf(d7, w0, 32); |
| 3596 } |
| 3597 |
| 3598 |
| 3599 void LCodeGen::DoDeferredRandom(LRandom* instr) { |
| 3600 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
| 3601 // Return value is in x0. |
| 3602 } |
| 3603 |
| 3604 |
| 3535 void LCodeGen::DoMathExp(LMathExp* instr) { | 3605 void LCodeGen::DoMathExp(LMathExp* instr) { |
| 3536 DoubleRegister input = ToDoubleRegister(instr->value()); | 3606 DoubleRegister input = ToDoubleRegister(instr->value()); |
| 3537 DoubleRegister result = ToDoubleRegister(instr->result()); | 3607 DoubleRegister result = ToDoubleRegister(instr->result()); |
| 3538 DoubleRegister double_temp1 = ToDoubleRegister(instr->double_temp1()); | 3608 DoubleRegister double_temp1 = ToDoubleRegister(instr->double_temp1()); |
| 3539 DoubleRegister double_temp2 = double_scratch(); | 3609 DoubleRegister double_temp2 = double_scratch(); |
| 3540 Register temp1 = ToRegister(instr->temp1()); | 3610 Register temp1 = ToRegister(instr->temp1()); |
| 3541 Register temp2 = ToRegister(instr->temp2()); | 3611 Register temp2 = ToRegister(instr->temp2()); |
| 3542 Register temp3 = ToRegister(instr->temp3()); | 3612 Register temp3 = ToRegister(instr->temp3()); |
| 3543 | 3613 |
| 3544 MathExpGenerator::EmitMathExp(masm(), input, result, | 3614 MathExpGenerator::EmitMathExp(masm(), input, result, |
| (...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5271 __ Bind(&out_of_object); | 5341 __ Bind(&out_of_object); |
| 5272 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5342 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
| 5273 // Index is equal to negated out of object property index plus 1. | 5343 // Index is equal to negated out of object property index plus 1. |
| 5274 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5344 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 5275 __ Ldr(result, FieldMemOperand(result, | 5345 __ Ldr(result, FieldMemOperand(result, |
| 5276 FixedArray::kHeaderSize - kPointerSize)); | 5346 FixedArray::kHeaderSize - kPointerSize)); |
| 5277 __ Bind(&done); | 5347 __ Bind(&done); |
| 5278 } | 5348 } |
| 5279 | 5349 |
| 5280 } } // namespace v8::internal | 5350 } } // namespace v8::internal |
| OLD | NEW |