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

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

Issue 355009: Fix a latent bug in the top-level compilation of function calls.... (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/ia32/fast-codegen-ia32.cc ('k') | no next file » | 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 CallFunctionStub stub(arg_count, NOT_IN_LOOP); 795 CallFunctionStub stub(arg_count, NOT_IN_LOOP);
796 __ CallStub(&stub); 796 __ CallStub(&stub);
797 // Restore context register. 797 // Restore context register.
798 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 798 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
799 // Discard the function left on TOS. 799 // Discard the function left on TOS.
800 DropAndMove(expr->context(), rax); 800 DropAndMove(expr->context(), rax);
801 } 801 }
802 802
803 803
804 void FastCodeGenerator::VisitCall(Call* expr) { 804 void FastCodeGenerator::VisitCall(Call* expr) {
805 Comment cmnt(masm_, "[ Call");
805 Expression* fun = expr->expression(); 806 Expression* fun = expr->expression();
806 Variable* var = fun->AsVariableProxy()->AsVariable(); 807 Variable* var = fun->AsVariableProxy()->AsVariable();
807 808
808 if (var != NULL && 809 if (var != NULL && var->is_possibly_eval()) {
809 var->is_possibly_eval()) { 810 // Call to the identifier 'eval'.
810 // Call to eval. 811 UNREACHABLE();
812 } else if (var != NULL && !var->is_this() && var->is_global()) {
813 // Call to a global variable.
814 __ Push(var->name());
815 // Push global object as receiver for the call IC lookup.
816 __ push(CodeGenerator::GlobalObject());
817 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT);
818 } else if (var != NULL && var->slot() != NULL &&
819 var->slot()->type() == Slot::LOOKUP) {
820 // Call to a lookup slot.
811 UNREACHABLE(); 821 UNREACHABLE();
812 } else if (fun->AsProperty() != NULL) { 822 } else if (fun->AsProperty() != NULL) {
813 // Call on a property. 823 // Call to an object property.
814 Property* prop = fun->AsProperty(); 824 Property* prop = fun->AsProperty();
815 Literal* key = prop->key()->AsLiteral(); 825 Literal* key = prop->key()->AsLiteral();
816 if (key != NULL && key->handle()->IsSymbol()) { 826 if (key != NULL && key->handle()->IsSymbol()) {
817 // Call on a named property: foo.x(1,2,3) 827 // Call to a named property, use call IC.
818 __ Push(key->handle()); 828 __ Push(key->handle());
819 Visit(prop->obj()); 829 Visit(prop->obj());
820 // Use call IC
821 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); 830 EmitCallWithIC(expr, RelocInfo::CODE_TARGET);
822 } else { 831 } else {
823 // Call on a keyed property: foo[key](1,2,3) 832 // Call to a keyed property, use keyed load IC followed by function
824 // Use a keyed load IC followed by a call IC. 833 // call.
825 Visit(prop->obj()); 834 Visit(prop->obj());
826 Visit(prop->key()); 835 Visit(prop->key());
827 // Record source position of property. 836 // Record source code position for IC call.
828 SetSourcePosition(prop->position()); 837 SetSourcePosition(prop->position());
829 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 838 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
830 __ call(ic, RelocInfo::CODE_TARGET); 839 __ call(ic, RelocInfo::CODE_TARGET);
831 // By emitting a nop we make sure that we do not have a "test eax,..." 840 // By emitting a nop we make sure that we do not have a "test eax,..."
832 // instruction after the call it is treated specially by the LoadIC code. 841 // instruction after the call it is treated specially by the LoadIC code.
833 __ nop(); 842 __ nop();
834 // Drop key left on the stack by IC. 843 // Drop key left on the stack by IC.
835 __ addq(rsp, Immediate(kPointerSize)); 844 __ addq(rsp, Immediate(kPointerSize));
836 // Pop receiver. 845 // Pop receiver.
837 __ pop(rbx); 846 __ pop(rbx);
838 // Push result (function). 847 // Push result (function).
839 __ push(rax); 848 __ push(rax);
840 // Push receiver object on stack. 849 // Push receiver object on stack.
841 if (prop->is_synthetic()) { 850 if (prop->is_synthetic()) {
842 __ push(CodeGenerator::GlobalObject()); 851 __ push(CodeGenerator::GlobalObject());
843 } else { 852 } else {
844 __ push(rbx); 853 __ push(rbx);
845 } 854 }
846 EmitCallWithStub(expr); 855 EmitCallWithStub(expr);
847 } 856 }
848 } else if (var != NULL) {
849 // Call on a global variable
850 ASSERT(var != NULL && !var->is_this() && var->is_global());
851 ASSERT(!var->is_possibly_eval());
852 __ Push(var->name());
853 // Push global object (receiver).
854 __ push(CodeGenerator::GlobalObject());
855 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT);
856 } else if (var != NULL && var->slot() != NULL &&
857 var->slot()->type() == Slot::LOOKUP) {
858 // Call inside a with-statement
859 UNREACHABLE();
860 } else { 857 } else {
861 // Call with an arbitrary function expression. 858 // Call to some other function expression.
862 Visit(expr->expression()); 859 Visit(expr->expression());
863 // Load global receiver object. 860 // Load global receiver object.
864 __ movq(rbx, CodeGenerator::GlobalObject()); 861 __ movq(rbx, CodeGenerator::GlobalObject());
865 __ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); 862 __ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
866 // Emit function call. 863 // Emit function call.
867 EmitCallWithStub(expr); 864 EmitCallWithStub(expr);
868 } 865 }
869 } 866 }
870 867
871 868
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 true_label_ = saved_true; 1287 true_label_ = saved_true;
1291 false_label_ = saved_false; 1288 false_label_ = saved_false;
1292 // Convert current context to test context: End post-test code. 1289 // Convert current context to test context: End post-test code.
1293 } 1290 }
1294 1291
1295 1292
1296 #undef __ 1293 #undef __
1297 1294
1298 1295
1299 } } // namespace v8::internal 1296 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/fast-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698