OLD | NEW |
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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 EmitCallWithStub(expr); | 1693 EmitCallWithStub(expr); |
1694 } | 1694 } |
1695 } | 1695 } |
1696 | 1696 |
1697 | 1697 |
1698 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 1698 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
1699 Comment cmnt(masm_, "[ CallNew"); | 1699 Comment cmnt(masm_, "[ CallNew"); |
1700 // According to ECMA-262, section 11.2.2, page 44, the function | 1700 // According to ECMA-262, section 11.2.2, page 44, the function |
1701 // expression in new calls must be evaluated before the | 1701 // expression in new calls must be evaluated before the |
1702 // arguments. | 1702 // arguments. |
1703 // Push function on the stack. | 1703 |
| 1704 // Push constructor on the stack. If it's not a function it's used as |
| 1705 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
| 1706 // ignored. |
1704 VisitForValue(expr->expression(), kStack); | 1707 VisitForValue(expr->expression(), kStack); |
1705 | 1708 |
1706 // Push global object (receiver). | |
1707 __ push(CodeGenerator::GlobalObject()); | |
1708 | |
1709 // Push the arguments ("left-to-right") on the stack. | 1709 // Push the arguments ("left-to-right") on the stack. |
1710 ZoneList<Expression*>* args = expr->arguments(); | 1710 ZoneList<Expression*>* args = expr->arguments(); |
1711 int arg_count = args->length(); | 1711 int arg_count = args->length(); |
1712 for (int i = 0; i < arg_count; i++) { | 1712 for (int i = 0; i < arg_count; i++) { |
1713 VisitForValue(args->at(i), kStack); | 1713 VisitForValue(args->at(i), kStack); |
1714 } | 1714 } |
1715 | 1715 |
1716 // Call the construct call builtin that handles allocation and | 1716 // Call the construct call builtin that handles allocation and |
1717 // constructor invocation. | 1717 // constructor invocation. |
1718 SetSourcePosition(expr->position()); | 1718 SetSourcePosition(expr->position()); |
1719 | 1719 |
1720 // Load function, arg_count into edi and eax. | 1720 // Load function and argument count into edi and eax. |
1721 __ Set(eax, Immediate(arg_count)); | 1721 __ Set(eax, Immediate(arg_count)); |
1722 // Function is in esp[arg_count + 1]. | 1722 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
1723 __ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize)); | |
1724 | 1723 |
1725 Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall)); | 1724 Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall)); |
1726 __ call(construct_builtin, RelocInfo::CONSTRUCT_CALL); | 1725 __ call(construct_builtin, RelocInfo::CONSTRUCT_CALL); |
1727 | 1726 Apply(context_, eax); |
1728 // Replace function on TOS with result in eax, or pop it. | |
1729 DropAndApply(1, context_, eax); | |
1730 } | 1727 } |
1731 | 1728 |
1732 | 1729 |
1733 void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) { | 1730 void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) { |
1734 ASSERT(args->length() == 1); | 1731 ASSERT(args->length() == 1); |
1735 | 1732 |
1736 VisitForValue(args->at(0), kAccumulator); | 1733 VisitForValue(args->at(0), kAccumulator); |
1737 | 1734 |
1738 Label materialize_true, materialize_false; | 1735 Label materialize_true, materialize_false; |
1739 Label* if_true = NULL; | 1736 Label* if_true = NULL; |
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 // And return. | 3160 // And return. |
3164 __ ret(0); | 3161 __ ret(0); |
3165 } | 3162 } |
3166 | 3163 |
3167 | 3164 |
3168 #undef __ | 3165 #undef __ |
3169 | 3166 |
3170 } } // namespace v8::internal | 3167 } } // namespace v8::internal |
3171 | 3168 |
3172 #endif // V8_TARGET_ARCH_IA32 | 3169 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |