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

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

Issue 11624022: Handle non-constant divisor in MathFloorOfDiv, on ia32/x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years 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
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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 } 1298 }
1299 1299
1300 1300
1301 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { 1301 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1302 if (divisor->IsConstant() && 1302 if (divisor->IsConstant() &&
1303 HConstant::cast(divisor)->HasInteger32Value()) { 1303 HConstant::cast(divisor)->HasInteger32Value()) {
1304 HConstant* constant_val = HConstant::cast(divisor); 1304 HConstant* constant_val = HConstant::cast(divisor);
1305 return constant_val->CopyToRepresentation(Representation::Integer32(), 1305 return constant_val->CopyToRepresentation(Representation::Integer32(),
1306 divisor->block()->zone()); 1306 divisor->block()->zone());
1307 } 1307 }
1308 // A value with an integer representation does not need to be transformed.
1309 if (divisor->representation().IsInteger32())
Yang 2012/12/27 14:41:53 For if-else, we always insert brackets.
1310 return divisor;
Yang 2012/12/27 14:41:53 Please conform to the usual code style. Specifical
1311 // A change from an integer32 can be replaced by the integer32 value.
1312 else if (divisor->IsChange() &&
1313 HChange::cast(divisor)->from().IsInteger32())
1314 return HChange::cast(divisor)->value();
1308 return NULL; 1315 return NULL;
1309 } 1316 }
1310 1317
1311 1318
1312 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1319 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1313 HValue* right = instr->right(); 1320 HValue* right = instr->right();
1321 if (!right->IsConstant()) {
1322 ASSERT(right->representation().IsInteger32());
1323 // The temporary operand is necessary to ensure that right is not allocated
1324 // into edx.
1325 LOperand* temp = FixedTemp(edx);
1326 LOperand* dividend = UseFixed(instr->left(), eax);
1327 LOperand* divisor = UseRegister(instr->right());
1328 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp);
1329 return AssignEnvironment(DefineFixed(flooring_div, eax));
1330 }
1331
1314 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); 1332 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value());
1315 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); 1333 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right));
1316 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); 1334 int32_t divisor_si = HConstant::cast(right)->Integer32Value();
1317 if (divisor_si == 0) { 1335 if (divisor_si == 0) {
1318 LOperand* dividend = UseRegister(instr->left()); 1336 LOperand* dividend = UseRegister(instr->left());
1319 return AssignEnvironment(DefineAsRegister( 1337 return AssignEnvironment(DefineAsRegister(
1320 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); 1338 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)));
1321 } else if (IsPowerOf2(abs(divisor_si))) { 1339 } else if (IsPowerOf2(abs(divisor_si))) {
1322 // use dividend as temp if divisor < 0 && divisor != -1 1340 // use dividend as temp if divisor < 0 && divisor != -1
1323 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) : 1341 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) :
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2496 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2479 LOperand* object = UseRegister(instr->object()); 2497 LOperand* object = UseRegister(instr->object());
2480 LOperand* index = UseTempRegister(instr->index()); 2498 LOperand* index = UseTempRegister(instr->index());
2481 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2499 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2482 } 2500 }
2483 2501
2484 2502
2485 } } // namespace v8::internal 2503 } } // namespace v8::internal
2486 2504
2487 #endif // V8_TARGET_ARCH_IA32 2505 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698