Chromium Code Reviews| 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 3707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3718 Label no_conversion; | 3718 Label no_conversion; |
| 3719 __ test(result_register(), Immediate(kSmiTagMask)); | 3719 __ test(result_register(), Immediate(kSmiTagMask)); |
| 3720 __ j(zero, &no_conversion); | 3720 __ j(zero, &no_conversion); |
| 3721 ToNumberStub convert_stub; | 3721 ToNumberStub convert_stub; |
| 3722 __ CallStub(&convert_stub); | 3722 __ CallStub(&convert_stub); |
| 3723 __ bind(&no_conversion); | 3723 __ bind(&no_conversion); |
| 3724 context()->Plug(result_register()); | 3724 context()->Plug(result_register()); |
| 3725 break; | 3725 break; |
| 3726 } | 3726 } |
| 3727 | 3727 |
| 3728 case Token::SUB: { | 3728 case Token::SUB: |
| 3729 Comment cmt(masm_, "[ UnaryOperation (SUB)"); | 3729 EmitUnaryOperation(expr, "[ UnaryOperation (SUB)"); |
| 3730 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | |
| 3731 UnaryOverwriteMode overwrite = | |
| 3732 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 3733 GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS); | |
|
fschneider
2011/04/27 11:34:36
Please remove the code for the GenericUnaryOpStub
Sven Panne
2011/04/27 17:19:31
I already have exactly this on my TODO list, plus
| |
| 3734 // GenericUnaryOpStub expects the argument to be in the | |
| 3735 // accumulator register eax. | |
| 3736 VisitForAccumulatorValue(expr->expression()); | |
| 3737 __ CallStub(&stub); | |
| 3738 context()->Plug(eax); | |
| 3739 break; | 3730 break; |
| 3740 } | |
| 3741 | 3731 |
| 3742 case Token::BIT_NOT: { | 3732 case Token::BIT_NOT: |
| 3743 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); | 3733 EmitUnaryOperation(expr, "[ UnaryOperation (BIT_NOT)"); |
| 3744 // The generic unary operation stub expects the argument to be | |
| 3745 // in the accumulator register eax. | |
| 3746 VisitForAccumulatorValue(expr->expression()); | |
| 3747 Label done; | |
| 3748 bool inline_smi_case = ShouldInlineSmiCase(expr->op()); | |
| 3749 if (inline_smi_case) { | |
| 3750 NearLabel call_stub; | |
| 3751 __ test(eax, Immediate(kSmiTagMask)); | |
| 3752 __ j(not_zero, &call_stub); | |
| 3753 __ lea(eax, Operand(eax, kSmiTagMask)); | |
| 3754 __ not_(eax); | |
| 3755 __ jmp(&done); | |
| 3756 __ bind(&call_stub); | |
| 3757 } | |
| 3758 bool overwrite = expr->expression()->ResultOverwriteAllowed(); | |
| 3759 UnaryOverwriteMode mode = | |
| 3760 overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 3761 UnaryOpFlags flags = inline_smi_case | |
| 3762 ? NO_UNARY_SMI_CODE_IN_STUB | |
| 3763 : NO_UNARY_FLAGS; | |
| 3764 GenericUnaryOpStub stub(Token::BIT_NOT, mode, flags); | |
| 3765 __ CallStub(&stub); | |
| 3766 __ bind(&done); | |
| 3767 context()->Plug(eax); | |
| 3768 break; | 3734 break; |
| 3769 } | |
| 3770 | 3735 |
| 3771 default: | 3736 default: |
| 3772 UNREACHABLE(); | 3737 UNREACHABLE(); |
| 3773 } | 3738 } |
| 3774 } | 3739 } |
| 3775 | 3740 |
| 3776 | 3741 |
| 3742 void FullCodeGenerator::EmitUnaryOperation(UnaryOperation* expr, | |
| 3743 const char* comment) { | |
| 3744 // TODO(svenpanne): Allowing format strings in Comment would be nice here... | |
| 3745 Comment cmt(masm_, comment); | |
| 3746 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | |
| 3747 UnaryOverwriteMode overwrite = | |
| 3748 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 3749 TypeRecordingUnaryOpStub stub(expr->op(), overwrite); | |
| 3750 // TypeRecordingUnaryOpStub expects the argument to be in the | |
| 3751 // accumulator register eax. | |
| 3752 VisitForAccumulatorValue(expr->expression()); | |
| 3753 SetSourcePosition(expr->position()); | |
| 3754 EmitCallIC(stub.GetCode(), NULL); | |
| 3755 context()->Plug(eax); | |
| 3756 } | |
| 3757 | |
| 3758 | |
| 3777 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 3759 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 3778 Comment cmnt(masm_, "[ CountOperation"); | 3760 Comment cmnt(masm_, "[ CountOperation"); |
| 3779 SetSourcePosition(expr->position()); | 3761 SetSourcePosition(expr->position()); |
| 3780 | 3762 |
| 3781 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' | 3763 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 3782 // as the left-hand side. | 3764 // as the left-hand side. |
| 3783 if (!expr->expression()->IsValidLeftHandSide()) { | 3765 if (!expr->expression()->IsValidLeftHandSide()) { |
| 3784 VisitForEffect(expr->expression()); | 3766 VisitForEffect(expr->expression()); |
| 3785 return; | 3767 return; |
| 3786 } | 3768 } |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4323 // And return. | 4305 // And return. |
| 4324 __ ret(0); | 4306 __ ret(0); |
| 4325 } | 4307 } |
| 4326 | 4308 |
| 4327 | 4309 |
| 4328 #undef __ | 4310 #undef __ |
| 4329 | 4311 |
| 4330 } } // namespace v8::internal | 4312 } } // namespace v8::internal |
| 4331 | 4313 |
| 4332 #endif // V8_TARGET_ARCH_IA32 | 4314 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |