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

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

Issue 346029: Support for function calls on an arbitrary expression that returns... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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/compiler.cc ('k') | src/x64/fast-codegen-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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 __ CallStub(&stub); 781 __ CallStub(&stub);
782 // Restore context register. 782 // Restore context register.
783 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 783 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
784 // Discard the function left on TOS. 784 // Discard the function left on TOS.
785 DropAndMove(expr->context(), eax); 785 DropAndMove(expr->context(), eax);
786 } 786 }
787 787
788 788
789 void FastCodeGenerator::VisitCall(Call* expr) { 789 void FastCodeGenerator::VisitCall(Call* expr) {
790 Expression* fun = expr->expression(); 790 Expression* fun = expr->expression();
791 Variable* var = fun->AsVariableProxy()->AsVariable();
791 792
792 if (fun->AsProperty() != NULL) { 793 if (var != NULL &&
794 var->is_possibly_eval()) {
795 // Call to eval.
796 UNREACHABLE();
797 } else if (fun->AsProperty() != NULL) {
793 // Call on a property. 798 // Call on a property.
794 Property* prop = fun->AsProperty(); 799 Property* prop = fun->AsProperty();
795 Literal* key = prop->key()->AsLiteral(); 800 Literal* key = prop->key()->AsLiteral();
796 if (key != NULL && key->handle()->IsSymbol()) { 801 if (key != NULL && key->handle()->IsSymbol()) {
797 // Call on a named property: foo.x(1,2,3) 802 // Call on a named property: foo.x(1,2,3)
798 __ push(Immediate(key->handle())); 803 __ push(Immediate(key->handle()));
799 Visit(prop->obj()); 804 Visit(prop->obj());
800 // Use call IC. 805 // Use call IC.
801 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); 806 EmitCallWithIC(expr, RelocInfo::CODE_TARGET);
802 } else { 807 } else {
(...skipping 15 matching lines...) Expand all
818 // Push result (function). 823 // Push result (function).
819 __ push(eax); 824 __ push(eax);
820 // Push receiver object on stack. 825 // Push receiver object on stack.
821 if (prop->is_synthetic()) { 826 if (prop->is_synthetic()) {
822 __ push(CodeGenerator::GlobalObject()); 827 __ push(CodeGenerator::GlobalObject());
823 } else { 828 } else {
824 __ push(ebx); 829 __ push(ebx);
825 } 830 }
826 EmitCallWithStub(expr); 831 EmitCallWithStub(expr);
827 } 832 }
828 } else if (fun->AsVariableProxy()->AsVariable() != NULL) { 833 } else if (var != NULL) {
829 // Call on a global variable 834 // Call on a global variable
830 Variable* var = fun->AsVariableProxy()->AsVariable(); 835 ASSERT(var != NULL);
831 ASSERT(var != NULL && !var->is_this() && var->is_global()); 836 ASSERT(!var->is_this());
837 ASSERT(var->is_global());
832 ASSERT(!var->is_possibly_eval()); 838 ASSERT(!var->is_possibly_eval());
833 __ push(Immediate(var->name())); 839 __ push(Immediate(var->name()));
834 // Push global object (receiver). 840 // Push global object (receiver).
835 __ push(CodeGenerator::GlobalObject()); 841 __ push(CodeGenerator::GlobalObject());
836 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); 842 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT);
843 } else if (var != NULL && var->slot() != NULL &&
844 var->slot()->type() == Slot::LOOKUP) {
845 // Call inside a with-statement
846 UNREACHABLE();
837 } else { 847 } else {
838 // Calls we cannot handle right now. 848 // Call with an arbitrary function expression.
839 // Should bailout in the CodeGenSelector. 849 Visit(expr->expression());
840 UNREACHABLE(); 850 // Load global receiver object.
851 __ mov(ebx, CodeGenerator::GlobalObject());
852 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
853 // Emit function call.
854 EmitCallWithStub(expr);
841 } 855 }
842 } 856 }
843 857
844 void FastCodeGenerator::VisitCallNew(CallNew* expr) { 858 void FastCodeGenerator::VisitCallNew(CallNew* expr) {
845 Comment cmnt(masm_, "[ CallNew"); 859 Comment cmnt(masm_, "[ CallNew");
846 // According to ECMA-262, section 11.2.2, page 44, the function 860 // According to ECMA-262, section 11.2.2, page 44, the function
847 // expression in new calls must be evaluated before the 861 // expression in new calls must be evaluated before the
848 // arguments. 862 // arguments.
849 // Push function on the stack. 863 // Push function on the stack.
850 Visit(expr->expression()); 864 Visit(expr->expression());
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 default: 1121 default:
1108 UNREACHABLE(); 1122 UNREACHABLE();
1109 } 1123 }
1110 } 1124 }
1111 1125
1112 1126
1113 #undef __ 1127 #undef __
1114 1128
1115 1129
1116 } } // namespace v8::internal 1130 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/x64/fast-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698