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"
20 class LCodeGenBase BASE_EMBEDDED {
22 LCodeGenBase(LChunk* chunk,
23 MacroAssembler* assembler,
24 CompilationInfo* info);
25 virtual ~LCodeGenBase() {}
28 MacroAssembler* masm() const { return masm_; }
29 CompilationInfo* info() const { return info_; }
30 Isolate* isolate() const { return info_->isolate(); }
31 Factory* factory() const { return isolate()->factory(); }
32 Heap* heap() const { return isolate()->heap(); }
33 Zone* zone() const { return zone_; }
34 LPlatformChunk* chunk() const { return chunk_; }
35 HGraph* graph() const;
37 void FPRINTF_CHECKING Comment(const char* format, ...);
38 void DeoptComment(const Deoptimizer::DeoptInfo& deopt_info);
39 static Deoptimizer::DeoptInfo MakeDeoptInfo(
40 LInstruction* instr, Deoptimizer::DeoptReason deopt_reason);
43 virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
44 virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
46 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
47 virtual void RecordAndWritePosition(int position) = 0;
49 int GetNextEmittedBlock() const;
51 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
53 // Check that an environment assigned via AssignEnvironment is actually being
54 // used. Redundant assignments keep things alive longer than necessary, and
55 // consequently lead to worse code, so it's important to minimize this.
56 void CheckEnvironmentUsage();
66 LPlatformChunk* const chunk_;
67 MacroAssembler* const masm_;
68 CompilationInfo* const info_;
72 int current_instruction_;
73 const ZoneList<LInstruction*>* instructions_;
74 int last_lazy_deopt_pc_;
76 bool is_unused() const { return status_ == UNUSED; }
77 bool is_generating() const { return status_ == GENERATING; }
78 bool is_done() const { return status_ == DONE; }
79 bool is_aborted() const { return status_ == ABORTED; }
81 void Abort(BailoutReason reason);
82 void Retry(BailoutReason reason);
84 // Methods for code dependencies.
85 void AddDeprecationDependency(Handle<Map> map);
86 void AddStabilityDependency(Handle<Map> map);
90 } } // namespace v8::internal
92 #endif // V8_LITHIUM_CODEGEN_H_