OLD | NEW |
| (Empty) |
1 // Copyright 2013 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_LITHIUM_CODEGEN_H_ | |
6 #define V8_LITHIUM_CODEGEN_H_ | |
7 | |
8 #include "src/bailout-reason.h" | |
9 #include "src/compiler.h" | |
10 #include "src/deoptimizer.h" | |
11 | |
12 namespace v8 { | |
13 namespace internal { | |
14 | |
15 class LEnvironment; | |
16 class LInstruction; | |
17 class LPlatformChunk; | |
18 | |
19 class LCodeGenBase BASE_EMBEDDED { | |
20 public: | |
21 LCodeGenBase(LChunk* chunk, | |
22 MacroAssembler* assembler, | |
23 CompilationInfo* info); | |
24 virtual ~LCodeGenBase() {} | |
25 | |
26 // Simple accessors. | |
27 MacroAssembler* masm() const { return masm_; } | |
28 CompilationInfo* info() const { return info_; } | |
29 Isolate* isolate() const { return info_->isolate(); } | |
30 Factory* factory() const { return isolate()->factory(); } | |
31 Heap* heap() const { return isolate()->heap(); } | |
32 Zone* zone() const { return zone_; } | |
33 LPlatformChunk* chunk() const { return chunk_; } | |
34 HGraph* graph() const; | |
35 | |
36 void FPRINTF_CHECKING Comment(const char* format, ...); | |
37 void DeoptComment(const Deoptimizer::DeoptInfo& deopt_info); | |
38 static Deoptimizer::DeoptInfo MakeDeoptInfo( | |
39 LInstruction* instr, Deoptimizer::DeoptReason deopt_reason); | |
40 | |
41 bool GenerateBody(); | |
42 virtual void GenerateBodyInstructionPre(LInstruction* instr) {} | |
43 virtual void GenerateBodyInstructionPost(LInstruction* instr) {} | |
44 | |
45 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0; | |
46 virtual void RecordAndWritePosition(int position) = 0; | |
47 | |
48 int GetNextEmittedBlock() const; | |
49 | |
50 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); | |
51 | |
52 void WriteTranslationFrame(LEnvironment* environment, | |
53 Translation* translation); | |
54 int DefineDeoptimizationLiteral(Handle<Object> literal); | |
55 | |
56 // Check that an environment assigned via AssignEnvironment is actually being | |
57 // used. Redundant assignments keep things alive longer than necessary, and | |
58 // consequently lead to worse code, so it's important to minimize this. | |
59 void CheckEnvironmentUsage(); | |
60 | |
61 protected: | |
62 enum Status { | |
63 UNUSED, | |
64 GENERATING, | |
65 DONE, | |
66 ABORTED | |
67 }; | |
68 | |
69 LPlatformChunk* const chunk_; | |
70 MacroAssembler* const masm_; | |
71 CompilationInfo* const info_; | |
72 Zone* zone_; | |
73 Status status_; | |
74 int current_block_; | |
75 int current_instruction_; | |
76 const ZoneList<LInstruction*>* instructions_; | |
77 ZoneList<Handle<Object> > deoptimization_literals_; | |
78 int last_lazy_deopt_pc_; | |
79 | |
80 bool is_unused() const { return status_ == UNUSED; } | |
81 bool is_generating() const { return status_ == GENERATING; } | |
82 bool is_done() const { return status_ == DONE; } | |
83 bool is_aborted() const { return status_ == ABORTED; } | |
84 | |
85 void Abort(BailoutReason reason); | |
86 void Retry(BailoutReason reason); | |
87 | |
88 // Methods for code dependencies. | |
89 void AddDeprecationDependency(Handle<Map> map); | |
90 void AddStabilityDependency(Handle<Map> map); | |
91 }; | |
92 | |
93 | |
94 } // namespace internal | |
95 } // namespace v8 | |
96 | |
97 #endif // V8_LITHIUM_CODEGEN_H_ | |
OLD | NEW |