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