| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3695 | 3695 |
| 3696 void LCodeGen::DoMathClz32(LMathClz32* instr) { | 3696 void LCodeGen::DoMathClz32(LMathClz32* instr) { |
| 3697 Register input = ToRegister(instr->value()); | 3697 Register input = ToRegister(instr->value()); |
| 3698 Register result = ToRegister(instr->result()); | 3698 Register result = ToRegister(instr->result()); |
| 3699 | 3699 |
| 3700 __ Lzcnt(result, input); | 3700 __ Lzcnt(result, input); |
| 3701 } | 3701 } |
| 3702 | 3702 |
| 3703 | 3703 |
| 3704 void LCodeGen::DoMathExp(LMathExp* instr) { | 3704 void LCodeGen::DoMathExp(LMathExp* instr) { |
| 3705 X87Register input = ToX87Register(instr->value()); | 3705 X87Register result = ToX87Register(instr->result()); |
| 3706 X87Register result_reg = ToX87Register(instr->result()); | 3706 X87Register input_reg = ToX87Register(instr->value()); |
| 3707 Register temp_result = ToRegister(instr->temp1()); | 3707 __ fld(x87_stack_.st(input_reg)); |
| 3708 Register temp = ToRegister(instr->temp2()); | |
| 3709 Label slow, done, smi, finish; | |
| 3710 DCHECK(result_reg.is(input)); | |
| 3711 | 3708 |
| 3712 // Store input into Heap number and call runtime function kMathExpRT. | 3709 // Pass one double as argument on the stack. |
| 3713 if (FLAG_inline_new) { | 3710 __ PrepareCallCFunction(2, eax); |
| 3714 __ AllocateHeapNumber(temp_result, temp, no_reg, &slow); | 3711 __ fstp_d(MemOperand(esp, 0)); |
| 3715 __ jmp(&done, Label::kNear); | 3712 X87PrepareToWrite(result); |
| 3716 } | 3713 __ CallCFunction(ExternalReference::ieee754_exp_function(isolate()), 2); |
| 3717 | 3714 // Return value is in st(0) on ia32. |
| 3718 // Slow case: Call the runtime system to do the number allocation. | 3715 X87CommitWrite(result); |
| 3719 __ bind(&slow); | |
| 3720 { | |
| 3721 // TODO(3095996): Put a valid pointer value in the stack slot where the | |
| 3722 // result register is stored, as this register is in the pointer map, but | |
| 3723 // contains an integer value. | |
| 3724 __ Move(temp_result, Immediate(0)); | |
| 3725 | |
| 3726 // Preserve the value of all registers. | |
| 3727 PushSafepointRegistersScope scope(this); | |
| 3728 | |
| 3729 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
| 3730 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | |
| 3731 RecordSafepointWithRegisters(instr->pointer_map(), 0, | |
| 3732 Safepoint::kNoLazyDeopt); | |
| 3733 __ StoreToSafepointRegisterSlot(temp_result, eax); | |
| 3734 } | |
| 3735 __ bind(&done); | |
| 3736 X87LoadForUsage(input); | |
| 3737 __ fstp_d(FieldOperand(temp_result, HeapNumber::kValueOffset)); | |
| 3738 | |
| 3739 { | |
| 3740 // Preserve the value of all registers. | |
| 3741 PushSafepointRegistersScope scope(this); | |
| 3742 | |
| 3743 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
| 3744 __ push(temp_result); | |
| 3745 __ CallRuntimeSaveDoubles(Runtime::kMathExpRT); | |
| 3746 RecordSafepointWithRegisters(instr->pointer_map(), 1, | |
| 3747 Safepoint::kNoLazyDeopt); | |
| 3748 __ StoreToSafepointRegisterSlot(temp_result, eax); | |
| 3749 } | |
| 3750 X87PrepareToWrite(result_reg); | |
| 3751 // return value of MathExpRT is Smi or Heap Number. | |
| 3752 __ JumpIfSmi(temp_result, &smi); | |
| 3753 // Heap number(double) | |
| 3754 __ fld_d(FieldOperand(temp_result, HeapNumber::kValueOffset)); | |
| 3755 __ jmp(&finish); | |
| 3756 // SMI | |
| 3757 __ bind(&smi); | |
| 3758 __ SmiUntag(temp_result); | |
| 3759 __ push(temp_result); | |
| 3760 __ fild_s(MemOperand(esp, 0)); | |
| 3761 __ pop(temp_result); | |
| 3762 __ bind(&finish); | |
| 3763 X87CommitWrite(result_reg); | |
| 3764 } | 3716 } |
| 3765 | 3717 |
| 3766 void LCodeGen::PrepareForTailCall(const ParameterCount& actual, | 3718 void LCodeGen::PrepareForTailCall(const ParameterCount& actual, |
| 3767 Register scratch1, Register scratch2, | 3719 Register scratch1, Register scratch2, |
| 3768 Register scratch3) { | 3720 Register scratch3) { |
| 3769 #if DEBUG | 3721 #if DEBUG |
| 3770 if (actual.is_reg()) { | 3722 if (actual.is_reg()) { |
| 3771 DCHECK(!AreAliased(actual.reg(), scratch1, scratch2, scratch3)); | 3723 DCHECK(!AreAliased(actual.reg(), scratch1, scratch2, scratch3)); |
| 3772 } else { | 3724 } else { |
| 3773 DCHECK(!AreAliased(scratch1, scratch2, scratch3)); | 3725 DCHECK(!AreAliased(scratch1, scratch2, scratch3)); |
| (...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5833 __ bind(deferred->exit()); | 5785 __ bind(deferred->exit()); |
| 5834 __ bind(&done); | 5786 __ bind(&done); |
| 5835 } | 5787 } |
| 5836 | 5788 |
| 5837 #undef __ | 5789 #undef __ |
| 5838 | 5790 |
| 5839 } // namespace internal | 5791 } // namespace internal |
| 5840 } // namespace v8 | 5792 } // namespace v8 |
| 5841 | 5793 |
| 5842 #endif // V8_TARGET_ARCH_X87 | 5794 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |