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. |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame^] | 174 | void WriteTranslation(LEnvironment* environment, Translation* translation); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 175 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 176 | // Declare methods that deal with the individual node types. |
| 177 | #define DECLARE_DO(type) void Do##type(L##type* node); |
| 178 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 179 | #undef DECLARE_DO |
| 180 | |
| 181 | private: |
| 182 | enum Status { |
| 183 | UNUSED, |
| 184 | GENERATING, |
| 185 | DONE, |
| 186 | ABORTED |
| 187 | }; |
| 188 | |
| 189 | bool is_unused() const { return status_ == UNUSED; } |
| 190 | bool is_generating() const { return status_ == GENERATING; } |
| 191 | bool is_done() const { return status_ == DONE; } |
| 192 | bool is_aborted() const { return status_ == ABORTED; } |
| 193 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 194 | StrictModeFlag strict_mode_flag() const { |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 195 | return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 196 | } |
| 197 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 198 | LPlatformChunk* chunk() const { return chunk_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 199 | Scope* scope() const { return scope_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 200 | HGraph* graph() const { return chunk()->graph(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 201 | |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 202 | Register scratch0() { return r9; } |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 203 | DwVfpRegister double_scratch0() { return kScratchDoubleReg; } |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 204 | |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 205 | int GetNextEmittedBlock() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 206 | LInstruction* GetNextInstruction(); |
| 207 | |
| 208 | void EmitClassOfTest(Label* if_true, |
| 209 | Label* if_false, |
| 210 | Handle<String> class_name, |
| 211 | Register input, |
| 212 | Register temporary, |
| 213 | Register temporary2); |
| 214 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 215 | int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 216 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 217 | void Abort(const char* reason); |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 218 | void FPRINTF_CHECKING Comment(const char* format, ...); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 219 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 220 | void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | |
| 222 | // Code generation passes. Returns true if code generation should |
| 223 | // continue. |
| 224 | bool GeneratePrologue(); |
| 225 | bool GenerateBody(); |
| 226 | bool GenerateDeferredCode(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 227 | bool GenerateDeoptJumpTable(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 228 | bool GenerateSafepointTable(); |
| 229 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 230 | enum SafepointMode { |
| 231 | RECORD_SIMPLE_SAFEPOINT, |
| 232 | RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 233 | }; |
| 234 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 235 | void CallCode( |
| 236 | Handle<Code> code, |
| 237 | RelocInfo::Mode mode, |
| 238 | LInstruction* instr, |
| 239 | TargetAddressStorageMode storage_mode = CAN_INLINE_TARGET_ADDRESS); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 240 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 241 | void CallCodeGeneric( |
| 242 | Handle<Code> code, |
| 243 | RelocInfo::Mode mode, |
| 244 | LInstruction* instr, |
| 245 | SafepointMode safepoint_mode, |
| 246 | TargetAddressStorageMode storage_mode = CAN_INLINE_TARGET_ADDRESS); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 247 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 248 | void CallRuntime(const Runtime::Function* function, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 249 | int num_arguments, |
| 250 | LInstruction* instr); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 251 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 252 | void CallRuntime(Runtime::FunctionId id, |
| 253 | int num_arguments, |
| 254 | LInstruction* instr) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 255 | const Runtime::Function* function = Runtime::FunctionForId(id); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 256 | CallRuntime(function, num_arguments, instr); |
| 257 | } |
| 258 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 259 | void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 260 | int argc, |
| 261 | LInstruction* instr); |
| 262 | |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 263 | enum R1State { |
| 264 | R1_UNINITIALIZED, |
| 265 | R1_CONTAINS_TARGET |
| 266 | }; |
| 267 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 268 | // 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] | 269 | // to be in r1. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 270 | void CallKnownFunction(Handle<JSFunction> function, |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 271 | int formal_parameter_count, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 272 | int arity, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 273 | LInstruction* instr, |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 274 | CallKind call_kind, |
| 275 | R1State r1_state); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 276 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 277 | void LoadHeapObject(Register result, Handle<HeapObject> object); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 278 | |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 279 | void RecordSafepointWithLazyDeopt(LInstruction* instr, |
| 280 | SafepointMode safepoint_mode); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 281 | |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 282 | void RegisterEnvironmentForDeoptimization(LEnvironment* environment, |
| 283 | Safepoint::DeoptMode mode); |
danno@chromium.org | aefd607 | 2013-05-14 14:11:47 +0000 | [diff] [blame] | 284 | void DeoptimizeIf(Condition cc, |
| 285 | LEnvironment* environment, |
| 286 | Deoptimizer::BailoutType bailout_type); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 287 | void DeoptimizeIf(Condition cc, LEnvironment* environment); |
danno@chromium.org | aefd607 | 2013-05-14 14:11:47 +0000 | [diff] [blame] | 288 | void SoftDeoptimize(LEnvironment* environment); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 289 | |
| 290 | void AddToTranslation(Translation* translation, |
| 291 | LOperand* op, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 292 | bool is_tagged, |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame^] | 293 | bool is_uint32); |
ulan@chromium.org | 6ba1fd0 | 2013-02-14 14:56:11 +0000 | [diff] [blame] | 294 | void RegisterDependentCodeForEmbeddedMaps(Handle<Code> code); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 295 | void PopulateDeoptimizationData(Handle<Code> code); |
| 296 | int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 297 | |
| 298 | void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 299 | |
| 300 | Register ToRegister(int index) const; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 301 | DwVfpRegister ToDoubleRegister(int index) const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 302 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 303 | void EmitIntegerMathAbs(LMathAbs* instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 304 | |
| 305 | // Support for recording safepoint and position information. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 306 | void RecordSafepoint(LPointerMap* pointers, |
| 307 | Safepoint::Kind kind, |
| 308 | int arguments, |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 309 | Safepoint::DeoptMode mode); |
| 310 | void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); |
| 311 | void RecordSafepoint(Safepoint::DeoptMode mode); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 312 | void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 313 | int arguments, |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 314 | Safepoint::DeoptMode mode); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 315 | void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 316 | int arguments, |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 317 | Safepoint::DeoptMode mode); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 318 | void RecordPosition(int position); |
| 319 | |
| 320 | static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 321 | void EmitGoto(int block); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 322 | void EmitBranch(int left_block, int right_block, Condition cc); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 323 | void EmitNumberUntagD(Register input, |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 324 | DwVfpRegister result, |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 325 | bool allow_undefined_as_nan, |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 326 | bool deoptimize_on_minus_zero, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 327 | LEnvironment* env, |
| 328 | NumberUntagDMode mode); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 329 | |
| 330 | // Emits optimized code for typeof x == "y". Modifies input register. |
| 331 | // Returns the condition on which a final split to |
| 332 | // true and false label should be made, to optimize fallthrough. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 333 | Condition EmitTypeofIs(Label* true_label, |
| 334 | Label* false_label, |
| 335 | Register input, |
| 336 | Handle<String> type_name); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 337 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 338 | // Emits optimized code for %_IsObject(x). Preserves input register. |
| 339 | // Returns the condition on which a final split to |
| 340 | // true and false label should be made, to optimize fallthrough. |
| 341 | Condition EmitIsObject(Register input, |
| 342 | Register temp1, |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 343 | Label* is_not_object, |
| 344 | Label* is_object); |
| 345 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 346 | // Emits optimized code for %_IsString(x). Preserves input register. |
| 347 | // Returns the condition on which a final split to |
| 348 | // true and false label should be made, to optimize fallthrough. |
| 349 | Condition EmitIsString(Register input, |
| 350 | Register temp1, |
| 351 | Label* is_not_string); |
| 352 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 353 | // Emits optimized code for %_IsConstructCall(). |
| 354 | // Caller should branch on equal condition. |
| 355 | void EmitIsConstructCall(Register temp1, Register temp2); |
| 356 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 357 | void EmitLoadFieldOrConstantFunction(Register result, |
| 358 | Register object, |
| 359 | Handle<Map> type, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 360 | Handle<String> name, |
| 361 | LEnvironment* env); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 362 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 363 | // Emits optimized code to deep-copy the contents of statically known |
| 364 | // object graphs (e.g. object literal boilerplate). |
| 365 | void EmitDeepCopy(Handle<JSObject> object, |
| 366 | Register result, |
| 367 | Register source, |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 368 | int* offset, |
| 369 | AllocationSiteMode mode); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 370 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 371 | // Emit optimized code for integer division. |
| 372 | // Inputs are signed. |
| 373 | // All registers are clobbered. |
| 374 | // If 'remainder' is no_reg, it is not computed. |
| 375 | void EmitSignedIntegerDivisionByConstant(Register result, |
| 376 | Register dividend, |
| 377 | int32_t divisor, |
| 378 | Register remainder, |
| 379 | Register scratch, |
| 380 | LEnvironment* environment); |
| 381 | |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 382 | void EnsureSpaceForLazyDeopt(); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 383 | void DoLoadKeyedExternalArray(LLoadKeyed* instr); |
| 384 | void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); |
| 385 | void DoLoadKeyedFixedArray(LLoadKeyed* instr); |
| 386 | void DoStoreKeyedExternalArray(LStoreKeyed* instr); |
| 387 | void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); |
| 388 | void DoStoreKeyedFixedArray(LStoreKeyed* instr); |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 389 | |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 390 | Zone* zone_; |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 391 | LPlatformChunk* const chunk_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 392 | MacroAssembler* const masm_; |
| 393 | CompilationInfo* const info_; |
| 394 | |
| 395 | int current_block_; |
| 396 | int current_instruction_; |
| 397 | const ZoneList<LInstruction*>* instructions_; |
| 398 | ZoneList<LEnvironment*> deoptimizations_; |
danno@chromium.org | aefd607 | 2013-05-14 14:11:47 +0000 | [diff] [blame] | 399 | ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 400 | ZoneList<Handle<Object> > deoptimization_literals_; |
| 401 | int inlined_function_count_; |
| 402 | Scope* const scope_; |
| 403 | Status status_; |
| 404 | TranslationBuffer translations_; |
| 405 | ZoneList<LDeferredCode*> deferred_; |
| 406 | int osr_pc_offset_; |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 407 | int last_lazy_deopt_pc_; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 408 | bool frame_is_built_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 409 | |
| 410 | // Builder that keeps track of safepoints in the code. The table |
| 411 | // itself is emitted at the end of the generated code. |
| 412 | SafepointTableBuilder safepoints_; |
| 413 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 414 | // Compiler from a set of parallel moves to a sequential list of moves. |
| 415 | LGapResolver resolver_; |
| 416 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 417 | Safepoint::Kind expected_safepoint_kind_; |
| 418 | |
| 419 | class PushSafepointRegistersScope BASE_EMBEDDED { |
| 420 | public: |
| 421 | PushSafepointRegistersScope(LCodeGen* codegen, |
| 422 | Safepoint::Kind kind) |
| 423 | : codegen_(codegen) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 424 | ASSERT(codegen_->info()->is_calling()); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 425 | ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 426 | codegen_->expected_safepoint_kind_ = kind; |
| 427 | |
| 428 | switch (codegen_->expected_safepoint_kind_) { |
| 429 | case Safepoint::kWithRegisters: |
| 430 | codegen_->masm_->PushSafepointRegisters(); |
| 431 | break; |
| 432 | case Safepoint::kWithRegistersAndDoubles: |
| 433 | codegen_->masm_->PushSafepointRegistersAndDoubles(); |
| 434 | break; |
| 435 | default: |
| 436 | UNREACHABLE(); |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | ~PushSafepointRegistersScope() { |
| 441 | Safepoint::Kind kind = codegen_->expected_safepoint_kind_; |
| 442 | ASSERT((kind & Safepoint::kWithRegisters) != 0); |
| 443 | switch (kind) { |
| 444 | case Safepoint::kWithRegisters: |
| 445 | codegen_->masm_->PopSafepointRegisters(); |
| 446 | break; |
| 447 | case Safepoint::kWithRegistersAndDoubles: |
| 448 | codegen_->masm_->PopSafepointRegistersAndDoubles(); |
| 449 | break; |
| 450 | default: |
| 451 | UNREACHABLE(); |
| 452 | } |
| 453 | codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 454 | } |
| 455 | |
| 456 | private: |
| 457 | LCodeGen* codegen_; |
| 458 | }; |
| 459 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 460 | friend class LDeferredCode; |
| 461 | friend class LEnvironment; |
| 462 | friend class SafepointGenerator; |
| 463 | DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
| 464 | }; |
| 465 | |
| 466 | |
| 467 | class LDeferredCode: public ZoneObject { |
| 468 | public: |
| 469 | explicit LDeferredCode(LCodeGen* codegen) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 470 | : codegen_(codegen), |
| 471 | external_exit_(NULL), |
| 472 | instruction_index_(codegen->current_instruction_) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 473 | codegen->AddDeferredCode(this); |
| 474 | } |
| 475 | |
| 476 | virtual ~LDeferredCode() { } |
| 477 | virtual void Generate() = 0; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 478 | virtual LInstruction* instr() = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 479 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 480 | void SetExit(Label* exit) { external_exit_ = exit; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 481 | Label* entry() { return &entry_; } |
| 482 | Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 483 | int instruction_index() const { return instruction_index_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 484 | |
| 485 | protected: |
| 486 | LCodeGen* codegen() const { return codegen_; } |
| 487 | MacroAssembler* masm() const { return codegen_->masm(); } |
| 488 | |
| 489 | private: |
| 490 | LCodeGen* codegen_; |
| 491 | Label entry_; |
| 492 | Label exit_; |
| 493 | Label* external_exit_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 494 | int instruction_index_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 495 | }; |
| 496 | |
| 497 | } } // namespace v8::internal |
| 498 | |
| 499 | #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |