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

Side by Side Diff: src/x64/full-codegen-x64.cc

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

Powered by Google App Engine
This is Rietveld 408576698