| 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 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2566 | 2566 |
| 2567 | 2567 |
| 2568 void FullCodeGenerator::CallIC(Handle<Code> code, | 2568 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2569 TypeFeedbackId ast_id) { | 2569 TypeFeedbackId ast_id) { |
| 2570 ic_total_count_++; | 2570 ic_total_count_++; |
| 2571 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2571 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2572 } | 2572 } |
| 2573 | 2573 |
| 2574 | 2574 |
| 2575 // Code common for calls using the IC. | 2575 // Code common for calls using the IC. |
| 2576 void FullCodeGenerator::EmitCallWithIC(Call* expr) { | 2576 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
| 2577 Expression* callee = expr->expression(); | 2577 Expression* callee = expr->expression(); |
| 2578 ZoneList<Expression*>* args = expr->arguments(); | |
| 2579 int arg_count = args->length(); | |
| 2580 | 2578 |
| 2581 CallFunctionFlags flags; | 2579 CallIC::CallType call_type = callee->IsVariableProxy() |
| 2582 // Get the target function; | 2580 ? CallIC::FUNCTION |
| 2583 if (callee->IsVariableProxy()) { | 2581 : CallIC::METHOD; |
| 2582 // Get the target function. |
| 2583 if (call_type == CallIC::FUNCTION) { |
| 2584 { StackValueContext context(this); | 2584 { StackValueContext context(this); |
| 2585 EmitVariableLoad(callee->AsVariableProxy()); | 2585 EmitVariableLoad(callee->AsVariableProxy()); |
| 2586 PrepareForBailout(callee, NO_REGISTERS); | 2586 PrepareForBailout(callee, NO_REGISTERS); |
| 2587 } | 2587 } |
| 2588 // Push undefined as receiver. This is patched in the method prologue if it | 2588 // Push undefined as receiver. This is patched in the method prologue if it |
| 2589 // is a sloppy mode method. | 2589 // is a sloppy mode method. |
| 2590 __ Push(isolate()->factory()->undefined_value()); | 2590 __ Push(isolate()->factory()->undefined_value()); |
| 2591 flags = NO_CALL_FUNCTION_FLAGS; | |
| 2592 } else { | 2591 } else { |
| 2593 // Load the function from the receiver. | 2592 // Load the function from the receiver. |
| 2594 ASSERT(callee->IsProperty()); | 2593 ASSERT(callee->IsProperty()); |
| 2595 __ movp(rax, Operand(rsp, 0)); | 2594 __ movp(rax, Operand(rsp, 0)); |
| 2596 EmitNamedPropertyLoad(callee->AsProperty()); | 2595 EmitNamedPropertyLoad(callee->AsProperty()); |
| 2597 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2596 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2598 // Push the target function under the receiver. | 2597 // Push the target function under the receiver. |
| 2599 __ Push(Operand(rsp, 0)); | 2598 __ Push(Operand(rsp, 0)); |
| 2600 __ movp(Operand(rsp, kPointerSize), rax); | 2599 __ movp(Operand(rsp, kPointerSize), rax); |
| 2601 flags = CALL_AS_METHOD; | |
| 2602 } | 2600 } |
| 2603 | 2601 |
| 2604 // Load the arguments. | 2602 EmitCall(expr, call_type); |
| 2605 { PreservePositionScope scope(masm()->positions_recorder()); | |
| 2606 for (int i = 0; i < arg_count; i++) { | |
| 2607 VisitForStackValue(args->at(i)); | |
| 2608 } | |
| 2609 } | |
| 2610 | |
| 2611 // Record source position for debugger. | |
| 2612 SetSourcePosition(expr->position()); | |
| 2613 CallFunctionStub stub(arg_count, flags); | |
| 2614 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | |
| 2615 __ CallStub(&stub); | |
| 2616 | |
| 2617 RecordJSReturnSite(expr); | |
| 2618 | |
| 2619 // Restore context register. | |
| 2620 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | |
| 2621 | |
| 2622 context()->DropAndPlug(1, rax); | |
| 2623 } | 2603 } |
| 2624 | 2604 |
| 2625 | 2605 |
| 2626 // Common code for calls using the IC. | 2606 // Common code for calls using the IC. |
| 2627 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, | 2607 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
| 2628 Expression* key) { | 2608 Expression* key) { |
| 2629 // Load the key. | 2609 // Load the key. |
| 2630 VisitForAccumulatorValue(key); | 2610 VisitForAccumulatorValue(key); |
| 2631 | 2611 |
| 2632 Expression* callee = expr->expression(); | 2612 Expression* callee = expr->expression(); |
| 2633 ZoneList<Expression*>* args = expr->arguments(); | |
| 2634 int arg_count = args->length(); | |
| 2635 | 2613 |
| 2636 // Load the function from the receiver. | 2614 // Load the function from the receiver. |
| 2637 ASSERT(callee->IsProperty()); | 2615 ASSERT(callee->IsProperty()); |
| 2638 __ movp(rdx, Operand(rsp, 0)); | 2616 __ movp(rdx, Operand(rsp, 0)); |
| 2639 EmitKeyedPropertyLoad(callee->AsProperty()); | 2617 EmitKeyedPropertyLoad(callee->AsProperty()); |
| 2640 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2618 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2641 | 2619 |
| 2642 // Push the target function under the receiver. | 2620 // Push the target function under the receiver. |
| 2643 __ Push(Operand(rsp, 0)); | 2621 __ Push(Operand(rsp, 0)); |
| 2644 __ movp(Operand(rsp, kPointerSize), rax); | 2622 __ movp(Operand(rsp, kPointerSize), rax); |
| 2645 | 2623 |
| 2646 // Load the arguments. | 2624 EmitCall(expr, CallIC::METHOD); |
| 2647 { PreservePositionScope scope(masm()->positions_recorder()); | |
| 2648 for (int i = 0; i < arg_count; i++) { | |
| 2649 VisitForStackValue(args->at(i)); | |
| 2650 } | |
| 2651 } | |
| 2652 | |
| 2653 // Record source position for debugger. | |
| 2654 SetSourcePosition(expr->position()); | |
| 2655 CallFunctionStub stub(arg_count, CALL_AS_METHOD); | |
| 2656 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | |
| 2657 __ CallStub(&stub); | |
| 2658 | |
| 2659 RecordJSReturnSite(expr); | |
| 2660 // Restore context register. | |
| 2661 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | |
| 2662 | |
| 2663 context()->DropAndPlug(1, rax); | |
| 2664 } | 2625 } |
| 2665 | 2626 |
| 2666 | 2627 |
| 2667 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 2628 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
| 2668 // Code common for calls using the call stub. | 2629 // Load the arguments. |
| 2669 ZoneList<Expression*>* args = expr->arguments(); | 2630 ZoneList<Expression*>* args = expr->arguments(); |
| 2670 int arg_count = args->length(); | 2631 int arg_count = args->length(); |
| 2671 { PreservePositionScope scope(masm()->positions_recorder()); | 2632 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2672 for (int i = 0; i < arg_count; i++) { | 2633 for (int i = 0; i < arg_count; i++) { |
| 2673 VisitForStackValue(args->at(i)); | 2634 VisitForStackValue(args->at(i)); |
| 2674 } | 2635 } |
| 2675 } | 2636 } |
| 2676 // Record source position for debugger. | 2637 |
| 2638 // Record source position of the IC call. |
| 2677 SetSourcePosition(expr->position()); | 2639 SetSourcePosition(expr->position()); |
| 2678 | 2640 Handle<Code> ic = CallIC::initialize_stub( |
| 2641 isolate(), arg_count, call_type); |
| 2679 Handle<Object> uninitialized = | 2642 Handle<Object> uninitialized = |
| 2680 TypeFeedbackInfo::UninitializedSentinel(isolate()); | 2643 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
| 2681 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); | 2644 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
| 2682 __ Move(rbx, FeedbackVector()); | 2645 __ Move(rbx, FeedbackVector()); |
| 2683 __ Move(rdx, Smi::FromInt(expr->CallFeedbackSlot())); | 2646 __ Move(rdx, Smi::FromInt(expr->CallFeedbackSlot())); |
| 2647 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2648 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2649 // by the vector above. |
| 2650 CallIC(ic); |
| 2684 | 2651 |
| 2685 // Record call targets in unoptimized code. | |
| 2686 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); | |
| 2687 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | |
| 2688 __ CallStub(&stub); | |
| 2689 RecordJSReturnSite(expr); | 2652 RecordJSReturnSite(expr); |
| 2653 |
| 2690 // Restore context register. | 2654 // Restore context register. |
| 2691 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2655 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2692 // Discard the function left on TOS. | 2656 // Discard the function left on TOS. |
| 2693 context()->DropAndPlug(1, rax); | 2657 context()->DropAndPlug(1, rax); |
| 2694 } | 2658 } |
| 2695 | 2659 |
| 2696 | 2660 |
| 2697 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2661 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
| 2698 // Push copy of the first argument or undefined if it doesn't exist. | 2662 // Push copy of the first argument or undefined if it doesn't exist. |
| 2699 if (arg_count > 0) { | 2663 if (arg_count > 0) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 // Record source position for debugger. | 2720 // Record source position for debugger. |
| 2757 SetSourcePosition(expr->position()); | 2721 SetSourcePosition(expr->position()); |
| 2758 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); | 2722 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2759 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2723 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2760 __ CallStub(&stub); | 2724 __ CallStub(&stub); |
| 2761 RecordJSReturnSite(expr); | 2725 RecordJSReturnSite(expr); |
| 2762 // Restore context register. | 2726 // Restore context register. |
| 2763 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2727 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2764 context()->DropAndPlug(1, rax); | 2728 context()->DropAndPlug(1, rax); |
| 2765 } else if (call_type == Call::GLOBAL_CALL) { | 2729 } else if (call_type == Call::GLOBAL_CALL) { |
| 2766 EmitCallWithIC(expr); | 2730 EmitCallWithLoadIC(expr); |
| 2767 | 2731 |
| 2768 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 2732 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 2769 // Call to a lookup slot (dynamically introduced variable). | 2733 // Call to a lookup slot (dynamically introduced variable). |
| 2770 VariableProxy* proxy = callee->AsVariableProxy(); | 2734 VariableProxy* proxy = callee->AsVariableProxy(); |
| 2771 Label slow, done; | 2735 Label slow, done; |
| 2772 | 2736 |
| 2773 { PreservePositionScope scope(masm()->positions_recorder()); | 2737 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2774 // Generate code for loading from variables potentially shadowed by | 2738 // Generate code for loading from variables potentially shadowed by |
| 2775 // eval-introduced variables. | 2739 // eval-introduced variables. |
| 2776 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); | 2740 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2793 // Push function. | 2757 // Push function. |
| 2794 __ Push(rax); | 2758 __ Push(rax); |
| 2795 // The receiver is implicitly the global receiver. Indicate this by | 2759 // The receiver is implicitly the global receiver. Indicate this by |
| 2796 // passing the hole to the call function stub. | 2760 // passing the hole to the call function stub. |
| 2797 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2761 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 2798 __ bind(&call); | 2762 __ bind(&call); |
| 2799 } | 2763 } |
| 2800 | 2764 |
| 2801 // The receiver is either the global receiver or an object found by | 2765 // The receiver is either the global receiver or an object found by |
| 2802 // LoadContextSlot. | 2766 // LoadContextSlot. |
| 2803 EmitCallWithStub(expr); | 2767 EmitCall(expr); |
| 2804 } else if (call_type == Call::PROPERTY_CALL) { | 2768 } else if (call_type == Call::PROPERTY_CALL) { |
| 2805 Property* property = callee->AsProperty(); | 2769 Property* property = callee->AsProperty(); |
| 2806 { PreservePositionScope scope(masm()->positions_recorder()); | 2770 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2807 VisitForStackValue(property->obj()); | 2771 VisitForStackValue(property->obj()); |
| 2808 } | 2772 } |
| 2809 if (property->key()->IsPropertyName()) { | 2773 if (property->key()->IsPropertyName()) { |
| 2810 EmitCallWithIC(expr); | 2774 EmitCallWithLoadIC(expr); |
| 2811 } else { | 2775 } else { |
| 2812 EmitKeyedCallWithIC(expr, property->key()); | 2776 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2813 } | 2777 } |
| 2814 } else { | 2778 } else { |
| 2815 ASSERT(call_type == Call::OTHER_CALL); | 2779 ASSERT(call_type == Call::OTHER_CALL); |
| 2816 // Call to an arbitrary expression not handled specially above. | 2780 // Call to an arbitrary expression not handled specially above. |
| 2817 { PreservePositionScope scope(masm()->positions_recorder()); | 2781 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2818 VisitForStackValue(callee); | 2782 VisitForStackValue(callee); |
| 2819 } | 2783 } |
| 2820 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2784 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 2821 // Emit function call. | 2785 // Emit function call. |
| 2822 EmitCallWithStub(expr); | 2786 EmitCall(expr); |
| 2823 } | 2787 } |
| 2824 | 2788 |
| 2825 #ifdef DEBUG | 2789 #ifdef DEBUG |
| 2826 // RecordJSReturnSite should have been called. | 2790 // RecordJSReturnSite should have been called. |
| 2827 ASSERT(expr->return_is_recorded_); | 2791 ASSERT(expr->return_is_recorded_); |
| 2828 #endif | 2792 #endif |
| 2829 } | 2793 } |
| 2830 | 2794 |
| 2831 | 2795 |
| 2832 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2796 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2862 if (FLAG_pretenuring_call_new) { | 2826 if (FLAG_pretenuring_call_new) { |
| 2863 StoreFeedbackVectorSlot(expr->AllocationSiteFeedbackSlot(), | 2827 StoreFeedbackVectorSlot(expr->AllocationSiteFeedbackSlot(), |
| 2864 isolate()->factory()->NewAllocationSite()); | 2828 isolate()->factory()->NewAllocationSite()); |
| 2865 ASSERT(expr->AllocationSiteFeedbackSlot() == | 2829 ASSERT(expr->AllocationSiteFeedbackSlot() == |
| 2866 expr->CallNewFeedbackSlot() + 1); | 2830 expr->CallNewFeedbackSlot() + 1); |
| 2867 } | 2831 } |
| 2868 | 2832 |
| 2869 __ Move(rbx, FeedbackVector()); | 2833 __ Move(rbx, FeedbackVector()); |
| 2870 __ Move(rdx, Smi::FromInt(expr->CallNewFeedbackSlot())); | 2834 __ Move(rdx, Smi::FromInt(expr->CallNewFeedbackSlot())); |
| 2871 | 2835 |
| 2872 CallConstructStub stub(RECORD_CALL_TARGET); | 2836 CallConstructStub stub(RECORD_CONSTRUCTOR_TARGET); |
| 2873 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); | 2837 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
| 2874 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2838 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 2875 context()->Plug(rax); | 2839 context()->Plug(rax); |
| 2876 } | 2840 } |
| 2877 | 2841 |
| 2878 | 2842 |
| 2879 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2843 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 2880 ZoneList<Expression*>* args = expr->arguments(); | 2844 ZoneList<Expression*>* args = expr->arguments(); |
| 2881 ASSERT(args->length() == 1); | 2845 ASSERT(args->length() == 1); |
| 2882 | 2846 |
| (...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4917 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4881 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4918 Assembler::target_address_at(call_target_address, | 4882 Assembler::target_address_at(call_target_address, |
| 4919 unoptimized_code)); | 4883 unoptimized_code)); |
| 4920 return OSR_AFTER_STACK_CHECK; | 4884 return OSR_AFTER_STACK_CHECK; |
| 4921 } | 4885 } |
| 4922 | 4886 |
| 4923 | 4887 |
| 4924 } } // namespace v8::internal | 4888 } } // namespace v8::internal |
| 4925 | 4889 |
| 4926 #endif // V8_TARGET_ARCH_X64 | 4890 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |