| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 __ CallStub(&stub); | 795 __ CallStub(&stub); |
| 796 // Restore context register. | 796 // Restore context register. |
| 797 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 797 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 798 // Discard the function left on TOS. | 798 // Discard the function left on TOS. |
| 799 DropAndMove(expr->context(), rax); | 799 DropAndMove(expr->context(), rax); |
| 800 } | 800 } |
| 801 | 801 |
| 802 | 802 |
| 803 void FastCodeGenerator::VisitCall(Call* expr) { | 803 void FastCodeGenerator::VisitCall(Call* expr) { |
| 804 Expression* fun = expr->expression(); | 804 Expression* fun = expr->expression(); |
| 805 Variable* var = fun->AsVariableProxy()->AsVariable(); |
| 805 | 806 |
| 806 if (fun->AsProperty() != NULL) { | 807 if (var != NULL && |
| 808 var->is_possibly_eval()) { |
| 809 // Call to eval. |
| 810 UNREACHABLE(); |
| 811 } else if (fun->AsProperty() != NULL) { |
| 807 // Call on a property. | 812 // Call on a property. |
| 808 Property* prop = fun->AsProperty(); | 813 Property* prop = fun->AsProperty(); |
| 809 Literal* key = prop->key()->AsLiteral(); | 814 Literal* key = prop->key()->AsLiteral(); |
| 810 if (key != NULL && key->handle()->IsSymbol()) { | 815 if (key != NULL && key->handle()->IsSymbol()) { |
| 811 // Call on a named property: foo.x(1,2,3) | 816 // Call on a named property: foo.x(1,2,3) |
| 812 __ Push(key->handle()); | 817 __ Push(key->handle()); |
| 813 Visit(prop->obj()); | 818 Visit(prop->obj()); |
| 814 // Use call IC | 819 // Use call IC |
| 815 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); | 820 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); |
| 816 } else { | 821 } else { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 832 // Push result (function). | 837 // Push result (function). |
| 833 __ push(rax); | 838 __ push(rax); |
| 834 // Push receiver object on stack. | 839 // Push receiver object on stack. |
| 835 if (prop->is_synthetic()) { | 840 if (prop->is_synthetic()) { |
| 836 __ push(CodeGenerator::GlobalObject()); | 841 __ push(CodeGenerator::GlobalObject()); |
| 837 } else { | 842 } else { |
| 838 __ push(rbx); | 843 __ push(rbx); |
| 839 } | 844 } |
| 840 EmitCallWithStub(expr); | 845 EmitCallWithStub(expr); |
| 841 } | 846 } |
| 842 } else if (fun->AsVariableProxy()->AsVariable() != NULL) { | 847 } else if (var != NULL) { |
| 843 // Call on a global variable | 848 // Call on a global variable |
| 844 Variable* var = fun->AsVariableProxy()->AsVariable(); | |
| 845 ASSERT(var != NULL && !var->is_this() && var->is_global()); | 849 ASSERT(var != NULL && !var->is_this() && var->is_global()); |
| 846 ASSERT(!var->is_possibly_eval()); | 850 ASSERT(!var->is_possibly_eval()); |
| 847 __ Push(var->name()); | 851 __ Push(var->name()); |
| 848 // Push global object (receiver). | 852 // Push global object (receiver). |
| 849 __ push(CodeGenerator::GlobalObject()); | 853 __ push(CodeGenerator::GlobalObject()); |
| 850 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); | 854 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); |
| 855 } else if (var != NULL && var->slot() != NULL && |
| 856 var->slot()->type() == Slot::LOOKUP) { |
| 857 // Call inside a with-statement |
| 858 UNREACHABLE(); |
| 851 } else { | 859 } else { |
| 852 // Calls we cannot handle right now. | 860 // Call with an arbitrary function expression. |
| 853 // Should bailout in the CodeGenSelector. | 861 Visit(expr->expression()); |
| 854 UNREACHABLE(); | 862 // Load global receiver object. |
| 863 __ movq(rbx, CodeGenerator::GlobalObject()); |
| 864 __ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
| 865 // Emit function call. |
| 866 EmitCallWithStub(expr); |
| 855 } | 867 } |
| 856 } | 868 } |
| 857 | 869 |
| 858 | 870 |
| 859 void FastCodeGenerator::VisitCallNew(CallNew* expr) { | 871 void FastCodeGenerator::VisitCallNew(CallNew* expr) { |
| 860 Comment cmnt(masm_, "[ CallNew"); | 872 Comment cmnt(masm_, "[ CallNew"); |
| 861 // According to ECMA-262, section 11.2.2, page 44, the function | 873 // According to ECMA-262, section 11.2.2, page 44, the function |
| 862 // expression in new calls must be evaluated before the | 874 // expression in new calls must be evaluated before the |
| 863 // arguments. | 875 // arguments. |
| 864 // Push function on the stack. | 876 // Push function on the stack. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1131 |
| 1120 break; | 1132 break; |
| 1121 } | 1133 } |
| 1122 default: | 1134 default: |
| 1123 UNREACHABLE(); | 1135 UNREACHABLE(); |
| 1124 } | 1136 } |
| 1125 } | 1137 } |
| 1126 | 1138 |
| 1127 | 1139 |
| 1128 } } // namespace v8::internal | 1140 } } // namespace v8::internal |
| OLD | NEW |