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