OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 | 2666 |
2667 void FullCodeGenerator::VisitCall(Call* expr) { | 2667 void FullCodeGenerator::VisitCall(Call* expr) { |
2668 #ifdef DEBUG | 2668 #ifdef DEBUG |
2669 // We want to verify that RecordJSReturnSite gets called on all paths | 2669 // We want to verify that RecordJSReturnSite gets called on all paths |
2670 // through this function. Avoid early returns. | 2670 // through this function. Avoid early returns. |
2671 expr->return_is_recorded_ = false; | 2671 expr->return_is_recorded_ = false; |
2672 #endif | 2672 #endif |
2673 | 2673 |
2674 Comment cmnt(masm_, "[ Call"); | 2674 Comment cmnt(masm_, "[ Call"); |
2675 Expression* callee = expr->expression(); | 2675 Expression* callee = expr->expression(); |
2676 VariableProxy* proxy = callee->AsVariableProxy(); | 2676 Call::CallType call_type = expr->GetCallType(isolate()); |
2677 Property* property = callee->AsProperty(); | |
2678 | 2677 |
2679 if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) { | 2678 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
2680 // In a call to eval, we first call %ResolvePossiblyDirectEval to | 2679 // In a call to eval, we first call %ResolvePossiblyDirectEval to |
2681 // resolve the function we need to call and the receiver of the call. | 2680 // resolve the function we need to call and the receiver of the call. |
2682 // Then we call the resolved function using the given arguments. | 2681 // Then we call the resolved function using the given arguments. |
2683 ZoneList<Expression*>* args = expr->arguments(); | 2682 ZoneList<Expression*>* args = expr->arguments(); |
2684 int arg_count = args->length(); | 2683 int arg_count = args->length(); |
2685 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 2684 { PreservePositionScope pos_scope(masm()->positions_recorder()); |
2686 VisitForStackValue(callee); | 2685 VisitForStackValue(callee); |
2687 // Reserved receiver slot. | 2686 // Reserved receiver slot. |
2688 __ push(Immediate(isolate()->factory()->undefined_value())); | 2687 __ push(Immediate(isolate()->factory()->undefined_value())); |
2689 // Push the arguments. | 2688 // Push the arguments. |
(...skipping 14 matching lines...) Expand all Loading... |
2704 // Record source position for debugger. | 2703 // Record source position for debugger. |
2705 SetSourcePosition(expr->position()); | 2704 SetSourcePosition(expr->position()); |
2706 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); | 2705 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); |
2707 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2706 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2708 __ CallStub(&stub); | 2707 __ CallStub(&stub); |
2709 RecordJSReturnSite(expr); | 2708 RecordJSReturnSite(expr); |
2710 // Restore context register. | 2709 // Restore context register. |
2711 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2710 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2712 context()->DropAndPlug(1, eax); | 2711 context()->DropAndPlug(1, eax); |
2713 | 2712 |
2714 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { | 2713 } else if (call_type == Call::GLOBAL_CALL) { |
2715 // Push global object as receiver for the call IC. | 2714 // Push global object as receiver for the call IC. |
2716 __ push(GlobalObjectOperand()); | 2715 __ push(GlobalObjectOperand()); |
| 2716 VariableProxy* proxy = callee->AsVariableProxy(); |
2717 EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); | 2717 EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); |
2718 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 2718 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
2719 // Call to a lookup slot (dynamically introduced variable). | 2719 // Call to a lookup slot (dynamically introduced variable). |
| 2720 VariableProxy* proxy = callee->AsVariableProxy(); |
2720 Label slow, done; | 2721 Label slow, done; |
2721 { PreservePositionScope scope(masm()->positions_recorder()); | 2722 { PreservePositionScope scope(masm()->positions_recorder()); |
2722 // Generate code for loading from variables potentially shadowed by | 2723 // Generate code for loading from variables potentially shadowed by |
2723 // eval-introduced variables. | 2724 // eval-introduced variables. |
2724 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); | 2725 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |
2725 } | 2726 } |
2726 __ bind(&slow); | 2727 __ bind(&slow); |
2727 // Call the runtime to find the function to call (returned in eax) and | 2728 // Call the runtime to find the function to call (returned in eax) and |
2728 // the object holding it (returned in edx). | 2729 // the object holding it (returned in edx). |
2729 __ push(context_register()); | 2730 __ push(context_register()); |
(...skipping 13 matching lines...) Expand all Loading... |
2743 // The receiver is implicitly the global receiver. Indicate this by | 2744 // The receiver is implicitly the global receiver. Indicate this by |
2744 // passing the hole to the call function stub. | 2745 // passing the hole to the call function stub. |
2745 __ push(Immediate(isolate()->factory()->undefined_value())); | 2746 __ push(Immediate(isolate()->factory()->undefined_value())); |
2746 __ bind(&call); | 2747 __ bind(&call); |
2747 } | 2748 } |
2748 | 2749 |
2749 // The receiver is either the global receiver or an object found by | 2750 // The receiver is either the global receiver or an object found by |
2750 // LoadContextSlot. | 2751 // LoadContextSlot. |
2751 EmitCallWithStub(expr); | 2752 EmitCallWithStub(expr); |
2752 | 2753 |
2753 } else if (property != NULL) { | 2754 } else if (call_type == Call::PROPERTY_CALL) { |
| 2755 Property* property = callee->AsProperty(); |
2754 { PreservePositionScope scope(masm()->positions_recorder()); | 2756 { PreservePositionScope scope(masm()->positions_recorder()); |
2755 VisitForStackValue(property->obj()); | 2757 VisitForStackValue(property->obj()); |
2756 } | 2758 } |
2757 if (property->key()->IsPropertyName()) { | 2759 if (property->key()->IsPropertyName()) { |
2758 EmitCallWithIC(expr, | 2760 EmitCallWithIC(expr, |
2759 property->key()->AsLiteral()->value(), | 2761 property->key()->AsLiteral()->value(), |
2760 NOT_CONTEXTUAL); | 2762 NOT_CONTEXTUAL); |
2761 } else { | 2763 } else { |
2762 EmitKeyedCallWithIC(expr, property->key()); | 2764 EmitKeyedCallWithIC(expr, property->key()); |
2763 } | 2765 } |
2764 | 2766 |
2765 } else { | 2767 } else { |
| 2768 ASSERT(call_type == Call::OTHER_CALL); |
2766 // Call to an arbitrary expression not handled specially above. | 2769 // Call to an arbitrary expression not handled specially above. |
2767 { PreservePositionScope scope(masm()->positions_recorder()); | 2770 { PreservePositionScope scope(masm()->positions_recorder()); |
2768 VisitForStackValue(callee); | 2771 VisitForStackValue(callee); |
2769 } | 2772 } |
2770 __ push(Immediate(isolate()->factory()->undefined_value())); | 2773 __ push(Immediate(isolate()->factory()->undefined_value())); |
2771 // Emit function call. | 2774 // Emit function call. |
2772 EmitCallWithStub(expr); | 2775 EmitCallWithStub(expr); |
2773 } | 2776 } |
2774 | 2777 |
2775 #ifdef DEBUG | 2778 #ifdef DEBUG |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4898 | 4901 |
4899 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4902 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4900 Assembler::target_address_at(call_target_address)); | 4903 Assembler::target_address_at(call_target_address)); |
4901 return OSR_AFTER_STACK_CHECK; | 4904 return OSR_AFTER_STACK_CHECK; |
4902 } | 4905 } |
4903 | 4906 |
4904 | 4907 |
4905 } } // namespace v8::internal | 4908 } } // namespace v8::internal |
4906 | 4909 |
4907 #endif // V8_TARGET_ARCH_IA32 | 4910 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |