OLD | NEW |
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 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 LOperand* divisor = UseRegister(instr->right()); | 1328 LOperand* divisor = UseRegister(instr->right()); |
1329 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1329 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
1330 return AssignEnvironment(DefineFixed(result, eax)); | 1330 return AssignEnvironment(DefineFixed(result, eax)); |
1331 } else { | 1331 } else { |
1332 ASSERT(instr->representation().IsTagged()); | 1332 ASSERT(instr->representation().IsTagged()); |
1333 return DoArithmeticT(Token::DIV, instr); | 1333 return DoArithmeticT(Token::DIV, instr); |
1334 } | 1334 } |
1335 } | 1335 } |
1336 | 1336 |
1337 | 1337 |
| 1338 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { |
| 1339 // A value with an integer representation does not need to be transformed. |
| 1340 if (dividend->representation().IsInteger32()) { |
| 1341 return dividend; |
| 1342 // A change from an integer32 can be replaced by the integer32 value. |
| 1343 } else if (dividend->IsChange() && |
| 1344 HChange::cast(dividend)->from().IsInteger32()) { |
| 1345 return HChange::cast(dividend)->value(); |
| 1346 } |
| 1347 return NULL; |
| 1348 } |
| 1349 |
| 1350 |
| 1351 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1352 if (divisor->IsConstant() && |
| 1353 HConstant::cast(divisor)->HasInteger32Value()) { |
| 1354 HConstant* constant_val = HConstant::cast(divisor); |
| 1355 return constant_val->CopyToRepresentation(Representation::Integer32()); |
| 1356 } |
| 1357 return NULL; |
| 1358 } |
| 1359 |
| 1360 |
1338 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1361 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1339 UNIMPLEMENTED(); | 1362 HValue* right = instr->right(); |
1340 return NULL; | 1363 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); |
| 1364 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); |
| 1365 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); |
| 1366 if (divisor_si == 0) { |
| 1367 LOperand* dividend = UseRegister(instr->left()); |
| 1368 return AssignEnvironment(DefineAsRegister( |
| 1369 new LMathFloorOfDiv(dividend, divisor, NULL))); |
| 1370 } else if (IsPowerOf2(abs(divisor_si))) { |
| 1371 // use dividend as temp if divisor < 0 && divisor != -1 |
| 1372 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) : |
| 1373 UseRegisterAtStart(instr->left()); |
| 1374 LInstruction* result = DefineAsRegister( |
| 1375 new LMathFloorOfDiv(dividend, divisor, NULL)); |
| 1376 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1377 } else { |
| 1378 // needs edx:eax, plus a temp |
| 1379 LOperand* dividend = UseFixed(instr->left(), eax); |
| 1380 LOperand* temp = TempRegister(); |
| 1381 LInstruction* result = DefineFixed( |
| 1382 new LMathFloorOfDiv(dividend, divisor, temp), edx); |
| 1383 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1384 } |
1341 } | 1385 } |
1342 | 1386 |
1343 | 1387 |
1344 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1388 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1345 if (instr->representation().IsInteger32()) { | 1389 if (instr->representation().IsInteger32()) { |
1346 ASSERT(instr->left()->representation().IsInteger32()); | 1390 ASSERT(instr->left()->representation().IsInteger32()); |
1347 ASSERT(instr->right()->representation().IsInteger32()); | 1391 ASSERT(instr->right()->representation().IsInteger32()); |
1348 | 1392 |
1349 LInstruction* result; | 1393 LInstruction* result; |
1350 if (instr->HasPowerOf2Divisor()) { | 1394 if (instr->HasPowerOf2Divisor()) { |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2475 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2432 LOperand* object = UseRegister(instr->object()); | 2476 LOperand* object = UseRegister(instr->object()); |
2433 LOperand* index = UseTempRegister(instr->index()); | 2477 LOperand* index = UseTempRegister(instr->index()); |
2434 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2478 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2435 } | 2479 } |
2436 | 2480 |
2437 | 2481 |
2438 } } // namespace v8::internal | 2482 } } // namespace v8::internal |
2439 | 2483 |
2440 #endif // V8_TARGET_ARCH_IA32 | 2484 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |