OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 private: | 811 private: |
812 Token::Value op_; | 812 Token::Value op_; |
813 Register dst_; | 813 Register dst_; |
814 Register left_; | 814 Register left_; |
815 Register right_; | 815 Register right_; |
816 OverwriteMode mode_; | 816 OverwriteMode mode_; |
817 }; | 817 }; |
818 | 818 |
819 | 819 |
820 void DeferredInlineBinaryOperation::Generate() { | 820 void DeferredInlineBinaryOperation::Generate() { |
821 Label done; | |
822 if (CpuFeatures::IsSupported(SSE2) && ((op_ == Token::ADD) || | |
823 (op_ ==Token::SUB) || | |
824 (op_ == Token::MUL) || | |
825 (op_ == Token::DIV))) { | |
826 CpuFeatures::Scope use_sse2(SSE2); | |
827 Label call_runtime, after_alloc_failure; | |
828 Label left_smi, right_smi, load_right, do_op; | |
829 __ test(left_, Immediate(kSmiTagMask)); | |
830 __ j(zero, &left_smi); | |
831 __ cmp(FieldOperand(left_, HeapObject::kMapOffset), | |
832 Factory::heap_number_map()); | |
833 __ j(not_equal, &call_runtime); | |
834 __ movdbl(xmm0, FieldOperand(left_, HeapNumber::kValueOffset)); | |
835 if (mode_ == OVERWRITE_LEFT) { | |
836 __ mov(dst_, left_); | |
837 } | |
838 __ jmp(&load_right); | |
839 | |
840 __ bind(&left_smi); | |
841 __ sar(left_, 1); | |
Kasper Lund
2009/12/18 07:23:13
1 -> kSmiTagSize
| |
842 __ cvtsi2sd(xmm0, Operand(left_)); | |
843 __ shl(left_, 1); | |
Kasper Lund
2009/12/18 07:23:13
1 -> kSmiTagSize
| |
844 if (mode_ == OVERWRITE_LEFT) { | |
845 Label alloc_failure; | |
846 __ push(left_); | |
847 __ AllocateHeapNumber(dst_, left_, no_reg, &after_alloc_failure); | |
848 __ pop(left_); | |
849 } | |
850 | |
851 __ bind(&load_right); | |
852 __ test(right_, Immediate(kSmiTagMask)); | |
853 __ j(zero, &right_smi); | |
854 __ cmp(FieldOperand(right_, HeapObject::kMapOffset), | |
855 Factory::heap_number_map()); | |
856 __ j(not_equal, &call_runtime); | |
857 __ movdbl(xmm1, FieldOperand(right_, HeapNumber::kValueOffset)); | |
858 if (mode_ == OVERWRITE_RIGHT) { | |
859 __ mov(dst_, right_); | |
860 } else if (mode_ == NO_OVERWRITE) { | |
861 Label alloc_failure; | |
862 __ push(left_); | |
863 __ AllocateHeapNumber(dst_, left_, no_reg, &after_alloc_failure); | |
864 __ pop(left_); | |
865 } | |
866 __ jmp(&do_op); | |
867 | |
868 __ bind(&right_smi); | |
869 __ sar(right_, 1); | |
Kasper Lund
2009/12/18 07:23:13
1 -> kSmiTagSize
| |
870 __ cvtsi2sd(xmm1, Operand(right_)); | |
871 __ shl(right_, 1); | |
Kasper Lund
2009/12/18 07:23:13
1 -> kSmiTagSize
| |
872 if (mode_ == OVERWRITE_RIGHT || mode_ == NO_OVERWRITE) { | |
873 Label alloc_failure; | |
874 __ push(left_); | |
875 __ AllocateHeapNumber(dst_, left_, no_reg, &after_alloc_failure); | |
876 __ pop(left_); | |
877 } | |
878 | |
879 __ bind(&do_op); | |
880 switch (op_) { | |
881 case Token::ADD: __ addsd(xmm0, xmm1); break; | |
882 case Token::SUB: __ subsd(xmm0, xmm1); break; | |
883 case Token::MUL: __ mulsd(xmm0, xmm1); break; | |
884 case Token::DIV: __ divsd(xmm0, xmm1); break; | |
885 default: UNREACHABLE(); | |
886 } | |
887 __ movdbl(FieldOperand(dst_, HeapNumber::kValueOffset), xmm0); | |
888 __ jmp(&done); | |
Kasper Lund
2009/12/18 07:23:13
Could this be a jmp(exit_label())?
| |
889 | |
890 __ bind(&after_alloc_failure); | |
891 __ pop(left_); | |
892 __ bind(&call_runtime); | |
893 } | |
821 GenericBinaryOpStub stub(op_, mode_, NO_SMI_CODE_IN_STUB); | 894 GenericBinaryOpStub stub(op_, mode_, NO_SMI_CODE_IN_STUB); |
822 stub.GenerateCall(masm_, left_, right_); | 895 stub.GenerateCall(masm_, left_, right_); |
823 if (!dst_.is(eax)) __ mov(dst_, eax); | 896 if (!dst_.is(eax)) __ mov(dst_, eax); |
897 __ bind(&done); | |
824 } | 898 } |
825 | 899 |
826 | 900 |
827 void CodeGenerator::GenericBinaryOperation(Token::Value op, | 901 void CodeGenerator::GenericBinaryOperation(Token::Value op, |
828 StaticType* type, | 902 StaticType* type, |
829 OverwriteMode overwrite_mode) { | 903 OverwriteMode overwrite_mode) { |
830 Comment cmnt(masm_, "[ BinaryOperation"); | 904 Comment cmnt(masm_, "[ BinaryOperation"); |
831 Comment cmnt_token(masm_, Token::String(op)); | 905 Comment cmnt_token(masm_, Token::String(op)); |
832 | 906 |
833 if (op == Token::COMMA) { | 907 if (op == Token::COMMA) { |
(...skipping 7844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8678 __ add(Operand(dest), Immediate(2)); | 8752 __ add(Operand(dest), Immediate(2)); |
8679 } | 8753 } |
8680 __ sub(Operand(count), Immediate(1)); | 8754 __ sub(Operand(count), Immediate(1)); |
8681 __ j(not_zero, &loop); | 8755 __ j(not_zero, &loop); |
8682 } | 8756 } |
8683 | 8757 |
8684 | 8758 |
8685 #undef __ | 8759 #undef __ |
8686 | 8760 |
8687 } } // namespace v8::internal | 8761 } } // namespace v8::internal |
OLD | NEW |