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

Side by Side Diff: src/x87/builtins-x87.cc

Issue 1703233003: X87: [es6] [interpreter] Add tail calls support to Ignition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 __ jmp(ebx); 92 __ jmp(ebx);
93 } 93 }
94 94
95 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { 95 static void GenerateTailCallToSharedCode(MacroAssembler* masm) {
96 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 96 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
97 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kCodeOffset)); 97 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kCodeOffset));
98 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); 98 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize));
99 __ jmp(ebx); 99 __ jmp(ebx);
100 } 100 }
101 101
102
103 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { 102 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) {
104 // Checking whether the queued function is ready for install is optional, 103 // Checking whether the queued function is ready for install is optional,
105 // since we come across interrupts and stack checks elsewhere. However, 104 // since we come across interrupts and stack checks elsewhere. However,
106 // not checking may delay installing ready functions, and always checking 105 // not checking may delay installing ready functions, and always checking
107 // would be quite expensive. A good compromise is to first check against 106 // would be quite expensive. A good compromise is to first check against
108 // stack limit as a cue for an interrupt signal. 107 // stack limit as a cue for an interrupt signal.
109 Label ok; 108 Label ok;
110 ExternalReference stack_limit = 109 ExternalReference stack_limit =
111 ExternalReference::address_of_stack_limit(masm->isolate()); 110 ExternalReference::address_of_stack_limit(masm->isolate());
112 __ cmp(esp, Operand::StaticVariable(stack_limit)); 111 __ cmp(esp, Operand::StaticVariable(stack_limit));
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 __ bind(&loop_header); 670 __ bind(&loop_header);
672 __ Push(Operand(ebx, 0)); 671 __ Push(Operand(ebx, 0));
673 __ sub(ebx, Immediate(kPointerSize)); 672 __ sub(ebx, Immediate(kPointerSize));
674 __ bind(&loop_check); 673 __ bind(&loop_check);
675 __ cmp(ebx, array_limit); 674 __ cmp(ebx, array_limit);
676 __ j(greater, &loop_header, Label::kNear); 675 __ j(greater, &loop_header, Label::kNear);
677 } 676 }
678 677
679 678
680 // static 679 // static
681 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { 680 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
681 MacroAssembler* masm, TailCallMode tail_call_mode) {
682 // ----------- S t a t e ------------- 682 // ----------- S t a t e -------------
683 // -- eax : the number of arguments (not including the receiver) 683 // -- eax : the number of arguments (not including the receiver)
684 // -- ebx : the address of the first argument to be pushed. Subsequent 684 // -- ebx : the address of the first argument to be pushed. Subsequent
685 // arguments should be consecutive above this, in the same order as 685 // arguments should be consecutive above this, in the same order as
686 // they are to be pushed onto the stack. 686 // they are to be pushed onto the stack.
687 // -- edi : the target to call (can be any Object). 687 // -- edi : the target to call (can be any Object).
688 // ----------------------------------- 688 // -----------------------------------
689 689
690 // Pop return address to allow tail-call after pushing arguments. 690 // Pop return address to allow tail-call after pushing arguments.
691 __ Pop(edx); 691 __ Pop(edx);
692 692
693 // Find the address of the last argument. 693 // Find the address of the last argument.
694 __ mov(ecx, eax); 694 __ mov(ecx, eax);
695 __ add(ecx, Immediate(1)); // Add one for receiver. 695 __ add(ecx, Immediate(1)); // Add one for receiver.
696 __ shl(ecx, kPointerSizeLog2); 696 __ shl(ecx, kPointerSizeLog2);
697 __ neg(ecx); 697 __ neg(ecx);
698 __ add(ecx, ebx); 698 __ add(ecx, ebx);
699 699
700 Generate_InterpreterPushArgs(masm, ecx); 700 Generate_InterpreterPushArgs(masm, ecx);
701 701
702 // Call the target. 702 // Call the target.
703 __ Push(edx); // Re-push return address. 703 __ Push(edx); // Re-push return address.
704 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 704 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
705 tail_call_mode),
706 RelocInfo::CODE_TARGET);
705 } 707 }
706 708
707 709
708 // static 710 // static
709 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { 711 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
710 // ----------- S t a t e ------------- 712 // ----------- S t a t e -------------
711 // -- eax : the number of arguments (not including the receiver) 713 // -- eax : the number of arguments (not including the receiver)
712 // -- edx : the new target 714 // -- edx : the new target
713 // -- edi : the constructor 715 // -- edi : the constructor
714 // -- ebx : the address of the first argument to be pushed. Subsequent 716 // -- ebx : the address of the first argument to be pushed. Subsequent
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 Comment cmnt(masm, "[ PrepareForTailCall"); 2011 Comment cmnt(masm, "[ PrepareForTailCall");
2010 2012
2011 // Prepare for tail call only if the debugger is not active. 2013 // Prepare for tail call only if the debugger is not active.
2012 Label done; 2014 Label done;
2013 ExternalReference debug_is_active = 2015 ExternalReference debug_is_active =
2014 ExternalReference::debug_is_active_address(masm->isolate()); 2016 ExternalReference::debug_is_active_address(masm->isolate());
2015 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); 2017 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active));
2016 __ cmp(scratch1, Immediate(0)); 2018 __ cmp(scratch1, Immediate(0));
2017 __ j(not_equal, &done, Label::kNear); 2019 __ j(not_equal, &done, Label::kNear);
2018 2020
2021 // Drop possible interpreter handler/stub frame.
2022 {
2023 Label no_interpreter_frame;
2024 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset),
2025 Immediate(Smi::FromInt(StackFrame::STUB)));
2026 __ j(not_equal, &no_interpreter_frame, Label::kNear);
2027 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2028 __ bind(&no_interpreter_frame);
2029 }
2030
2019 // Check if next frame is an arguments adaptor frame. 2031 // Check if next frame is an arguments adaptor frame.
2020 Label no_arguments_adaptor, formal_parameter_count_loaded; 2032 Label no_arguments_adaptor, formal_parameter_count_loaded;
2021 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 2033 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2022 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), 2034 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset),
2023 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 2035 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2024 __ j(not_equal, &no_arguments_adaptor, Label::kNear); 2036 __ j(not_equal, &no_arguments_adaptor, Label::kNear);
2025 2037
2026 // Drop arguments adaptor frame and load arguments count. 2038 // Drop arguments adaptor frame and load arguments count.
2027 __ mov(ebp, scratch2); 2039 __ mov(ebp, scratch2);
2028 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); 2040 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset));
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 2808
2797 __ bind(&ok); 2809 __ bind(&ok);
2798 __ ret(0); 2810 __ ret(0);
2799 } 2811 }
2800 2812
2801 #undef __ 2813 #undef __
2802 } // namespace internal 2814 } // namespace internal
2803 } // namespace v8 2815 } // namespace v8
2804 2816
2805 #endif // V8_TARGET_ARCH_X87 2817 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698