| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 void LCodeGen::DoModI(LModI* instr) { | 795 void LCodeGen::DoModI(LModI* instr) { |
| 796 if (instr->hydrogen()->HasPowerOf2Divisor()) { | 796 if (instr->hydrogen()->HasPowerOf2Divisor()) { |
| 797 Register dividend = ToRegister(instr->InputAt(0)); | 797 Register dividend = ToRegister(instr->InputAt(0)); |
| 798 | 798 |
| 799 int32_t divisor = | 799 int32_t divisor = |
| 800 HConstant::cast(instr->hydrogen()->right())->Integer32Value(); | 800 HConstant::cast(instr->hydrogen()->right())->Integer32Value(); |
| 801 | 801 |
| 802 if (divisor < 0) divisor = -divisor; | 802 if (divisor < 0) divisor = -divisor; |
| 803 | 803 |
| 804 Label positive_dividend, done; | 804 Label positive_dividend, done; |
| 805 __ tst(dividend, Operand(dividend)); | 805 __ cmp(dividend, Operand(0)); |
| 806 __ b(pl, &positive_dividend); | 806 __ b(pl, &positive_dividend); |
| 807 __ rsb(dividend, dividend, Operand(0)); | 807 __ rsb(dividend, dividend, Operand(0)); |
| 808 __ and_(dividend, dividend, Operand(divisor - 1)); | 808 __ and_(dividend, dividend, Operand(divisor - 1)); |
| 809 __ rsb(dividend, dividend, Operand(0), SetCC); | 809 __ rsb(dividend, dividend, Operand(0), SetCC); |
| 810 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 810 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 811 __ b(ne, &done); | 811 __ b(ne, &done); |
| 812 DeoptimizeIf(al, instr->environment()); | 812 DeoptimizeIf(al, instr->environment()); |
| 813 } | 813 } |
| 814 __ bind(&positive_dividend); | 814 __ bind(&positive_dividend); |
| 815 __ and_(dividend, dividend, Operand(divisor - 1)); | 815 __ and_(dividend, dividend, Operand(divisor - 1)); |
| 816 __ bind(&done); | 816 __ bind(&done); |
| 817 return; | 817 return; |
| 818 } | 818 } |
| 819 | 819 |
| 820 class DeferredModI: public LDeferredCode { | |
| 821 public: | |
| 822 DeferredModI(LCodeGen* codegen, LModI* instr) | |
| 823 : LDeferredCode(codegen), instr_(instr) { } | |
| 824 virtual void Generate() { | |
| 825 codegen()->DoDeferredBinaryOpStub(instr_, Token::MOD); | |
| 826 } | |
| 827 private: | |
| 828 LModI* instr_; | |
| 829 }; | |
| 830 // These registers hold untagged 32 bit values. | 820 // These registers hold untagged 32 bit values. |
| 831 Register left = ToRegister(instr->InputAt(0)); | 821 Register left = ToRegister(instr->InputAt(0)); |
| 832 Register right = ToRegister(instr->InputAt(1)); | 822 Register right = ToRegister(instr->InputAt(1)); |
| 833 Register result = ToRegister(instr->result()); | 823 Register result = ToRegister(instr->result()); |
| 824 |
| 834 Register scratch = scratch0(); | 825 Register scratch = scratch0(); |
| 826 Register scratch2 = ToRegister(instr->TempAt(0)); |
| 827 DwVfpRegister dividend = ToDoubleRegister(instr->TempAt(1)); |
| 828 DwVfpRegister divisor = ToDoubleRegister(instr->TempAt(2)); |
| 829 DwVfpRegister quotient = double_scratch0(); |
| 835 | 830 |
| 836 Label deoptimize, done; | 831 ASSERT(result.is(left)); |
| 832 |
| 833 ASSERT(!dividend.is(divisor)); |
| 834 ASSERT(!dividend.is(quotient)); |
| 835 ASSERT(!divisor.is(quotient)); |
| 836 ASSERT(!scratch.is(left)); |
| 837 ASSERT(!scratch.is(right)); |
| 838 ASSERT(!scratch.is(result)); |
| 839 |
| 840 Label done, vfp_modulo, both_positive, right_negative; |
| 841 |
| 837 // Check for x % 0. | 842 // Check for x % 0. |
| 838 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { | 843 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
| 839 __ tst(right, Operand(right)); | 844 __ cmp(right, Operand(0)); |
| 840 __ b(eq, &deoptimize); | 845 DeoptimizeIf(eq, instr->environment()); |
| 841 } | 846 } |
| 842 | 847 |
| 843 // Check for (0 % -x) that will produce negative zero. | 848 // (0 % x) must yield 0 (if x is finite, which is the case here). |
| 844 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 849 __ cmp(left, Operand(0)); |
| 845 Label ok; | 850 __ b(eq, &done); |
| 846 __ tst(left, Operand(left)); | 851 // Preload right in a vfp register. |
| 847 __ b(ne, &ok); | 852 __ vmov(divisor.low(), right); |
| 848 __ tst(right, Operand(right)); | 853 __ b(lt, &vfp_modulo); |
| 849 __ b(pl, &ok); | |
| 850 __ b(al, &deoptimize); | |
| 851 __ bind(&ok); | |
| 852 } | |
| 853 | 854 |
| 854 // Try a few common cases before using the stub. | 855 __ cmp(left, Operand(right)); |
| 855 Label call_stub; | 856 __ b(lt, &done); |
| 857 |
| 858 // Check for (positive) power of two on the right hand side. |
| 859 __ JumpIfNotPowerOfTwoOrZeroAndNeg(right, |
| 860 scratch, |
| 861 &right_negative, |
| 862 &both_positive); |
| 863 // Perform modulo operation (scratch contains right - 1). |
| 864 __ and_(result, scratch, Operand(left)); |
| 865 __ b(&done); |
| 866 |
| 867 __ bind(&right_negative); |
| 868 // Negate right. The sign of the divisor does not matter. |
| 869 __ rsb(right, right, Operand(0)); |
| 870 |
| 871 __ bind(&both_positive); |
| 856 const int kUnfolds = 3; | 872 const int kUnfolds = 3; |
| 857 // Skip if either side is negative. | |
| 858 __ cmp(left, Operand(0)); | |
| 859 __ cmp(right, Operand(0), NegateCondition(mi)); | |
| 860 __ b(mi, &call_stub); | |
| 861 // If the right hand side is smaller than the (nonnegative) | 873 // If the right hand side is smaller than the (nonnegative) |
| 862 // left hand side, it is the result. Else try a few subtractions | 874 // left hand side, the left hand side is the result. |
| 863 // of the left hand side. | 875 // Else try a few subtractions of the left hand side. |
| 864 __ mov(scratch, left); | 876 __ mov(scratch, left); |
| 865 for (int i = 0; i < kUnfolds; i++) { | 877 for (int i = 0; i < kUnfolds; i++) { |
| 866 // Check if the left hand side is less or equal than the | 878 // Check if the left hand side is less or equal than the |
| 867 // the right hand side. | 879 // the right hand side. |
| 868 __ cmp(scratch, right); | 880 __ cmp(scratch, Operand(right)); |
| 869 __ mov(result, scratch, LeaveCC, lt); | 881 __ mov(result, scratch, LeaveCC, lt); |
| 870 __ b(lt, &done); | 882 __ b(lt, &done); |
| 871 // If not, reduce the left hand side by the right hand | 883 // If not, reduce the left hand side by the right hand |
| 872 // side and check again. | 884 // side and check again. |
| 873 if (i < kUnfolds - 1) __ sub(scratch, scratch, right); | 885 if (i < kUnfolds - 1) __ sub(scratch, scratch, right); |
| 874 } | 886 } |
| 875 | 887 |
| 876 // Check for power of two on the right hand side. | 888 __ bind(&vfp_modulo); |
| 877 __ JumpIfNotPowerOfTwoOrZero(right, scratch, &call_stub); | 889 // Load the arguments in VFP registers. |
| 878 // Perform modulo operation (scratch contains right - 1). | 890 // The divisor value is preloaded before. Be careful that 'right' is only live |
| 879 __ and_(result, scratch, Operand(left)); | 891 // on entry. |
| 880 __ b(&done); | 892 __ vmov(dividend.low(), left); |
| 893 // From here on don't use right as it may have been reallocated (for example |
| 894 // to scratch2). |
| 895 right = no_reg; |
| 881 | 896 |
| 882 __ bind(&call_stub); | 897 __ vcvt_f64_s32(dividend, dividend.low()); |
| 883 // Call the stub. The numbers in r0 and r1 have | 898 __ vcvt_f64_s32(divisor, divisor.low()); |
| 884 // to be tagged to Smis. If that is not possible, deoptimize. | |
| 885 DeferredModI* deferred = new DeferredModI(this, instr); | |
| 886 __ TrySmiTag(left, &deoptimize, scratch); | |
| 887 __ TrySmiTag(right, &deoptimize, scratch); | |
| 888 | 899 |
| 889 __ b(al, deferred->entry()); | 900 // We do not care about the sign of the divisor. |
| 890 __ bind(deferred->exit()); | 901 __ vabs(divisor, divisor); |
| 902 // Compute the quotient and round it to a 32bit integer. |
| 903 __ vdiv(quotient, dividend, divisor); |
| 904 __ vcvt_s32_f64(quotient.low(), quotient); |
| 905 __ vcvt_f64_s32(quotient, quotient.low()); |
| 891 | 906 |
| 892 // If the result in r0 is a Smi, untag it, else deoptimize. | 907 // Compute the remainder in result. |
| 893 __ JumpIfNotSmi(result, &deoptimize); | 908 DwVfpRegister double_scratch = dividend; |
| 894 __ SmiUntag(result); | 909 __ vmul(double_scratch, divisor, quotient); |
| 910 __ vcvt_s32_f64(double_scratch.low(), double_scratch); |
| 911 __ vmov(scratch, double_scratch.low()); |
| 895 | 912 |
| 896 __ b(al, &done); | 913 if (!instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 897 __ bind(&deoptimize); | 914 __ sub(result, left, scratch); |
| 898 DeoptimizeIf(al, instr->environment()); | 915 } else { |
| 916 Label ok; |
| 917 // Check for -0. |
| 918 __ sub(scratch2, left, scratch, SetCC); |
| 919 __ b(ne, &ok); |
| 920 __ cmp(left, Operand(0)); |
| 921 DeoptimizeIf(mi, instr->environment()); |
| 922 __ bind(&ok); |
| 923 // Load the result and we are done. |
| 924 __ mov(result, scratch2); |
| 925 } |
| 926 |
| 899 __ bind(&done); | 927 __ bind(&done); |
| 900 } | 928 } |
| 901 | 929 |
| 902 | 930 |
| 903 void LCodeGen::DoDivI(LDivI* instr) { | 931 void LCodeGen::DoDivI(LDivI* instr) { |
| 904 class DeferredDivI: public LDeferredCode { | 932 class DeferredDivI: public LDeferredCode { |
| 905 public: | 933 public: |
| 906 DeferredDivI(LCodeGen* codegen, LDivI* instr) | 934 DeferredDivI(LCodeGen* codegen, LDivI* instr) |
| 907 : LDeferredCode(codegen), instr_(instr) { } | 935 : LDeferredCode(codegen), instr_(instr) { } |
| 908 virtual void Generate() { | 936 virtual void Generate() { |
| 909 codegen()->DoDeferredBinaryOpStub(instr_, Token::DIV); | 937 codegen()->DoDeferredBinaryOpStub(instr_, Token::DIV); |
| 910 } | 938 } |
| 911 private: | 939 private: |
| 912 LDivI* instr_; | 940 LDivI* instr_; |
| 913 }; | 941 }; |
| 914 | 942 |
| 915 const Register left = ToRegister(instr->InputAt(0)); | 943 const Register left = ToRegister(instr->InputAt(0)); |
| 916 const Register right = ToRegister(instr->InputAt(1)); | 944 const Register right = ToRegister(instr->InputAt(1)); |
| 917 const Register scratch = scratch0(); | 945 const Register scratch = scratch0(); |
| 918 const Register result = ToRegister(instr->result()); | 946 const Register result = ToRegister(instr->result()); |
| 919 | 947 |
| 920 // Check for x / 0. | 948 // Check for x / 0. |
| 921 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { | 949 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
| 922 __ tst(right, right); | 950 __ cmp(right, Operand(0)); |
| 923 DeoptimizeIf(eq, instr->environment()); | 951 DeoptimizeIf(eq, instr->environment()); |
| 924 } | 952 } |
| 925 | 953 |
| 926 // Check for (0 / -x) that will produce negative zero. | 954 // Check for (0 / -x) that will produce negative zero. |
| 927 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 955 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 928 Label left_not_zero; | 956 Label left_not_zero; |
| 929 __ tst(left, Operand(left)); | 957 __ cmp(left, Operand(0)); |
| 930 __ b(ne, &left_not_zero); | 958 __ b(ne, &left_not_zero); |
| 931 __ tst(right, Operand(right)); | 959 __ cmp(right, Operand(0)); |
| 932 DeoptimizeIf(mi, instr->environment()); | 960 DeoptimizeIf(mi, instr->environment()); |
| 933 __ bind(&left_not_zero); | 961 __ bind(&left_not_zero); |
| 934 } | 962 } |
| 935 | 963 |
| 936 // Check for (-kMinInt / -1). | 964 // Check for (-kMinInt / -1). |
| 937 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 965 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 938 Label left_not_min_int; | 966 Label left_not_min_int; |
| 939 __ cmp(left, Operand(kMinInt)); | 967 __ cmp(left, Operand(kMinInt)); |
| 940 __ b(ne, &left_not_min_int); | 968 __ b(ne, &left_not_min_int); |
| 941 __ cmp(right, Operand(-1)); | 969 __ cmp(right, Operand(-1)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 __ mov(ip, Operand(left, ASR, 31)); | 1056 __ mov(ip, Operand(left, ASR, 31)); |
| 1029 __ cmp(ip, Operand(scratch)); | 1057 __ cmp(ip, Operand(scratch)); |
| 1030 DeoptimizeIf(ne, instr->environment()); | 1058 DeoptimizeIf(ne, instr->environment()); |
| 1031 } else { | 1059 } else { |
| 1032 __ mul(left, left, right); | 1060 __ mul(left, left, right); |
| 1033 } | 1061 } |
| 1034 | 1062 |
| 1035 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1063 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1036 // Bail out if the result is supposed to be negative zero. | 1064 // Bail out if the result is supposed to be negative zero. |
| 1037 Label done; | 1065 Label done; |
| 1038 __ tst(left, Operand(left)); | 1066 __ cmp(left, Operand(0)); |
| 1039 __ b(ne, &done); | 1067 __ b(ne, &done); |
| 1040 if (instr->InputAt(1)->IsConstantOperand()) { | 1068 if (instr->InputAt(1)->IsConstantOperand()) { |
| 1041 if (ToInteger32(LConstantOperand::cast(instr->InputAt(1))) <= 0) { | 1069 if (ToInteger32(LConstantOperand::cast(instr->InputAt(1))) <= 0) { |
| 1042 DeoptimizeIf(al, instr->environment()); | 1070 DeoptimizeIf(al, instr->environment()); |
| 1043 } | 1071 } |
| 1044 } else { | 1072 } else { |
| 1045 // Test the non-zero operand for negative sign. | 1073 // Test the non-zero operand for negative sign. |
| 1046 __ cmp(ToRegister(instr->TempAt(0)), Operand(0)); | 1074 __ cmp(ToRegister(instr->TempAt(0)), Operand(0)); |
| 1047 DeoptimizeIf(mi, instr->environment()); | 1075 DeoptimizeIf(mi, instr->environment()); |
| 1048 } | 1076 } |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 } | 1921 } |
| 1894 | 1922 |
| 1895 | 1923 |
| 1896 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { | 1924 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { |
| 1897 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. | 1925 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. |
| 1898 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. | 1926 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. |
| 1899 | 1927 |
| 1900 InstanceofStub stub(InstanceofStub::kArgsInRegisters); | 1928 InstanceofStub stub(InstanceofStub::kArgsInRegisters); |
| 1901 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 1929 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1902 | 1930 |
| 1903 Label true_value, done; | 1931 __ cmp(r0, Operand(0)); |
| 1904 __ tst(r0, r0); | |
| 1905 __ mov(r0, Operand(factory()->false_value()), LeaveCC, ne); | 1932 __ mov(r0, Operand(factory()->false_value()), LeaveCC, ne); |
| 1906 __ mov(r0, Operand(factory()->true_value()), LeaveCC, eq); | 1933 __ mov(r0, Operand(factory()->true_value()), LeaveCC, eq); |
| 1907 } | 1934 } |
| 1908 | 1935 |
| 1909 | 1936 |
| 1910 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { | 1937 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { |
| 1911 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. | 1938 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. |
| 1912 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. | 1939 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. |
| 1913 | 1940 |
| 1914 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1941 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1915 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1942 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1916 | 1943 |
| 1917 InstanceofStub stub(InstanceofStub::kArgsInRegisters); | 1944 InstanceofStub stub(InstanceofStub::kArgsInRegisters); |
| 1918 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 1945 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1919 __ tst(r0, Operand(r0)); | 1946 __ cmp(r0, Operand(0)); |
| 1920 EmitBranch(true_block, false_block, eq); | 1947 EmitBranch(true_block, false_block, eq); |
| 1921 } | 1948 } |
| 1922 | 1949 |
| 1923 | 1950 |
| 1924 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { | 1951 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
| 1925 class DeferredInstanceOfKnownGlobal: public LDeferredCode { | 1952 class DeferredInstanceOfKnownGlobal: public LDeferredCode { |
| 1926 public: | 1953 public: |
| 1927 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, | 1954 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, |
| 1928 LInstanceOfKnownGlobal* instr) | 1955 LInstanceOfKnownGlobal* instr) |
| 1929 : LDeferredCode(codegen), instr_(instr) { } | 1956 : LDeferredCode(codegen), instr_(instr) { } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2399 // number of arguments. | 2426 // number of arguments. |
| 2400 __ push(receiver); | 2427 __ push(receiver); |
| 2401 __ mov(receiver, length); | 2428 __ mov(receiver, length); |
| 2402 // The arguments are at a one pointer size offset from elements. | 2429 // The arguments are at a one pointer size offset from elements. |
| 2403 __ add(elements, elements, Operand(1 * kPointerSize)); | 2430 __ add(elements, elements, Operand(1 * kPointerSize)); |
| 2404 | 2431 |
| 2405 // Loop through the arguments pushing them onto the execution | 2432 // Loop through the arguments pushing them onto the execution |
| 2406 // stack. | 2433 // stack. |
| 2407 Label invoke, loop; | 2434 Label invoke, loop; |
| 2408 // length is a small non-negative integer, due to the test above. | 2435 // length is a small non-negative integer, due to the test above. |
| 2409 __ tst(length, Operand(length)); | 2436 __ cmp(length, Operand(0)); |
| 2410 __ b(eq, &invoke); | 2437 __ b(eq, &invoke); |
| 2411 __ bind(&loop); | 2438 __ bind(&loop); |
| 2412 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); | 2439 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); |
| 2413 __ push(scratch); | 2440 __ push(scratch); |
| 2414 __ sub(length, length, Operand(1), SetCC); | 2441 __ sub(length, length, Operand(1), SetCC); |
| 2415 __ b(ne, &loop); | 2442 __ b(ne, &loop); |
| 2416 | 2443 |
| 2417 __ bind(&invoke); | 2444 __ bind(&invoke); |
| 2418 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 2445 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 2419 LPointerMap* pointers = instr->pointer_map(); | 2446 LPointerMap* pointers = instr->pointer_map(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 __ EmitVFPTruncate(kRoundToMinusInf, | 2662 __ EmitVFPTruncate(kRoundToMinusInf, |
| 2636 single_scratch, | 2663 single_scratch, |
| 2637 input, | 2664 input, |
| 2638 scratch1, | 2665 scratch1, |
| 2639 scratch2); | 2666 scratch2); |
| 2640 DeoptimizeIf(ne, instr->environment()); | 2667 DeoptimizeIf(ne, instr->environment()); |
| 2641 | 2668 |
| 2642 // Move the result back to general purpose register r0. | 2669 // Move the result back to general purpose register r0. |
| 2643 __ vmov(result, single_scratch); | 2670 __ vmov(result, single_scratch); |
| 2644 | 2671 |
| 2645 // Test for -0. | 2672 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 2646 Label done; | 2673 // Test for -0. |
| 2647 __ cmp(result, Operand(0)); | 2674 Label done; |
| 2648 __ b(ne, &done); | 2675 __ cmp(result, Operand(0)); |
| 2649 __ vmov(scratch1, input.high()); | 2676 __ b(ne, &done); |
| 2650 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 2677 __ vmov(scratch1, input.high()); |
| 2651 DeoptimizeIf(ne, instr->environment()); | 2678 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 2652 __ bind(&done); | 2679 DeoptimizeIf(ne, instr->environment()); |
| 2680 __ bind(&done); |
| 2681 } |
| 2653 } | 2682 } |
| 2654 | 2683 |
| 2655 | 2684 |
| 2656 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2685 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
| 2657 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 2686 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
| 2658 Register result = ToRegister(instr->result()); | 2687 Register result = ToRegister(instr->result()); |
| 2659 Register scratch1 = scratch0(); | 2688 Register scratch1 = scratch0(); |
| 2660 Register scratch2 = result; | 2689 Register scratch2 = result; |
| 2661 __ EmitVFPTruncate(kRoundToNearest, | 2690 __ EmitVFPTruncate(kRoundToNearest, |
| 2662 double_scratch0().low(), | 2691 double_scratch0().low(), |
| 2663 input, | 2692 input, |
| 2664 scratch1, | 2693 scratch1, |
| 2665 scratch2); | 2694 scratch2); |
| 2666 DeoptimizeIf(ne, instr->environment()); | 2695 DeoptimizeIf(ne, instr->environment()); |
| 2667 __ vmov(result, double_scratch0().low()); | 2696 __ vmov(result, double_scratch0().low()); |
| 2668 | 2697 |
| 2669 // Test for -0. | 2698 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 2670 Label done; | 2699 // Test for -0. |
| 2671 __ cmp(result, Operand(0)); | 2700 Label done; |
| 2672 __ b(ne, &done); | 2701 __ cmp(result, Operand(0)); |
| 2673 __ vmov(scratch1, input.high()); | 2702 __ b(ne, &done); |
| 2674 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 2703 __ vmov(scratch1, input.high()); |
| 2675 DeoptimizeIf(ne, instr->environment()); | 2704 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 2676 __ bind(&done); | 2705 DeoptimizeIf(ne, instr->environment()); |
| 2706 __ bind(&done); |
| 2707 } |
| 2677 } | 2708 } |
| 2678 | 2709 |
| 2679 | 2710 |
| 2680 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2711 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
| 2681 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 2712 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
| 2682 ASSERT(ToDoubleRegister(instr->result()).is(input)); | 2713 ASSERT(ToDoubleRegister(instr->result()).is(input)); |
| 2683 __ vsqrt(input, input); | 2714 __ vsqrt(input, input); |
| 2684 } | 2715 } |
| 2685 | 2716 |
| 2686 | 2717 |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3972 ASSERT(!environment->HasBeenRegistered()); | 4003 ASSERT(!environment->HasBeenRegistered()); |
| 3973 RegisterEnvironmentForDeoptimization(environment); | 4004 RegisterEnvironmentForDeoptimization(environment); |
| 3974 ASSERT(osr_pc_offset_ == -1); | 4005 ASSERT(osr_pc_offset_ == -1); |
| 3975 osr_pc_offset_ = masm()->pc_offset(); | 4006 osr_pc_offset_ = masm()->pc_offset(); |
| 3976 } | 4007 } |
| 3977 | 4008 |
| 3978 | 4009 |
| 3979 #undef __ | 4010 #undef __ |
| 3980 | 4011 |
| 3981 } } // namespace v8::internal | 4012 } } // namespace v8::internal |
| OLD | NEW |