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