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