sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| 29 | #define V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| 30 | |
| 31 | #include "arm/lithium-arm.h" |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 32 | #include "arm/lithium-gap-resolver-arm.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 33 | #include "deoptimizer.h" |
| 34 | #include "safepoint-table.h" |
| 35 | #include "scopes.h" |
| 36 | |
| 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
| 40 | // Forward declarations. |
| 41 | class LDeferredCode; |
| 42 | class SafepointGenerator; |
| 43 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 44 | class LCodeGen BASE_EMBEDDED { |
| 45 | public: |
| 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), |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 54 | deopt_jump_table_(4), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 55 | deoptimization_literals_(8), |
| 56 | inlined_function_count_(0), |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 57 | scope_(info->scope()), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 58 | status_(UNUSED), |
| 59 | deferred_(8), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 60 | osr_pc_offset_(-1), |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 61 | resolver_(this), |
| 62 | expected_safepoint_kind_(Safepoint::kSimple) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 63 | PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 64 | } |
| 65 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 66 | |
| 67 | // Simple accessors. |
| 68 | MacroAssembler* masm() const { return masm_; } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 69 | CompilationInfo* info() const { return info_; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 70 | Isolate* isolate() const { return info_->isolate(); } |
| 71 | Factory* factory() const { return isolate()->factory(); } |
| 72 | Heap* heap() const { return isolate()->heap(); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 73 | |
| 74 | // Support for converting LOperands to assembler types. |
| 75 | // LOperand must be a register. |
| 76 | Register ToRegister(LOperand* op) const; |
| 77 | |
| 78 | // LOperand is loaded into scratch, unless already a register. |
| 79 | Register EmitLoadRegister(LOperand* op, Register scratch); |
| 80 | |
| 81 | // LOperand must be a double register. |
| 82 | DoubleRegister ToDoubleRegister(LOperand* op) const; |
| 83 | |
| 84 | // LOperand is loaded into dbl_scratch, unless already a double register. |
| 85 | DoubleRegister EmitLoadDoubleRegister(LOperand* op, |
| 86 | SwVfpRegister flt_scratch, |
| 87 | DoubleRegister dbl_scratch); |
| 88 | int ToInteger32(LConstantOperand* op) const; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame^] | 89 | double ToDouble(LConstantOperand* op) const; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 90 | Operand ToOperand(LOperand* op); |
| 91 | MemOperand ToMemOperand(LOperand* op) const; |
| 92 | // Returns a MemOperand pointing to the high word of a DoubleStackSlot. |
| 93 | MemOperand ToHighMemOperand(LOperand* op) const; |
| 94 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 95 | // Try to generate code for the entire chunk, but it may fail if the |
| 96 | // chunk contains constructs we cannot handle. Returns true if the |
| 97 | // code generation attempt succeeded. |
| 98 | bool GenerateCode(); |
| 99 | |
| 100 | // Finish the code by setting stack height, safepoint, and bailout |
| 101 | // information on it. |
| 102 | void FinishCode(Handle<Code> code); |
| 103 | |
| 104 | // Deferred code support. |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 105 | template<int T> |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 106 | void DoDeferredBinaryOpStub(LTemplateInstruction<1, 2, T>* instr, |
| 107 | Token::Value op); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 108 | void DoDeferredNumberTagD(LNumberTagD* instr); |
| 109 | void DoDeferredNumberTagI(LNumberTagI* instr); |
| 110 | void DoDeferredTaggedToI(LTaggedToI* instr); |
| 111 | void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 112 | void DoDeferredStackCheck(LStackCheck* instr); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 113 | void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 114 | void DoDeferredStringCharFromCode(LStringCharFromCode* instr); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 115 | void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 116 | Label* map_check); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 117 | |
| 118 | // Parallel move support. |
| 119 | void DoParallelMove(LParallelMove* move); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 120 | void DoGap(LGap* instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 121 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 122 | // Emit frame translation commands for an environment. |
| 123 | void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 124 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 125 | // Declare methods that deal with the individual node types. |
| 126 | #define DECLARE_DO(type) void Do##type(L##type* node); |
| 127 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 128 | #undef DECLARE_DO |
| 129 | |
| 130 | private: |
| 131 | enum Status { |
| 132 | UNUSED, |
| 133 | GENERATING, |
| 134 | DONE, |
| 135 | ABORTED |
| 136 | }; |
| 137 | |
| 138 | bool is_unused() const { return status_ == UNUSED; } |
| 139 | bool is_generating() const { return status_ == GENERATING; } |
| 140 | bool is_done() const { return status_ == DONE; } |
| 141 | bool is_aborted() const { return status_ == ABORTED; } |
| 142 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame^] | 143 | StrictModeFlag strict_mode_flag() const { |
| 144 | return info()->strict_mode_flag(); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 145 | } |
| 146 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 147 | LChunk* chunk() const { return chunk_; } |
| 148 | Scope* scope() const { return scope_; } |
| 149 | HGraph* graph() const { return chunk_->graph(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 150 | |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 151 | Register scratch0() { return r9; } |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 152 | DwVfpRegister double_scratch0() { return d15; } |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 153 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 154 | int GetNextEmittedBlock(int block); |
| 155 | LInstruction* GetNextInstruction(); |
| 156 | |
| 157 | void EmitClassOfTest(Label* if_true, |
| 158 | Label* if_false, |
| 159 | Handle<String> class_name, |
| 160 | Register input, |
| 161 | Register temporary, |
| 162 | Register temporary2); |
| 163 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 164 | int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
| 165 | int GetParameterCount() const { return scope()->num_parameters(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 166 | |
| 167 | void Abort(const char* format, ...); |
| 168 | void Comment(const char* format, ...); |
| 169 | |
| 170 | void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
| 171 | |
| 172 | // Code generation passes. Returns true if code generation should |
| 173 | // continue. |
| 174 | bool GeneratePrologue(); |
| 175 | bool GenerateBody(); |
| 176 | bool GenerateDeferredCode(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 177 | bool GenerateDeoptJumpTable(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 178 | bool GenerateSafepointTable(); |
| 179 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 180 | enum SafepointMode { |
| 181 | RECORD_SIMPLE_SAFEPOINT, |
| 182 | RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 183 | }; |
| 184 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 185 | void CallCode(Handle<Code> code, |
| 186 | RelocInfo::Mode mode, |
| 187 | LInstruction* instr); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 188 | |
| 189 | void CallCodeGeneric(Handle<Code> code, |
| 190 | RelocInfo::Mode mode, |
| 191 | LInstruction* instr, |
| 192 | SafepointMode safepoint_mode); |
| 193 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 194 | void CallRuntime(const Runtime::Function* function, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 195 | int num_arguments, |
| 196 | LInstruction* instr); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 197 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 198 | void CallRuntime(Runtime::FunctionId id, |
| 199 | int num_arguments, |
| 200 | LInstruction* instr) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 201 | const Runtime::Function* function = Runtime::FunctionForId(id); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 202 | CallRuntime(function, num_arguments, instr); |
| 203 | } |
| 204 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 205 | void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 206 | int argc, |
| 207 | LInstruction* instr); |
| 208 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 209 | // Generate a direct call to a known function. Expects the function |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame^] | 210 | // to be in r1. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 211 | void CallKnownFunction(Handle<JSFunction> function, |
| 212 | int arity, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 213 | LInstruction* instr, |
| 214 | CallKind call_kind); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 215 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 216 | void LoadHeapObject(Register result, Handle<HeapObject> object); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 217 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 218 | void RegisterLazyDeoptimization(LInstruction* instr, |
| 219 | SafepointMode safepoint_mode); |
| 220 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
| 222 | void DeoptimizeIf(Condition cc, LEnvironment* environment); |
| 223 | |
| 224 | void AddToTranslation(Translation* translation, |
| 225 | LOperand* op, |
| 226 | bool is_tagged); |
| 227 | void PopulateDeoptimizationData(Handle<Code> code); |
| 228 | int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 229 | |
| 230 | void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 231 | |
| 232 | Register ToRegister(int index) const; |
| 233 | DoubleRegister ToDoubleRegister(int index) const; |
| 234 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 235 | // Specific math operations - used from DoUnaryMathOperation. |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 236 | void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 237 | void DoMathAbs(LUnaryMathOperation* instr); |
| 238 | void DoMathFloor(LUnaryMathOperation* instr); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 239 | void DoMathRound(LUnaryMathOperation* instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 240 | void DoMathSqrt(LUnaryMathOperation* instr); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 241 | void DoMathPowHalf(LUnaryMathOperation* instr); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 242 | void DoMathLog(LUnaryMathOperation* instr); |
| 243 | void DoMathCos(LUnaryMathOperation* instr); |
| 244 | void DoMathSin(LUnaryMathOperation* instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 245 | |
| 246 | // Support for recording safepoint and position information. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 247 | void RecordSafepoint(LPointerMap* pointers, |
| 248 | Safepoint::Kind kind, |
| 249 | int arguments, |
| 250 | int deoptimization_index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 251 | void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 252 | void RecordSafepoint(int deoptimization_index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 253 | void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 254 | int arguments, |
| 255 | int deoptimization_index); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 256 | void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 257 | int arguments, |
| 258 | int deoptimization_index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 259 | void RecordPosition(int position); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 260 | int LastSafepointEnd() { |
| 261 | return static_cast<int>(safepoints_.GetPcAfterGap()); |
| 262 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 263 | |
| 264 | static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 265 | void EmitGoto(int block); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 266 | void EmitBranch(int left_block, int right_block, Condition cc); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 267 | void EmitNumberUntagD(Register input, |
| 268 | DoubleRegister result, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 269 | bool deoptimize_on_undefined, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 270 | LEnvironment* env); |
| 271 | |
| 272 | // Emits optimized code for typeof x == "y". Modifies input register. |
| 273 | // Returns the condition on which a final split to |
| 274 | // true and false label should be made, to optimize fallthrough. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame^] | 275 | Condition EmitTypeofIs(Label* true_label, |
| 276 | Label* false_label, |
| 277 | Register input, |
| 278 | Handle<String> type_name); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 279 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 280 | // Emits optimized code for %_IsObject(x). Preserves input register. |
| 281 | // Returns the condition on which a final split to |
| 282 | // true and false label should be made, to optimize fallthrough. |
| 283 | Condition EmitIsObject(Register input, |
| 284 | Register temp1, |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 285 | Label* is_not_object, |
| 286 | Label* is_object); |
| 287 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 288 | // Emits optimized code for %_IsConstructCall(). |
| 289 | // Caller should branch on equal condition. |
| 290 | void EmitIsConstructCall(Register temp1, Register temp2); |
| 291 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 292 | void EmitLoadFieldOrConstantFunction(Register result, |
| 293 | Register object, |
| 294 | Handle<Map> type, |
| 295 | Handle<String> name); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 296 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 297 | struct JumpTableEntry { |
| 298 | explicit inline JumpTableEntry(Address entry) |
| 299 | : label(), |
| 300 | address(entry) { } |
| 301 | Label label; |
| 302 | Address address; |
| 303 | }; |
| 304 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 305 | LChunk* const chunk_; |
| 306 | MacroAssembler* const masm_; |
| 307 | CompilationInfo* const info_; |
| 308 | |
| 309 | int current_block_; |
| 310 | int current_instruction_; |
| 311 | const ZoneList<LInstruction*>* instructions_; |
| 312 | ZoneList<LEnvironment*> deoptimizations_; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 313 | ZoneList<JumpTableEntry> deopt_jump_table_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 314 | ZoneList<Handle<Object> > deoptimization_literals_; |
| 315 | int inlined_function_count_; |
| 316 | Scope* const scope_; |
| 317 | Status status_; |
| 318 | TranslationBuffer translations_; |
| 319 | ZoneList<LDeferredCode*> deferred_; |
| 320 | int osr_pc_offset_; |
| 321 | |
| 322 | // Builder that keeps track of safepoints in the code. The table |
| 323 | // itself is emitted at the end of the generated code. |
| 324 | SafepointTableBuilder safepoints_; |
| 325 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 326 | // Compiler from a set of parallel moves to a sequential list of moves. |
| 327 | LGapResolver resolver_; |
| 328 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 329 | Safepoint::Kind expected_safepoint_kind_; |
| 330 | |
| 331 | class PushSafepointRegistersScope BASE_EMBEDDED { |
| 332 | public: |
| 333 | PushSafepointRegistersScope(LCodeGen* codegen, |
| 334 | Safepoint::Kind kind) |
| 335 | : codegen_(codegen) { |
| 336 | ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 337 | codegen_->expected_safepoint_kind_ = kind; |
| 338 | |
| 339 | switch (codegen_->expected_safepoint_kind_) { |
| 340 | case Safepoint::kWithRegisters: |
| 341 | codegen_->masm_->PushSafepointRegisters(); |
| 342 | break; |
| 343 | case Safepoint::kWithRegistersAndDoubles: |
| 344 | codegen_->masm_->PushSafepointRegistersAndDoubles(); |
| 345 | break; |
| 346 | default: |
| 347 | UNREACHABLE(); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | ~PushSafepointRegistersScope() { |
| 352 | Safepoint::Kind kind = codegen_->expected_safepoint_kind_; |
| 353 | ASSERT((kind & Safepoint::kWithRegisters) != 0); |
| 354 | switch (kind) { |
| 355 | case Safepoint::kWithRegisters: |
| 356 | codegen_->masm_->PopSafepointRegisters(); |
| 357 | break; |
| 358 | case Safepoint::kWithRegistersAndDoubles: |
| 359 | codegen_->masm_->PopSafepointRegistersAndDoubles(); |
| 360 | break; |
| 361 | default: |
| 362 | UNREACHABLE(); |
| 363 | } |
| 364 | codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 365 | } |
| 366 | |
| 367 | private: |
| 368 | LCodeGen* codegen_; |
| 369 | }; |
| 370 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 371 | friend class LDeferredCode; |
| 372 | friend class LEnvironment; |
| 373 | friend class SafepointGenerator; |
| 374 | DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
| 375 | }; |
| 376 | |
| 377 | |
| 378 | class LDeferredCode: public ZoneObject { |
| 379 | public: |
| 380 | explicit LDeferredCode(LCodeGen* codegen) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 381 | : codegen_(codegen), |
| 382 | external_exit_(NULL), |
| 383 | instruction_index_(codegen->current_instruction_) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 384 | codegen->AddDeferredCode(this); |
| 385 | } |
| 386 | |
| 387 | virtual ~LDeferredCode() { } |
| 388 | virtual void Generate() = 0; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 389 | virtual LInstruction* instr() = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 390 | |
| 391 | void SetExit(Label *exit) { external_exit_ = exit; } |
| 392 | Label* entry() { return &entry_; } |
| 393 | Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 394 | int instruction_index() const { return instruction_index_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 395 | |
| 396 | protected: |
| 397 | LCodeGen* codegen() const { return codegen_; } |
| 398 | MacroAssembler* masm() const { return codegen_->masm(); } |
| 399 | |
| 400 | private: |
| 401 | LCodeGen* codegen_; |
| 402 | Label entry_; |
| 403 | Label exit_; |
| 404 | Label* external_exit_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 405 | int instruction_index_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 406 | }; |
| 407 | |
| 408 | } } // namespace v8::internal |
| 409 | |
| 410 | #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |