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_
10 #include "src/bailout-reason.h"
11 #include "src/compiler.h"
12 #include "src/deoptimizer.h"
21 class LCodeGenBase BASE_EMBEDDED {
23 LCodeGenBase(LChunk* chunk,
24 MacroAssembler* assembler,
25 CompilationInfo* info);
26 virtual ~LCodeGenBase() {}
29 MacroAssembler* masm() const { return masm_; }
30 CompilationInfo* info() const { return info_; }
31 Isolate* isolate() const { return info_->isolate(); }
32 Factory* factory() const { return isolate()->factory(); }
33 Heap* heap() const { return isolate()->heap(); }
34 Zone* zone() const { return zone_; }
35 LPlatformChunk* chunk() const { return chunk_; }
36 HGraph* graph() const;
38 void FPRINTF_CHECKING Comment(const char* format, ...);
39 void DeoptComment(const Deoptimizer::DeoptInfo& deopt_info);
40 static Deoptimizer::DeoptInfo MakeDeoptInfo(
41 LInstruction* instr, Deoptimizer::DeoptReason deopt_reason);
44 virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
45 virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
47 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
48 virtual void RecordAndWritePosition(int position) = 0;
50 int GetNextEmittedBlock() const;
52 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
54 void WriteTranslationFrame(LEnvironment* environment,
55 Translation* translation);
56 int DefineDeoptimizationLiteral(Handle<Object> literal);
58 // Check that an environment assigned via AssignEnvironment is actually being
59 // used. Redundant assignments keep things alive longer than necessary, and
60 // consequently lead to worse code, so it's important to minimize this.
61 void CheckEnvironmentUsage();
71 LPlatformChunk* const chunk_;
72 MacroAssembler* const masm_;
73 CompilationInfo* const info_;
77 int current_instruction_;
78 const ZoneList<LInstruction*>* instructions_;
79 ZoneList<Handle<Object> > deoptimization_literals_;
80 int last_lazy_deopt_pc_;
82 bool is_unused() const { return status_ == UNUSED; }
83 bool is_generating() const { return status_ == GENERATING; }
84 bool is_done() const { return status_ == DONE; }
85 bool is_aborted() const { return status_ == ABORTED; }
87 void Abort(BailoutReason reason);
88 void Retry(BailoutReason reason);
90 // Methods for code dependencies.
91 void AddDeprecationDependency(Handle<Map> map);
92 void AddStabilityDependency(Handle<Map> map);
96 } } // namespace v8::internal
98 #endif // V8_LITHIUM_CODEGEN_H_