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/compiler.h"
11 #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::Reason& reason);
40 virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
41 virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
43 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
44 virtual void RecordAndWritePosition(int position) = 0;
46 int GetNextEmittedBlock() const;
48 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
50 // Check that an environment assigned via AssignEnvironment is actually being
51 // used. Redundant assignments keep things alive longer than necessary, and
52 // consequently lead to worse code, so it's important to minimize this.
53 void CheckEnvironmentUsage();
63 LPlatformChunk* const chunk_;
64 MacroAssembler* const masm_;
65 CompilationInfo* const info_;
69 int current_instruction_;
70 const ZoneList<LInstruction*>* instructions_;
71 int last_lazy_deopt_pc_;
73 bool is_unused() const { return status_ == UNUSED; }
74 bool is_generating() const { return status_ == GENERATING; }
75 bool is_done() const { return status_ == DONE; }
76 bool is_aborted() const { return status_ == ABORTED; }
78 void Abort(BailoutReason reason);
80 // Methods for code dependencies.
81 void AddDeprecationDependency(Handle<Map> map);
82 void AddStabilityDependency(Handle<Map> map);
86 } } // namespace v8::internal
88 #endif // V8_LITHIUM_CODEGEN_H_