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

Side by Side Diff: src/x64/lithium-codegen-x64.h

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/ic-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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 11 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_X64_LITHIUM_CODEGEN_X64_H_ 28 #ifndef V8_X64_LITHIUM_CODEGEN_X64_H_
29 #define V8_X64_LITHIUM_CODEGEN_X64_H_ 29 #define V8_X64_LITHIUM_CODEGEN_X64_H_
30 30
31 #include "x64/lithium-x64.h" 31 #include "x64/lithium-x64.h"
32 32
33 #include "checks.h"
33 #include "deoptimizer.h" 34 #include "deoptimizer.h"
34 #include "safepoint-table.h" 35 #include "safepoint-table.h"
35 #include "scopes.h" 36 #include "scopes.h"
37 #include "x64/lithium-gap-resolver-x64.h"
36 38
37 namespace v8 { 39 namespace v8 {
38 namespace internal { 40 namespace internal {
39 41
40 // Forward declarations. 42 // Forward declarations.
41 class LDeferredCode; 43 class LDeferredCode;
44 class SafepointGenerator;
42 45
43 class LCodeGen BASE_EMBEDDED { 46 class LCodeGen BASE_EMBEDDED {
44 public: 47 public:
45 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) { } 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
49 : chunk_(chunk),
50 masm_(assembler),
51 info_(info),
52 current_block_(-1),
53 current_instruction_(-1),
54 instructions_(chunk->instructions()),
55 deoptimizations_(4),
56 deoptimization_literals_(8),
57 inlined_function_count_(0),
58 scope_(chunk->graph()->info()->scope()),
59 status_(UNUSED),
60 deferred_(8),
61 osr_pc_offset_(-1),
62 resolver_(this) {
63 PopulateDeoptimizationLiteralsWithInlinedFunctions();
64 }
65
66 // Simple accessors.
67 MacroAssembler* masm() const { return masm_; }
68
69 // Support for converting LOperands to assembler types.
70 Register ToRegister(LOperand* op) const;
71 XMMRegister ToDoubleRegister(LOperand* op) const;
72 bool IsInteger32Constant(LConstantOperand* op) const;
73 int ToInteger32(LConstantOperand* op) const;
74 bool IsTaggedConstant(LConstantOperand* op) const;
75 Handle<Object> ToHandle(LConstantOperand* op) const;
76 Operand ToOperand(LOperand* op) const;
77
46 78
47 // Try to generate code for the entire chunk, but it may fail if the 79 // Try to generate code for the entire chunk, but it may fail if the
48 // chunk contains constructs we cannot handle. Returns true if the 80 // chunk contains constructs we cannot handle. Returns true if the
49 // code generation attempt succeeded. 81 // code generation attempt succeeded.
50 bool GenerateCode() { 82 bool GenerateCode();
51 UNIMPLEMENTED();
52 return false;
53 }
54 83
55 // Finish the code by setting stack height, safepoint, and bailout 84 // Finish the code by setting stack height, safepoint, and bailout
56 // information on it. 85 // information on it.
57 void FinishCode(Handle<Code> code) { UNIMPLEMENTED(); } 86 void FinishCode(Handle<Code> code);
87
88 // Deferred code support.
89 void DoDeferredNumberTagD(LNumberTagD* instr);
90 void DoDeferredTaggedToI(LTaggedToI* instr);
91 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr);
92 void DoDeferredStackCheck(LGoto* instr);
93 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
94 Label* map_check);
95
96 // Parallel move support.
97 void DoParallelMove(LParallelMove* move);
98
99 // Emit frame translation commands for an environment.
100 void WriteTranslation(LEnvironment* environment, Translation* translation);
101
102 // Declare methods that deal with the individual node types.
103 #define DECLARE_DO(type) void Do##type(L##type* node);
104 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
105 #undef DECLARE_DO
106
107 private:
108 enum Status {
109 UNUSED,
110 GENERATING,
111 DONE,
112 ABORTED
113 };
114
115 bool is_unused() const { return status_ == UNUSED; }
116 bool is_generating() const { return status_ == GENERATING; }
117 bool is_done() const { return status_ == DONE; }
118 bool is_aborted() const { return status_ == ABORTED; }
119
120 LChunk* chunk() const { return chunk_; }
121 Scope* scope() const { return scope_; }
122 HGraph* graph() const { return chunk_->graph(); }
123
124 int GetNextEmittedBlock(int block);
125 LInstruction* GetNextInstruction();
126
127 void EmitClassOfTest(Label* if_true,
128 Label* if_false,
129 Handle<String> class_name,
130 Register input,
131 Register temporary);
132
133 int StackSlotCount() const { return chunk()->spill_slot_count(); }
134 int ParameterCount() const { return scope()->num_parameters(); }
135
136 void Abort(const char* format, ...);
137 void Comment(const char* format, ...);
138
139 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
140
141 // Code generation passes. Returns true if code generation should
142 // continue.
143 bool GeneratePrologue();
144 bool GenerateBody();
145 bool GenerateDeferredCode();
146 bool GenerateSafepointTable();
147
148 void CallCode(Handle<Code> code,
149 RelocInfo::Mode mode,
150 LInstruction* instr);
151 void CallRuntime(Runtime::Function* function,
152 int num_arguments,
153 LInstruction* instr);
154 void CallRuntime(Runtime::FunctionId id,
155 int num_arguments,
156 LInstruction* instr) {
157 Runtime::Function* function = Runtime::FunctionForId(id);
158 CallRuntime(function, num_arguments, instr);
159 }
160
161 // Generate a direct call to a known function. Expects the function
162 // to be in edi.
163 void CallKnownFunction(Handle<JSFunction> function,
164 int arity,
165 LInstruction* instr);
166
167 void LoadHeapObject(Register result, Handle<HeapObject> object);
168
169 void RegisterLazyDeoptimization(LInstruction* instr);
170 void RegisterEnvironmentForDeoptimization(LEnvironment* environment);
171 void DeoptimizeIf(Condition cc, LEnvironment* environment);
172
173 void AddToTranslation(Translation* translation,
174 LOperand* op,
175 bool is_tagged);
176 void PopulateDeoptimizationData(Handle<Code> code);
177 int DefineDeoptimizationLiteral(Handle<Object> literal);
178
179 void PopulateDeoptimizationLiteralsWithInlinedFunctions();
180
181 Register ToRegister(int index) const;
182 XMMRegister ToDoubleRegister(int index) const;
183
184 // Specific math operations - used from DoUnaryMathOperation.
185 void DoMathAbs(LUnaryMathOperation* instr);
186 void DoMathFloor(LUnaryMathOperation* instr);
187 void DoMathRound(LUnaryMathOperation* instr);
188 void DoMathSqrt(LUnaryMathOperation* instr);
189 void DoMathPowHalf(LUnaryMathOperation* instr);
190 void DoMathLog(LUnaryMathOperation* instr);
191 void DoMathCos(LUnaryMathOperation* instr);
192 void DoMathSin(LUnaryMathOperation* instr);
193
194 // Support for recording safepoint and position information.
195 void RecordSafepoint(LPointerMap* pointers,
196 Safepoint::Kind kind,
197 int arguments,
198 int deoptimization_index);
199 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
200 void RecordSafepointWithRegisters(LPointerMap* pointers,
201 int arguments,
202 int deoptimization_index);
203 void RecordPosition(int position);
204
205 static Condition TokenToCondition(Token::Value op, bool is_unsigned);
206 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL);
207 void EmitBranch(int left_block, int right_block, Condition cc);
208 void EmitCmpI(LOperand* left, LOperand* right);
209 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env);
210
211 // Emits optimized code for typeof x == "y". Modifies input register.
212 // Returns the condition on which a final split to
213 // true and false label should be made, to optimize fallthrough.
214 Condition EmitTypeofIs(Label* true_label, Label* false_label,
215 Register input, Handle<String> type_name);
216
217 // Emits optimized code for %_IsObject(x). Preserves input register.
218 // Returns the condition on which a final split to
219 // true and false label should be made, to optimize fallthrough.
220 Condition EmitIsObject(Register input,
221 Label* is_not_object,
222 Label* is_object);
223
224 // Emits optimized code for %_IsConstructCall().
225 // Caller should branch on equal condition.
226 void EmitIsConstructCall(Register temp);
227
228 LChunk* const chunk_;
229 MacroAssembler* const masm_;
230 CompilationInfo* const info_;
231
232 int current_block_;
233 int current_instruction_;
234 const ZoneList<LInstruction*>* instructions_;
235 ZoneList<LEnvironment*> deoptimizations_;
236 ZoneList<Handle<Object> > deoptimization_literals_;
237 int inlined_function_count_;
238 Scope* const scope_;
239 Status status_;
240 TranslationBuffer translations_;
241 ZoneList<LDeferredCode*> deferred_;
242 int osr_pc_offset_;
243
244 // Builder that keeps track of safepoints in the code. The table
245 // itself is emitted at the end of the generated code.
246 SafepointTableBuilder safepoints_;
247
248 // Compiler from a set of parallel moves to a sequential list of moves.
249 LGapResolver resolver_;
250
251 friend class LDeferredCode;
252 friend class LEnvironment;
253 friend class SafepointGenerator;
254 DISALLOW_COPY_AND_ASSIGN(LCodeGen);
58 }; 255 };
59 256
257
258 class LDeferredCode: public ZoneObject {
259 public:
260 explicit LDeferredCode(LCodeGen* codegen)
261 : codegen_(codegen), external_exit_(NULL) {
262 codegen->AddDeferredCode(this);
263 }
264
265 virtual ~LDeferredCode() { }
266 virtual void Generate() = 0;
267
268 void SetExit(Label *exit) { external_exit_ = exit; }
269 Label* entry() { return &entry_; }
270 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; }
271
272 protected:
273 LCodeGen* codegen() const { return codegen_; }
274 MacroAssembler* masm() const { return codegen_->masm(); }
275
276 private:
277 LCodeGen* codegen_;
278 Label entry_;
279 Label exit_;
280 Label* external_exit_;
281 };
282
60 } } // namespace v8::internal 283 } } // namespace v8::internal
61 284
62 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ 285 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698