Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / v8 / src / lithium-codegen.h
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.
4
5 #ifndef V8_LITHIUM_CODEGEN_H_
6 #define V8_LITHIUM_CODEGEN_H_
7
8 #include "v8.h"
9
10 #include "compiler.h"
11
12 namespace v8 {
13 namespace internal {
14
15 class LInstruction;
16 class LPlatformChunk;
17
18 class LCodeGenBase BASE_EMBEDDED {
19  public:
20   LCodeGenBase(LChunk* chunk,
21                MacroAssembler* assembler,
22                CompilationInfo* info);
23   virtual ~LCodeGenBase() {}
24
25   // Simple accessors.
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;
34
35   void FPRINTF_CHECKING Comment(const char* format, ...);
36
37   bool GenerateBody();
38   virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
39   virtual void GenerateBodyInstructionPost(LInstruction* instr) {}
40
41   virtual void EnsureSpaceForLazyDeopt(int space_needed) = 0;
42   virtual void RecordAndWritePosition(int position) = 0;
43
44   int GetNextEmittedBlock() const;
45
46   void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
47
48   // Check that an environment assigned via AssignEnvironment is actually being
49   // used. Redundant assignments keep things alive longer than necessary, and
50   // consequently lead to worse code, so it's important to minimize this.
51   void CheckEnvironmentUsage();
52
53  protected:
54   enum Status {
55     UNUSED,
56     GENERATING,
57     DONE,
58     ABORTED
59   };
60
61   LPlatformChunk* const chunk_;
62   MacroAssembler* const masm_;
63   CompilationInfo* const info_;
64   Zone* zone_;
65   Status status_;
66   int current_block_;
67   int current_instruction_;
68   const ZoneList<LInstruction*>* instructions_;
69   int last_lazy_deopt_pc_;
70
71   bool is_unused() const { return status_ == UNUSED; }
72   bool is_generating() const { return status_ == GENERATING; }
73   bool is_done() const { return status_ == DONE; }
74   bool is_aborted() const { return status_ == ABORTED; }
75
76   void Abort(BailoutReason reason);
77
78   // Methods for code dependencies.
79   void AddDeprecationDependency(Handle<Map> map);
80   void AddStabilityDependency(Handle<Map> map);
81 };
82
83
84 } }  // namespace v8::internal
85
86 #endif  // V8_LITHIUM_CODEGEN_H_