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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 LOperand* divisor = UseRegister(instr->right()); | 1278 LOperand* divisor = UseRegister(instr->right()); |
1279 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1279 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
1280 return AssignEnvironment(DefineFixed(result, rax)); | 1280 return AssignEnvironment(DefineFixed(result, rax)); |
1281 } else { | 1281 } else { |
1282 ASSERT(instr->representation().IsTagged()); | 1282 ASSERT(instr->representation().IsTagged()); |
1283 return DoArithmeticT(Token::DIV, instr); | 1283 return DoArithmeticT(Token::DIV, instr); |
1284 } | 1284 } |
1285 } | 1285 } |
1286 | 1286 |
1287 | 1287 |
| 1288 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { |
| 1289 // A value with an integer representation does not need to be transformed. |
| 1290 if (dividend->representation().IsInteger32()) { |
| 1291 return dividend; |
| 1292 // A change from an integer32 can be replaced by the integer32 value. |
| 1293 } else if (dividend->IsChange() && |
| 1294 HChange::cast(dividend)->from().IsInteger32()) { |
| 1295 return HChange::cast(dividend)->value(); |
| 1296 } |
| 1297 return NULL; |
| 1298 } |
| 1299 |
| 1300 |
| 1301 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1302 if (divisor->IsConstant() && |
| 1303 HConstant::cast(divisor)->HasInteger32Value()) { |
| 1304 HConstant* constant_val = HConstant::cast(divisor); |
| 1305 return constant_val->CopyToRepresentation(Representation::Integer32()); |
| 1306 } |
| 1307 return NULL; |
| 1308 } |
| 1309 |
| 1310 |
1288 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1311 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1289 UNIMPLEMENTED(); | 1312 HValue* right = instr->right(); |
1290 return NULL; | 1313 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); |
| 1314 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); |
| 1315 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); |
| 1316 if (divisor_si == 0) { |
| 1317 LOperand* dividend = UseRegister(instr->left()); |
| 1318 return AssignEnvironment(DefineAsRegister( |
| 1319 new LMathFloorOfDiv(dividend, divisor, NULL))); |
| 1320 } else if (IsPowerOf2(abs(divisor_si))) { |
| 1321 LOperand* dividend = UseRegisterAtStart(instr->left()); |
| 1322 LInstruction* result = DefineAsRegister( |
| 1323 new LMathFloorOfDiv(dividend, divisor, NULL)); |
| 1324 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1325 } else { |
| 1326 // use two r64 |
| 1327 LOperand* dividend = UseRegisterAtStart(instr->left()); |
| 1328 LOperand* temp = TempRegister(); |
| 1329 LInstruction* result = DefineAsRegister( |
| 1330 new LMathFloorOfDiv(dividend, divisor, temp)); |
| 1331 return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1332 } |
1291 } | 1333 } |
1292 | 1334 |
1293 | 1335 |
1294 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1336 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1295 if (instr->representation().IsInteger32()) { | 1337 if (instr->representation().IsInteger32()) { |
1296 ASSERT(instr->left()->representation().IsInteger32()); | 1338 ASSERT(instr->left()->representation().IsInteger32()); |
1297 ASSERT(instr->right()->representation().IsInteger32()); | 1339 ASSERT(instr->right()->representation().IsInteger32()); |
1298 | 1340 |
1299 LInstruction* result; | 1341 LInstruction* result; |
1300 if (instr->HasPowerOf2Divisor()) { | 1342 if (instr->HasPowerOf2Divisor()) { |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2357 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2316 LOperand* object = UseRegister(instr->object()); | 2358 LOperand* object = UseRegister(instr->object()); |
2317 LOperand* index = UseTempRegister(instr->index()); | 2359 LOperand* index = UseTempRegister(instr->index()); |
2318 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2360 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2319 } | 2361 } |
2320 | 2362 |
2321 | 2363 |
2322 } } // namespace v8::internal | 2364 } } // namespace v8::internal |
2323 | 2365 |
2324 #endif // V8_TARGET_ARCH_X64 | 2366 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |