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