| 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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1030 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1031 __ j(not_zero, &done, Label::kNear); | 1031 __ j(not_zero, &done, Label::kNear); |
| 1032 DeoptimizeIf(no_condition, instr->environment()); | 1032 DeoptimizeIf(no_condition, instr->environment()); |
| 1033 } else { | 1033 } else { |
| 1034 __ jmp(&done, Label::kNear); | 1034 __ jmp(&done, Label::kNear); |
| 1035 } | 1035 } |
| 1036 __ bind(&positive_dividend); | 1036 __ bind(&positive_dividend); |
| 1037 __ andl(dividend, Immediate(divisor - 1)); | 1037 __ andl(dividend, Immediate(divisor - 1)); |
| 1038 __ bind(&done); | 1038 __ bind(&done); |
| 1039 } else { | 1039 } else { |
| 1040 Label done, remainder_eq_dividend, slow, do_subtraction, both_positive; | 1040 Label done, remainder_eq_dividend, slow, both_positive; |
| 1041 Register left_reg = ToRegister(instr->left()); | 1041 Register left_reg = ToRegister(instr->left()); |
| 1042 Register right_reg = ToRegister(instr->right()); | 1042 Register right_reg = ToRegister(instr->right()); |
| 1043 Register result_reg = ToRegister(instr->result()); | 1043 Register result_reg = ToRegister(instr->result()); |
| 1044 | 1044 |
| 1045 ASSERT(left_reg.is(rax)); | 1045 ASSERT(left_reg.is(rax)); |
| 1046 ASSERT(result_reg.is(rdx)); | 1046 ASSERT(result_reg.is(rdx)); |
| 1047 ASSERT(!right_reg.is(rax)); | 1047 ASSERT(!right_reg.is(rax)); |
| 1048 ASSERT(!right_reg.is(rdx)); | 1048 ASSERT(!right_reg.is(rdx)); |
| 1049 | 1049 |
| 1050 // Check for x % 0. | 1050 // Check for x % 0. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1066 // If the dividend is smaller than the nonnegative | 1066 // If the dividend is smaller than the nonnegative |
| 1067 // divisor, the dividend is the result. | 1067 // divisor, the dividend is the result. |
| 1068 __ cmpl(left_reg, right_reg); | 1068 __ cmpl(left_reg, right_reg); |
| 1069 __ j(less, &remainder_eq_dividend, Label::kNear); | 1069 __ j(less, &remainder_eq_dividend, Label::kNear); |
| 1070 | 1070 |
| 1071 // Check if the divisor is a PowerOfTwo integer. | 1071 // Check if the divisor is a PowerOfTwo integer. |
| 1072 Register scratch = ToRegister(instr->temp()); | 1072 Register scratch = ToRegister(instr->temp()); |
| 1073 __ movl(scratch, right_reg); | 1073 __ movl(scratch, right_reg); |
| 1074 __ subl(scratch, Immediate(1)); | 1074 __ subl(scratch, Immediate(1)); |
| 1075 __ testl(scratch, right_reg); | 1075 __ testl(scratch, right_reg); |
| 1076 __ j(not_zero, &do_subtraction, Label::kNear); | 1076 __ j(not_zero, &slow, Label::kNear); |
| 1077 __ andl(left_reg, scratch); | 1077 __ andl(left_reg, scratch); |
| 1078 __ jmp(&remainder_eq_dividend, Label::kNear); | 1078 __ jmp(&remainder_eq_dividend, Label::kNear); |
| 1079 | 1079 |
| 1080 __ bind(&do_subtraction); | |
| 1081 const int kUnfolds = 3; | |
| 1082 // Try a few subtractions of the dividend. | |
| 1083 __ movl(scratch, left_reg); | |
| 1084 for (int i = 0; i < kUnfolds; i++) { | |
| 1085 // Reduce the dividend by the divisor. | |
| 1086 __ subl(left_reg, right_reg); | |
| 1087 // Check if the dividend is less than the divisor. | |
| 1088 __ cmpl(left_reg, right_reg); | |
| 1089 __ j(less, &remainder_eq_dividend, Label::kNear); | |
| 1090 } | |
| 1091 __ movl(left_reg, scratch); | |
| 1092 | |
| 1093 // Slow case, using idiv instruction. | 1080 // Slow case, using idiv instruction. |
| 1094 __ bind(&slow); | 1081 __ bind(&slow); |
| 1095 | 1082 |
| 1096 // Check for (kMinInt % -1). | 1083 // Check for (kMinInt % -1). |
| 1097 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 1084 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 1098 Label left_not_min_int; | 1085 Label left_not_min_int; |
| 1099 __ cmpl(left_reg, Immediate(kMinInt)); | 1086 __ cmpl(left_reg, Immediate(kMinInt)); |
| 1100 __ j(not_zero, &left_not_min_int, Label::kNear); | 1087 __ j(not_zero, &left_not_min_int, Label::kNear); |
| 1101 __ cmpl(right_reg, Immediate(-1)); | 1088 __ cmpl(right_reg, Immediate(-1)); |
| 1102 DeoptimizeIf(zero, instr->environment()); | 1089 DeoptimizeIf(zero, instr->environment()); |
| (...skipping 4639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5742 FixedArray::kHeaderSize - kPointerSize)); | 5729 FixedArray::kHeaderSize - kPointerSize)); |
| 5743 __ bind(&done); | 5730 __ bind(&done); |
| 5744 } | 5731 } |
| 5745 | 5732 |
| 5746 | 5733 |
| 5747 #undef __ | 5734 #undef __ |
| 5748 | 5735 |
| 5749 } } // namespace v8::internal | 5736 } } // namespace v8::internal |
| 5750 | 5737 |
| 5751 #endif // V8_TARGET_ARCH_X64 | 5738 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |