OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 addl(Operand(dst, kSmiShift / kBitsPerByte), | 1373 addl(Operand(dst, kSmiShift / kBitsPerByte), |
1374 Immediate(constant->value())); | 1374 Immediate(constant->value())); |
1375 } else { | 1375 } else { |
1376 DCHECK(SmiValuesAre31Bits()); | 1376 DCHECK(SmiValuesAre31Bits()); |
1377 addp(dst, Immediate(constant)); | 1377 addp(dst, Immediate(constant)); |
1378 } | 1378 } |
1379 } | 1379 } |
1380 } | 1380 } |
1381 | 1381 |
1382 | 1382 |
1383 void MacroAssembler::SmiAddConstant(Register dst, | 1383 void MacroAssembler::SmiAddConstant(Register dst, Register src, Smi* constant, |
1384 Register src, | 1384 SmiOperationConstraints constraints, |
1385 Smi* constant, | |
1386 SmiOperationExecutionMode mode, | |
1387 Label* bailout_label, | 1385 Label* bailout_label, |
1388 Label::Distance near_jump) { | 1386 Label::Distance near_jump) { |
1389 if (constant->value() == 0) { | 1387 if (constant->value() == 0) { |
1390 if (!dst.is(src)) { | 1388 if (!dst.is(src)) { |
1391 movp(dst, src); | 1389 movp(dst, src); |
1392 } | 1390 } |
1393 } else if (dst.is(src)) { | 1391 } else if (dst.is(src)) { |
1394 DCHECK(!dst.is(kScratchRegister)); | 1392 DCHECK(!dst.is(kScratchRegister)); |
1395 LoadSmiConstant(kScratchRegister, constant); | 1393 LoadSmiConstant(kScratchRegister, constant); |
1396 addp(dst, kScratchRegister); | 1394 addp(dst, kScratchRegister); |
1397 if (mode.Contains(BAILOUT_ON_NO_OVERFLOW)) { | 1395 if (constraints & SmiOperationConstraint::kBailoutOnNoOverflow) { |
1398 j(no_overflow, bailout_label, near_jump); | 1396 j(no_overflow, bailout_label, near_jump); |
1399 DCHECK(mode.Contains(PRESERVE_SOURCE_REGISTER)); | 1397 DCHECK(constraints & SmiOperationConstraint::kPreserveSourceRegister); |
1400 subp(dst, kScratchRegister); | 1398 subp(dst, kScratchRegister); |
1401 } else if (mode.Contains(BAILOUT_ON_OVERFLOW)) { | 1399 } else if (constraints & SmiOperationConstraint::kBailoutOnOverflow) { |
1402 if (mode.Contains(PRESERVE_SOURCE_REGISTER)) { | 1400 if (constraints & SmiOperationConstraint::kPreserveSourceRegister) { |
1403 Label done; | 1401 Label done; |
1404 j(no_overflow, &done, Label::kNear); | 1402 j(no_overflow, &done, Label::kNear); |
1405 subp(dst, kScratchRegister); | 1403 subp(dst, kScratchRegister); |
1406 jmp(bailout_label, near_jump); | 1404 jmp(bailout_label, near_jump); |
1407 bind(&done); | 1405 bind(&done); |
1408 } else { | 1406 } else { |
1409 // Bailout if overflow without reserving src. | 1407 // Bailout if overflow without reserving src. |
1410 j(overflow, bailout_label, near_jump); | 1408 j(overflow, bailout_label, near_jump); |
1411 } | 1409 } |
1412 } else { | 1410 } else { |
1413 CHECK(mode.IsEmpty()); | 1411 UNREACHABLE(); |
1414 } | 1412 } |
1415 } else { | 1413 } else { |
1416 DCHECK(mode.Contains(PRESERVE_SOURCE_REGISTER)); | 1414 DCHECK(constraints & SmiOperationConstraint::kPreserveSourceRegister); |
1417 DCHECK(mode.Contains(BAILOUT_ON_OVERFLOW)); | 1415 DCHECK(constraints & SmiOperationConstraint::kBailoutOnOverflow); |
1418 LoadSmiConstant(dst, constant); | 1416 LoadSmiConstant(dst, constant); |
1419 addp(dst, src); | 1417 addp(dst, src); |
1420 j(overflow, bailout_label, near_jump); | 1418 j(overflow, bailout_label, near_jump); |
1421 } | 1419 } |
1422 } | 1420 } |
1423 | 1421 |
1424 | 1422 |
1425 void MacroAssembler::SmiSubConstant(Register dst, Register src, Smi* constant) { | 1423 void MacroAssembler::SmiSubConstant(Register dst, Register src, Smi* constant) { |
1426 if (constant->value() == 0) { | 1424 if (constant->value() == 0) { |
1427 if (!dst.is(src)) { | 1425 if (!dst.is(src)) { |
(...skipping 11 matching lines...) Expand all Loading... |
1439 addp(dst, src); | 1437 addp(dst, src); |
1440 } else { | 1438 } else { |
1441 // Subtract by adding the negation. | 1439 // Subtract by adding the negation. |
1442 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); | 1440 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); |
1443 addp(dst, src); | 1441 addp(dst, src); |
1444 } | 1442 } |
1445 } | 1443 } |
1446 } | 1444 } |
1447 | 1445 |
1448 | 1446 |
1449 void MacroAssembler::SmiSubConstant(Register dst, | 1447 void MacroAssembler::SmiSubConstant(Register dst, Register src, Smi* constant, |
1450 Register src, | 1448 SmiOperationConstraints constraints, |
1451 Smi* constant, | |
1452 SmiOperationExecutionMode mode, | |
1453 Label* bailout_label, | 1449 Label* bailout_label, |
1454 Label::Distance near_jump) { | 1450 Label::Distance near_jump) { |
1455 if (constant->value() == 0) { | 1451 if (constant->value() == 0) { |
1456 if (!dst.is(src)) { | 1452 if (!dst.is(src)) { |
1457 movp(dst, src); | 1453 movp(dst, src); |
1458 } | 1454 } |
1459 } else if (dst.is(src)) { | 1455 } else if (dst.is(src)) { |
1460 DCHECK(!dst.is(kScratchRegister)); | 1456 DCHECK(!dst.is(kScratchRegister)); |
1461 LoadSmiConstant(kScratchRegister, constant); | 1457 LoadSmiConstant(kScratchRegister, constant); |
1462 subp(dst, kScratchRegister); | 1458 subp(dst, kScratchRegister); |
1463 if (mode.Contains(BAILOUT_ON_NO_OVERFLOW)) { | 1459 if (constraints & SmiOperationConstraint::kBailoutOnNoOverflow) { |
1464 j(no_overflow, bailout_label, near_jump); | 1460 j(no_overflow, bailout_label, near_jump); |
1465 DCHECK(mode.Contains(PRESERVE_SOURCE_REGISTER)); | 1461 DCHECK(constraints & SmiOperationConstraint::kPreserveSourceRegister); |
1466 addp(dst, kScratchRegister); | 1462 addp(dst, kScratchRegister); |
1467 } else if (mode.Contains(BAILOUT_ON_OVERFLOW)) { | 1463 } else if (constraints & SmiOperationConstraint::kBailoutOnOverflow) { |
1468 if (mode.Contains(PRESERVE_SOURCE_REGISTER)) { | 1464 if (constraints & SmiOperationConstraint::kPreserveSourceRegister) { |
1469 Label done; | 1465 Label done; |
1470 j(no_overflow, &done, Label::kNear); | 1466 j(no_overflow, &done, Label::kNear); |
1471 addp(dst, kScratchRegister); | 1467 addp(dst, kScratchRegister); |
1472 jmp(bailout_label, near_jump); | 1468 jmp(bailout_label, near_jump); |
1473 bind(&done); | 1469 bind(&done); |
1474 } else { | 1470 } else { |
1475 // Bailout if overflow without reserving src. | 1471 // Bailout if overflow without reserving src. |
1476 j(overflow, bailout_label, near_jump); | 1472 j(overflow, bailout_label, near_jump); |
1477 } | 1473 } |
1478 } else { | 1474 } else { |
1479 CHECK(mode.IsEmpty()); | 1475 UNREACHABLE(); |
1480 } | 1476 } |
1481 } else { | 1477 } else { |
1482 DCHECK(mode.Contains(PRESERVE_SOURCE_REGISTER)); | 1478 DCHECK(constraints & SmiOperationConstraint::kPreserveSourceRegister); |
1483 DCHECK(mode.Contains(BAILOUT_ON_OVERFLOW)); | 1479 DCHECK(constraints & SmiOperationConstraint::kBailoutOnOverflow); |
1484 if (constant->value() == Smi::kMinValue) { | 1480 if (constant->value() == Smi::kMinValue) { |
1485 DCHECK(!dst.is(kScratchRegister)); | 1481 DCHECK(!dst.is(kScratchRegister)); |
1486 movp(dst, src); | 1482 movp(dst, src); |
1487 LoadSmiConstant(kScratchRegister, constant); | 1483 LoadSmiConstant(kScratchRegister, constant); |
1488 subp(dst, kScratchRegister); | 1484 subp(dst, kScratchRegister); |
1489 j(overflow, bailout_label, near_jump); | 1485 j(overflow, bailout_label, near_jump); |
1490 } else { | 1486 } else { |
1491 // Subtract by adding the negation. | 1487 // Subtract by adding the negation. |
1492 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); | 1488 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); |
1493 addp(dst, src); | 1489 addp(dst, src); |
(...skipping 3600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5094 movl(rax, dividend); | 5090 movl(rax, dividend); |
5095 shrl(rax, Immediate(31)); | 5091 shrl(rax, Immediate(31)); |
5096 addl(rdx, rax); | 5092 addl(rdx, rax); |
5097 } | 5093 } |
5098 | 5094 |
5099 | 5095 |
5100 } // namespace internal | 5096 } // namespace internal |
5101 } // namespace v8 | 5097 } // namespace v8 |
5102 | 5098 |
5103 #endif // V8_TARGET_ARCH_X64 | 5099 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |