OLD | NEW |
1 // Copyright 2011 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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 28 #ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
30 | 30 |
31 #include "ia32/lithium-ia32.h" | 31 #include "ia32/lithium-ia32.h" |
32 | 32 |
33 #include "checks.h" | 33 #include "checks.h" |
34 #include "deoptimizer.h" | 34 #include "deoptimizer.h" |
35 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
36 #include "scopes.h" | 36 #include "scopes.h" |
| 37 #include "ia32/lithium-gap-resolver-ia32.h" |
37 | 38 |
38 namespace v8 { | 39 namespace v8 { |
39 namespace internal { | 40 namespace internal { |
40 | 41 |
41 // Forward declarations. | 42 // Forward declarations. |
42 class LDeferredCode; | 43 class LDeferredCode; |
43 class LGapNode; | 44 class LGapNode; |
44 class SafepointGenerator; | 45 class SafepointGenerator; |
45 | 46 |
46 class LGapResolver BASE_EMBEDDED { | |
47 public: | |
48 LGapResolver(); | |
49 const ZoneList<LMoveOperands>* Resolve(const ZoneList<LMoveOperands>* moves, | |
50 LOperand* marker_operand); | |
51 | |
52 private: | |
53 LGapNode* LookupNode(LOperand* operand); | |
54 bool CanReach(LGapNode* a, LGapNode* b, int visited_id); | |
55 bool CanReach(LGapNode* a, LGapNode* b); | |
56 void RegisterMove(LMoveOperands move); | |
57 void AddResultMove(LOperand* from, LOperand* to); | |
58 void AddResultMove(LGapNode* from, LGapNode* to); | |
59 void ResolveCycle(LGapNode* start, LOperand* marker_operand); | |
60 | |
61 ZoneList<LGapNode*> nodes_; | |
62 ZoneList<LGapNode*> identified_cycles_; | |
63 ZoneList<LMoveOperands> result_; | |
64 int next_visited_id_; | |
65 }; | |
66 | |
67 | |
68 class LCodeGen BASE_EMBEDDED { | 47 class LCodeGen BASE_EMBEDDED { |
69 public: | 48 public: |
70 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
71 : chunk_(chunk), | 50 : chunk_(chunk), |
72 masm_(assembler), | 51 masm_(assembler), |
73 info_(info), | 52 info_(info), |
74 current_block_(-1), | 53 current_block_(-1), |
75 current_instruction_(-1), | 54 current_instruction_(-1), |
76 instructions_(chunk->instructions()), | 55 instructions_(chunk->instructions()), |
77 deoptimizations_(4), | 56 deoptimizations_(4), |
78 deoptimization_literals_(8), | 57 deoptimization_literals_(8), |
79 inlined_function_count_(0), | 58 inlined_function_count_(0), |
80 scope_(chunk->graph()->info()->scope()), | 59 scope_(chunk->graph()->info()->scope()), |
81 status_(UNUSED), | 60 status_(UNUSED), |
82 deferred_(8), | 61 deferred_(8), |
83 osr_pc_offset_(-1) { | 62 osr_pc_offset_(-1), |
| 63 resolver_(this) { |
84 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
85 } | 65 } |
86 | 66 |
| 67 // Simple accessors. |
| 68 MacroAssembler* masm() const { return masm_; } |
| 69 |
| 70 // Support for converting LOperands to assembler types. |
| 71 Operand ToOperand(LOperand* op) const; |
| 72 Register ToRegister(LOperand* op) const; |
| 73 XMMRegister ToDoubleRegister(LOperand* op) const; |
| 74 Immediate ToImmediate(LOperand* op); |
| 75 |
| 76 // The operand denoting the second word (the one with a higher address) of |
| 77 // a double stack slot. |
| 78 Operand HighOperand(LOperand* op); |
| 79 |
87 // Try to generate code for the entire chunk, but it may fail if the | 80 // Try to generate code for the entire chunk, but it may fail if the |
88 // chunk contains constructs we cannot handle. Returns true if the | 81 // chunk contains constructs we cannot handle. Returns true if the |
89 // code generation attempt succeeded. | 82 // code generation attempt succeeded. |
90 bool GenerateCode(); | 83 bool GenerateCode(); |
91 | 84 |
92 // Finish the code by setting stack height, safepoint, and bailout | 85 // Finish the code by setting stack height, safepoint, and bailout |
93 // information on it. | 86 // information on it. |
94 void FinishCode(Handle<Code> code); | 87 void FinishCode(Handle<Code> code); |
95 | 88 |
96 // Deferred code support. | 89 // Deferred code support. |
(...skipping 25 matching lines...) Expand all Loading... |
122 }; | 115 }; |
123 | 116 |
124 bool is_unused() const { return status_ == UNUSED; } | 117 bool is_unused() const { return status_ == UNUSED; } |
125 bool is_generating() const { return status_ == GENERATING; } | 118 bool is_generating() const { return status_ == GENERATING; } |
126 bool is_done() const { return status_ == DONE; } | 119 bool is_done() const { return status_ == DONE; } |
127 bool is_aborted() const { return status_ == ABORTED; } | 120 bool is_aborted() const { return status_ == ABORTED; } |
128 | 121 |
129 LChunk* chunk() const { return chunk_; } | 122 LChunk* chunk() const { return chunk_; } |
130 Scope* scope() const { return scope_; } | 123 Scope* scope() const { return scope_; } |
131 HGraph* graph() const { return chunk_->graph(); } | 124 HGraph* graph() const { return chunk_->graph(); } |
132 MacroAssembler* masm() const { return masm_; } | |
133 | 125 |
134 int GetNextEmittedBlock(int block); | 126 int GetNextEmittedBlock(int block); |
135 LInstruction* GetNextInstruction(); | 127 LInstruction* GetNextInstruction(); |
136 | 128 |
137 void EmitClassOfTest(Label* if_true, | 129 void EmitClassOfTest(Label* if_true, |
138 Label* if_false, | 130 Label* if_false, |
139 Handle<String> class_name, | 131 Handle<String> class_name, |
140 Register input, | 132 Register input, |
141 Register temporary, | 133 Register temporary, |
142 Register temporary2); | 134 Register temporary2); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void AddToTranslation(Translation* translation, | 176 void AddToTranslation(Translation* translation, |
185 LOperand* op, | 177 LOperand* op, |
186 bool is_tagged); | 178 bool is_tagged); |
187 void PopulateDeoptimizationData(Handle<Code> code); | 179 void PopulateDeoptimizationData(Handle<Code> code); |
188 int DefineDeoptimizationLiteral(Handle<Object> literal); | 180 int DefineDeoptimizationLiteral(Handle<Object> literal); |
189 | 181 |
190 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 182 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
191 | 183 |
192 Register ToRegister(int index) const; | 184 Register ToRegister(int index) const; |
193 XMMRegister ToDoubleRegister(int index) const; | 185 XMMRegister ToDoubleRegister(int index) const; |
194 Register ToRegister(LOperand* op) const; | |
195 XMMRegister ToDoubleRegister(LOperand* op) const; | |
196 int ToInteger32(LConstantOperand* op) const; | 186 int ToInteger32(LConstantOperand* op) const; |
197 Operand ToOperand(LOperand* op) const; | |
198 Immediate ToImmediate(LOperand* op); | |
199 | 187 |
200 // Specific math operations - used from DoUnaryMathOperation. | 188 // Specific math operations - used from DoUnaryMathOperation. |
201 void DoMathAbs(LUnaryMathOperation* instr); | 189 void DoMathAbs(LUnaryMathOperation* instr); |
202 void DoMathFloor(LUnaryMathOperation* instr); | 190 void DoMathFloor(LUnaryMathOperation* instr); |
203 void DoMathRound(LUnaryMathOperation* instr); | 191 void DoMathRound(LUnaryMathOperation* instr); |
204 void DoMathSqrt(LUnaryMathOperation* instr); | 192 void DoMathSqrt(LUnaryMathOperation* instr); |
205 void DoMathPowHalf(LUnaryMathOperation* instr); | 193 void DoMathPowHalf(LUnaryMathOperation* instr); |
206 void DoMathLog(LUnaryMathOperation* instr); | 194 void DoMathLog(LUnaryMathOperation* instr); |
207 void DoMathCos(LUnaryMathOperation* instr); | 195 void DoMathCos(LUnaryMathOperation* instr); |
208 void DoMathSin(LUnaryMathOperation* instr); | 196 void DoMathSin(LUnaryMathOperation* instr); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 private: | 274 private: |
287 LCodeGen* codegen_; | 275 LCodeGen* codegen_; |
288 Label entry_; | 276 Label entry_; |
289 Label exit_; | 277 Label exit_; |
290 Label* external_exit_; | 278 Label* external_exit_; |
291 }; | 279 }; |
292 | 280 |
293 } } // namespace v8::internal | 281 } } // namespace v8::internal |
294 | 282 |
295 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 283 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
OLD | NEW |