| OLD | NEW |
| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 CallFunctionStub stub(arg_count, NOT_IN_LOOP); | 762 CallFunctionStub stub(arg_count, NOT_IN_LOOP); |
| 763 __ CallStub(&stub); | 763 __ CallStub(&stub); |
| 764 // Restore context register. | 764 // Restore context register. |
| 765 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 765 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 766 // Discard the function left on TOS. | 766 // Discard the function left on TOS. |
| 767 DropAndMove(expr->context(), r0); | 767 DropAndMove(expr->context(), r0); |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 void FastCodeGenerator::VisitCall(Call* expr) { | 771 void FastCodeGenerator::VisitCall(Call* expr) { |
| 772 Comment cmnt(masm_, "[ Call"); |
| 772 Expression* fun = expr->expression(); | 773 Expression* fun = expr->expression(); |
| 773 Variable* var = fun->AsVariableProxy()->AsVariable(); | 774 Variable* var = fun->AsVariableProxy()->AsVariable(); |
| 774 | 775 |
| 775 if (var != NULL && | 776 if (var != NULL && var->is_possibly_eval()) { |
| 776 var->is_possibly_eval()) { | 777 // Call to the identifier 'eval'. |
| 777 // Call to eval. | 778 UNREACHABLE(); |
| 779 } else if (var != NULL && !var->is_this() && var->is_global()) { |
| 780 // Call to a global variable. |
| 781 __ mov(r1, Operand(var->name())); |
| 782 // Push global object as receiver for the call IC lookup. |
| 783 __ ldr(r0, CodeGenerator::GlobalObject()); |
| 784 __ stm(db_w, sp, r1.bit() | r0.bit()); |
| 785 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); |
| 786 } else if (var != NULL && var->slot() != NULL && |
| 787 var->slot()->type() == Slot::LOOKUP) { |
| 788 // Call to a lookup slot. |
| 778 UNREACHABLE(); | 789 UNREACHABLE(); |
| 779 } else if (fun->AsProperty() != NULL) { | 790 } else if (fun->AsProperty() != NULL) { |
| 780 // Call on a property. | 791 // Call to an object property. |
| 781 Property* prop = fun->AsProperty(); | 792 Property* prop = fun->AsProperty(); |
| 782 Literal* key = prop->key()->AsLiteral(); | 793 Literal* key = prop->key()->AsLiteral(); |
| 783 if (key != NULL && key->handle()->IsSymbol()) { | 794 if (key != NULL && key->handle()->IsSymbol()) { |
| 784 // Call on a named property: foo.x(1,2,3) | 795 // Call to a named property, use call IC. |
| 785 __ mov(r0, Operand(key->handle())); | 796 __ mov(r0, Operand(key->handle())); |
| 786 __ push(r0); | 797 __ push(r0); |
| 787 Visit(prop->obj()); | 798 Visit(prop->obj()); |
| 788 // Use call IC. | |
| 789 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); | 799 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); |
| 790 } else { | 800 } else { |
| 791 // Call on a keyed property : foo[key](1,2,3) | 801 // Call to a keyed property, use keyed load IC followed by function |
| 792 // Use a keyed load IC followed by a call IC. | 802 // call. |
| 793 Visit(prop->obj()); | 803 Visit(prop->obj()); |
| 794 Visit(prop->key()); | 804 Visit(prop->key()); |
| 795 // Record source position of property. | 805 // Record source code position for IC call. |
| 796 SetSourcePosition(prop->position()); | 806 SetSourcePosition(prop->position()); |
| 797 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 807 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 798 __ Call(ic, RelocInfo::CODE_TARGET); | 808 __ Call(ic, RelocInfo::CODE_TARGET); |
| 799 // Load receiver object into r1. | 809 // Load receiver object into r1. |
| 800 if (prop->is_synthetic()) { | 810 if (prop->is_synthetic()) { |
| 801 __ ldr(r1, CodeGenerator::GlobalObject()); | 811 __ ldr(r1, CodeGenerator::GlobalObject()); |
| 802 } else { | 812 } else { |
| 803 __ ldr(r1, MemOperand(sp, kPointerSize)); | 813 __ ldr(r1, MemOperand(sp, kPointerSize)); |
| 804 } | 814 } |
| 805 // Overwrite (object, key) with (function, receiver). | 815 // Overwrite (object, key) with (function, receiver). |
| 806 __ str(r0, MemOperand(sp, kPointerSize)); | 816 __ str(r0, MemOperand(sp, kPointerSize)); |
| 807 __ str(r1, MemOperand(sp)); | 817 __ str(r1, MemOperand(sp)); |
| 808 EmitCallWithStub(expr); | 818 EmitCallWithStub(expr); |
| 809 } | 819 } |
| 810 } else if (var != NULL) { | |
| 811 // Call on a global variable | |
| 812 ASSERT(var != NULL && !var->is_this() && var->is_global()); | |
| 813 ASSERT(!var->is_possibly_eval()); | |
| 814 __ mov(r1, Operand(var->name())); | |
| 815 // Push global object as receiver. | |
| 816 __ ldr(r0, CodeGenerator::GlobalObject()); | |
| 817 __ stm(db_w, sp, r1.bit() | r0.bit()); | |
| 818 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); | |
| 819 } else if (var != NULL && var->slot() != NULL && | |
| 820 var->slot()->type() == Slot::LOOKUP) { | |
| 821 // Call inside a with-statement | |
| 822 UNREACHABLE(); | |
| 823 } else { | 820 } else { |
| 824 // Call with an arbitrary function expression. | 821 // Call to some other function expression. |
| 825 Visit(expr->expression()); | 822 Visit(expr->expression()); |
| 826 // Load global receiver object. | 823 // Load global receiver object. |
| 827 __ ldr(r1, CodeGenerator::GlobalObject()); | 824 __ ldr(r1, CodeGenerator::GlobalObject()); |
| 828 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); | 825 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); |
| 829 __ push(r1); | 826 __ push(r1); |
| 830 // Emit function call. | 827 // Emit function call. |
| 831 EmitCallWithStub(expr); | 828 EmitCallWithStub(expr); |
| 832 } | 829 } |
| 833 } | 830 } |
| 834 | 831 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 true_label_ = saved_true; | 1266 true_label_ = saved_true; |
| 1270 false_label_ = saved_false; | 1267 false_label_ = saved_false; |
| 1271 // Convert current context to test context: End post-test code. | 1268 // Convert current context to test context: End post-test code. |
| 1272 } | 1269 } |
| 1273 | 1270 |
| 1274 | 1271 |
| 1275 #undef __ | 1272 #undef __ |
| 1276 | 1273 |
| 1277 | 1274 |
| 1278 } } // namespace v8::internal | 1275 } } // namespace v8::internal |
| OLD | NEW |