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

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

Issue 3136032: Simplify the way constructors are called and avoid pushing... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 3 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
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | src/x64/virtual-frame-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 EmitCallWithStub(expr); 1702 EmitCallWithStub(expr);
1703 } 1703 }
1704 } 1704 }
1705 1705
1706 1706
1707 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 1707 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
1708 Comment cmnt(masm_, "[ CallNew"); 1708 Comment cmnt(masm_, "[ CallNew");
1709 // According to ECMA-262, section 11.2.2, page 44, the function 1709 // According to ECMA-262, section 11.2.2, page 44, the function
1710 // expression in new calls must be evaluated before the 1710 // expression in new calls must be evaluated before the
1711 // arguments. 1711 // arguments.
1712 // Push function on the stack. 1712
1713 // Push constructor on the stack. If it's not a function it's used as
1714 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
1715 // ignored.
1713 VisitForValue(expr->expression(), kStack); 1716 VisitForValue(expr->expression(), kStack);
1714 1717
1715 // Push global object (receiver).
1716 __ push(CodeGenerator::GlobalObject());
1717
1718 // Push the arguments ("left-to-right") on the stack. 1718 // Push the arguments ("left-to-right") on the stack.
1719 ZoneList<Expression*>* args = expr->arguments(); 1719 ZoneList<Expression*>* args = expr->arguments();
1720 int arg_count = args->length(); 1720 int arg_count = args->length();
1721 for (int i = 0; i < arg_count; i++) { 1721 for (int i = 0; i < arg_count; i++) {
1722 VisitForValue(args->at(i), kStack); 1722 VisitForValue(args->at(i), kStack);
1723 } 1723 }
1724 1724
1725 // Call the construct call builtin that handles allocation and 1725 // Call the construct call builtin that handles allocation and
1726 // constructor invocation. 1726 // constructor invocation.
1727 SetSourcePosition(expr->position()); 1727 SetSourcePosition(expr->position());
1728 1728
1729 // Load function, arg_count into rdi and rax. 1729 // Load function and argument count into rdi and rax.
1730 __ Set(rax, arg_count); 1730 __ Set(rax, arg_count);
1731 // Function is in rsp[arg_count + 1]. 1731 __ movq(rdi, Operand(rsp, arg_count * kPointerSize));
1732 __ movq(rdi, Operand(rsp, rax, times_pointer_size, kPointerSize));
1733 1732
1734 Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall)); 1733 Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall));
1735 __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL); 1734 __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
1736 1735 Apply(context_, rax);
1737 // Replace function on TOS with result in rax, or pop it.
1738 DropAndApply(1, context_, rax);
1739 } 1736 }
1740 1737
1741 1738
1742 void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) { 1739 void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
1743 ASSERT(args->length() == 1); 1740 ASSERT(args->length() == 1);
1744 1741
1745 VisitForValue(args->at(0), kAccumulator); 1742 VisitForValue(args->at(0), kAccumulator);
1746 1743
1747 Label materialize_true, materialize_false; 1744 Label materialize_true, materialize_false;
1748 Label* if_true = NULL; 1745 Label* if_true = NULL;
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 __ ret(0); 3153 __ ret(0);
3157 } 3154 }
3158 3155
3159 3156
3160 #undef __ 3157 #undef __
3161 3158
3162 3159
3163 } } // namespace v8::internal 3160 } } // namespace v8::internal
3164 3161
3165 #endif // V8_TARGET_ARCH_X64 3162 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | src/x64/virtual-frame-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698