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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 // Nothing to do. | 825 // Nothing to do. |
826 } | 826 } |
827 | 827 |
828 | 828 |
829 void LCodeGen::DoModI(LModI* instr) { | 829 void LCodeGen::DoModI(LModI* instr) { |
830 Abort("DoModI unimplemented."); | 830 Abort("DoModI unimplemented."); |
831 } | 831 } |
832 | 832 |
833 | 833 |
834 void LCodeGen::DoDivI(LDivI* instr) { | 834 void LCodeGen::DoDivI(LDivI* instr) { |
835 Abort("DoDivI unimplemented."); | 835 const Register left = ToRegister(instr->left()); |
836 const Register right = ToRegister(instr->right()); | |
837 const Register scratch = scratch0(); | |
838 const Register result = ToRegister(instr->result()); | |
839 | |
840 // Check for x / 0. | |
841 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { | |
842 __ tst(right, right); | |
843 DeoptimizeIf(eq, instr->environment()); | |
844 } | |
845 | |
846 // Check for (0 / -x) that will produce negative zero. | |
847 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
848 Label left_not_zero; | |
849 __ tst(left, Operand(left)); | |
850 __ b(ne, &left_not_zero); | |
851 __ tst(right, Operand(right)); | |
852 DeoptimizeIf(mi, instr->environment()); | |
853 __ bind(&left_not_zero); | |
854 } | |
855 | |
856 // Check for (-kMinInt / -1). | |
857 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | |
858 Label left_not_min_int; | |
859 __ cmp(left, Operand(kMinInt)); | |
860 __ b(ne, &left_not_min_int); | |
861 __ cmp(right, Operand(-1)); | |
862 DeoptimizeIf(eq, instr->environment()); | |
863 __ bind(&left_not_min_int); | |
864 } | |
865 | |
866 Label done, deoptimize; | |
867 // Test for a few common cases first. | |
868 __ cmp(right, Operand(1)); | |
869 __ mov(result, left, LeaveCC, eq); | |
870 __ b(eq, &done); | |
871 | |
872 __ cmp(right, Operand(2)); | |
873 __ tst(left, Operand(1), eq); | |
874 __ mov(result, Operand(left, ASR, 1), LeaveCC, eq); | |
875 __ b(eq, &done); | |
876 | |
877 __ cmp(right, Operand(4)); | |
878 __ tst(left, Operand(3), eq); | |
879 __ mov(result, Operand(left, ASR, 2), LeaveCC, eq); | |
880 __ b(eq, &done); | |
881 | |
882 // Call the generic stub. The numbers in r0 and r1 have | |
883 // to be tagged to Smis. If that is not possible, deoptimize. | |
884 const int32_t kTwoHighestBits = 3<<30; | |
Søren Thygesen Gjesse
2011/01/13 08:28:38
In other parts of the code we write this as 0xc000
Karl Klose
2011/01/13 13:52:31
I have created a TrySmiTag instruction in the macr
| |
885 __ and_(scratch, left, Operand(kTwoHighestBits)); | |
Søren Thygesen Gjesse
2011/01/13 08:28:38
You can use SetCC on the and instruction to set th
Karl Klose
2011/01/13 13:52:31
s.a.
| |
886 __ cmp(scratch, Operand(1 << 31)); | |
887 __ cmp(scratch, Operand(1 << 30), ne); | |
888 __ b(eq, &deoptimize); | |
Søren Thygesen Gjesse
2011/01/13 08:28:38
There is a SmiTag instruction in the macro assembl
Karl Klose
2011/01/13 13:52:31
s.a.
| |
889 __ mov(left, Operand(left, LSL, 1)); | |
890 | |
891 __ and_(scratch, right, Operand(kTwoHighestBits)); | |
892 __ cmp(scratch, Operand(1 << 31)); | |
893 __ cmp(scratch, Operand(1 << 30), ne); | |
894 __ b(eq, &deoptimize); | |
895 __ mov(right, Operand(right, LSL, 1)); | |
896 | |
897 GenericBinaryOpStub stub(Token::DIV, OVERWRITE_LEFT, left, right); | |
Søren Thygesen Gjesse
2011/01/13 08:28:38
The LDivI instruction is not marked as call which
Karl Klose
2011/01/13 13:52:31
Done.
| |
898 __ CallStub(&stub); | |
899 | |
900 // If the result in r0 is a Smi, untag it, else deoptimize. | |
901 __ BranchOnNotSmi(result, &deoptimize); | |
902 __ mov(result, Operand(result, ASR, 1)); | |
903 __ b(&done); | |
904 | |
905 __ bind(&deoptimize); | |
906 DeoptimizeIf(al, instr->environment()); | |
907 __ bind(&done); | |
908 | |
836 } | 909 } |
837 | 910 |
838 | 911 |
839 void LCodeGen::DoMulI(LMulI* instr) { | 912 void LCodeGen::DoMulI(LMulI* instr) { |
840 Register scratch = scratch0(); | 913 Register scratch = scratch0(); |
841 Register left = ToRegister(instr->left()); | 914 Register left = ToRegister(instr->left()); |
842 Register right = EmitLoadRegister(instr->right(), scratch); | 915 Register right = EmitLoadRegister(instr->right(), scratch); |
843 | 916 |
844 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && | 917 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && |
845 !instr->right()->IsConstantOperand()) { | 918 !instr->right()->IsConstantOperand()) { |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2830 | 2903 |
2831 | 2904 |
2832 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2905 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
2833 Abort("DoOsrEntry unimplemented."); | 2906 Abort("DoOsrEntry unimplemented."); |
2834 } | 2907 } |
2835 | 2908 |
2836 | 2909 |
2837 #undef __ | 2910 #undef __ |
2838 | 2911 |
2839 } } // namespace v8::internal | 2912 } } // namespace v8::internal |
OLD | NEW |