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