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