| 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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1325   } else { | 1325   } else { | 
| 1326     return DoArithmeticT(instr->op(), instr); | 1326     return DoArithmeticT(instr->op(), instr); | 
| 1327   } | 1327   } | 
| 1328 } | 1328 } | 
| 1329 | 1329 | 
| 1330 | 1330 | 
| 1331 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1331 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 
| 1332   if (instr->representation().IsSmiOrInteger32()) { | 1332   if (instr->representation().IsSmiOrInteger32()) { | 
| 1333     ASSERT(instr->left()->representation().Equals(instr->representation())); | 1333     ASSERT(instr->left()->representation().Equals(instr->representation())); | 
| 1334     ASSERT(instr->right()->representation().Equals(instr->representation())); | 1334     ASSERT(instr->right()->representation().Equals(instr->representation())); | 
| 1335     if (instr->HasPowerOf2Divisor()) { | 1335     if (instr->RightIsPowerOf2()) { | 
| 1336       ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1336       ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 
| 1337       LOperand* value = UseRegisterAtStart(instr->left()); | 1337       LOperand* value = UseRegisterAtStart(instr->left()); | 
| 1338       LDivI* div = | 1338       LDivI* div = | 
| 1339           new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 1339           new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 
| 1340       return AssignEnvironment(DefineSameAsFirst(div)); | 1340       return AssignEnvironment(DefineSameAsFirst(div)); | 
| 1341     } | 1341     } | 
| 1342     // The temporary operand is necessary to ensure that right is not allocated | 1342     // The temporary operand is necessary to ensure that right is not allocated | 
| 1343     // into edx. | 1343     // into edx. | 
| 1344     LOperand* temp = FixedTemp(edx); | 1344     LOperand* temp = FixedTemp(edx); | 
| 1345     LOperand* dividend = UseFixed(instr->left(), eax); | 1345     LOperand* dividend = UseFixed(instr->left(), eax); | 
| 1346     LOperand* divisor = UseRegister(instr->right()); | 1346     LOperand* divisor = UseRegister(instr->right()); | 
| 1347     LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1347     LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 
| 1348     return AssignEnvironment(DefineFixed(result, eax)); | 1348     return AssignEnvironment(DefineFixed(result, eax)); | 
| 1349   } else if (instr->representation().IsDouble()) { | 1349   } else if (instr->representation().IsDouble()) { | 
| 1350     return DoArithmeticD(Token::DIV, instr); | 1350     return DoArithmeticD(Token::DIV, instr); | 
| 1351   } else { | 1351   } else { | 
| 1352     return DoArithmeticT(Token::DIV, instr); | 1352     return DoArithmeticT(Token::DIV, instr); | 
| 1353   } | 1353   } | 
| 1354 } | 1354 } | 
| 1355 | 1355 | 
| 1356 | 1356 | 
| 1357 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |  | 
| 1358   if (divisor->IsConstant() && |  | 
| 1359       HConstant::cast(divisor)->HasInteger32Value()) { |  | 
| 1360     HConstant* constant_val = HConstant::cast(divisor); |  | 
| 1361     return constant_val->CopyToRepresentation(Representation::Integer32(), |  | 
| 1362                                               divisor->block()->zone()); |  | 
| 1363   } |  | 
| 1364   // A value with an integer representation does not need to be transformed. |  | 
| 1365   if (divisor->representation().IsInteger32()) { |  | 
| 1366     return divisor; |  | 
| 1367   // A change from an integer32 can be replaced by the integer32 value. |  | 
| 1368   } else if (divisor->IsChange() && |  | 
| 1369              HChange::cast(divisor)->from().IsInteger32()) { |  | 
| 1370     return HChange::cast(divisor)->value(); |  | 
| 1371   } |  | 
| 1372   return NULL; |  | 
| 1373 } |  | 
| 1374 |  | 
| 1375 |  | 
| 1376 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1357 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 
| 1377   HValue* right = instr->right(); | 1358   HValue* right = instr->right(); | 
| 1378   if (!right->IsConstant()) { | 1359   if (!right->IsConstant()) { | 
| 1379     ASSERT(right->representation().IsInteger32()); | 1360     ASSERT(right->representation().IsInteger32()); | 
| 1380     // The temporary operand is necessary to ensure that right is not allocated | 1361     // The temporary operand is necessary to ensure that right is not allocated | 
| 1381     // into edx. | 1362     // into edx. | 
| 1382     LOperand* temp = FixedTemp(edx); | 1363     LOperand* temp = FixedTemp(edx); | 
| 1383     LOperand* dividend = UseFixed(instr->left(), eax); | 1364     LOperand* dividend = UseFixed(instr->left(), eax); | 
| 1384     LOperand* divisor = UseRegister(instr->right()); | 1365     LOperand* divisor = UseRegister(instr->right()); | 
| 1385     LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); | 1366     LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1411 } | 1392 } | 
| 1412 | 1393 | 
| 1413 | 1394 | 
| 1414 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1395 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 
| 1415   HValue* left = instr->left(); | 1396   HValue* left = instr->left(); | 
| 1416   HValue* right = instr->right(); | 1397   HValue* right = instr->right(); | 
| 1417   if (instr->representation().IsSmiOrInteger32()) { | 1398   if (instr->representation().IsSmiOrInteger32()) { | 
| 1418     ASSERT(instr->left()->representation().Equals(instr->representation())); | 1399     ASSERT(instr->left()->representation().Equals(instr->representation())); | 
| 1419     ASSERT(instr->right()->representation().Equals(instr->representation())); | 1400     ASSERT(instr->right()->representation().Equals(instr->representation())); | 
| 1420 | 1401 | 
| 1421     if (instr->HasPowerOf2Divisor()) { | 1402     if (instr->RightIsPowerOf2()) { | 
| 1422       ASSERT(!right->CanBeZero()); | 1403       ASSERT(!right->CanBeZero()); | 
| 1423       LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1404       LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 
| 1424                                      UseOrConstant(right), | 1405                                      UseOrConstant(right), | 
| 1425                                      NULL); | 1406                                      NULL); | 
| 1426       LInstruction* result = DefineSameAsFirst(mod); | 1407       LInstruction* result = DefineSameAsFirst(mod); | 
| 1427       return (left->CanBeNegative() && | 1408       return (left->CanBeNegative() && | 
| 1428               instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1409               instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 
| 1429           ? AssignEnvironment(result) | 1410           ? AssignEnvironment(result) | 
| 1430           : result; | 1411           : result; | 
| 1431       return AssignEnvironment(DefineSameAsFirst(mod)); | 1412       return AssignEnvironment(DefineSameAsFirst(mod)); | 
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2643 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2624 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 
| 2644   LOperand* object = UseRegister(instr->object()); | 2625   LOperand* object = UseRegister(instr->object()); | 
| 2645   LOperand* index = UseTempRegister(instr->index()); | 2626   LOperand* index = UseTempRegister(instr->index()); | 
| 2646   return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2627   return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 
| 2647 } | 2628 } | 
| 2648 | 2629 | 
| 2649 | 2630 | 
| 2650 } }  // namespace v8::internal | 2631 } }  // namespace v8::internal | 
| 2651 | 2632 | 
| 2652 #endif  // V8_TARGET_ARCH_IA32 | 2633 #endif  // V8_TARGET_ARCH_IA32 | 
| OLD | NEW | 
|---|