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"
18 class LCodeGenBase BASE_EMBEDDED {
20 LCodeGenBase(LChunk* chunk,
21 MacroAssembler* assembler,
22 CompilationInfo* info);
23 virtual ~LCodeGenBase() {}
26 MacroAssembler* masm() const { return masm_; }
27 CompilationInfo* info() const { return info_; }
28 Isolate* isolate() const { return info_->isolate(); }
29 Factory* factory() const { return isolate()->factory(); }
30 Heap* heap() const { return isolate()->heap(); }
31 Zone* zone() const { return zone_; }
32 LPlatformChunk* chunk() const { return chunk_; }
33 HGraph* graph() const;
35 void FPRINTF_CHECKING Comment(const char* format, ...);
36 void DeoptComment(const char* mnemonic, const char* reason);
39 virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
40 virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
42 virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
43 virtual void RecordAndWritePosition(int position) = 0;
45 int GetNextEmittedBlock() const;
47 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
49 // Check that an environment assigned via AssignEnvironment is actually being
50 // used. Redundant assignments keep things alive longer than necessary, and
51 // consequently lead to worse code, so it's important to minimize this.
52 void CheckEnvironmentUsage();
62 LPlatformChunk* const chunk_;
63 MacroAssembler* const masm_;
64 CompilationInfo* const info_;
68 int current_instruction_;
69 const ZoneList<LInstruction*>* instructions_;
70 int last_lazy_deopt_pc_;
72 bool is_unused() const { return status_ == UNUSED; }
73 bool is_generating() const { return status_ == GENERATING; }
74 bool is_done() const { return status_ == DONE; }
75 bool is_aborted() const { return status_ == ABORTED; }
77 void Abort(BailoutReason reason);
79 // Methods for code dependencies.
80 void AddDeprecationDependency(Handle<Map> map);
81 void AddStabilityDependency(Handle<Map> map);
85 } } // namespace v8::internal
87 #endif // V8_LITHIUM_CODEGEN_H_