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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 } else { | 1246 } else { |
1247 return DoArithmeticT(instr->op(), instr); | 1247 return DoArithmeticT(instr->op(), instr); |
1248 } | 1248 } |
1249 } | 1249 } |
1250 | 1250 |
1251 | 1251 |
1252 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1252 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
1253 if (instr->representation().IsSmiOrInteger32()) { | 1253 if (instr->representation().IsSmiOrInteger32()) { |
1254 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1254 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1255 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1255 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1256 if (instr->HasPowerOf2Divisor()) { | 1256 if (instr->RightIsPowerOf2()) { |
1257 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1257 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
1258 LOperand* value = UseRegisterAtStart(instr->left()); | 1258 LOperand* value = UseRegisterAtStart(instr->left()); |
1259 LDivI* div = | 1259 LDivI* div = |
1260 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 1260 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); |
1261 return AssignEnvironment(DefineSameAsFirst(div)); | 1261 return AssignEnvironment(DefineSameAsFirst(div)); |
1262 } | 1262 } |
1263 // The temporary operand is necessary to ensure that right is not allocated | 1263 // The temporary operand is necessary to ensure that right is not allocated |
1264 // into rdx. | 1264 // into rdx. |
1265 LOperand* temp = FixedTemp(rdx); | 1265 LOperand* temp = FixedTemp(rdx); |
1266 LOperand* dividend = UseFixed(instr->left(), rax); | 1266 LOperand* dividend = UseFixed(instr->left(), rax); |
1267 LOperand* divisor = UseRegister(instr->right()); | 1267 LOperand* divisor = UseRegister(instr->right()); |
1268 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1268 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
1269 return AssignEnvironment(DefineFixed(result, rax)); | 1269 return AssignEnvironment(DefineFixed(result, rax)); |
1270 } else if (instr->representation().IsDouble()) { | 1270 } else if (instr->representation().IsDouble()) { |
1271 return DoArithmeticD(Token::DIV, instr); | 1271 return DoArithmeticD(Token::DIV, instr); |
1272 } else { | 1272 } else { |
1273 return DoArithmeticT(Token::DIV, instr); | 1273 return DoArithmeticT(Token::DIV, instr); |
1274 } | 1274 } |
1275 } | 1275 } |
1276 | 1276 |
1277 | 1277 |
1278 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | |
1279 if (divisor->IsConstant() && | |
1280 HConstant::cast(divisor)->HasInteger32Value()) { | |
1281 HConstant* constant_val = HConstant::cast(divisor); | |
1282 return constant_val->CopyToRepresentation(Representation::Integer32(), | |
1283 divisor->block()->zone()); | |
1284 } | |
1285 // A value with an integer representation does not need to be transformed. | |
1286 if (divisor->representation().IsInteger32()) { | |
1287 return divisor; | |
1288 // A change from an integer32 can be replaced by the integer32 value. | |
1289 } else if (divisor->IsChange() && | |
1290 HChange::cast(divisor)->from().IsInteger32()) { | |
1291 return HChange::cast(divisor)->value(); | |
1292 } | |
1293 return NULL; | |
1294 } | |
1295 | |
1296 | |
1297 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1278 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1298 HValue* right = instr->right(); | 1279 HValue* right = instr->right(); |
1299 if (!right->IsConstant()) { | 1280 if (!right->IsConstant()) { |
1300 ASSERT(right->representation().IsInteger32()); | 1281 ASSERT(right->representation().IsInteger32()); |
1301 // The temporary operand is necessary to ensure that right is not allocated | 1282 // The temporary operand is necessary to ensure that right is not allocated |
1302 // into rdx. | 1283 // into rdx. |
1303 LOperand* temp = FixedTemp(rdx); | 1284 LOperand* temp = FixedTemp(rdx); |
1304 LOperand* dividend = UseFixed(instr->left(), rax); | 1285 LOperand* dividend = UseFixed(instr->left(), rax); |
1305 LOperand* divisor = UseRegister(instr->right()); | 1286 LOperand* divisor = UseRegister(instr->right()); |
1306 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); | 1287 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); |
(...skipping 22 matching lines...) Expand all Loading... |
1329 } | 1310 } |
1330 } | 1311 } |
1331 | 1312 |
1332 | 1313 |
1333 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1314 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1334 HValue* left = instr->left(); | 1315 HValue* left = instr->left(); |
1335 HValue* right = instr->right(); | 1316 HValue* right = instr->right(); |
1336 if (instr->representation().IsSmiOrInteger32()) { | 1317 if (instr->representation().IsSmiOrInteger32()) { |
1337 ASSERT(left->representation().Equals(instr->representation())); | 1318 ASSERT(left->representation().Equals(instr->representation())); |
1338 ASSERT(right->representation().Equals(instr->representation())); | 1319 ASSERT(right->representation().Equals(instr->representation())); |
1339 if (instr->HasPowerOf2Divisor()) { | 1320 if (instr->RightIsPowerOf2()) { |
1340 ASSERT(!right->CanBeZero()); | 1321 ASSERT(!right->CanBeZero()); |
1341 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1322 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
1342 UseOrConstant(right), | 1323 UseOrConstant(right), |
1343 NULL); | 1324 NULL); |
1344 LInstruction* result = DefineSameAsFirst(mod); | 1325 LInstruction* result = DefineSameAsFirst(mod); |
1345 return (left->CanBeNegative() && | 1326 return (left->CanBeNegative() && |
1346 instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1327 instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
1347 ? AssignEnvironment(result) | 1328 ? AssignEnvironment(result) |
1348 : result; | 1329 : result; |
1349 } else { | 1330 } else { |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2470 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2490 LOperand* object = UseRegister(instr->object()); | 2471 LOperand* object = UseRegister(instr->object()); |
2491 LOperand* index = UseTempRegister(instr->index()); | 2472 LOperand* index = UseTempRegister(instr->index()); |
2492 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2473 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2493 } | 2474 } |
2494 | 2475 |
2495 | 2476 |
2496 } } // namespace v8::internal | 2477 } } // namespace v8::internal |
2497 | 2478 |
2498 #endif // V8_TARGET_ARCH_X64 | 2479 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |