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

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

Issue 15769010: Improve code for integral modulus calculation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 6 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/mips/lithium-codegen-mips.cc ('k') | src/utils.h » ('j') | 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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } 1357 }
1358 1358
1359 1359
1360 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1360 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1361 UNIMPLEMENTED(); 1361 UNIMPLEMENTED();
1362 return NULL; 1362 return NULL;
1363 } 1363 }
1364 1364
1365 1365
1366 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1366 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1367 HValue* left = instr->left();
1368 HValue* right = instr->right();
1367 if (instr->representation().IsInteger32()) { 1369 if (instr->representation().IsInteger32()) {
1368 ASSERT(instr->left()->representation().IsInteger32()); 1370 ASSERT(left->representation().IsInteger32());
1369 ASSERT(instr->right()->representation().IsInteger32()); 1371 ASSERT(right->representation().IsInteger32());
1370
1371 LModI* mod;
1372 if (instr->HasPowerOf2Divisor()) { 1372 if (instr->HasPowerOf2Divisor()) {
1373 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); 1373 ASSERT(!right->CanBeZero());
1374 LOperand* value = UseRegisterAtStart(instr->left()); 1374 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
1375 mod = new(zone()) LModI(value, UseOrConstant(instr->right())); 1375 UseOrConstant(right));
1376 LInstruction* result = DefineAsRegister(mod);
1377 return (left->CanBeNegative() &&
1378 instr->CheckFlag(HValue::kBailoutOnMinusZero))
1379 ? AssignEnvironment(result)
1380 : result;
1376 } else { 1381 } else {
1377 LOperand* dividend = UseRegister(instr->left()); 1382 LModI* mod = new(zone()) LModI(UseRegister(left),
1378 LOperand* divisor = UseRegister(instr->right()); 1383 UseRegister(right),
1379 mod = new(zone()) LModI(dividend, 1384 TempRegister(),
1380 divisor, 1385 FixedTemp(f20),
1381 TempRegister(), 1386 FixedTemp(f22));
1382 FixedTemp(f20), 1387 LInstruction* result = DefineAsRegister(mod);
1383 FixedTemp(f22)); 1388 return (right->CanBeZero() ||
1384 } 1389 (left->RangeCanInclude(kMinInt) &&
1385 1390 right->RangeCanInclude(-1)) ||
1386 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1391 instr->CheckFlag(HValue::kBailoutOnMinusZero))
1387 instr->CheckFlag(HValue::kCanBeDivByZero) || 1392 ? AssignEnvironment(result)
1388 instr->CheckFlag(HValue::kCanOverflow)) { 1393 : result;
1389 return AssignEnvironment(DefineAsRegister(mod));
1390 } else {
1391 return DefineAsRegister(mod);
1392 } 1394 }
1393 } else if (instr->representation().IsSmiOrTagged()) { 1395 } else if (instr->representation().IsSmiOrTagged()) {
1394 return DoArithmeticT(Token::MOD, instr); 1396 return DoArithmeticT(Token::MOD, instr);
1395 } else { 1397 } else {
1396 ASSERT(instr->representation().IsDouble()); 1398 ASSERT(instr->representation().IsDouble());
1397 // We call a C function for double modulo. It can't trigger a GC. 1399 // We call a C function for double modulo. It can't trigger a GC. We need
1398 // We need to use fixed result register for the call. 1400 // to use fixed result register for the call.
1399 // TODO(fschneider): Allow any register as input registers. 1401 // TODO(fschneider): Allow any register as input registers.
1400 LOperand* left = UseFixedDouble(instr->left(), f2); 1402 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD,
1401 LOperand* right = UseFixedDouble(instr->right(), f4); 1403 UseFixedDouble(left, f2),
1402 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); 1404 UseFixedDouble(right, f4));
1403 return MarkAsCall(DefineFixedDouble(result, f2), instr); 1405 return MarkAsCall(DefineFixedDouble(mod, f2), instr);
1404 } 1406 }
1405 } 1407 }
1406 1408
1407 1409
1408 LInstruction* LChunkBuilder::DoMul(HMul* instr) { 1410 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1409 if (instr->representation().IsInteger32()) { 1411 if (instr->representation().IsInteger32()) {
1410 ASSERT(instr->left()->representation().IsInteger32()); 1412 ASSERT(instr->left()->representation().IsInteger32());
1411 ASSERT(instr->right()->representation().IsInteger32()); 1413 ASSERT(instr->right()->representation().IsInteger32());
1412 LOperand* left; 1414 LOperand* left;
1413 LOperand* right = UseOrConstant(instr->BetterRightOperand()); 1415 LOperand* right = UseOrConstant(instr->BetterRightOperand());
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 2509
2508 2510
2509 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2511 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2510 LOperand* object = UseRegister(instr->object()); 2512 LOperand* object = UseRegister(instr->object());
2511 LOperand* index = UseRegister(instr->index()); 2513 LOperand* index = UseRegister(instr->index());
2512 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2514 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2513 } 2515 }
2514 2516
2515 2517
2516 } } // namespace v8::internal 2518 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.cc ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698