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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value()))); | 703 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value()))); |
704 } | 704 } |
705 | 705 |
706 | 706 |
707 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { | 707 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { |
708 UNREACHABLE(); | 708 UNREACHABLE(); |
709 return NULL; | 709 return NULL; |
710 } | 710 } |
711 | 711 |
712 | 712 |
713 LInstruction* LChunkBuilder::DoSoftDeoptimize(HSoftDeoptimize* instr) { | |
714 return AssignEnvironment(new(zone()) LDeoptimize); | |
715 } | |
716 | |
717 | |
718 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 713 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
719 return AssignEnvironment(new(zone()) LDeoptimize); | 714 return AssignEnvironment(new(zone()) LDeoptimize); |
720 } | 715 } |
721 | 716 |
722 | 717 |
723 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 718 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
724 HBitwiseBinaryOperation* instr) { | 719 HBitwiseBinaryOperation* instr) { |
725 if (instr->representation().IsSmiOrTagged()) { | 720 if (instr->representation().IsTagged()) { |
726 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 721 ASSERT(instr->left()->representation().IsTagged()); |
727 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 722 ASSERT(instr->right()->representation().IsTagged()); |
728 | 723 |
729 LOperand* left = UseFixed(instr->left(), rdx); | 724 LOperand* left = UseFixed(instr->left(), rdx); |
730 LOperand* right = UseFixed(instr->right(), rax); | 725 LOperand* right = UseFixed(instr->right(), rax); |
731 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); | 726 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); |
732 return MarkAsCall(DefineFixed(result, rax), instr); | 727 return MarkAsCall(DefineFixed(result, rax), instr); |
733 } | 728 } |
734 | 729 |
735 ASSERT(instr->representation().IsInteger32()); | 730 ASSERT(instr->representation().IsSmiOrInteger32()); |
736 ASSERT(instr->left()->representation().IsInteger32()); | 731 ASSERT(instr->left()->representation().Equals(instr->representation())); |
737 ASSERT(instr->right()->representation().IsInteger32()); | 732 ASSERT(instr->right()->representation().Equals(instr->representation())); |
738 LOperand* left = UseRegisterAtStart(instr->left()); | 733 LOperand* left = UseRegisterAtStart(instr->left()); |
739 | 734 |
740 HValue* right_value = instr->right(); | 735 HValue* right_value = instr->right(); |
741 LOperand* right = NULL; | 736 LOperand* right = NULL; |
742 int constant_value = 0; | 737 int constant_value = 0; |
743 if (right_value->IsConstant()) { | 738 if (right_value->IsConstant()) { |
744 HConstant* constant = HConstant::cast(right_value); | 739 HConstant* constant = HConstant::cast(right_value); |
745 right = chunk_->DefineConstantOperand(constant); | 740 right = chunk_->DefineConstantOperand(constant); |
746 constant_value = constant->Integer32Value() & 0x1f; | 741 constant_value = constant->Integer32Value() & 0x1f; |
747 } else { | 742 } else { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 780 |
786 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 781 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
787 HArithmeticBinaryOperation* instr) { | 782 HArithmeticBinaryOperation* instr) { |
788 ASSERT(op == Token::ADD || | 783 ASSERT(op == Token::ADD || |
789 op == Token::DIV || | 784 op == Token::DIV || |
790 op == Token::MOD || | 785 op == Token::MOD || |
791 op == Token::MUL || | 786 op == Token::MUL || |
792 op == Token::SUB); | 787 op == Token::SUB); |
793 HValue* left = instr->left(); | 788 HValue* left = instr->left(); |
794 HValue* right = instr->right(); | 789 HValue* right = instr->right(); |
795 ASSERT(left->representation().IsSmiOrTagged()); | 790 ASSERT(left->representation().IsTagged()); |
796 ASSERT(right->representation().IsSmiOrTagged()); | 791 ASSERT(right->representation().IsTagged()); |
797 LOperand* left_operand = UseFixed(left, rdx); | 792 LOperand* left_operand = UseFixed(left, rdx); |
798 LOperand* right_operand = UseFixed(right, rax); | 793 LOperand* right_operand = UseFixed(right, rax); |
799 LArithmeticT* result = | 794 LArithmeticT* result = |
800 new(zone()) LArithmeticT(op, left_operand, right_operand); | 795 new(zone()) LArithmeticT(op, left_operand, right_operand); |
801 return MarkAsCall(DefineFixed(result, rax), instr); | 796 return MarkAsCall(DefineFixed(result, rax), instr); |
802 } | 797 } |
803 | 798 |
804 | 799 |
805 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { | 800 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { |
806 ASSERT(is_building()); | 801 ASSERT(is_building()); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 return DoShift(Token::SAR, instr); | 1312 return DoShift(Token::SAR, instr); |
1318 } | 1313 } |
1319 | 1314 |
1320 | 1315 |
1321 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1316 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
1322 return DoShift(Token::SHL, instr); | 1317 return DoShift(Token::SHL, instr); |
1323 } | 1318 } |
1324 | 1319 |
1325 | 1320 |
1326 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1321 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
1327 if (instr->representation().IsInteger32()) { | 1322 if (instr->representation().IsSmiOrInteger32()) { |
1328 ASSERT(instr->left()->representation().IsInteger32()); | 1323 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1329 ASSERT(instr->right()->representation().IsInteger32()); | 1324 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1330 | 1325 |
1331 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1326 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1332 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1327 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1333 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1328 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
1334 } else { | 1329 } else { |
1335 ASSERT(instr->representation().IsSmiOrTagged()); | 1330 ASSERT(instr->representation().IsTagged()); |
1336 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 1331 ASSERT(instr->left()->representation().IsTagged()); |
1337 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 1332 ASSERT(instr->right()->representation().IsTagged()); |
1338 | 1333 |
1339 LOperand* left = UseFixed(instr->left(), rdx); | 1334 LOperand* left = UseFixed(instr->left(), rdx); |
1340 LOperand* right = UseFixed(instr->right(), rax); | 1335 LOperand* right = UseFixed(instr->right(), rax); |
1341 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1336 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
1342 return MarkAsCall(DefineFixed(result, rax), instr); | 1337 return MarkAsCall(DefineFixed(result, rax), instr); |
1343 } | 1338 } |
1344 } | 1339 } |
1345 | 1340 |
1346 | 1341 |
1347 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { | 1342 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { |
1348 ASSERT(instr->value()->representation().IsInteger32()); | 1343 ASSERT(instr->value()->representation().IsInteger32()); |
1349 ASSERT(instr->representation().IsInteger32()); | 1344 ASSERT(instr->representation().IsInteger32()); |
1350 if (instr->HasNoUses()) return NULL; | 1345 if (instr->HasNoUses()) return NULL; |
1351 LOperand* input = UseRegisterAtStart(instr->value()); | 1346 LOperand* input = UseRegisterAtStart(instr->value()); |
1352 LBitNotI* result = new(zone()) LBitNotI(input); | 1347 LBitNotI* result = new(zone()) LBitNotI(input); |
1353 return DefineSameAsFirst(result); | 1348 return DefineSameAsFirst(result); |
1354 } | 1349 } |
1355 | 1350 |
1356 | 1351 |
1357 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1352 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
1358 if (instr->representation().IsDouble()) { | 1353 if (instr->representation().IsDouble()) { |
1359 return DoArithmeticD(Token::DIV, instr); | 1354 return DoArithmeticD(Token::DIV, instr); |
1360 } else if (instr->representation().IsInteger32()) { | 1355 } else if (instr->representation().IsSmiOrInteger32()) { |
| 1356 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1357 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1361 if (instr->HasPowerOf2Divisor()) { | 1358 if (instr->HasPowerOf2Divisor()) { |
1362 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1359 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
1363 LOperand* value = UseRegisterAtStart(instr->left()); | 1360 LOperand* value = UseRegisterAtStart(instr->left()); |
1364 LDivI* div = | 1361 LDivI* div = |
1365 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 1362 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); |
1366 return AssignEnvironment(DefineSameAsFirst(div)); | 1363 return AssignEnvironment(DefineSameAsFirst(div)); |
1367 } | 1364 } |
1368 // The temporary operand is necessary to ensure that right is not allocated | 1365 // The temporary operand is necessary to ensure that right is not allocated |
1369 // into rdx. | 1366 // into rdx. |
1370 LOperand* temp = FixedTemp(rdx); | 1367 LOperand* temp = FixedTemp(rdx); |
1371 LOperand* dividend = UseFixed(instr->left(), rax); | 1368 LOperand* dividend = UseFixed(instr->left(), rax); |
1372 LOperand* divisor = UseRegister(instr->right()); | 1369 LOperand* divisor = UseRegister(instr->right()); |
1373 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1370 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
1374 return AssignEnvironment(DefineFixed(result, rax)); | 1371 return AssignEnvironment(DefineFixed(result, rax)); |
1375 } else { | 1372 } else { |
1376 ASSERT(instr->representation().IsSmiOrTagged()); | 1373 ASSERT(instr->representation().IsTagged()); |
1377 return DoArithmeticT(Token::DIV, instr); | 1374 return DoArithmeticT(Token::DIV, instr); |
1378 } | 1375 } |
1379 } | 1376 } |
1380 | 1377 |
1381 | 1378 |
1382 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1379 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
1383 if (divisor->IsConstant() && | 1380 if (divisor->IsConstant() && |
1384 HConstant::cast(divisor)->HasInteger32Value()) { | 1381 HConstant::cast(divisor)->HasInteger32Value()) { |
1385 HConstant* constant_val = HConstant::cast(divisor); | 1382 HConstant* constant_val = HConstant::cast(divisor); |
1386 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1383 return constant_val->CopyToRepresentation(Representation::Integer32(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 LInstruction* result = DefineAsRegister( | 1427 LInstruction* result = DefineAsRegister( |
1431 new(zone()) LMathFloorOfDiv(dividend, divisor, temp)); | 1428 new(zone()) LMathFloorOfDiv(dividend, divisor, temp)); |
1432 return divisor_si < 0 ? AssignEnvironment(result) : result; | 1429 return divisor_si < 0 ? AssignEnvironment(result) : result; |
1433 } | 1430 } |
1434 } | 1431 } |
1435 | 1432 |
1436 | 1433 |
1437 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1434 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1438 HValue* left = instr->left(); | 1435 HValue* left = instr->left(); |
1439 HValue* right = instr->right(); | 1436 HValue* right = instr->right(); |
1440 if (instr->representation().IsInteger32()) { | 1437 if (instr->representation().IsSmiOrInteger32()) { |
1441 ASSERT(left->representation().IsInteger32()); | 1438 ASSERT(left->representation().Equals(instr->representation())); |
1442 ASSERT(right->representation().IsInteger32()); | 1439 ASSERT(right->representation().Equals(instr->representation())); |
1443 if (instr->HasPowerOf2Divisor()) { | 1440 if (instr->HasPowerOf2Divisor()) { |
1444 ASSERT(!right->CanBeZero()); | 1441 ASSERT(!right->CanBeZero()); |
1445 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1442 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
1446 UseOrConstant(right), | 1443 UseOrConstant(right), |
1447 NULL); | 1444 NULL); |
1448 LInstruction* result = DefineSameAsFirst(mod); | 1445 LInstruction* result = DefineSameAsFirst(mod); |
1449 return (left->CanBeNegative() && | 1446 return (left->CanBeNegative() && |
1450 instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1447 instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
1451 ? AssignEnvironment(result) | 1448 ? AssignEnvironment(result) |
1452 : result; | 1449 : result; |
(...skipping 12 matching lines...) Expand all Loading... |
1465 return (right->CanBeZero() || | 1462 return (right->CanBeZero() || |
1466 (left->RangeCanInclude(kMinInt) && | 1463 (left->RangeCanInclude(kMinInt) && |
1467 right->RangeCanInclude(-1) && | 1464 right->RangeCanInclude(-1) && |
1468 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || | 1465 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || |
1469 (left->CanBeNegative() && | 1466 (left->CanBeNegative() && |
1470 instr->CanBeZero() && | 1467 instr->CanBeZero() && |
1471 instr->CheckFlag(HValue::kBailoutOnMinusZero))) | 1468 instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
1472 ? AssignEnvironment(result) | 1469 ? AssignEnvironment(result) |
1473 : result; | 1470 : result; |
1474 } | 1471 } |
1475 } else if (instr->representation().IsSmiOrTagged()) { | 1472 } else if (instr->representation().IsTagged()) { |
1476 return DoArithmeticT(Token::MOD, instr); | 1473 return DoArithmeticT(Token::MOD, instr); |
1477 } else { | 1474 } else { |
1478 ASSERT(instr->representation().IsDouble()); | 1475 ASSERT(instr->representation().IsDouble()); |
1479 // We call a C function for double modulo. It can't trigger a GC. We need to | 1476 // We call a C function for double modulo. It can't trigger a GC. We need to |
1480 // use fixed result register for the call. | 1477 // use fixed result register for the call. |
1481 // TODO(fschneider): Allow any register as input registers. | 1478 // TODO(fschneider): Allow any register as input registers. |
1482 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD, | 1479 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD, |
1483 UseFixedDouble(left, xmm2), | 1480 UseFixedDouble(left, xmm2), |
1484 UseFixedDouble(right, xmm1)); | 1481 UseFixedDouble(right, xmm1)); |
1485 return MarkAsCall(DefineFixedDouble(mod, xmm1), instr); | 1482 return MarkAsCall(DefineFixedDouble(mod, xmm1), instr); |
1486 } | 1483 } |
1487 } | 1484 } |
1488 | 1485 |
1489 | 1486 |
1490 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1487 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
1491 if (instr->representation().IsInteger32()) { | 1488 if (instr->representation().IsSmiOrInteger32()) { |
1492 ASSERT(instr->left()->representation().IsInteger32()); | 1489 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1493 ASSERT(instr->right()->representation().IsInteger32()); | 1490 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1494 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1491 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1495 LOperand* right = UseOrConstant(instr->BetterRightOperand()); | 1492 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
1496 LMulI* mul = new(zone()) LMulI(left, right); | 1493 LMulI* mul = new(zone()) LMulI(left, right); |
1497 if (instr->CheckFlag(HValue::kCanOverflow) || | 1494 if (instr->CheckFlag(HValue::kCanOverflow) || |
1498 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1495 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1499 AssignEnvironment(mul); | 1496 AssignEnvironment(mul); |
1500 } | 1497 } |
1501 return DefineSameAsFirst(mul); | 1498 return DefineSameAsFirst(mul); |
1502 } else if (instr->representation().IsDouble()) { | 1499 } else if (instr->representation().IsDouble()) { |
1503 return DoArithmeticD(Token::MUL, instr); | 1500 return DoArithmeticD(Token::MUL, instr); |
1504 } else { | 1501 } else { |
1505 ASSERT(instr->representation().IsSmiOrTagged()); | 1502 ASSERT(instr->representation().IsTagged()); |
1506 return DoArithmeticT(Token::MUL, instr); | 1503 return DoArithmeticT(Token::MUL, instr); |
1507 } | 1504 } |
1508 } | 1505 } |
1509 | 1506 |
1510 | 1507 |
1511 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1508 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
1512 if (instr->representation().IsInteger32()) { | 1509 if (instr->representation().IsSmiOrInteger32()) { |
1513 ASSERT(instr->left()->representation().IsInteger32()); | 1510 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1514 ASSERT(instr->right()->representation().IsInteger32()); | 1511 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1515 LOperand* left = UseRegisterAtStart(instr->left()); | 1512 LOperand* left = UseRegisterAtStart(instr->left()); |
1516 LOperand* right = UseOrConstantAtStart(instr->right()); | 1513 LOperand* right = UseOrConstantAtStart(instr->right()); |
1517 LSubI* sub = new(zone()) LSubI(left, right); | 1514 LSubI* sub = new(zone()) LSubI(left, right); |
1518 LInstruction* result = DefineSameAsFirst(sub); | 1515 LInstruction* result = DefineSameAsFirst(sub); |
1519 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1516 if (instr->CheckFlag(HValue::kCanOverflow)) { |
1520 result = AssignEnvironment(result); | 1517 result = AssignEnvironment(result); |
1521 } | 1518 } |
1522 return result; | 1519 return result; |
1523 } else if (instr->representation().IsDouble()) { | 1520 } else if (instr->representation().IsDouble()) { |
1524 return DoArithmeticD(Token::SUB, instr); | 1521 return DoArithmeticD(Token::SUB, instr); |
1525 } else { | 1522 } else { |
1526 ASSERT(instr->representation().IsSmiOrTagged()); | 1523 ASSERT(instr->representation().IsTagged()); |
1527 return DoArithmeticT(Token::SUB, instr); | 1524 return DoArithmeticT(Token::SUB, instr); |
1528 } | 1525 } |
1529 } | 1526 } |
1530 | 1527 |
1531 | 1528 |
1532 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1529 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
1533 if (instr->representation().IsInteger32()) { | 1530 if (instr->representation().IsSmiOrInteger32()) { |
1534 // Check to see if it would be advantageous to use an lea instruction rather | 1531 // Check to see if it would be advantageous to use an lea instruction rather |
1535 // than an add. This is the case when no overflow check is needed and there | 1532 // than an add. This is the case when no overflow check is needed and there |
1536 // are multiple uses of the add's inputs, so using a 3-register add will | 1533 // are multiple uses of the add's inputs, so using a 3-register add will |
1537 // preserve all input values for later uses. | 1534 // preserve all input values for later uses. |
1538 bool use_lea = LAddI::UseLea(instr); | 1535 bool use_lea = LAddI::UseLea(instr); |
1539 ASSERT(instr->left()->representation().IsInteger32()); | 1536 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1540 ASSERT(instr->right()->representation().IsInteger32()); | 1537 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1541 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1538 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1542 HValue* right_candidate = instr->BetterRightOperand(); | 1539 HValue* right_candidate = instr->BetterRightOperand(); |
1543 LOperand* right = use_lea | 1540 LOperand* right = use_lea |
1544 ? UseRegisterOrConstantAtStart(right_candidate) | 1541 ? UseRegisterOrConstantAtStart(right_candidate) |
1545 : UseOrConstantAtStart(right_candidate); | 1542 : UseOrConstantAtStart(right_candidate); |
1546 LAddI* add = new(zone()) LAddI(left, right); | 1543 LAddI* add = new(zone()) LAddI(left, right); |
1547 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | 1544 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
1548 LInstruction* result = use_lea | 1545 LInstruction* result = use_lea |
1549 ? DefineAsRegister(add) | 1546 ? DefineAsRegister(add) |
1550 : DefineSameAsFirst(add); | 1547 : DefineSameAsFirst(add); |
1551 if (can_overflow) { | 1548 if (can_overflow) { |
1552 result = AssignEnvironment(result); | 1549 result = AssignEnvironment(result); |
1553 } | 1550 } |
1554 return result; | 1551 return result; |
1555 } else if (instr->representation().IsDouble()) { | 1552 } else if (instr->representation().IsDouble()) { |
1556 return DoArithmeticD(Token::ADD, instr); | 1553 return DoArithmeticD(Token::ADD, instr); |
1557 } else { | 1554 } else { |
1558 ASSERT(instr->representation().IsSmiOrTagged()); | 1555 ASSERT(instr->representation().IsTagged()); |
1559 return DoArithmeticT(Token::ADD, instr); | 1556 return DoArithmeticT(Token::ADD, instr); |
1560 } | 1557 } |
1561 return NULL; | 1558 return NULL; |
1562 } | 1559 } |
1563 | 1560 |
1564 | 1561 |
1565 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1562 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
1566 LOperand* left = NULL; | 1563 LOperand* left = NULL; |
1567 LOperand* right = NULL; | 1564 LOperand* right = NULL; |
1568 if (instr->representation().IsInteger32()) { | 1565 if (instr->representation().IsSmiOrInteger32()) { |
1569 ASSERT(instr->left()->representation().IsInteger32()); | 1566 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1570 ASSERT(instr->right()->representation().IsInteger32()); | 1567 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1571 left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1568 left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1572 right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1569 right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1573 } else { | 1570 } else { |
1574 ASSERT(instr->representation().IsDouble()); | 1571 ASSERT(instr->representation().IsDouble()); |
1575 ASSERT(instr->left()->representation().IsDouble()); | 1572 ASSERT(instr->left()->representation().IsDouble()); |
1576 ASSERT(instr->right()->representation().IsDouble()); | 1573 ASSERT(instr->right()->representation().IsDouble()); |
1577 left = UseRegisterAtStart(instr->left()); | 1574 left = UseRegisterAtStart(instr->left()); |
1578 right = UseRegisterAtStart(instr->right()); | 1575 right = UseRegisterAtStart(instr->right()); |
1579 } | 1576 } |
1580 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); | 1577 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 | 1642 |
1646 | 1643 |
1647 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( | 1644 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( |
1648 HCompareObjectEqAndBranch* instr) { | 1645 HCompareObjectEqAndBranch* instr) { |
1649 LOperand* left = UseRegisterAtStart(instr->left()); | 1646 LOperand* left = UseRegisterAtStart(instr->left()); |
1650 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | 1647 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); |
1651 return new(zone()) LCmpObjectEqAndBranch(left, right); | 1648 return new(zone()) LCmpObjectEqAndBranch(left, right); |
1652 } | 1649 } |
1653 | 1650 |
1654 | 1651 |
1655 LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch( | |
1656 HCompareConstantEqAndBranch* instr) { | |
1657 LOperand* value = UseRegisterAtStart(instr->value()); | |
1658 return new(zone()) LCmpConstantEqAndBranch(value); | |
1659 } | |
1660 | |
1661 | |
1662 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { | 1652 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
1663 ASSERT(instr->value()->representation().IsTagged()); | 1653 ASSERT(instr->value()->representation().IsTagged()); |
1664 return new(zone()) LIsObjectAndBranch(UseRegisterAtStart(instr->value())); | 1654 return new(zone()) LIsObjectAndBranch(UseRegisterAtStart(instr->value())); |
1665 } | 1655 } |
1666 | 1656 |
1667 | 1657 |
1668 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { | 1658 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { |
1669 ASSERT(instr->value()->representation().IsTagged()); | 1659 ASSERT(instr->value()->representation().IsTagged()); |
1670 LOperand* value = UseRegisterAtStart(instr->value()); | 1660 LOperand* value = UseRegisterAtStart(instr->value()); |
1671 LOperand* temp = TempRegister(); | 1661 LOperand* temp = TempRegister(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 | 1932 |
1943 | 1933 |
1944 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 1934 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
1945 LOperand* value = UseRegisterAtStart(instr->value()); | 1935 LOperand* value = UseRegisterAtStart(instr->value()); |
1946 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); | 1936 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); |
1947 return AssignEnvironment(result); | 1937 return AssignEnvironment(result); |
1948 } | 1938 } |
1949 | 1939 |
1950 | 1940 |
1951 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { | 1941 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
1952 LUnallocated* temp = TempRegister(); | 1942 LUnallocated* temp = NULL; |
| 1943 if (!instr->CanOmitPrototypeChecks()) temp = TempRegister(); |
1953 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp); | 1944 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp); |
| 1945 if (instr->CanOmitPrototypeChecks()) return result; |
1954 return AssignEnvironment(result); | 1946 return AssignEnvironment(result); |
1955 } | 1947 } |
1956 | 1948 |
1957 | 1949 |
1958 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { | 1950 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { |
1959 LOperand* value = UseRegisterAtStart(instr->value()); | 1951 LOperand* value = UseRegisterAtStart(instr->value()); |
1960 return AssignEnvironment(new(zone()) LCheckFunction(value)); | 1952 return AssignEnvironment(new(zone()) LCheckFunction(value)); |
1961 } | 1953 } |
1962 | 1954 |
1963 | 1955 |
1964 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | 1956 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
1965 LOperand* value = UseRegisterAtStart(instr->value()); | 1957 LOperand* value = NULL; |
| 1958 if (!instr->CanOmitMapChecks()) value = UseRegisterAtStart(instr->value()); |
1966 LCheckMaps* result = new(zone()) LCheckMaps(value); | 1959 LCheckMaps* result = new(zone()) LCheckMaps(value); |
| 1960 if (instr->CanOmitMapChecks()) return result; |
1967 return AssignEnvironment(result); | 1961 return AssignEnvironment(result); |
1968 } | 1962 } |
1969 | 1963 |
1970 | 1964 |
1971 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | 1965 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
1972 HValue* value = instr->value(); | 1966 HValue* value = instr->value(); |
1973 Representation input_rep = value->representation(); | 1967 Representation input_rep = value->representation(); |
1974 LOperand* reg = UseRegister(value); | 1968 LOperand* reg = UseRegister(value); |
1975 if (input_rep.IsDouble()) { | 1969 if (input_rep.IsDouble()) { |
1976 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); | 1970 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 | 2111 |
2118 | 2112 |
2119 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 2113 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
2120 HLoadExternalArrayPointer* instr) { | 2114 HLoadExternalArrayPointer* instr) { |
2121 LOperand* input = UseRegisterAtStart(instr->value()); | 2115 LOperand* input = UseRegisterAtStart(instr->value()); |
2122 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 2116 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
2123 } | 2117 } |
2124 | 2118 |
2125 | 2119 |
2126 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2120 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
2127 ASSERT(instr->key()->representation().IsInteger32() || | 2121 ASSERT(instr->key()->representation().IsInteger32()); |
2128 instr->key()->representation().IsSmi()); | |
2129 ElementsKind elements_kind = instr->elements_kind(); | 2122 ElementsKind elements_kind = instr->elements_kind(); |
2130 bool clobbers_key = instr->key()->representation().IsSmi(); | 2123 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2131 LOperand* key = clobbers_key | |
2132 ? UseTempRegister(instr->key()) | |
2133 : UseRegisterOrConstantAtStart(instr->key()); | |
2134 LLoadKeyed* result = NULL; | 2124 LLoadKeyed* result = NULL; |
2135 | 2125 |
2136 if (!instr->is_external()) { | 2126 if (!instr->is_external()) { |
2137 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2127 LOperand* obj = UseRegisterAtStart(instr->elements()); |
2138 result = new(zone()) LLoadKeyed(obj, key); | 2128 result = new(zone()) LLoadKeyed(obj, key); |
2139 } else { | 2129 } else { |
2140 ASSERT( | 2130 ASSERT( |
2141 (instr->representation().IsInteger32() && | 2131 (instr->representation().IsInteger32() && |
2142 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2132 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2143 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2133 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
(...skipping 17 matching lines...) Expand all Loading... |
2161 LOperand* object = UseFixed(instr->object(), rdx); | 2151 LOperand* object = UseFixed(instr->object(), rdx); |
2162 LOperand* key = UseFixed(instr->key(), rax); | 2152 LOperand* key = UseFixed(instr->key(), rax); |
2163 | 2153 |
2164 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); | 2154 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); |
2165 return MarkAsCall(DefineFixed(result, rax), instr); | 2155 return MarkAsCall(DefineFixed(result, rax), instr); |
2166 } | 2156 } |
2167 | 2157 |
2168 | 2158 |
2169 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2159 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2170 ElementsKind elements_kind = instr->elements_kind(); | 2160 ElementsKind elements_kind = instr->elements_kind(); |
2171 bool clobbers_key = instr->key()->representation().IsSmi(); | |
2172 | 2161 |
2173 if (!instr->is_external()) { | 2162 if (!instr->is_external()) { |
2174 ASSERT(instr->elements()->representation().IsTagged()); | 2163 ASSERT(instr->elements()->representation().IsTagged()); |
2175 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2164 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2176 LOperand* object = NULL; | 2165 LOperand* object = NULL; |
2177 LOperand* key = NULL; | 2166 LOperand* key = NULL; |
2178 LOperand* val = NULL; | 2167 LOperand* val = NULL; |
2179 | 2168 |
2180 if (instr->value()->representation().IsDouble()) { | 2169 if (instr->value()->representation().IsDouble()) { |
2181 object = UseRegisterAtStart(instr->elements()); | 2170 object = UseRegisterAtStart(instr->elements()); |
2182 val = UseTempRegister(instr->value()); | 2171 val = UseTempRegister(instr->value()); |
2183 key = clobbers_key ? UseTempRegister(instr->key()) | 2172 key = UseRegisterOrConstantAtStart(instr->key()); |
2184 : UseRegisterOrConstantAtStart(instr->key()); | |
2185 } else { | 2173 } else { |
2186 ASSERT(instr->value()->representation().IsSmiOrTagged()); | 2174 ASSERT(instr->value()->representation().IsSmiOrTagged()); |
2187 object = UseTempRegister(instr->elements()); | 2175 object = UseTempRegister(instr->elements()); |
2188 if (needs_write_barrier) { | 2176 if (needs_write_barrier) { |
2189 val = UseTempRegister(instr->value()); | 2177 val = UseTempRegister(instr->value()); |
2190 key = UseTempRegister(instr->key()); | 2178 key = UseTempRegister(instr->key()); |
2191 } else { | 2179 } else { |
2192 val = UseRegisterOrConstantAtStart(instr->value()); | 2180 val = UseRegisterOrConstantAtStart(instr->value()); |
2193 | 2181 key = UseRegisterOrConstantAtStart(instr->key()); |
2194 if (clobbers_key) { | |
2195 key = UseTempRegister(instr->key()); | |
2196 } else { | |
2197 key = UseRegisterOrConstantAtStart(instr->key()); | |
2198 } | |
2199 } | 2182 } |
2200 } | 2183 } |
2201 | 2184 |
2202 return new(zone()) LStoreKeyed(object, key, val); | 2185 return new(zone()) LStoreKeyed(object, key, val); |
2203 } | 2186 } |
2204 | 2187 |
2205 ASSERT( | 2188 ASSERT( |
2206 (instr->value()->representation().IsInteger32() && | 2189 (instr->value()->representation().IsInteger32() && |
2207 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2190 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2208 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2191 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2209 (instr->value()->representation().IsDouble() && | 2192 (instr->value()->representation().IsDouble() && |
2210 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2193 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
2211 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2194 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
2212 ASSERT(instr->elements()->representation().IsExternal()); | 2195 ASSERT(instr->elements()->representation().IsExternal()); |
2213 bool val_is_temp_register = | 2196 bool val_is_temp_register = |
2214 elements_kind == EXTERNAL_PIXEL_ELEMENTS || | 2197 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
2215 elements_kind == EXTERNAL_FLOAT_ELEMENTS; | 2198 elements_kind == EXTERNAL_FLOAT_ELEMENTS; |
2216 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) | 2199 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) |
2217 : UseRegister(instr->value()); | 2200 : UseRegister(instr->value()); |
2218 LOperand* key = clobbers_key ? UseTempRegister(instr->key()) | 2201 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2219 : UseRegisterOrConstantAtStart(instr->key()); | |
2220 LOperand* external_pointer = UseRegister(instr->elements()); | 2202 LOperand* external_pointer = UseRegister(instr->elements()); |
2221 return new(zone()) LStoreKeyed(external_pointer, key, val); | 2203 return new(zone()) LStoreKeyed(external_pointer, key, val); |
2222 } | 2204 } |
2223 | 2205 |
2224 | 2206 |
2225 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2207 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2226 LOperand* object = UseFixed(instr->object(), rdx); | 2208 LOperand* object = UseFixed(instr->object(), rdx); |
2227 LOperand* key = UseFixed(instr->key(), rcx); | 2209 LOperand* key = UseFixed(instr->key(), rcx); |
2228 LOperand* value = UseFixed(instr->value(), rax); | 2210 LOperand* value = UseFixed(instr->value(), rax); |
2229 | 2211 |
(...skipping 10 matching lines...) Expand all Loading... |
2240 LInstruction* LChunkBuilder::DoTransitionElementsKind( | 2222 LInstruction* LChunkBuilder::DoTransitionElementsKind( |
2241 HTransitionElementsKind* instr) { | 2223 HTransitionElementsKind* instr) { |
2242 LOperand* object = UseRegister(instr->object()); | 2224 LOperand* object = UseRegister(instr->object()); |
2243 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { | 2225 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { |
2244 LOperand* object = UseRegister(instr->object()); | 2226 LOperand* object = UseRegister(instr->object()); |
2245 LOperand* new_map_reg = TempRegister(); | 2227 LOperand* new_map_reg = TempRegister(); |
2246 LOperand* temp_reg = TempRegister(); | 2228 LOperand* temp_reg = TempRegister(); |
2247 LTransitionElementsKind* result = | 2229 LTransitionElementsKind* result = |
2248 new(zone()) LTransitionElementsKind(object, new_map_reg, temp_reg); | 2230 new(zone()) LTransitionElementsKind(object, new_map_reg, temp_reg); |
2249 return result; | 2231 return result; |
2250 } else if (FLAG_compiled_transitions) { | 2232 } else { |
2251 LTransitionElementsKind* result = | 2233 LTransitionElementsKind* result = |
2252 new(zone()) LTransitionElementsKind(object, NULL, NULL); | 2234 new(zone()) LTransitionElementsKind(object, NULL, NULL); |
2253 return AssignPointerMap(result); | 2235 return AssignPointerMap(result); |
2254 } else { | |
2255 LOperand* object = UseFixed(instr->object(), rax); | |
2256 LOperand* fixed_object_reg = FixedTemp(rdx); | |
2257 LOperand* new_map_reg = FixedTemp(rbx); | |
2258 LTransitionElementsKind* result = | |
2259 new(zone()) LTransitionElementsKind(object, | |
2260 new_map_reg, | |
2261 fixed_object_reg); | |
2262 return MarkAsCall(result, instr); | |
2263 } | 2236 } |
2264 } | 2237 } |
2265 | 2238 |
2266 | 2239 |
2267 LInstruction* LChunkBuilder::DoTrapAllocationMemento( | 2240 LInstruction* LChunkBuilder::DoTrapAllocationMemento( |
2268 HTrapAllocationMemento* instr) { | 2241 HTrapAllocationMemento* instr) { |
2269 LOperand* object = UseRegister(instr->object()); | 2242 LOperand* object = UseRegister(instr->object()); |
2270 LOperand* temp = TempRegister(); | 2243 LOperand* temp = TempRegister(); |
2271 LTrapAllocationMemento* result = | 2244 LTrapAllocationMemento* result = |
2272 new(zone()) LTrapAllocationMemento(object, temp); | 2245 new(zone()) LTrapAllocationMemento(object, temp); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2554 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2582 LOperand* object = UseRegister(instr->object()); | 2555 LOperand* object = UseRegister(instr->object()); |
2583 LOperand* index = UseTempRegister(instr->index()); | 2556 LOperand* index = UseTempRegister(instr->index()); |
2584 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2557 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2585 } | 2558 } |
2586 | 2559 |
2587 | 2560 |
2588 } } // namespace v8::internal | 2561 } } // namespace v8::internal |
2589 | 2562 |
2590 #endif // V8_TARGET_ARCH_X64 | 2563 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |