| 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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 } | 1237 } |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 | 1240 |
| 1241 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { | 1241 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { |
| 1242 ASSERT(instr->representation().IsSmiOrInteger32()); | 1242 ASSERT(instr->representation().IsSmiOrInteger32()); |
| 1243 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1243 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1244 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1244 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1245 LOperand* dividend = UseRegister(instr->left()); | 1245 LOperand* dividend = UseRegister(instr->left()); |
| 1246 int32_t divisor = instr->right()->GetInteger32Constant(); | 1246 int32_t divisor = instr->right()->GetInteger32Constant(); |
| 1247 LInstruction* result = | 1247 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I( |
| 1248 DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor)); | 1248 dividend, divisor)); |
| 1249 bool can_deopt = | 1249 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || |
| 1250 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1250 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) || |
| 1251 instr->left()->RangeCanInclude(0) && divisor < 0) || | |
| 1252 (instr->CheckFlag(HValue::kCanOverflow) && | |
| 1253 instr->left()->RangeCanInclude(kMinInt) && divisor == -1) || | |
| 1254 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && | 1251 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && |
| 1255 divisor != 1 && divisor != -1); | 1252 divisor != 1 && divisor != -1)) { |
| 1256 return can_deopt ? AssignEnvironment(result) : result; | 1253 result = AssignEnvironment(result); |
| 1254 } |
| 1255 return result; |
| 1257 } | 1256 } |
| 1258 | 1257 |
| 1259 | 1258 |
| 1260 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { | 1259 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { |
| 1261 ASSERT(instr->representation().IsInteger32()); | 1260 ASSERT(instr->representation().IsInteger32()); |
| 1262 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1261 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1263 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1262 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1264 LOperand* dividend = UseRegister(instr->left()); | 1263 LOperand* dividend = UseRegister(instr->left()); |
| 1265 int32_t divisor = instr->right()->GetInteger32Constant(); | 1264 int32_t divisor = instr->right()->GetInteger32Constant(); |
| 1266 LInstruction* result = | 1265 LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI( |
| 1267 DefineAsRegister(new(zone()) LDivByConstI(dividend, divisor)); | 1266 dividend, divisor)); |
| 1268 bool can_deopt = | 1267 if (divisor == 0 || |
| 1269 divisor == 0 || | 1268 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || |
| 1270 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1269 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
| 1271 instr->left()->RangeCanInclude(0) && divisor < 0) || | 1270 result = AssignEnvironment(result); |
| 1272 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32); | 1271 } |
| 1273 return can_deopt ? AssignEnvironment(result) : result; | 1272 return result; |
| 1274 } | 1273 } |
| 1275 | 1274 |
| 1276 | 1275 |
| 1277 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { | 1276 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { |
| 1278 ASSERT(instr->representation().IsSmiOrInteger32()); | 1277 ASSERT(instr->representation().IsSmiOrInteger32()); |
| 1279 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1278 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1280 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1279 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1281 LOperand* dividend = UseRegister(instr->left()); | 1280 LOperand* dividend = UseRegister(instr->left()); |
| 1282 LOperand* divisor = UseRegister(instr->right()); | 1281 LOperand* divisor = UseRegister(instr->right()); |
| 1283 LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4); | 1282 LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { | 1318 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { |
| 1320 ASSERT(instr->representation().IsInteger32()); | 1319 ASSERT(instr->representation().IsInteger32()); |
| 1321 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1320 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1322 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1321 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1323 LOperand* dividend = UseRegister(instr->left()); | 1322 LOperand* dividend = UseRegister(instr->left()); |
| 1324 int32_t divisor = instr->right()->GetInteger32Constant(); | 1323 int32_t divisor = instr->right()->GetInteger32Constant(); |
| 1325 LInstruction* result = | 1324 LInstruction* result = |
| 1326 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor)); | 1325 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor)); |
| 1327 bool can_deopt = | 1326 bool can_deopt = |
| 1328 divisor == 0 || | 1327 divisor == 0 || |
| 1329 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1328 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0); |
| 1330 instr->left()->RangeCanInclude(0) && divisor < 0); | |
| 1331 return can_deopt ? AssignEnvironment(result) : result; | 1329 return can_deopt ? AssignEnvironment(result) : result; |
| 1332 } | 1330 } |
| 1333 | 1331 |
| 1334 | 1332 |
| 1335 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1333 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
| 1336 if (instr->RightIsPowerOf2()) { | 1334 if (instr->RightIsPowerOf2()) { |
| 1337 return DoFlooringDivByPowerOf2I(instr); | 1335 return DoFlooringDivByPowerOf2I(instr); |
| 1338 } else if (instr->right()->IsConstant()) { | 1336 } else if (instr->right()->IsConstant()) { |
| 1339 return DoFlooringDivByConstI(instr); | 1337 return DoFlooringDivByConstI(instr); |
| 1340 } else { | 1338 } else { |
| 1341 return DoDivI(instr); | 1339 return DoDivI(instr); |
| 1342 } | 1340 } |
| 1343 } | 1341 } |
| 1344 | 1342 |
| 1345 | 1343 |
| 1346 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { | 1344 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { |
| 1347 ASSERT(instr->representation().IsSmiOrInteger32()); | 1345 ASSERT(instr->representation().IsSmiOrInteger32()); |
| 1348 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1346 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1349 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1347 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1350 LOperand* dividend = UseRegisterAtStart(instr->left()); | 1348 LOperand* dividend = UseRegisterAtStart(instr->left()); |
| 1351 int32_t divisor = instr->right()->GetInteger32Constant(); | 1349 int32_t divisor = instr->right()->GetInteger32Constant(); |
| 1352 LInstruction* result = | 1350 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( |
| 1353 DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor)); | 1351 dividend, divisor)); |
| 1354 bool can_deopt = | 1352 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1355 instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1353 result = AssignEnvironment(result); |
| 1356 instr->left()->CanBeNegative(); | 1354 } |
| 1357 return can_deopt ? AssignEnvironment(result) : result; | 1355 return result; |
| 1358 } | 1356 } |
| 1359 | 1357 |
| 1360 | 1358 |
| 1361 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { | 1359 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { |
| 1362 ASSERT(instr->representation().IsSmiOrInteger32()); | 1360 ASSERT(instr->representation().IsSmiOrInteger32()); |
| 1363 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1361 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1364 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1362 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1365 LOperand* dividend = UseRegister(instr->left()); | 1363 LOperand* dividend = UseRegister(instr->left()); |
| 1366 int32_t divisor = instr->right()->GetInteger32Constant(); | 1364 int32_t divisor = instr->right()->GetInteger32Constant(); |
| 1367 LInstruction* result = | 1365 LInstruction* result = DefineAsRegister(new(zone()) LModByConstI( |
| 1368 DefineAsRegister(new(zone()) LModByConstI(dividend, divisor)); | 1366 dividend, divisor)); |
| 1369 bool can_deopt = | 1367 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1370 divisor == 0 || | 1368 result = AssignEnvironment(result); |
| 1371 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1369 } |
| 1372 instr->left()->CanBeNegative()); | 1370 return result; |
| 1373 return can_deopt ? AssignEnvironment(result) : result; | |
| 1374 } | 1371 } |
| 1375 | 1372 |
| 1376 | 1373 |
| 1377 LInstruction* LChunkBuilder::DoModI(HMod* instr) { | 1374 LInstruction* LChunkBuilder::DoModI(HMod* instr) { |
| 1378 ASSERT(instr->representation().IsSmiOrInteger32()); | 1375 ASSERT(instr->representation().IsSmiOrInteger32()); |
| 1379 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1376 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1380 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1377 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1381 if (CpuFeatures::IsSupported(SUDIV)) { | 1378 LOperand* dividend = UseRegister(instr->left()); |
| 1382 LOperand* dividend = UseRegister(instr->left()); | 1379 LOperand* divisor = UseRegister(instr->right()); |
| 1383 LOperand* divisor = UseRegister(instr->right()); | 1380 LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d10); |
| 1384 LInstruction* result = | 1381 LOperand* temp2 = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d11); |
| 1385 DefineAsRegister(new(zone()) LModI(dividend, divisor, NULL, NULL)); | 1382 LInstruction* result = DefineAsRegister(new(zone()) LModI( |
| 1386 bool can_deopt = (instr->right()->CanBeZero() || | 1383 dividend, divisor, temp, temp2)); |
| 1387 (instr->left()->RangeCanInclude(kMinInt) && | 1384 if (instr->CheckFlag(HValue::kCanBeDivByZero) || |
| 1388 instr->right()->RangeCanInclude(-1) && | 1385 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1389 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || | 1386 result = AssignEnvironment(result); |
| 1390 (instr->left()->CanBeNegative() && | |
| 1391 instr->CanBeZero() && | |
| 1392 instr->CheckFlag(HValue::kBailoutOnMinusZero))); | |
| 1393 return can_deopt ? AssignEnvironment(result) : result; | |
| 1394 } else { | |
| 1395 LOperand* dividend = UseRegister(instr->left()); | |
| 1396 LOperand* divisor = UseRegister(instr->right()); | |
| 1397 LOperand* temp = FixedTemp(d10); | |
| 1398 LOperand* temp2 = FixedTemp(d11); | |
| 1399 LInstruction* result = | |
| 1400 DefineAsRegister(new(zone()) LModI(dividend, divisor, temp, temp2)); | |
| 1401 bool can_deopt = (instr->right()->CanBeZero() || | |
| 1402 (instr->left()->CanBeNegative() && | |
| 1403 instr->CanBeZero() && | |
| 1404 instr->CheckFlag(HValue::kBailoutOnMinusZero))); | |
| 1405 return can_deopt ? AssignEnvironment(result) : result; | |
| 1406 } | 1387 } |
| 1388 return result; |
| 1407 } | 1389 } |
| 1408 | 1390 |
| 1409 | 1391 |
| 1410 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1392 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
| 1411 if (instr->representation().IsSmiOrInteger32()) { | 1393 if (instr->representation().IsSmiOrInteger32()) { |
| 1412 if (instr->RightIsPowerOf2()) { | 1394 if (instr->RightIsPowerOf2()) { |
| 1413 return DoModByPowerOf2I(instr); | 1395 return DoModByPowerOf2I(instr); |
| 1414 } else if (instr->right()->IsConstant()) { | 1396 } else if (instr->right()->IsConstant()) { |
| 1415 return DoModByConstI(instr); | 1397 return DoModByConstI(instr); |
| 1416 } else { | 1398 } else { |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2554 } | 2536 } |
| 2555 | 2537 |
| 2556 | 2538 |
| 2557 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2539 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2558 LOperand* object = UseRegister(instr->object()); | 2540 LOperand* object = UseRegister(instr->object()); |
| 2559 LOperand* index = UseRegister(instr->index()); | 2541 LOperand* index = UseRegister(instr->index()); |
| 2560 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2542 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2561 } | 2543 } |
| 2562 | 2544 |
| 2563 } } // namespace v8::internal | 2545 } } // namespace v8::internal |
| OLD | NEW |