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

Side by Side Diff: src/x64/lithium-x64.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 7 years, 12 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') | test/mjsunit/math-floor-of-div.js » ('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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 } 1221 }
1222 1222
1223 1223
1224 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { 1224 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1225 if (divisor->IsConstant() && 1225 if (divisor->IsConstant() &&
1226 HConstant::cast(divisor)->HasInteger32Value()) { 1226 HConstant::cast(divisor)->HasInteger32Value()) {
1227 HConstant* constant_val = HConstant::cast(divisor); 1227 HConstant* constant_val = HConstant::cast(divisor);
1228 return constant_val->CopyToRepresentation(Representation::Integer32(), 1228 return constant_val->CopyToRepresentation(Representation::Integer32(),
1229 divisor->block()->zone()); 1229 divisor->block()->zone());
1230 } 1230 }
1231 // A value with an integer representation does not need to be transformed.
1232 if (divisor->representation().IsInteger32()) {
1233 return divisor;
1234 // A change from an integer32 can be replaced by the integer32 value.
1235 } else if (divisor->IsChange() &&
1236 HChange::cast(divisor)->from().IsInteger32()) {
1237 return HChange::cast(divisor)->value();
1238 }
1231 return NULL; 1239 return NULL;
1232 } 1240 }
1233 1241
1234 1242
1235 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1243 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1236 HValue* right = instr->right(); 1244 HValue* right = instr->right();
1245 if (!right->IsConstant()) {
1246 ASSERT(right->representation().IsInteger32());
1247 // The temporary operand is necessary to ensure that right is not allocated
1248 // into rdx.
1249 LOperand* temp = FixedTemp(rdx);
1250 LOperand* dividend = UseFixed(instr->left(), rax);
1251 LOperand* divisor = UseRegister(instr->right());
1252 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp);
1253 return AssignEnvironment(DefineFixed(flooring_div, rax));
1254 }
1255
1237 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); 1256 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value());
1238 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); 1257 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right));
1239 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); 1258 int32_t divisor_si = HConstant::cast(right)->Integer32Value();
1240 if (divisor_si == 0) { 1259 if (divisor_si == 0) {
1241 LOperand* dividend = UseRegister(instr->left()); 1260 LOperand* dividend = UseRegister(instr->left());
1242 return AssignEnvironment(DefineAsRegister( 1261 return AssignEnvironment(DefineAsRegister(
1243 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); 1262 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)));
1244 } else if (IsPowerOf2(abs(divisor_si))) { 1263 } else if (IsPowerOf2(abs(divisor_si))) {
1245 LOperand* dividend = UseRegisterAtStart(instr->left()); 1264 LOperand* dividend = UseRegisterAtStart(instr->left());
1246 LInstruction* result = DefineAsRegister( 1265 LInstruction* result = DefineAsRegister(
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2346 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2328 LOperand* object = UseRegister(instr->object()); 2347 LOperand* object = UseRegister(instr->object());
2329 LOperand* index = UseTempRegister(instr->index()); 2348 LOperand* index = UseTempRegister(instr->index());
2330 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2349 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2331 } 2350 }
2332 2351
2333 2352
2334 } } // namespace v8::internal 2353 } } // namespace v8::internal
2335 2354
2336 #endif // V8_TARGET_ARCH_X64 2355 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | test/mjsunit/math-floor-of-div.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698