OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 20 matching lines...) Expand all Loading... |
32 | 32 |
33 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
34 #include "safepoint-table.h" | 34 #include "safepoint-table.h" |
35 #include "scopes.h" | 35 #include "scopes.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 // Forward declarations. | 40 // Forward declarations. |
41 class LDeferredCode; | 41 class LDeferredCode; |
| 42 class SafepointGenerator; |
42 | 43 |
43 class LCodeGen BASE_EMBEDDED { | 44 class LCodeGen BASE_EMBEDDED { |
44 public: | 45 public: |
45 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) { } | 46 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 47 : chunk_(chunk), |
| 48 masm_(assembler), |
| 49 info_(info), |
| 50 current_block_(-1), |
| 51 current_instruction_(-1), |
| 52 instructions_(chunk->instructions()), |
| 53 deoptimizations_(4), |
| 54 deoptimization_literals_(8), |
| 55 inlined_function_count_(0), |
| 56 scope_(chunk->graph()->info()->scope()), |
| 57 status_(UNUSED), |
| 58 deferred_(8), |
| 59 osr_pc_offset_(-1) { |
| 60 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 61 } |
46 | 62 |
47 // Try to generate code for the entire chunk, but it may fail if the | 63 // Try to generate code for the entire chunk, but it may fail if the |
48 // chunk contains constructs we cannot handle. Returns true if the | 64 // chunk contains constructs we cannot handle. Returns true if the |
49 // code generation attempt succeeded. | 65 // code generation attempt succeeded. |
50 bool GenerateCode() { | 66 bool GenerateCode() { |
51 UNIMPLEMENTED(); | 67 UNIMPLEMENTED(); |
52 return false; | 68 return false; |
53 } | 69 } |
54 | 70 |
| 71 |
55 // Finish the code by setting stack height, safepoint, and bailout | 72 // Finish the code by setting stack height, safepoint, and bailout |
56 // information on it. | 73 // information on it. |
57 void FinishCode(Handle<Code> code) { UNIMPLEMENTED(); } | 74 void FinishCode(Handle<Code> code) { UNIMPLEMENTED(); } |
| 75 |
| 76 // Parallel move support. |
| 77 void DoParallelMove(LParallelMove* move); |
| 78 |
| 79 // Declare methods that deal with the individual node types. |
| 80 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 81 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 82 #undef DECLARE_DO |
| 83 |
| 84 private: |
| 85 enum Status { |
| 86 UNUSED, |
| 87 GENERATING, |
| 88 DONE, |
| 89 ABORTED |
| 90 }; |
| 91 |
| 92 bool is_unused() const { return status_ == UNUSED; } |
| 93 bool is_generating() const { return status_ == GENERATING; } |
| 94 bool is_done() const { return status_ == DONE; } |
| 95 bool is_aborted() const { return status_ == ABORTED; } |
| 96 |
| 97 LChunk* chunk() const { return chunk_; } |
| 98 Scope* scope() const { return scope_; } |
| 99 HGraph* graph() const { return chunk_->graph(); } |
| 100 MacroAssembler* masm() const { return masm_; } |
| 101 |
| 102 int GetNextEmittedBlock(int block) { |
| 103 UNIMPLEMENTED(); |
| 104 return 0; |
| 105 } |
| 106 LInstruction* GetNextInstruction() { |
| 107 UNIMPLEMENTED(); |
| 108 return NULL; |
| 109 } |
| 110 |
| 111 void EmitClassOfTest(Label* if_true, |
| 112 Label* if_false, |
| 113 Handle<String> class_name, |
| 114 Register input, |
| 115 Register temporary, |
| 116 Register temporary2) { UNIMPLEMENTED(); } |
| 117 |
| 118 int StackSlotCount() const { return chunk()->spill_slot_count(); } |
| 119 int ParameterCount() const { return scope()->num_parameters(); } |
| 120 |
| 121 void Abort(const char* format, ...) { UNIMPLEMENTED(); } |
| 122 void Comment(const char* format, ...) { UNIMPLEMENTED(); } |
| 123 |
| 124 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
| 125 |
| 126 // Code generation passes. Returns true if code generation should |
| 127 // continue. |
| 128 bool GeneratePrologue() { |
| 129 UNIMPLEMENTED(); |
| 130 return true; |
| 131 } |
| 132 bool GenerateBody() { |
| 133 UNIMPLEMENTED(); |
| 134 return true; |
| 135 } |
| 136 bool GenerateDeferredCode() { |
| 137 UNIMPLEMENTED(); |
| 138 return true; |
| 139 } |
| 140 bool GenerateSafepointTable() { |
| 141 UNIMPLEMENTED(); |
| 142 return true; |
| 143 } |
| 144 |
| 145 void CallCode(Handle<Code> code, |
| 146 RelocInfo::Mode mode, |
| 147 LInstruction* instr) { UNIMPLEMENTED(); } |
| 148 void CallRuntime(Runtime::Function* function, |
| 149 int num_arguments, |
| 150 LInstruction* instr) { UNIMPLEMENTED(); } |
| 151 void CallRuntime(Runtime::FunctionId id, |
| 152 int num_arguments, |
| 153 LInstruction* instr) { |
| 154 Runtime::Function* function = Runtime::FunctionForId(id); |
| 155 CallRuntime(function, num_arguments, instr); |
| 156 } |
| 157 |
| 158 void DeoptimizeIf(Condition cc, LEnvironment* environment) { |
| 159 UNIMPLEMENTED(); |
| 160 } |
| 161 void PopulateDeoptimizationLiteralsWithInlinedFunctions() { UNIMPLEMENTED(); } |
| 162 |
| 163 LChunk* const chunk_; |
| 164 MacroAssembler* const masm_; |
| 165 CompilationInfo* const info_; |
| 166 |
| 167 int current_block_; |
| 168 int current_instruction_; |
| 169 const ZoneList<LInstruction*>* instructions_; |
| 170 ZoneList<LEnvironment*> deoptimizations_; |
| 171 ZoneList<Handle<Object> > deoptimization_literals_; |
| 172 int inlined_function_count_; |
| 173 Scope* const scope_; |
| 174 Status status_; |
| 175 TranslationBuffer translations_; |
| 176 ZoneList<LDeferredCode*> deferred_; |
| 177 int osr_pc_offset_; |
| 178 |
| 179 // Builder that keeps track of safepoints in the code. The table |
| 180 // itself is emitted at the end of the generated code. |
| 181 SafepointTableBuilder safepoints_; |
| 182 |
| 183 friend class LDeferredCode; |
| 184 friend class LEnvironment; |
| 185 friend class SafepointGenerator; |
| 186 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
| 187 }; |
| 188 |
| 189 |
| 190 class LDeferredCode: public ZoneObject { |
| 191 public: |
| 192 explicit LDeferredCode(LCodeGen* codegen) |
| 193 : codegen_(codegen), external_exit_(NULL) { |
| 194 codegen->AddDeferredCode(this); |
| 195 } |
| 196 |
| 197 virtual ~LDeferredCode() { } |
| 198 virtual void Generate() = 0; |
| 199 |
| 200 void SetExit(Label *exit) { external_exit_ = exit; } |
| 201 Label* entry() { return &entry_; } |
| 202 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
| 203 |
| 204 protected: |
| 205 LCodeGen* codegen() const { return codegen_; } |
| 206 MacroAssembler* masm() const { return codegen_->masm(); } |
| 207 |
| 208 private: |
| 209 LCodeGen* codegen_; |
| 210 Label entry_; |
| 211 Label exit_; |
| 212 Label* external_exit_; |
58 }; | 213 }; |
59 | 214 |
60 } } // namespace v8::internal | 215 } } // namespace v8::internal |
61 | 216 |
62 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ | 217 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ |
OLD | NEW |