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 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 } else { | 1321 } else { |
1322 return DoArithmeticT(Token::MUL, instr); | 1322 return DoArithmeticT(Token::MUL, instr); |
1323 } | 1323 } |
1324 } | 1324 } |
1325 | 1325 |
1326 | 1326 |
1327 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1327 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
1328 if (instr->representation().IsInteger32()) { | 1328 if (instr->representation().IsInteger32()) { |
1329 ASSERT(instr->left()->representation().IsInteger32()); | 1329 ASSERT(instr->left()->representation().IsInteger32()); |
1330 ASSERT(instr->right()->representation().IsInteger32()); | 1330 ASSERT(instr->right()->representation().IsInteger32()); |
1331 | |
1332 if (instr->left()->IsConstant()) { | |
1333 // If lhs is constant, do reverse subtraction instead. | |
1334 ASSERT(!instr->right()->IsConstant()); | |
1335 return DoRSub(instr); | |
1336 } | |
1337 | |
1331 LOperand* left = UseRegisterAtStart(instr->left()); | 1338 LOperand* left = UseRegisterAtStart(instr->left()); |
1332 LOperand* right = UseOrConstantAtStart(instr->right()); | 1339 LOperand* right = UseOrConstantAtStart(instr->right()); |
1333 LSubI* sub = new(zone()) LSubI(left, right); | 1340 LSubI* sub = new(zone()) LSubI(left, right); |
1334 LInstruction* result = DefineAsRegister(sub); | 1341 LInstruction* result = DefineAsRegister(sub); |
1335 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1342 if (instr->CheckFlag(HValue::kCanOverflow)) { |
1336 result = AssignEnvironment(result); | 1343 result = AssignEnvironment(result); |
1337 } | 1344 } |
1338 return result; | 1345 return result; |
1339 } else if (instr->representation().IsDouble()) { | 1346 } else if (instr->representation().IsDouble()) { |
1340 return DoArithmeticD(Token::SUB, instr); | 1347 return DoArithmeticD(Token::SUB, instr); |
1341 } else { | 1348 } else { |
1342 return DoArithmeticT(Token::SUB, instr); | 1349 return DoArithmeticT(Token::SUB, instr); |
1343 } | 1350 } |
1344 } | 1351 } |
1345 | 1352 |
1353 | |
1354 LInstruction* LChunkBuilder::DoRSub(HSub* instr) { | |
1355 ASSERT(instr->representation().IsInteger32()); | |
1356 ASSERT(instr->left().IsInteger32()); | |
ulan_google
2012/11/20 08:53:06
This should be ASSERT(instr->left()->representatio
hans
2012/11/20 10:10:19
Done.
| |
1357 ASSERT(instr->right().IsInteger32()); | |
1358 | |
1359 // Note: The lhs of the subtraction becomes the rhs of the | |
1360 // reverse-subtraction. | |
1361 LOperand* left = UseRegisterAtStart(instr->right()); | |
1362 LOperand* right = UseOrConstantAtStart(instr->left()); | |
1363 LRSubI* rsb = new(zone()) LRSubI(left, right); | |
1364 LInstruction* result = DefineAsRegister(rsb); | |
1365 if (instr->CheckFlag(HValue::kCanOverflow)) { | |
1366 result = AssignEnvironment(result); | |
1367 } | |
1368 return result; | |
1369 } | |
1370 | |
1371 | |
1346 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { | 1372 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { |
1347 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); | 1373 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); |
1348 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); | 1374 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); |
1349 LOperand* addend_op = UseRegisterAtStart(addend); | 1375 LOperand* addend_op = UseRegisterAtStart(addend); |
1350 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, | 1376 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, |
1351 multiplicand_op)); | 1377 multiplicand_op)); |
1352 } | 1378 } |
1353 | 1379 |
1354 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1380 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
1355 if (instr->representation().IsInteger32()) { | 1381 if (instr->representation().IsInteger32()) { |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2300 | 2326 |
2301 | 2327 |
2302 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2328 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2303 LOperand* object = UseRegister(instr->object()); | 2329 LOperand* object = UseRegister(instr->object()); |
2304 LOperand* index = UseRegister(instr->index()); | 2330 LOperand* index = UseRegister(instr->index()); |
2305 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2331 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2306 } | 2332 } |
2307 | 2333 |
2308 | 2334 |
2309 } } // namespace v8::internal | 2335 } } // namespace v8::internal |
OLD | NEW |