| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3756 __ mov(frame_->Top(), eax); | 3756 __ mov(frame_->Top(), eax); |
| 3757 } else { | 3757 } else { |
| 3758 // Call the C runtime function. | 3758 // Call the C runtime function. |
| 3759 frame_->CallRuntime(function, arg_count); | 3759 frame_->CallRuntime(function, arg_count); |
| 3760 frame_->EmitPush(eax); | 3760 frame_->EmitPush(eax); |
| 3761 } | 3761 } |
| 3762 } | 3762 } |
| 3763 | 3763 |
| 3764 | 3764 |
| 3765 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { | 3765 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { |
| 3766 VirtualFrame::SpilledScope spilled_scope(this); | |
| 3767 // Note that because of NOT and an optimization in comparison of a typeof | 3766 // Note that because of NOT and an optimization in comparison of a typeof |
| 3768 // expression to a literal string, this function can fail to leave a value | 3767 // expression to a literal string, this function can fail to leave a value |
| 3769 // on top of the frame or in the cc register. | 3768 // on top of the frame or in the cc register. |
| 3770 Comment cmnt(masm_, "[ UnaryOperation"); | 3769 Comment cmnt(masm_, "[ UnaryOperation"); |
| 3771 | 3770 |
| 3772 Token::Value op = node->op(); | 3771 Token::Value op = node->op(); |
| 3773 | 3772 |
| 3774 if (op == Token::NOT) { | 3773 if (op == Token::NOT) { |
| 3774 VirtualFrame::SpilledScope spilled_scope(this); |
| 3775 LoadConditionAndSpill(node->expression(), NOT_INSIDE_TYPEOF, | 3775 LoadConditionAndSpill(node->expression(), NOT_INSIDE_TYPEOF, |
| 3776 false_target(), true_target(), true); | 3776 false_target(), true_target(), true); |
| 3777 cc_reg_ = NegateCondition(cc_reg_); | 3777 cc_reg_ = NegateCondition(cc_reg_); |
| 3778 | 3778 |
| 3779 } else if (op == Token::DELETE) { | 3779 } else if (op == Token::DELETE) { |
| 3780 VirtualFrame::SpilledScope spilled_scope(this); |
| 3780 Property* property = node->expression()->AsProperty(); | 3781 Property* property = node->expression()->AsProperty(); |
| 3781 if (property != NULL) { | 3782 if (property != NULL) { |
| 3782 LoadAndSpill(property->obj()); | 3783 LoadAndSpill(property->obj()); |
| 3783 LoadAndSpill(property->key()); | 3784 LoadAndSpill(property->key()); |
| 3784 frame_->InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, 2); | 3785 frame_->InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, 2); |
| 3785 frame_->EmitPush(eax); | 3786 frame_->EmitPush(eax); |
| 3786 return; | 3787 return; |
| 3787 } | 3788 } |
| 3788 | 3789 |
| 3789 Variable* variable = node->expression()->AsVariableProxy()->AsVariable(); | 3790 Variable* variable = node->expression()->AsVariableProxy()->AsVariable(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3813 // introduced variables is false. | 3814 // introduced variables is false. |
| 3814 frame_->EmitPush(Immediate(Factory::false_value())); | 3815 frame_->EmitPush(Immediate(Factory::false_value())); |
| 3815 | 3816 |
| 3816 } else { | 3817 } else { |
| 3817 // Default: Result of deleting expressions is true. | 3818 // Default: Result of deleting expressions is true. |
| 3818 LoadAndSpill(node->expression()); // may have side-effects | 3819 LoadAndSpill(node->expression()); // may have side-effects |
| 3819 __ Set(frame_->Top(), Immediate(Factory::true_value())); | 3820 __ Set(frame_->Top(), Immediate(Factory::true_value())); |
| 3820 } | 3821 } |
| 3821 | 3822 |
| 3822 } else if (op == Token::TYPEOF) { | 3823 } else if (op == Token::TYPEOF) { |
| 3824 VirtualFrame::SpilledScope spilled_scope(this); |
| 3823 // Special case for loading the typeof expression; see comment on | 3825 // Special case for loading the typeof expression; see comment on |
| 3824 // LoadTypeofExpression(). | 3826 // LoadTypeofExpression(). |
| 3825 LoadTypeofExpression(node->expression()); | 3827 LoadTypeofExpression(node->expression()); |
| 3826 frame_->CallRuntime(Runtime::kTypeof, 1); | 3828 frame_->CallRuntime(Runtime::kTypeof, 1); |
| 3827 frame_->EmitPush(eax); | 3829 frame_->EmitPush(eax); |
| 3828 | 3830 |
| 3829 } else { | 3831 } else { |
| 3830 LoadAndSpill(node->expression()); | 3832 Load(node->expression()); |
| 3831 switch (op) { | 3833 switch (op) { |
| 3832 case Token::NOT: | 3834 case Token::NOT: |
| 3833 case Token::DELETE: | 3835 case Token::DELETE: |
| 3834 case Token::TYPEOF: | 3836 case Token::TYPEOF: |
| 3835 UNREACHABLE(); // handled above | 3837 UNREACHABLE(); // handled above |
| 3836 break; | 3838 break; |
| 3837 | 3839 |
| 3838 case Token::SUB: { | 3840 case Token::SUB: { |
| 3841 VirtualFrame::SpilledScope spilled_scope(this); |
| 3839 UnarySubStub stub; | 3842 UnarySubStub stub; |
| 3840 // TODO(1222589): remove dependency of TOS being cached inside stub | 3843 // TODO(1222589): remove dependency of TOS being cached inside stub |
| 3841 frame_->EmitPop(eax); | 3844 frame_->EmitPop(eax); |
| 3842 frame_->CallStub(&stub, 0); | 3845 frame_->CallStub(&stub, 0); |
| 3843 frame_->EmitPush(eax); | 3846 frame_->EmitPush(eax); |
| 3844 break; | 3847 break; |
| 3845 } | 3848 } |
| 3846 | 3849 |
| 3847 case Token::BIT_NOT: { | 3850 case Token::BIT_NOT: { |
| 3851 VirtualFrame::SpilledScope spilled_scope(this); |
| 3848 // Smi check. | 3852 // Smi check. |
| 3849 JumpTarget smi_label(this); | 3853 JumpTarget smi_label(this); |
| 3850 JumpTarget continue_label(this); | 3854 JumpTarget continue_label(this); |
| 3851 frame_->EmitPop(eax); | 3855 frame_->EmitPop(eax); |
| 3852 __ test(eax, Immediate(kSmiTagMask)); | 3856 __ test(eax, Immediate(kSmiTagMask)); |
| 3853 smi_label.Branch(zero, taken); | 3857 smi_label.Branch(zero, taken); |
| 3854 | 3858 |
| 3855 frame_->EmitPush(eax); // undo popping of TOS | 3859 frame_->EmitPush(eax); // undo popping of TOS |
| 3856 frame_->InvokeBuiltin(Builtins::BIT_NOT, CALL_FUNCTION, 1); | 3860 frame_->InvokeBuiltin(Builtins::BIT_NOT, CALL_FUNCTION, 1); |
| 3857 | 3861 |
| 3858 continue_label.Jump(); | 3862 continue_label.Jump(); |
| 3859 smi_label.Bind(); | 3863 smi_label.Bind(); |
| 3860 __ not_(eax); | 3864 __ not_(eax); |
| 3861 __ and_(eax, ~kSmiTagMask); // Remove inverted smi-tag. | 3865 __ and_(eax, ~kSmiTagMask); // Remove inverted smi-tag. |
| 3862 continue_label.Bind(); | 3866 continue_label.Bind(); |
| 3863 frame_->EmitPush(eax); | 3867 frame_->EmitPush(eax); |
| 3864 break; | 3868 break; |
| 3865 } | 3869 } |
| 3866 | 3870 |
| 3867 case Token::VOID: | 3871 case Token::VOID: { |
| 3872 VirtualFrame::SpilledScope spilled_scope(this); |
| 3868 __ mov(frame_->Top(), Factory::undefined_value()); | 3873 __ mov(frame_->Top(), Factory::undefined_value()); |
| 3869 break; | 3874 break; |
| 3875 } |
| 3870 | 3876 |
| 3871 case Token::ADD: { | 3877 case Token::ADD: { |
| 3878 VirtualFrame::SpilledScope spilled_scope(this); |
| 3872 // Smi check. | 3879 // Smi check. |
| 3873 JumpTarget continue_label(this); | 3880 JumpTarget continue_label(this); |
| 3874 frame_->EmitPop(eax); | 3881 frame_->EmitPop(eax); |
| 3875 __ test(eax, Immediate(kSmiTagMask)); | 3882 __ test(eax, Immediate(kSmiTagMask)); |
| 3876 continue_label.Branch(zero); | 3883 continue_label.Branch(zero); |
| 3877 | 3884 |
| 3878 frame_->EmitPush(eax); | 3885 frame_->EmitPush(eax); |
| 3879 frame_->InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION, 1); | 3886 frame_->InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION, 1); |
| 3880 | 3887 |
| 3881 continue_label.Bind(); | 3888 continue_label.Bind(); |
| (...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6236 | 6243 |
| 6237 // Slow-case: Go through the JavaScript implementation. | 6244 // Slow-case: Go through the JavaScript implementation. |
| 6238 __ bind(&slow); | 6245 __ bind(&slow); |
| 6239 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 6246 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 6240 } | 6247 } |
| 6241 | 6248 |
| 6242 | 6249 |
| 6243 #undef __ | 6250 #undef __ |
| 6244 | 6251 |
| 6245 } } // namespace v8::internal | 6252 } } // namespace v8::internal |
| OLD | NEW |