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

Side by Side Diff: src/arm/fast-codegen-arm.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 | « no previous file | src/compiler.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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 __ CallStub(&stub); 758 __ CallStub(&stub);
759 // Restore context register. 759 // Restore context register.
760 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 760 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
761 // Discard the function left on TOS. 761 // Discard the function left on TOS.
762 DropAndMove(expr->context(), r0); 762 DropAndMove(expr->context(), r0);
763 } 763 }
764 764
765 765
766 void FastCodeGenerator::VisitCall(Call* expr) { 766 void FastCodeGenerator::VisitCall(Call* expr) {
767 Expression* fun = expr->expression(); 767 Expression* fun = expr->expression();
768 Variable* var = fun->AsVariableProxy()->AsVariable();
768 769
769 if (fun->AsProperty() != NULL) { 770 if (var != NULL &&
771 var->is_possibly_eval()) {
772 // Call to eval.
773 UNREACHABLE();
774 } else if (fun->AsProperty() != NULL) {
770 // Call on a property. 775 // Call on a property.
771 Property* prop = fun->AsProperty(); 776 Property* prop = fun->AsProperty();
772 Literal* key = prop->key()->AsLiteral(); 777 Literal* key = prop->key()->AsLiteral();
773 if (key != NULL && key->handle()->IsSymbol()) { 778 if (key != NULL && key->handle()->IsSymbol()) {
774 // Call on a named property: foo.x(1,2,3) 779 // Call on a named property: foo.x(1,2,3)
775 __ mov(r0, Operand(key->handle())); 780 __ mov(r0, Operand(key->handle()));
776 __ push(r0); 781 __ push(r0);
777 Visit(prop->obj()); 782 Visit(prop->obj());
778 // Use call IC. 783 // Use call IC.
779 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); 784 EmitCallWithIC(expr, RelocInfo::CODE_TARGET);
(...skipping 10 matching lines...) Expand all
790 if (prop->is_synthetic()) { 795 if (prop->is_synthetic()) {
791 __ ldr(r1, CodeGenerator::GlobalObject()); 796 __ ldr(r1, CodeGenerator::GlobalObject());
792 } else { 797 } else {
793 __ ldr(r1, MemOperand(sp, kPointerSize)); 798 __ ldr(r1, MemOperand(sp, kPointerSize));
794 } 799 }
795 // Overwrite (object, key) with (function, receiver). 800 // Overwrite (object, key) with (function, receiver).
796 __ str(r0, MemOperand(sp, kPointerSize)); 801 __ str(r0, MemOperand(sp, kPointerSize));
797 __ str(r1, MemOperand(sp)); 802 __ str(r1, MemOperand(sp));
798 EmitCallWithStub(expr); 803 EmitCallWithStub(expr);
799 } 804 }
800 } else if (fun->AsVariableProxy()->AsVariable() != NULL) { 805 } else if (var != NULL) {
801 // Call on a global variable 806 // Call on a global variable
802 Variable* var = fun->AsVariableProxy()->AsVariable();
803 ASSERT(var != NULL && !var->is_this() && var->is_global()); 807 ASSERT(var != NULL && !var->is_this() && var->is_global());
804 ASSERT(!var->is_possibly_eval()); 808 ASSERT(!var->is_possibly_eval());
805 __ mov(r1, Operand(var->name())); 809 __ mov(r1, Operand(var->name()));
806 // Push global object as receiver. 810 // Push global object as receiver.
807 __ ldr(r0, CodeGenerator::GlobalObject()); 811 __ ldr(r0, CodeGenerator::GlobalObject());
808 __ stm(db_w, sp, r1.bit() | r0.bit()); 812 __ stm(db_w, sp, r1.bit() | r0.bit());
809 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); 813 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT);
814 } else if (var != NULL && var->slot() != NULL &&
815 var->slot()->type() == Slot::LOOKUP) {
816 // Call inside a with-statement
817 UNREACHABLE();
810 } else { 818 } else {
811 // Calls we cannot handle right now. 819 // Call with an arbitrary function expression.
812 // Should bailout in the CodeGenSelector. 820 Visit(expr->expression());
813 UNREACHABLE(); 821 // Load global receiver object.
822 __ ldr(r1, CodeGenerator::GlobalObject());
823 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
824 __ push(r1);
825 // Emit function call.
826 EmitCallWithStub(expr);
814 } 827 }
815 } 828 }
816 829
817 830
818 void FastCodeGenerator::VisitCallNew(CallNew* expr) { 831 void FastCodeGenerator::VisitCallNew(CallNew* expr) {
819 Comment cmnt(masm_, "[ CallNew"); 832 Comment cmnt(masm_, "[ CallNew");
820 // According to ECMA-262, section 11.2.2, page 44, the function 833 // According to ECMA-262, section 11.2.2, page 44, the function
821 // expression in new calls must be evaluated before the 834 // expression in new calls must be evaluated before the
822 // arguments. 835 // arguments.
823 // Push function on the stack. 836 // Push function on the stack.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1099
1087 break; 1100 break;
1088 } 1101 }
1089 default: 1102 default:
1090 UNREACHABLE(); 1103 UNREACHABLE();
1091 } 1104 }
1092 } 1105 }
1093 1106
1094 1107
1095 } } // namespace v8::internal 1108 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698