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.
5 #ifndef V8_LITHIUM_CODEGEN_H_
6 #define V8_LITHIUM_CODEGEN_H_
8 #include "src/bailout-reason.h"
9 #include "src/compiler.h"
10 #include "src/deoptimizer.h"
19 class LCodeGenBase BASE_EMBEDDED {
21 LCodeGenBase(LChunk* chunk,
22 MacroAssembler* assembler,
23 CompilationInfo* info);
24 virtual ~LCodeGenBase() {}
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;
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);
42 virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
43 virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
45 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
46 virtual void RecordAndWritePosition(int position) = 0;
48 int GetNextEmittedBlock() const;
50 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
52 void WriteTranslationFrame(LEnvironment* environment,
53 Translation* translation);
54 int DefineDeoptimizationLiteral(Handle<Object> literal);
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();
69 LPlatformChunk* const chunk_;
70 MacroAssembler* const masm_;
71 CompilationInfo* const info_;
75 int current_instruction_;
76 const ZoneList<LInstruction*>* instructions_;
77 ZoneList<Handle<Object> > deoptimization_literals_;
78 int last_lazy_deopt_pc_;
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; }
85 void Abort(BailoutReason reason);
86 void Retry(BailoutReason reason);
88 // Methods for code dependencies.
89 void AddDeprecationDependency(Handle<Map> map);
90 void AddStabilityDependency(Handle<Map> map);
94 } // namespace internal
97 #endif // V8_LITHIUM_CODEGEN_H_