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

Side by Side Diff: src/ia32/fast-codegen-ia32.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/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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 CallFunctionStub stub(arg_count, NOT_IN_LOOP); 780 CallFunctionStub stub(arg_count, NOT_IN_LOOP);
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 Comment cmnt(masm_, "[ Call");
790 Expression* fun = expr->expression(); 791 Expression* fun = expr->expression();
791 Variable* var = fun->AsVariableProxy()->AsVariable(); 792 Variable* var = fun->AsVariableProxy()->AsVariable();
792 793
793 if (var != NULL && 794 if (var != NULL && var->is_possibly_eval()) {
794 var->is_possibly_eval()) { 795 // Call to the identifier 'eval'.
795 // Call to eval. 796 UNREACHABLE();
797 } else if (var != NULL && !var->is_this() && var->is_global()) {
798 // Call to a global variable.
799 __ push(Immediate(var->name()));
800 // Push global object as receiver for the call IC lookup.
801 __ push(CodeGenerator::GlobalObject());
802 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT);
803 } else if (var != NULL && var->slot() != NULL &&
804 var->slot()->type() == Slot::LOOKUP) {
805 // Call to a lookup slot.
796 UNREACHABLE(); 806 UNREACHABLE();
797 } else if (fun->AsProperty() != NULL) { 807 } else if (fun->AsProperty() != NULL) {
798 // Call on a property. 808 // Call to an object property.
799 Property* prop = fun->AsProperty(); 809 Property* prop = fun->AsProperty();
800 Literal* key = prop->key()->AsLiteral(); 810 Literal* key = prop->key()->AsLiteral();
801 if (key != NULL && key->handle()->IsSymbol()) { 811 if (key != NULL && key->handle()->IsSymbol()) {
802 // Call on a named property: foo.x(1,2,3) 812 // Call to a named property, use call IC.
803 __ push(Immediate(key->handle())); 813 __ push(Immediate(key->handle()));
804 Visit(prop->obj()); 814 Visit(prop->obj());
805 // Use call IC.
806 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); 815 EmitCallWithIC(expr, RelocInfo::CODE_TARGET);
807 } else { 816 } else {
808 // Call on a keyed property: foo[key](1,2,3) 817 // Call to a keyed property, use keyed load IC followed by function
809 // Use a keyed load IC followed by a call IC. 818 // call.
810 Visit(prop->obj()); 819 Visit(prop->obj());
811 Visit(prop->key()); 820 Visit(prop->key());
812 // Record source position of property. 821 // Record source code position for IC call.
813 SetSourcePosition(prop->position()); 822 SetSourcePosition(prop->position());
814 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 823 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
815 __ call(ic, RelocInfo::CODE_TARGET); 824 __ call(ic, RelocInfo::CODE_TARGET);
816 // By emitting a nop we make sure that we do not have a "test eax,..." 825 // By emitting a nop we make sure that we do not have a "test eax,..."
817 // instruction after the call it is treated specially by the LoadIC code. 826 // instruction after the call it is treated specially by the LoadIC code.
818 __ nop(); 827 __ nop();
819 // Drop key left on the stack by IC. 828 // Drop key left on the stack by IC.
820 __ add(Operand(esp), Immediate(kPointerSize)); 829 __ add(Operand(esp), Immediate(kPointerSize));
821 // Pop receiver. 830 // Pop receiver.
822 __ pop(ebx); 831 __ pop(ebx);
823 // Push result (function). 832 // Push result (function).
824 __ push(eax); 833 __ push(eax);
825 // Push receiver object on stack. 834 // Push receiver object on stack.
826 if (prop->is_synthetic()) { 835 if (prop->is_synthetic()) {
827 __ push(CodeGenerator::GlobalObject()); 836 __ push(CodeGenerator::GlobalObject());
828 } else { 837 } else {
829 __ push(ebx); 838 __ push(ebx);
830 } 839 }
831 EmitCallWithStub(expr); 840 EmitCallWithStub(expr);
832 } 841 }
833 } else if (var != NULL) {
834 // Call on a global variable
835 ASSERT(var != NULL);
836 ASSERT(!var->is_this());
837 ASSERT(var->is_global());
838 ASSERT(!var->is_possibly_eval());
839 __ push(Immediate(var->name()));
840 // Push global object (receiver).
841 __ push(CodeGenerator::GlobalObject());
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();
847 } else { 842 } else {
848 // Call with an arbitrary function expression. 843 // Call to some other function expression.
849 Visit(expr->expression()); 844 Visit(expr->expression());
850 // Load global receiver object. 845 // Load global receiver object.
851 __ mov(ebx, CodeGenerator::GlobalObject()); 846 __ mov(ebx, CodeGenerator::GlobalObject());
852 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); 847 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
853 // Emit function call. 848 // Emit function call.
854 EmitCallWithStub(expr); 849 EmitCallWithStub(expr);
855 } 850 }
856 } 851 }
857 852
858 void FastCodeGenerator::VisitCallNew(CallNew* expr) { 853 void FastCodeGenerator::VisitCallNew(CallNew* expr) {
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 true_label_ = saved_true; 1274 true_label_ = saved_true;
1280 false_label_ = saved_false; 1275 false_label_ = saved_false;
1281 // Convert current context to test context: End post-test code. 1276 // Convert current context to test context: End post-test code.
1282 } 1277 }
1283 1278
1284 1279
1285 #undef __ 1280 #undef __
1286 1281
1287 1282
1288 } } // namespace v8::internal 1283 } } // 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