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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 LOperand* divisor = UseRegister(instr->right()); | 1340 LOperand* divisor = UseRegister(instr->right()); |
1341 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1341 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
1342 return AssignEnvironment(DefineFixed(result, eax)); | 1342 return AssignEnvironment(DefineFixed(result, eax)); |
1343 } else { | 1343 } else { |
1344 ASSERT(instr->representation().IsTagged()); | 1344 ASSERT(instr->representation().IsTagged()); |
1345 return DoArithmeticT(Token::DIV, instr); | 1345 return DoArithmeticT(Token::DIV, instr); |
1346 } | 1346 } |
1347 } | 1347 } |
1348 | 1348 |
1349 | 1349 |
| 1350 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { |
| 1351 // A value with an integer representation does not need to be transformed. |
| 1352 if (dividend->representation().IsInteger32()) { |
| 1353 return dividend; |
| 1354 // A change from an integer32 can be replaced by the integer32 value. |
| 1355 } else if (dividend->IsChange() && |
| 1356 HChange::cast(dividend)->from().IsInteger32()) { |
| 1357 return HChange::cast(dividend)->value(); |
| 1358 } |
| 1359 return NULL; |
| 1360 } |
| 1361 |
| 1362 |
| 1363 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1364 if (divisor->IsConstant() && |
| 1365 HConstant::cast(divisor)->HasInteger32Value()) { |
| 1366 HConstant* constant_val = HConstant::cast(divisor); |
| 1367 return constant_val->CopyToRepresentation(Representation::Integer32(), |
| 1368 divisor->block()->zone()); |
| 1369 } |
| 1370 return NULL; |
| 1371 } |
| 1372 |
| 1373 |
1350 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1374 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1351 UNIMPLEMENTED(); | 1375 HValue* right = instr->right(); |
1352 return NULL; | 1376 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); |
| 1377 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); |
| 1378 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); |
| 1379 if (divisor_si == 0) { |
| 1380 LOperand* dividend = UseRegister(instr->left()); |
| 1381 return AssignEnvironment(DefineAsRegister( |
| 1382 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); |
| 1383 } else if (IsPowerOf2(abs(divisor_si))) { |
| 1384 // use dividend as temp if divisor < 0 && divisor != -1 |
| 1385 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) : |
| 1386 UseRegisterAtStart(instr->left()); |
| 1387 LInstruction* result = DefineAsRegister( |
| 1388 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)); |
| 1389 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1390 } else { |
| 1391 // needs edx:eax, plus a temp |
| 1392 LOperand* dividend = UseFixed(instr->left(), eax); |
| 1393 LOperand* temp = TempRegister(); |
| 1394 LInstruction* result = DefineFixed( |
| 1395 new(zone()) LMathFloorOfDiv(dividend, divisor, temp), edx); |
| 1396 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1397 } |
1353 } | 1398 } |
1354 | 1399 |
1355 | 1400 |
1356 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1401 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1357 if (instr->representation().IsInteger32()) { | 1402 if (instr->representation().IsInteger32()) { |
1358 ASSERT(instr->left()->representation().IsInteger32()); | 1403 ASSERT(instr->left()->representation().IsInteger32()); |
1359 ASSERT(instr->right()->representation().IsInteger32()); | 1404 ASSERT(instr->right()->representation().IsInteger32()); |
1360 | 1405 |
1361 LInstruction* result; | 1406 LInstruction* result; |
1362 if (instr->HasPowerOf2Divisor()) { | 1407 if (instr->HasPowerOf2Divisor()) { |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2493 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2449 LOperand* object = UseRegister(instr->object()); | 2494 LOperand* object = UseRegister(instr->object()); |
2450 LOperand* index = UseTempRegister(instr->index()); | 2495 LOperand* index = UseTempRegister(instr->index()); |
2451 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2496 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2452 } | 2497 } |
2453 | 2498 |
2454 | 2499 |
2455 } } // namespace v8::internal | 2500 } } // namespace v8::internal |
2456 | 2501 |
2457 #endif // V8_TARGET_ARCH_IA32 | 2502 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |