OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1084 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1085 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | 1085 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); |
1086 } | 1086 } |
1087 __ Branch(USE_DELAY_SLOT, &done); | 1087 __ Branch(USE_DELAY_SLOT, &done); |
1088 __ subu(result_reg, zero_reg, result_reg); | 1088 __ subu(result_reg, zero_reg, result_reg); |
1089 } | 1089 } |
1090 | 1090 |
1091 __ bind(&left_is_not_negative); | 1091 __ bind(&left_is_not_negative); |
1092 __ And(result_reg, left_reg, divisor - 1); | 1092 __ And(result_reg, left_reg, divisor - 1); |
1093 __ bind(&done); | 1093 __ bind(&done); |
1094 | |
1095 } else if (hmod->fixed_right_arg().has_value) { | |
1096 const Register left_reg = ToRegister(instr->left()); | |
1097 const Register result_reg = ToRegister(instr->result()); | |
1098 const Register right_reg = ToRegister(instr->right()); | |
1099 | |
1100 int32_t divisor = hmod->fixed_right_arg().value; | |
1101 ASSERT(IsPowerOf2(divisor)); | |
1102 | |
1103 // Check if our assumption of a fixed right operand still holds. | |
1104 DeoptimizeIf(ne, instr->environment(), right_reg, Operand(divisor)); | |
1105 | |
1106 Label left_is_not_negative, done; | |
1107 if (left->CanBeNegative()) { | |
1108 __ Branch(left_reg.is(result_reg) ? PROTECT : USE_DELAY_SLOT, | |
1109 &left_is_not_negative, ge, left_reg, Operand(zero_reg)); | |
1110 __ subu(result_reg, zero_reg, left_reg); | |
1111 __ And(result_reg, result_reg, divisor - 1); | |
1112 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
1113 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | |
1114 } | |
1115 __ Branch(USE_DELAY_SLOT, &done); | |
1116 __ subu(result_reg, zero_reg, result_reg); | |
1117 } | |
1118 | |
1119 __ bind(&left_is_not_negative); | |
1120 __ And(result_reg, left_reg, divisor - 1); | |
1121 __ bind(&done); | |
1122 | |
1123 } else { | 1094 } else { |
1124 const Register scratch = scratch0(); | 1095 const Register scratch = scratch0(); |
1125 const Register left_reg = ToRegister(instr->left()); | 1096 const Register left_reg = ToRegister(instr->left()); |
1126 const Register result_reg = ToRegister(instr->result()); | 1097 const Register result_reg = ToRegister(instr->result()); |
1127 | 1098 |
1128 // div runs in the background while we check for special cases. | 1099 // div runs in the background while we check for special cases. |
1129 Register right_reg = EmitLoadRegister(instr->right(), scratch); | 1100 Register right_reg = EmitLoadRegister(instr->right(), scratch); |
1130 __ div(left_reg, right_reg); | 1101 __ div(left_reg, right_reg); |
1131 | 1102 |
1132 Label done; | 1103 Label done; |
(...skipping 4781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5914 __ Subu(scratch, result, scratch); | 5885 __ Subu(scratch, result, scratch); |
5915 __ lw(result, FieldMemOperand(scratch, | 5886 __ lw(result, FieldMemOperand(scratch, |
5916 FixedArray::kHeaderSize - kPointerSize)); | 5887 FixedArray::kHeaderSize - kPointerSize)); |
5917 __ bind(&done); | 5888 __ bind(&done); |
5918 } | 5889 } |
5919 | 5890 |
5920 | 5891 |
5921 #undef __ | 5892 #undef __ |
5922 | 5893 |
5923 } } // namespace v8::internal | 5894 } } // namespace v8::internal |
OLD | NEW |