Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/x64/lithium-x64.cc

Issue 191293013: Cleanup some of the range uses in ModI/DivI. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 } 1241 }
1242 } 1242 }
1243 1243
1244 1244
1245 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { 1245 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1246 ASSERT(instr->representation().IsSmiOrInteger32()); 1246 ASSERT(instr->representation().IsSmiOrInteger32());
1247 ASSERT(instr->left()->representation().Equals(instr->representation())); 1247 ASSERT(instr->left()->representation().Equals(instr->representation()));
1248 ASSERT(instr->right()->representation().Equals(instr->representation())); 1248 ASSERT(instr->right()->representation().Equals(instr->representation()));
1249 LOperand* dividend = UseRegister(instr->left()); 1249 LOperand* dividend = UseRegister(instr->left());
1250 int32_t divisor = instr->right()->GetInteger32Constant(); 1250 int32_t divisor = instr->right()->GetInteger32Constant();
1251 LInstruction* result = 1251 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
1252 DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor)); 1252 dividend, divisor));
1253 bool can_deopt = 1253 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1254 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1254 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1255 instr->left()->RangeCanInclude(0) && divisor < 0) ||
1256 (instr->CheckFlag(HValue::kCanOverflow) &&
1257 instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
1258 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && 1255 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1259 divisor != 1 && divisor != -1); 1256 divisor != 1 && divisor != -1)) {
1260 return can_deopt ? AssignEnvironment(result) : result; 1257 result = AssignEnvironment(result);
1258 }
1259 return result;
1261 } 1260 }
1262 1261
1263 1262
1264 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { 1263 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1265 ASSERT(instr->representation().IsInteger32()); 1264 ASSERT(instr->representation().IsInteger32());
1266 ASSERT(instr->left()->representation().Equals(instr->representation())); 1265 ASSERT(instr->left()->representation().Equals(instr->representation()));
1267 ASSERT(instr->right()->representation().Equals(instr->representation())); 1266 ASSERT(instr->right()->representation().Equals(instr->representation()));
1268 LOperand* dividend = UseRegister(instr->left()); 1267 LOperand* dividend = UseRegister(instr->left());
1269 int32_t divisor = instr->right()->GetInteger32Constant(); 1268 int32_t divisor = instr->right()->GetInteger32Constant();
1270 LOperand* temp1 = FixedTemp(rax); 1269 LOperand* temp1 = FixedTemp(rax);
1271 LOperand* temp2 = FixedTemp(rdx); 1270 LOperand* temp2 = FixedTemp(rdx);
1272 LInstruction* result = 1271 LInstruction* result = DefineFixed(new(zone()) LDivByConstI(
1273 DefineFixed( 1272 dividend, divisor, temp1, temp2), rdx);
1274 new(zone()) LDivByConstI(dividend, divisor, temp1, temp2), rdx); 1273 if (divisor == 0 ||
1275 bool can_deopt = 1274 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1276 divisor == 0 || 1275 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1277 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1276 result = AssignEnvironment(result);
1278 instr->left()->RangeCanInclude(0) && divisor < 0) || 1277 }
1279 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32); 1278 return result;
1280 return can_deopt ? AssignEnvironment(result) : result;
1281 } 1279 }
1282 1280
1283 1281
1284 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { 1282 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) {
1285 ASSERT(instr->representation().IsSmiOrInteger32()); 1283 ASSERT(instr->representation().IsSmiOrInteger32());
1286 ASSERT(instr->left()->representation().Equals(instr->representation())); 1284 ASSERT(instr->left()->representation().Equals(instr->representation()));
1287 ASSERT(instr->right()->representation().Equals(instr->representation())); 1285 ASSERT(instr->right()->representation().Equals(instr->representation()));
1288 LOperand* dividend = UseFixed(instr->left(), rax); 1286 LOperand* dividend = UseFixed(instr->left(), rax);
1289 LOperand* divisor = UseRegister(instr->right()); 1287 LOperand* divisor = UseRegister(instr->right());
1290 LOperand* temp = FixedTemp(rdx); 1288 LOperand* temp = FixedTemp(rdx);
1291 LInstruction* result = 1289 LInstruction* result = DefineFixed(new(zone()) LDivI(
1292 DefineFixed(new(zone()) LDivI(dividend, divisor, temp), rax); 1290 dividend, divisor, temp), rax);
1293 return AssignEnvironment(result); 1291 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1292 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1293 instr->CheckFlag(HValue::kCanOverflow) ||
1294 (!instr->IsMathFloorOfDiv() &&
1295 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
1296 result = AssignEnvironment(result);
1297 }
1298 return result;
1294 } 1299 }
1295 1300
1296 1301
1297 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1302 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1298 if (instr->representation().IsSmiOrInteger32()) { 1303 if (instr->representation().IsSmiOrInteger32()) {
1299 if (instr->RightIsPowerOf2()) { 1304 if (instr->RightIsPowerOf2()) {
1300 return DoDivByPowerOf2I(instr); 1305 return DoDivByPowerOf2I(instr);
1301 } else if (instr->right()->IsConstant()) { 1306 } else if (instr->right()->IsConstant()) {
1302 return DoDivByConstI(instr); 1307 return DoDivByConstI(instr);
1303 } else { 1308 } else {
(...skipping 28 matching lines...) Expand all
1332 LOperand* temp1 = FixedTemp(rax); 1337 LOperand* temp1 = FixedTemp(rax);
1333 LOperand* temp2 = FixedTemp(rdx); 1338 LOperand* temp2 = FixedTemp(rdx);
1334 LInstruction* result = 1339 LInstruction* result =
1335 DefineFixed(new(zone()) LFlooringDivByConstI(dividend, 1340 DefineFixed(new(zone()) LFlooringDivByConstI(dividend,
1336 divisor, 1341 divisor,
1337 temp1, 1342 temp1,
1338 temp2), 1343 temp2),
1339 rdx); 1344 rdx);
1340 bool can_deopt = 1345 bool can_deopt =
1341 divisor == 0 || 1346 divisor == 0 ||
1342 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1347 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
1343 instr->left()->RangeCanInclude(0) && divisor < 0);
1344 return can_deopt ? AssignEnvironment(result) : result; 1348 return can_deopt ? AssignEnvironment(result) : result;
1345 } 1349 }
1346 1350
1347 1351
1348 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1352 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1349 if (instr->RightIsPowerOf2()) { 1353 if (instr->RightIsPowerOf2()) {
1350 return DoFlooringDivByPowerOf2I(instr); 1354 return DoFlooringDivByPowerOf2I(instr);
1351 } else if (instr->right()->IsConstant()) { 1355 } else if (instr->right()->IsConstant()) {
1352 return DoFlooringDivByConstI(instr); 1356 return DoFlooringDivByConstI(instr);
1353 } else { 1357 } else {
1354 return DoDivI(instr); 1358 return DoDivI(instr);
1355 } 1359 }
1356 } 1360 }
1357 1361
1358 1362
1359 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1363 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1360 ASSERT(instr->representation().IsSmiOrInteger32()); 1364 ASSERT(instr->representation().IsSmiOrInteger32());
1361 ASSERT(instr->left()->representation().Equals(instr->representation())); 1365 ASSERT(instr->left()->representation().Equals(instr->representation()));
1362 ASSERT(instr->right()->representation().Equals(instr->representation())); 1366 ASSERT(instr->right()->representation().Equals(instr->representation()));
1363 LOperand* dividend = UseRegisterAtStart(instr->left()); 1367 LOperand* dividend = UseRegisterAtStart(instr->left());
1364 int32_t divisor = instr->right()->GetInteger32Constant(); 1368 int32_t divisor = instr->right()->GetInteger32Constant();
1365 LInstruction* result = 1369 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
1366 DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor)); 1370 dividend, divisor));
1367 bool can_deopt = 1371 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1368 instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1372 result = AssignEnvironment(result);
1369 instr->left()->CanBeNegative(); 1373 }
1370 return can_deopt ? AssignEnvironment(result) : result; 1374 return result;
1371 } 1375 }
1372 1376
1373 1377
1374 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { 1378 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1375 ASSERT(instr->representation().IsSmiOrInteger32()); 1379 ASSERT(instr->representation().IsSmiOrInteger32());
1376 ASSERT(instr->left()->representation().Equals(instr->representation())); 1380 ASSERT(instr->left()->representation().Equals(instr->representation()));
1377 ASSERT(instr->right()->representation().Equals(instr->representation())); 1381 ASSERT(instr->right()->representation().Equals(instr->representation()));
1378 LOperand* dividend = UseRegister(instr->left()); 1382 LOperand* dividend = UseRegister(instr->left());
1379 int32_t divisor = instr->right()->GetInteger32Constant(); 1383 int32_t divisor = instr->right()->GetInteger32Constant();
1380 LOperand* temp1 = FixedTemp(rax); 1384 LOperand* temp1 = FixedTemp(rax);
1381 LOperand* temp2 = FixedTemp(rdx); 1385 LOperand* temp2 = FixedTemp(rdx);
1382 LInstruction* result = 1386 LInstruction* result = DefineFixed(new(zone()) LModByConstI(
1383 DefineFixed( 1387 dividend, divisor, temp1, temp2), rax);
1384 new(zone()) LModByConstI(dividend, divisor, temp1, temp2), rax); 1388 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1385 bool can_deopt = 1389 result = AssignEnvironment(result);
1386 divisor == 0 || 1390 }
1387 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1391 return result;
1388 instr->left()->CanBeNegative());
1389 return can_deopt ? AssignEnvironment(result) : result;
1390 } 1392 }
1391 1393
1392 1394
1393 LInstruction* LChunkBuilder::DoModI(HMod* instr) { 1395 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1394 ASSERT(instr->representation().IsSmiOrInteger32()); 1396 ASSERT(instr->representation().IsSmiOrInteger32());
1395 ASSERT(instr->left()->representation().Equals(instr->representation())); 1397 ASSERT(instr->left()->representation().Equals(instr->representation()));
1396 ASSERT(instr->right()->representation().Equals(instr->representation())); 1398 ASSERT(instr->right()->representation().Equals(instr->representation()));
1397 LOperand* dividend = UseFixed(instr->left(), rax); 1399 LOperand* dividend = UseFixed(instr->left(), rax);
1398 LOperand* divisor = UseRegister(instr->right()); 1400 LOperand* divisor = UseRegister(instr->right());
1399 LOperand* temp = FixedTemp(rdx); 1401 LOperand* temp = FixedTemp(rdx);
1400 LInstruction* result = 1402 LInstruction* result = DefineFixed(new(zone()) LModI(
1401 DefineFixed(new(zone()) LModI(dividend, divisor, temp), rdx); 1403 dividend, divisor, temp), rdx);
1402 bool can_deopt = (instr->right()->CanBeZero() || 1404 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1403 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1405 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1404 instr->left()->RangeCanInclude(kMinInt) && 1406 result = AssignEnvironment(result);
1405 instr->right()->RangeCanInclude(-1)) || 1407 }
1406 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1408 return result;
1407 instr->left()->CanBeNegative() &&
1408 instr->CanBeZero()));
1409 return can_deopt ? AssignEnvironment(result) : result;
1410 } 1409 }
1411 1410
1412 1411
1413 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1412 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1414 if (instr->representation().IsSmiOrInteger32()) { 1413 if (instr->representation().IsSmiOrInteger32()) {
1415 if (instr->RightIsPowerOf2()) { 1414 if (instr->RightIsPowerOf2()) {
1416 return DoModByPowerOf2I(instr); 1415 return DoModByPowerOf2I(instr);
1417 } else if (instr->right()->IsConstant()) { 1416 } else if (instr->right()->IsConstant()) {
1418 return DoModByConstI(instr); 1417 return DoModByConstI(instr);
1419 } else { 1418 } else {
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2531 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2533 LOperand* object = UseRegister(instr->object()); 2532 LOperand* object = UseRegister(instr->object());
2534 LOperand* index = UseTempRegister(instr->index()); 2533 LOperand* index = UseTempRegister(instr->index());
2535 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2534 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2536 } 2535 }
2537 2536
2538 2537
2539 } } // namespace v8::internal 2538 } } // namespace v8::internal
2540 2539
2541 #endif // V8_TARGET_ARCH_X64 2540 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698