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

Side by Side Diff: src/compiler/code-generator.h

Issue 2082263002: [turbofan]: Support using push instructions for setting up tail call parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comments Created 4 years, 5 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 | « src/compiler/arm64/code-generator-arm64.cc ('k') | src/compiler/code-generator.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_COMPILER_CODE_GENERATOR_H_ 5 #ifndef V8_COMPILER_CODE_GENERATOR_H_
6 #define V8_COMPILER_CODE_GENERATOR_H_ 6 #define V8_COMPILER_CODE_GENERATOR_H_
7 7
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/instruction.h" 9 #include "src/compiler/instruction.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 // Assemble instructions for the specified block. 96 // Assemble instructions for the specified block.
97 CodeGenResult AssembleBlock(const InstructionBlock* block); 97 CodeGenResult AssembleBlock(const InstructionBlock* block);
98 98
99 // Assemble code for the specified instruction. 99 // Assemble code for the specified instruction.
100 CodeGenResult AssembleInstruction(Instruction* instr, 100 CodeGenResult AssembleInstruction(Instruction* instr,
101 const InstructionBlock* block); 101 const InstructionBlock* block);
102 void AssembleSourcePosition(Instruction* instr); 102 void AssembleSourcePosition(Instruction* instr);
103 void AssembleGaps(Instruction* instr); 103 void AssembleGaps(Instruction* instr);
104 104
105 // Returns true if a instruction is a tail call that needs to adjust the stack
106 // pointer before execution. The stack slot index to the empty slot above the
107 // adjusted stack pointer is returned in |slot|.
108 bool GetSlotAboveSPBeforeTailCall(Instruction* instr, int* slot);
109
105 // =========================================================================== 110 // ===========================================================================
106 // ============= Architecture-specific code generation methods. ============== 111 // ============= Architecture-specific code generation methods. ==============
107 // =========================================================================== 112 // ===========================================================================
108 113
109 CodeGenResult AssembleArchInstruction(Instruction* instr); 114 CodeGenResult AssembleArchInstruction(Instruction* instr);
110 void AssembleArchJump(RpoNumber target); 115 void AssembleArchJump(RpoNumber target);
111 void AssembleArchBranch(Instruction* instr, BranchInfo* branch); 116 void AssembleArchBranch(Instruction* instr, BranchInfo* branch);
112 void AssembleArchBoolean(Instruction* instr, FlagsCondition condition); 117 void AssembleArchBoolean(Instruction* instr, FlagsCondition condition);
113 void AssembleArchLookupSwitch(Instruction* instr); 118 void AssembleArchLookupSwitch(Instruction* instr);
114 void AssembleArchTableSwitch(Instruction* instr); 119 void AssembleArchTableSwitch(Instruction* instr);
115 120
116 CodeGenResult AssembleDeoptimizerCall(int deoptimization_id, 121 CodeGenResult AssembleDeoptimizerCall(int deoptimization_id,
117 Deoptimizer::BailoutType bailout_type); 122 Deoptimizer::BailoutType bailout_type);
118 123
119 // Generates an architecture-specific, descriptor-specific prologue 124 // Generates an architecture-specific, descriptor-specific prologue
120 // to set up a stack frame. 125 // to set up a stack frame.
121 void AssembleConstructFrame(); 126 void AssembleConstructFrame();
122 127
123 // Generates an architecture-specific, descriptor-specific return sequence 128 // Generates an architecture-specific, descriptor-specific return sequence
124 // to tear down a stack frame. 129 // to tear down a stack frame.
125 void AssembleReturn(); 130 void AssembleReturn();
126 131
127 // Generates code to deconstruct a the caller's frame, including arguments.
128 void AssembleDeconstructActivationRecord(int stack_param_delta);
129
130 void AssembleDeconstructFrame(); 132 void AssembleDeconstructFrame();
131 133
132 // Generates code to manipulate the stack in preparation for a tail call. 134 // Generates code to manipulate the stack in preparation for a tail call.
133 void AssemblePrepareTailCall(int stack_param_delta); 135 void AssemblePrepareTailCall();
134 136
135 // Generates code to pop current frame if it is an arguments adaptor frame. 137 // Generates code to pop current frame if it is an arguments adaptor frame.
136 void AssemblePopArgumentsAdaptorFrame(Register args_reg, Register scratch1, 138 void AssemblePopArgumentsAdaptorFrame(Register args_reg, Register scratch1,
137 Register scratch2, Register scratch3); 139 Register scratch2, Register scratch3);
138 140
141 enum PushTypeFlag {
142 kImmediatePush = 0x1,
143 kScalarPush = 0x2,
144 kFloat32Push = 0x4,
145 kFloat64Push = 0x8,
146 kFloatPush = kFloat32Push | kFloat64Push
147 };
148
149 typedef base::Flags<PushTypeFlag> PushTypeFlags;
150
151 static bool IsValidPush(InstructionOperand source, PushTypeFlags push_type);
152
153 // Generate a list moves from an instruction that are candidates to be turned
154 // into push instructions on platforms that support them. In general, the list
155 // of push candidates are moves to a set of contiguous destination
156 // InstructionOperand locations on the stack that don't clobber values that
157 // are needed for resolve the gap or use values generated by the gap,
158 // i.e. moves that can be hoisted together before the actual gap and assembled
159 // together.
160 static void GetPushCompatibleMoves(Instruction* instr,
161 PushTypeFlags push_type,
162 ZoneVector<MoveOperands*>* pushes);
163
164 // Called before a tail call |instr|'s gap moves are assembled and allows
165 // gap-specific pre-processing, e.g. adjustment of the sp for tail calls that
166 // need it before gap moves or conversion of certain gap moves into pushes.
167 void AssembleTailCallBeforeGap(Instruction* instr,
168 int first_unused_stack_slot);
169 // Called after a tail call |instr|'s gap moves are assembled and allows
170 // gap-specific post-processing, e.g. adjustment of the sp for tail calls that
171 // need it after gap moves.
172 void AssembleTailCallAfterGap(Instruction* instr,
173 int first_unused_stack_slot);
174
139 // =========================================================================== 175 // ===========================================================================
140 // ============== Architecture-specific gap resolver methods. ================ 176 // ============== Architecture-specific gap resolver methods. ================
141 // =========================================================================== 177 // ===========================================================================
142 178
143 // Interface used by the gap resolver to emit moves and swaps. 179 // Interface used by the gap resolver to emit moves and swaps.
144 void AssembleMove(InstructionOperand* source, 180 void AssembleMove(InstructionOperand* source,
145 InstructionOperand* destination) final; 181 InstructionOperand* destination) final;
146 void AssembleSwap(InstructionOperand* source, 182 void AssembleSwap(InstructionOperand* source,
147 InstructionOperand* destination) final; 183 InstructionOperand* destination) final;
148 184
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 OutputFrameStateCombine combine, 217 OutputFrameStateCombine combine,
182 Translation* translation); 218 Translation* translation);
183 void AddTranslationForOperand(Translation* translation, Instruction* instr, 219 void AddTranslationForOperand(Translation* translation, Instruction* instr,
184 InstructionOperand* op, MachineType type); 220 InstructionOperand* op, MachineType type);
185 void EnsureSpaceForLazyDeopt(); 221 void EnsureSpaceForLazyDeopt();
186 void MarkLazyDeoptSite(); 222 void MarkLazyDeoptSite();
187 223
188 DeoptimizationExit* AddDeoptimizationExit(Instruction* instr, 224 DeoptimizationExit* AddDeoptimizationExit(Instruction* instr,
189 size_t frame_state_offset); 225 size_t frame_state_offset);
190 226
191 // Converts the delta in the number of stack parameter passed from a tail
192 // caller to the callee into the distance (in pointers) the SP must be
193 // adjusted, taking frame elision and other relevant factors into
194 // consideration.
195 int TailCallFrameStackSlotDelta(int stack_param_delta);
196
197 // =========================================================================== 227 // ===========================================================================
198 228
199 struct DeoptimizationState : ZoneObject { 229 struct DeoptimizationState : ZoneObject {
200 public: 230 public:
201 BailoutId bailout_id() const { return bailout_id_; } 231 BailoutId bailout_id() const { return bailout_id_; }
202 int translation_id() const { return translation_id_; } 232 int translation_id() const { return translation_id_; }
203 int pc_offset() const { return pc_offset_; } 233 int pc_offset() const { return pc_offset_; }
204 234
205 DeoptimizationState(BailoutId bailout_id, int translation_id, int pc_offset) 235 DeoptimizationState(BailoutId bailout_id, int translation_id, int pc_offset)
206 : bailout_id_(bailout_id), 236 : bailout_id_(bailout_id),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 OutOfLineCode* ools_; 273 OutOfLineCode* ools_;
244 int osr_pc_offset_; 274 int osr_pc_offset_;
245 SourcePositionTableBuilder source_position_table_builder_; 275 SourcePositionTableBuilder source_position_table_builder_;
246 }; 276 };
247 277
248 } // namespace compiler 278 } // namespace compiler
249 } // namespace internal 279 } // namespace internal
250 } // namespace v8 280 } // namespace v8
251 281
252 #endif // V8_COMPILER_CODE_GENERATOR_H 282 #endif // V8_COMPILER_CODE_GENERATOR_H
OLDNEW
« no previous file with comments | « src/compiler/arm64/code-generator-arm64.cc ('k') | src/compiler/code-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698