| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 Label no_conversion; | 3697 Label no_conversion; |
| 3698 Condition is_smi = masm_->CheckSmi(result_register()); | 3698 Condition is_smi = masm_->CheckSmi(result_register()); |
| 3699 __ j(is_smi, &no_conversion); | 3699 __ j(is_smi, &no_conversion); |
| 3700 ToNumberStub convert_stub; | 3700 ToNumberStub convert_stub; |
| 3701 __ CallStub(&convert_stub); | 3701 __ CallStub(&convert_stub); |
| 3702 __ bind(&no_conversion); | 3702 __ bind(&no_conversion); |
| 3703 context()->Plug(result_register()); | 3703 context()->Plug(result_register()); |
| 3704 break; | 3704 break; |
| 3705 } | 3705 } |
| 3706 | 3706 |
| 3707 case Token::SUB: { | 3707 case Token::SUB: |
| 3708 Comment cmt(masm_, "[ UnaryOperation (SUB)"); | 3708 EmitUnaryOperation(expr, "[ UnaryOperation (SUB)"); |
| 3709 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | |
| 3710 UnaryOverwriteMode overwrite = | |
| 3711 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 3712 GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS); | |
| 3713 // GenericUnaryOpStub expects the argument to be in the | |
| 3714 // accumulator register rax. | |
| 3715 VisitForAccumulatorValue(expr->expression()); | |
| 3716 __ CallStub(&stub); | |
| 3717 context()->Plug(rax); | |
| 3718 break; | 3709 break; |
| 3719 } | |
| 3720 | 3710 |
| 3721 case Token::BIT_NOT: { | 3711 case Token::BIT_NOT: |
| 3722 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); | 3712 EmitUnaryOperation(expr, "[ UnaryOperation (BIT_NOT)"); |
| 3723 // The generic unary operation stub expects the argument to be | |
| 3724 // in the accumulator register rax. | |
| 3725 VisitForAccumulatorValue(expr->expression()); | |
| 3726 Label done; | |
| 3727 bool inline_smi_case = ShouldInlineSmiCase(expr->op()); | |
| 3728 if (inline_smi_case) { | |
| 3729 Label call_stub; | |
| 3730 __ JumpIfNotSmi(rax, &call_stub); | |
| 3731 __ SmiNot(rax, rax); | |
| 3732 __ jmp(&done); | |
| 3733 __ bind(&call_stub); | |
| 3734 } | |
| 3735 bool overwrite = expr->expression()->ResultOverwriteAllowed(); | |
| 3736 UnaryOverwriteMode mode = | |
| 3737 overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 3738 UnaryOpFlags flags = inline_smi_case | |
| 3739 ? NO_UNARY_SMI_CODE_IN_STUB | |
| 3740 : NO_UNARY_FLAGS; | |
| 3741 GenericUnaryOpStub stub(Token::BIT_NOT, mode, flags); | |
| 3742 __ CallStub(&stub); | |
| 3743 __ bind(&done); | |
| 3744 context()->Plug(rax); | |
| 3745 break; | 3713 break; |
| 3746 } | |
| 3747 | 3714 |
| 3748 default: | 3715 default: |
| 3749 UNREACHABLE(); | 3716 UNREACHABLE(); |
| 3750 } | 3717 } |
| 3751 } | 3718 } |
| 3752 | 3719 |
| 3753 | 3720 |
| 3721 void FullCodeGenerator::EmitUnaryOperation(UnaryOperation* expr, |
| 3722 const char* comment) { |
| 3723 // TODO(svenpanne): Allowing format strings in Comment would be nice here... |
| 3724 Comment cmt(masm_, comment); |
| 3725 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
| 3726 UnaryOverwriteMode overwrite = |
| 3727 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
| 3728 TypeRecordingUnaryOpStub stub(expr->op(), overwrite); |
| 3729 // TypeRecordingUnaryOpStub expects the argument to be in the |
| 3730 // accumulator register rax. |
| 3731 VisitForAccumulatorValue(expr->expression()); |
| 3732 SetSourcePosition(expr->position()); |
| 3733 EmitCallIC(stub.GetCode(), NULL); |
| 3734 context()->Plug(rax); |
| 3735 } |
| 3736 |
| 3737 |
| 3754 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 3738 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 3755 Comment cmnt(masm_, "[ CountOperation"); | 3739 Comment cmnt(masm_, "[ CountOperation"); |
| 3756 SetSourcePosition(expr->position()); | 3740 SetSourcePosition(expr->position()); |
| 3757 | 3741 |
| 3758 // Invalid left-hand-sides are rewritten to have a 'throw | 3742 // Invalid left-hand-sides are rewritten to have a 'throw |
| 3759 // ReferenceError' as the left-hand side. | 3743 // ReferenceError' as the left-hand side. |
| 3760 if (!expr->expression()->IsValidLeftHandSide()) { | 3744 if (!expr->expression()->IsValidLeftHandSide()) { |
| 3761 VisitForEffect(expr->expression()); | 3745 VisitForEffect(expr->expression()); |
| 3762 return; | 3746 return; |
| 3763 } | 3747 } |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4305 __ ret(0); | 4289 __ ret(0); |
| 4306 } | 4290 } |
| 4307 | 4291 |
| 4308 | 4292 |
| 4309 #undef __ | 4293 #undef __ |
| 4310 | 4294 |
| 4311 | 4295 |
| 4312 } } // namespace v8::internal | 4296 } } // namespace v8::internal |
| 4313 | 4297 |
| 4314 #endif // V8_TARGET_ARCH_X64 | 4298 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |