| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 return; \ | 509 return; \ |
| 510 } | 510 } |
| 511 INLINE_RUNTIME_FUNCTION_LIST(CHECK_EMIT_INLINE_CALL) | 511 INLINE_RUNTIME_FUNCTION_LIST(CHECK_EMIT_INLINE_CALL) |
| 512 #undef CHECK_EMIT_INLINE_CALL | 512 #undef CHECK_EMIT_INLINE_CALL |
| 513 UNREACHABLE(); | 513 UNREACHABLE(); |
| 514 } | 514 } |
| 515 | 515 |
| 516 | 516 |
| 517 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 517 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 518 Comment cmnt(masm_, "[ BinaryOperation"); | 518 Comment cmnt(masm_, "[ BinaryOperation"); |
| 519 Token::Value op = expr->op(); |
| 520 Expression* left = expr->left(); |
| 521 Expression* right = expr->right(); |
| 519 | 522 |
| 520 OverwriteMode overwrite_mode = NO_OVERWRITE; | 523 OverwriteMode mode = NO_OVERWRITE; |
| 521 if (expr->left()->ResultOverwriteAllowed()) { | 524 if (left->ResultOverwriteAllowed()) { |
| 522 overwrite_mode = OVERWRITE_LEFT; | 525 mode = OVERWRITE_LEFT; |
| 523 } else if (expr->right()->ResultOverwriteAllowed()) { | 526 } else if (right->ResultOverwriteAllowed()) { |
| 524 overwrite_mode = OVERWRITE_RIGHT; | 527 mode = OVERWRITE_RIGHT; |
| 525 } | 528 } |
| 526 | 529 |
| 527 switch (expr->op()) { | 530 switch (op) { |
| 528 case Token::COMMA: | 531 case Token::COMMA: |
| 529 VisitForEffect(expr->left()); | 532 VisitForEffect(left); |
| 530 Visit(expr->right()); | 533 Visit(right); |
| 531 break; | 534 break; |
| 532 | 535 |
| 533 case Token::OR: | 536 case Token::OR: |
| 534 case Token::AND: | 537 case Token::AND: |
| 535 EmitLogicalOperation(expr); | 538 EmitLogicalOperation(expr); |
| 536 break; | 539 break; |
| 537 | 540 |
| 538 case Token::ADD: | 541 case Token::ADD: |
| 539 case Token::SUB: | 542 case Token::SUB: |
| 540 case Token::DIV: | 543 case Token::DIV: |
| 541 case Token::MOD: | 544 case Token::MOD: |
| 542 case Token::MUL: | 545 case Token::MUL: |
| 543 case Token::BIT_OR: | 546 case Token::BIT_OR: |
| 544 case Token::BIT_AND: | 547 case Token::BIT_AND: |
| 545 case Token::BIT_XOR: | 548 case Token::BIT_XOR: |
| 546 case Token::SHL: | 549 case Token::SHL: |
| 547 case Token::SHR: | 550 case Token::SHR: |
| 548 case Token::SAR: | 551 case Token::SAR: { |
| 549 VisitForValue(expr->left(), kStack); | 552 // Figure out if either of the operands is a constant. |
| 550 VisitForValue(expr->right(), kAccumulator); | 553 ConstantOperand constant = ShouldInlineSmiCase(op) |
| 554 ? GetConstantOperand(op, left, right) |
| 555 : kNoConstants; |
| 556 |
| 557 // Load only the operands that we need to materialize. |
| 558 if (constant == kNoConstants) { |
| 559 VisitForValue(left, kStack); |
| 560 VisitForValue(right, kAccumulator); |
| 561 } else if (constant == kRightConstant) { |
| 562 VisitForValue(left, kAccumulator); |
| 563 } else { |
| 564 ASSERT(constant == kLeftConstant); |
| 565 VisitForValue(right, kAccumulator); |
| 566 } |
| 567 |
| 551 SetSourcePosition(expr->position()); | 568 SetSourcePosition(expr->position()); |
| 552 EmitBinaryOp(expr->op(), context_, overwrite_mode); | 569 if (ShouldInlineSmiCase(op)) { |
| 570 EmitInlineSmiBinaryOp(expr, op, context_, mode, left, right, constant); |
| 571 } else { |
| 572 EmitBinaryOp(op, context_, mode); |
| 573 } |
| 553 break; | 574 break; |
| 575 } |
| 554 | 576 |
| 555 default: | 577 default: |
| 556 UNREACHABLE(); | 578 UNREACHABLE(); |
| 557 } | 579 } |
| 558 } | 580 } |
| 559 | 581 |
| 560 | 582 |
| 561 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { | 583 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { |
| 562 Label eval_right, done; | 584 Label eval_right, done; |
| 563 | 585 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 ASSERT(args->length() == 1); | 1129 ASSERT(args->length() == 1); |
| 1108 VisitForValue(args->at(0), kStack); | 1130 VisitForValue(args->at(0), kStack); |
| 1109 __ CallRuntime(Runtime::kRegExpCloneResult, 1); | 1131 __ CallRuntime(Runtime::kRegExpCloneResult, 1); |
| 1110 Apply(context_, result_register()); | 1132 Apply(context_, result_register()); |
| 1111 } | 1133 } |
| 1112 | 1134 |
| 1113 #undef __ | 1135 #undef __ |
| 1114 | 1136 |
| 1115 | 1137 |
| 1116 } } // namespace v8::internal | 1138 } } // namespace v8::internal |
| OLD | NEW |