OLD | NEW |
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 14 matching lines...) Expand all Loading... |
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_ARM_LITHIUM_CODEGEN_ARM_H_ | 28 #ifndef V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
29 #define V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 29 #define V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
30 | 30 |
31 #include "arm/lithium-arm.h" | 31 #include "arm/lithium-arm.h" |
32 | 32 |
33 #include "arm/lithium-gap-resolver-arm.h" | 33 #include "arm/lithium-gap-resolver-arm.h" |
34 #include "deoptimizer.h" | 34 #include "deoptimizer.h" |
| 35 #include "lithium-codegen.h" |
35 #include "safepoint-table.h" | 36 #include "safepoint-table.h" |
36 #include "scopes.h" | 37 #include "scopes.h" |
37 #include "v8utils.h" | 38 #include "v8utils.h" |
38 | 39 |
39 namespace v8 { | 40 namespace v8 { |
40 namespace internal { | 41 namespace internal { |
41 | 42 |
42 // Forward declarations. | 43 // Forward declarations. |
43 class LDeferredCode; | 44 class LDeferredCode; |
44 class SafepointGenerator; | 45 class SafepointGenerator; |
45 | 46 |
46 class LCodeGen V8_FINAL BASE_EMBEDDED { | 47 class LCodeGen: public LCodeGenBase { |
47 public: | 48 public: |
48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
49 : zone_(info->zone()), | 50 : LCodeGenBase(chunk, assembler, info), |
50 chunk_(static_cast<LPlatformChunk*>(chunk)), | |
51 masm_(assembler), | |
52 info_(info), | |
53 current_block_(-1), | |
54 current_instruction_(-1), | |
55 instructions_(chunk->instructions()), | |
56 deoptimizations_(4, info->zone()), | 51 deoptimizations_(4, info->zone()), |
57 deopt_jump_table_(4, info->zone()), | 52 deopt_jump_table_(4, info->zone()), |
58 deoptimization_literals_(8, info->zone()), | 53 deoptimization_literals_(8, info->zone()), |
59 inlined_function_count_(0), | 54 inlined_function_count_(0), |
60 scope_(info->scope()), | 55 scope_(info->scope()), |
61 status_(UNUSED), | |
62 translations_(info->zone()), | 56 translations_(info->zone()), |
63 deferred_(8, info->zone()), | 57 deferred_(8, info->zone()), |
64 osr_pc_offset_(-1), | 58 osr_pc_offset_(-1), |
65 last_lazy_deopt_pc_(0), | |
66 frame_is_built_(false), | 59 frame_is_built_(false), |
67 safepoints_(info->zone()), | 60 safepoints_(info->zone()), |
68 resolver_(this), | 61 resolver_(this), |
69 expected_safepoint_kind_(Safepoint::kSimple), | 62 expected_safepoint_kind_(Safepoint::kSimple), |
70 old_position_(RelocInfo::kNoPosition) { | 63 old_position_(RelocInfo::kNoPosition) { |
71 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
72 } | 65 } |
73 | 66 |
74 | 67 |
75 // Simple accessors. | |
76 MacroAssembler* masm() const { return masm_; } | |
77 CompilationInfo* info() const { return info_; } | |
78 Isolate* isolate() const { return info_->isolate(); } | |
79 Factory* factory() const { return isolate()->factory(); } | |
80 Heap* heap() const { return isolate()->heap(); } | |
81 Zone* zone() const { return zone_; } | |
82 | |
83 int LookupDestination(int block_id) const { | 68 int LookupDestination(int block_id) const { |
84 return chunk()->LookupDestination(block_id); | 69 return chunk()->LookupDestination(block_id); |
85 } | 70 } |
86 | 71 |
87 bool IsNextEmittedBlock(int block_id) const { | 72 bool IsNextEmittedBlock(int block_id) const { |
88 return LookupDestination(block_id) == GetNextEmittedBlock(); | 73 return LookupDestination(block_id) == GetNextEmittedBlock(); |
89 } | 74 } |
90 | 75 |
91 bool NeedsEagerFrame() const { | 76 bool NeedsEagerFrame() const { |
92 return GetStackSlotCount() > 0 || | 77 return GetStackSlotCount() > 0 || |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 156 |
172 // Emit frame translation commands for an environment. | 157 // Emit frame translation commands for an environment. |
173 void WriteTranslation(LEnvironment* environment, Translation* translation); | 158 void WriteTranslation(LEnvironment* environment, Translation* translation); |
174 | 159 |
175 // Declare methods that deal with the individual node types. | 160 // Declare methods that deal with the individual node types. |
176 #define DECLARE_DO(type) void Do##type(L##type* node); | 161 #define DECLARE_DO(type) void Do##type(L##type* node); |
177 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 162 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
178 #undef DECLARE_DO | 163 #undef DECLARE_DO |
179 | 164 |
180 private: | 165 private: |
181 enum Status { | |
182 UNUSED, | |
183 GENERATING, | |
184 DONE, | |
185 ABORTED | |
186 }; | |
187 | |
188 bool is_unused() const { return status_ == UNUSED; } | |
189 bool is_generating() const { return status_ == GENERATING; } | |
190 bool is_done() const { return status_ == DONE; } | |
191 bool is_aborted() const { return status_ == ABORTED; } | |
192 | |
193 StrictModeFlag strict_mode_flag() const { | 166 StrictModeFlag strict_mode_flag() const { |
194 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; | 167 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; |
195 } | 168 } |
196 | 169 |
197 LPlatformChunk* chunk() const { return chunk_; } | |
198 Scope* scope() const { return scope_; } | 170 Scope* scope() const { return scope_; } |
199 HGraph* graph() const { return chunk()->graph(); } | |
200 | 171 |
201 Register scratch0() { return r9; } | 172 Register scratch0() { return r9; } |
202 LowDwVfpRegister double_scratch0() { return kScratchDoubleReg; } | 173 LowDwVfpRegister double_scratch0() { return kScratchDoubleReg; } |
203 | 174 |
204 int GetNextEmittedBlock() const; | |
205 LInstruction* GetNextInstruction(); | 175 LInstruction* GetNextInstruction(); |
206 | 176 |
207 void EmitClassOfTest(Label* if_true, | 177 void EmitClassOfTest(Label* if_true, |
208 Label* if_false, | 178 Label* if_false, |
209 Handle<String> class_name, | 179 Handle<String> class_name, |
210 Register input, | 180 Register input, |
211 Register temporary, | 181 Register temporary, |
212 Register temporary2); | 182 Register temporary2); |
213 | 183 |
214 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } | 184 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
215 | 185 |
216 void Abort(BailoutReason reason); | 186 void Abort(BailoutReason reason); |
217 void FPRINTF_CHECKING Comment(const char* format, ...); | |
218 | 187 |
219 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } | 188 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } |
220 | 189 |
221 // Code generation passes. Returns true if code generation should | 190 // Code generation passes. Returns true if code generation should |
222 // continue. | 191 // continue. |
223 bool GeneratePrologue(); | 192 bool GeneratePrologue(); |
224 bool GenerateBody(); | |
225 bool GenerateDeferredCode(); | 193 bool GenerateDeferredCode(); |
226 bool GenerateDeoptJumpTable(); | 194 bool GenerateDeoptJumpTable(); |
227 bool GenerateSafepointTable(); | 195 bool GenerateSafepointTable(); |
228 | 196 |
229 // Generates the custom OSR entrypoint and sets the osr_pc_offset. | 197 // Generates the custom OSR entrypoint and sets the osr_pc_offset. |
230 void GenerateOsrPrologue(); | 198 void GenerateOsrPrologue(); |
231 | 199 |
232 enum SafepointMode { | 200 enum SafepointMode { |
233 RECORD_SIMPLE_SAFEPOINT, | 201 RECORD_SIMPLE_SAFEPOINT, |
234 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS | 202 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 Safepoint::DeoptMode mode); | 285 Safepoint::DeoptMode mode); |
318 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); | 286 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); |
319 void RecordSafepoint(Safepoint::DeoptMode mode); | 287 void RecordSafepoint(Safepoint::DeoptMode mode); |
320 void RecordSafepointWithRegisters(LPointerMap* pointers, | 288 void RecordSafepointWithRegisters(LPointerMap* pointers, |
321 int arguments, | 289 int arguments, |
322 Safepoint::DeoptMode mode); | 290 Safepoint::DeoptMode mode); |
323 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, | 291 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
324 int arguments, | 292 int arguments, |
325 Safepoint::DeoptMode mode); | 293 Safepoint::DeoptMode mode); |
326 void RecordPosition(int position); | 294 void RecordPosition(int position); |
327 void RecordAndUpdatePosition(int position); | 295 void RecordAndUpdatePosition(int position) V8_OVERRIDE; |
328 | 296 |
329 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 297 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
330 void EmitGoto(int block); | 298 void EmitGoto(int block); |
331 template<class InstrType> | 299 template<class InstrType> |
332 void EmitBranch(InstrType instr, Condition condition); | 300 void EmitBranch(InstrType instr, Condition condition); |
333 template<class InstrType> | 301 template<class InstrType> |
334 void EmitFalseBranch(InstrType instr, Condition condition); | 302 void EmitFalseBranch(InstrType instr, Condition condition); |
335 void EmitNumberUntagD(Register input, | 303 void EmitNumberUntagD(Register input, |
336 DwVfpRegister result, | 304 DwVfpRegister result, |
337 bool allow_undefined_as_nan, | 305 bool allow_undefined_as_nan, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // Inputs are signed. | 347 // Inputs are signed. |
380 // All registers are clobbered. | 348 // All registers are clobbered. |
381 // If 'remainder' is no_reg, it is not computed. | 349 // If 'remainder' is no_reg, it is not computed. |
382 void EmitSignedIntegerDivisionByConstant(Register result, | 350 void EmitSignedIntegerDivisionByConstant(Register result, |
383 Register dividend, | 351 Register dividend, |
384 int32_t divisor, | 352 int32_t divisor, |
385 Register remainder, | 353 Register remainder, |
386 Register scratch, | 354 Register scratch, |
387 LEnvironment* environment); | 355 LEnvironment* environment); |
388 | 356 |
389 void EnsureSpaceForLazyDeopt(); | 357 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE; |
390 void DoLoadKeyedExternalArray(LLoadKeyed* instr); | 358 void DoLoadKeyedExternalArray(LLoadKeyed* instr); |
391 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); | 359 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); |
392 void DoLoadKeyedFixedArray(LLoadKeyed* instr); | 360 void DoLoadKeyedFixedArray(LLoadKeyed* instr); |
393 void DoStoreKeyedExternalArray(LStoreKeyed* instr); | 361 void DoStoreKeyedExternalArray(LStoreKeyed* instr); |
394 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); | 362 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); |
395 void DoStoreKeyedFixedArray(LStoreKeyed* instr); | 363 void DoStoreKeyedFixedArray(LStoreKeyed* instr); |
396 | 364 |
397 Zone* zone_; | |
398 LPlatformChunk* const chunk_; | |
399 MacroAssembler* const masm_; | |
400 CompilationInfo* const info_; | |
401 | |
402 int current_block_; | |
403 int current_instruction_; | |
404 const ZoneList<LInstruction*>* instructions_; | |
405 ZoneList<LEnvironment*> deoptimizations_; | 365 ZoneList<LEnvironment*> deoptimizations_; |
406 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; | 366 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; |
407 ZoneList<Handle<Object> > deoptimization_literals_; | 367 ZoneList<Handle<Object> > deoptimization_literals_; |
408 int inlined_function_count_; | 368 int inlined_function_count_; |
409 Scope* const scope_; | 369 Scope* const scope_; |
410 Status status_; | |
411 TranslationBuffer translations_; | 370 TranslationBuffer translations_; |
412 ZoneList<LDeferredCode*> deferred_; | 371 ZoneList<LDeferredCode*> deferred_; |
413 int osr_pc_offset_; | 372 int osr_pc_offset_; |
414 int last_lazy_deopt_pc_; | |
415 bool frame_is_built_; | 373 bool frame_is_built_; |
416 | 374 |
417 // Builder that keeps track of safepoints in the code. The table | 375 // Builder that keeps track of safepoints in the code. The table |
418 // itself is emitted at the end of the generated code. | 376 // itself is emitted at the end of the generated code. |
419 SafepointTableBuilder safepoints_; | 377 SafepointTableBuilder safepoints_; |
420 | 378 |
421 // Compiler from a set of parallel moves to a sequential list of moves. | 379 // Compiler from a set of parallel moves to a sequential list of moves. |
422 LGapResolver resolver_; | 380 LGapResolver resolver_; |
423 | 381 |
424 Safepoint::Kind expected_safepoint_kind_; | 382 Safepoint::Kind expected_safepoint_kind_; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 LCodeGen* codegen_; | 457 LCodeGen* codegen_; |
500 Label entry_; | 458 Label entry_; |
501 Label exit_; | 459 Label exit_; |
502 Label* external_exit_; | 460 Label* external_exit_; |
503 int instruction_index_; | 461 int instruction_index_; |
504 }; | 462 }; |
505 | 463 |
506 } } // namespace v8::internal | 464 } } // namespace v8::internal |
507 | 465 |
508 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 466 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
OLD | NEW |