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

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

Issue 204583002: Implement flooring division by a constant via truncating division by a constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased 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/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.cc » ('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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1420
1421 1421
1422 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { 1422 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1423 ASSERT(instr->representation().IsInteger32()); 1423 ASSERT(instr->representation().IsInteger32());
1424 ASSERT(instr->left()->representation().Equals(instr->representation())); 1424 ASSERT(instr->left()->representation().Equals(instr->representation()));
1425 ASSERT(instr->right()->representation().Equals(instr->representation())); 1425 ASSERT(instr->right()->representation().Equals(instr->representation()));
1426 LOperand* dividend = UseRegister(instr->left()); 1426 LOperand* dividend = UseRegister(instr->left());
1427 int32_t divisor = instr->right()->GetInteger32Constant(); 1427 int32_t divisor = instr->right()->GetInteger32Constant();
1428 LOperand* temp1 = FixedTemp(eax); 1428 LOperand* temp1 = FixedTemp(eax);
1429 LOperand* temp2 = FixedTemp(edx); 1429 LOperand* temp2 = FixedTemp(edx);
1430 LOperand* temp3 =
1431 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1432 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1433 NULL : TempRegister();
1430 LInstruction* result = 1434 LInstruction* result =
1431 DefineFixed(new(zone()) LFlooringDivByConstI(dividend, 1435 DefineFixed(new(zone()) LFlooringDivByConstI(dividend,
1432 divisor, 1436 divisor,
1433 temp1, 1437 temp1,
1434 temp2), 1438 temp2,
1439 temp3),
1435 edx); 1440 edx);
1436 bool can_deopt = 1441 if (divisor == 0 ||
1437 divisor == 0 || 1442 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1438 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0); 1443 result = AssignEnvironment(result);
1439 return can_deopt ? AssignEnvironment(result) : result; 1444 }
1445 return result;
1440 } 1446 }
1441 1447
1442 1448
1443 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1449 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1444 if (instr->RightIsPowerOf2()) { 1450 if (instr->RightIsPowerOf2()) {
1445 return DoFlooringDivByPowerOf2I(instr); 1451 return DoFlooringDivByPowerOf2I(instr);
1446 } else if (false && instr->right()->IsConstant()) { 1452 } else if (instr->right()->IsConstant()) {
1447 return DoFlooringDivByConstI(instr); // TODO(svenpanne) Fix and re-enable. 1453 return DoFlooringDivByConstI(instr);
1448 } else { 1454 } else {
1449 return DoDivI(instr); 1455 return DoDivI(instr);
1450 } 1456 }
1451 } 1457 }
1452 1458
1453 1459
1454 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1460 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1455 ASSERT(instr->representation().IsSmiOrInteger32()); 1461 ASSERT(instr->representation().IsSmiOrInteger32());
1456 ASSERT(instr->left()->representation().Equals(instr->representation())); 1462 ASSERT(instr->left()->representation().Equals(instr->representation()));
1457 ASSERT(instr->right()->representation().Equals(instr->representation())); 1463 ASSERT(instr->right()->representation().Equals(instr->representation()));
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2681 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2676 LOperand* object = UseRegister(instr->object()); 2682 LOperand* object = UseRegister(instr->object());
2677 LOperand* index = UseTempRegister(instr->index()); 2683 LOperand* index = UseTempRegister(instr->index());
2678 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2684 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2679 } 2685 }
2680 2686
2681 2687
2682 } } // namespace v8::internal 2688 } } // namespace v8::internal
2683 2689
2684 #endif // V8_TARGET_ARCH_IA32 2690 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698