Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 6879081: Added type recording for unary minus and unary bitwise negation. Note that the (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Hopefully final version of this patch... Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
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...
fschneider 2011/04/26 13:32:52 It's a little complicated to do, since format stri
Sven Panne 2011/04/27 00:45:54 I thought about using something like vsnprintf in
fschneider 2011/04/27 11:34:36 As Kevin said, we do something similar in Cranksha
Sven Panne 2011/04/27 17:19:31 OK, I'll have a look, especially if the change is
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());
fschneider 2011/04/26 13:32:52 You need to call here: SetSourcePosition(expr->po
Sven Panne 2011/04/27 00:45:54 Done, for x64 and ARM, too. Why is Expression::po
fschneider 2011/04/27 11:34:36 I agree that it would be a good idea to make it ab
Sven Panne 2011/04/27 17:19:31 I'll investigate this later, and I wanted to do th
3753 __ CallStub(&stub);
fschneider 2011/04/26 13:32:52 You should use here: EmitCallIC(stub.GetCode(), N
Sven Panne 2011/04/27 00:45:54 I have to admit that I still don't understand this
fschneider 2011/04/27 11:34:36 Have a look at uses of JumpPatchSite for BinaryOpe
Sven Panne 2011/04/27 17:19:31 OK, I'll keep this in mind...
3754 context()->Plug(eax);
3755 }
3756
3757
3777 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { 3758 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
3778 Comment cmnt(masm_, "[ CountOperation"); 3759 Comment cmnt(masm_, "[ CountOperation");
3779 SetSourcePosition(expr->position()); 3760 SetSourcePosition(expr->position());
3780 3761
3781 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' 3762 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
3782 // as the left-hand side. 3763 // as the left-hand side.
3783 if (!expr->expression()->IsValidLeftHandSide()) { 3764 if (!expr->expression()->IsValidLeftHandSide()) {
3784 VisitForEffect(expr->expression()); 3765 VisitForEffect(expr->expression());
3785 return; 3766 return;
3786 } 3767 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
4323 // And return. 4304 // And return.
4324 __ ret(0); 4305 __ ret(0);
4325 } 4306 }
4326 4307
4327 4308
4328 #undef __ 4309 #undef __
4329 4310
4330 } } // namespace v8::internal 4311 } } // namespace v8::internal
4331 4312
4332 #endif // V8_TARGET_ARCH_IA32 4313 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698