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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1227 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1228 __ j(not_zero, &done, Label::kNear); | 1228 __ j(not_zero, &done, Label::kNear); |
1229 DeoptimizeIf(no_condition, instr->environment()); | 1229 DeoptimizeIf(no_condition, instr->environment()); |
1230 } else { | 1230 } else { |
1231 __ jmp(&done, Label::kNear); | 1231 __ jmp(&done, Label::kNear); |
1232 } | 1232 } |
1233 __ bind(&positive_dividend); | 1233 __ bind(&positive_dividend); |
1234 __ and_(dividend, divisor - 1); | 1234 __ and_(dividend, divisor - 1); |
1235 __ bind(&done); | 1235 __ bind(&done); |
1236 } else { | 1236 } else { |
1237 Label done, remainder_eq_dividend, slow, do_subtraction, both_positive; | 1237 Label done, remainder_eq_dividend, slow, both_positive; |
1238 Register left_reg = ToRegister(instr->left()); | 1238 Register left_reg = ToRegister(instr->left()); |
1239 Register right_reg = ToRegister(instr->right()); | 1239 Register right_reg = ToRegister(instr->right()); |
1240 Register result_reg = ToRegister(instr->result()); | 1240 Register result_reg = ToRegister(instr->result()); |
1241 | 1241 |
1242 ASSERT(left_reg.is(eax)); | 1242 ASSERT(left_reg.is(eax)); |
1243 ASSERT(result_reg.is(edx)); | 1243 ASSERT(result_reg.is(edx)); |
1244 ASSERT(!right_reg.is(eax)); | 1244 ASSERT(!right_reg.is(eax)); |
1245 ASSERT(!right_reg.is(edx)); | 1245 ASSERT(!right_reg.is(edx)); |
1246 | 1246 |
1247 // Check for x % 0. | 1247 // Check for x % 0. |
(...skipping 15 matching lines...) Expand all Loading... |
1263 // If the dividend is smaller than the nonnegative | 1263 // If the dividend is smaller than the nonnegative |
1264 // divisor, the dividend is the result. | 1264 // divisor, the dividend is the result. |
1265 __ cmp(left_reg, Operand(right_reg)); | 1265 __ cmp(left_reg, Operand(right_reg)); |
1266 __ j(less, &remainder_eq_dividend, Label::kNear); | 1266 __ j(less, &remainder_eq_dividend, Label::kNear); |
1267 | 1267 |
1268 // Check if the divisor is a PowerOfTwo integer. | 1268 // Check if the divisor is a PowerOfTwo integer. |
1269 Register scratch = ToRegister(instr->temp()); | 1269 Register scratch = ToRegister(instr->temp()); |
1270 __ mov(scratch, right_reg); | 1270 __ mov(scratch, right_reg); |
1271 __ sub(Operand(scratch), Immediate(1)); | 1271 __ sub(Operand(scratch), Immediate(1)); |
1272 __ test(scratch, Operand(right_reg)); | 1272 __ test(scratch, Operand(right_reg)); |
1273 __ j(not_zero, &do_subtraction, Label::kNear); | 1273 __ j(not_zero, &slow, Label::kNear); |
1274 __ and_(left_reg, Operand(scratch)); | 1274 __ and_(left_reg, Operand(scratch)); |
1275 __ jmp(&remainder_eq_dividend, Label::kNear); | 1275 __ jmp(&remainder_eq_dividend, Label::kNear); |
1276 | 1276 |
1277 __ bind(&do_subtraction); | |
1278 const int kUnfolds = 3; | |
1279 // Try a few subtractions of the dividend. | |
1280 __ mov(scratch, left_reg); | |
1281 for (int i = 0; i < kUnfolds; i++) { | |
1282 // Reduce the dividend by the divisor. | |
1283 __ sub(left_reg, Operand(right_reg)); | |
1284 // Check if the dividend is less than the divisor. | |
1285 __ cmp(left_reg, Operand(right_reg)); | |
1286 __ j(less, &remainder_eq_dividend, Label::kNear); | |
1287 } | |
1288 __ mov(left_reg, scratch); | |
1289 | |
1290 // Slow case, using idiv instruction. | 1277 // Slow case, using idiv instruction. |
1291 __ bind(&slow); | 1278 __ bind(&slow); |
1292 | 1279 |
1293 // Check for (kMinInt % -1). | 1280 // Check for (kMinInt % -1). |
1294 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 1281 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
1295 Label left_not_min_int; | 1282 Label left_not_min_int; |
1296 __ cmp(left_reg, kMinInt); | 1283 __ cmp(left_reg, kMinInt); |
1297 __ j(not_zero, &left_not_min_int, Label::kNear); | 1284 __ j(not_zero, &left_not_min_int, Label::kNear); |
1298 __ cmp(right_reg, -1); | 1285 __ cmp(right_reg, -1); |
1299 DeoptimizeIf(zero, instr->environment()); | 1286 DeoptimizeIf(zero, instr->environment()); |
(...skipping 5353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6653 FixedArray::kHeaderSize - kPointerSize)); | 6640 FixedArray::kHeaderSize - kPointerSize)); |
6654 __ bind(&done); | 6641 __ bind(&done); |
6655 } | 6642 } |
6656 | 6643 |
6657 | 6644 |
6658 #undef __ | 6645 #undef __ |
6659 | 6646 |
6660 } } // namespace v8::internal | 6647 } } // namespace v8::internal |
6661 | 6648 |
6662 #endif // V8_TARGET_ARCH_IA32 | 6649 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |