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 "mips/lithium-mips.h" |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 32 | #include "mips/lithium-gap-resolver-mips.h" |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 33 | #include "deoptimizer.h" |
| 34 | #include "safepoint-table.h" |
| 35 | #include "scopes.h" |
| 36 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 40 | // Forward declarations. |
| 41 | class LDeferredCode; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 42 | class SafepointGenerator; |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 43 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +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)), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +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()), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 57 | inlined_function_count_(0), |
| 58 | scope_(info->scope()), |
| 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()), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 62 | osr_pc_offset_(-1), |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +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()), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 65 | resolver_(this), |
| 66 | expected_safepoint_kind_(Safepoint::kSimple) { |
| 67 | PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | // Simple accessors. |
| 72 | MacroAssembler* masm() const { return masm_; } |
| 73 | CompilationInfo* info() const { return info_; } |
| 74 | Isolate* isolate() const { return info_->isolate(); } |
| 75 | Factory* factory() const { return isolate()->factory(); } |
| 76 | Heap* heap() const { return isolate()->heap(); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 77 | Zone* zone() const { return zone_; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +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 | FloatRegister flt_scratch, |
| 92 | DoubleRegister dbl_scratch); |
| 93 | int ToInteger32(LConstantOperand* op) const; |
| 94 | double ToDouble(LConstantOperand* op) const; |
| 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; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 99 | |
rossberg@chromium.org | fab1498 | 2012-01-05 15:02:15 +0000 | [diff] [blame] | 100 | bool IsInteger32(LConstantOperand* op) const; |
| 101 | Handle<Object> ToHandle(LConstantOperand* op) const; |
| 102 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +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. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 106 | bool GenerateCode(); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 107 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 108 | // Finish the code by setting stack height, safepoint, and bailout |
| 109 | // information on it. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 110 | void FinishCode(Handle<Code> code); |
| 111 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 112 | void DoDeferredNumberTagD(LNumberTagD* instr); |
| 113 | void DoDeferredNumberTagI(LNumberTagI* instr); |
| 114 | void DoDeferredTaggedToI(LTaggedToI* instr); |
| 115 | void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
| 116 | void DoDeferredStackCheck(LStackCheck* instr); |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 117 | void DoDeferredRandom(LRandom* instr); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 118 | void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 119 | void DoDeferredStringCharFromCode(LStringCharFromCode* instr); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 120 | void DoDeferredAllocateObject(LAllocateObject* instr); |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 121 | void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 122 | Label* map_check); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 123 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 124 | void DoCheckMapCommon(Register reg, Register scratch, Handle<Map> map, |
| 125 | CompareMapMode mode, LEnvironment* env); |
| 126 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 127 | // Parallel move support. |
| 128 | void DoParallelMove(LParallelMove* move); |
| 129 | void DoGap(LGap* instr); |
| 130 | |
danno@chromium.org | 129d398 | 2012-07-25 15:01:47 +0000 | [diff] [blame] | 131 | MemOperand PrepareKeyedOperand(Register key, |
| 132 | Register base, |
| 133 | bool key_is_constant, |
| 134 | int constant_key, |
| 135 | int element_size, |
| 136 | int shift_size, |
| 137 | int additional_index, |
| 138 | int additional_offset); |
| 139 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 140 | // Emit frame translation commands for an environment. |
| 141 | void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 142 | |
| 143 | // Declare methods that deal with the individual node types. |
| 144 | #define DECLARE_DO(type) void Do##type(L##type* node); |
| 145 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 146 | #undef DECLARE_DO |
| 147 | |
| 148 | private: |
| 149 | enum Status { |
| 150 | UNUSED, |
| 151 | GENERATING, |
| 152 | DONE, |
| 153 | ABORTED |
| 154 | }; |
| 155 | |
| 156 | bool is_unused() const { return status_ == UNUSED; } |
| 157 | bool is_generating() const { return status_ == GENERATING; } |
| 158 | bool is_done() const { return status_ == DONE; } |
| 159 | bool is_aborted() const { return status_ == ABORTED; } |
| 160 | |
| 161 | StrictModeFlag strict_mode_flag() const { |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 162 | return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 163 | } |
| 164 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 165 | LPlatformChunk* chunk() const { return chunk_; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 166 | Scope* scope() const { return scope_; } |
| 167 | HGraph* graph() const { return chunk_->graph(); } |
| 168 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 169 | Register scratch0() { return kLithiumScratchReg; } |
| 170 | Register scratch1() { return kLithiumScratchReg2; } |
| 171 | DoubleRegister double_scratch0() { return kLithiumScratchDouble; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 172 | |
| 173 | int GetNextEmittedBlock(int block); |
| 174 | LInstruction* GetNextInstruction(); |
| 175 | |
| 176 | void EmitClassOfTest(Label* if_true, |
| 177 | Label* if_false, |
| 178 | Handle<String> class_name, |
| 179 | Register input, |
| 180 | Register temporary, |
| 181 | Register temporary2); |
| 182 | |
| 183 | int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
| 184 | int GetParameterCount() const { return scope()->num_parameters(); } |
| 185 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame^] | 186 | void Abort(const char* reason); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 187 | void Comment(const char* format, ...); |
| 188 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 189 | void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 190 | |
| 191 | // Code generation passes. Returns true if code generation should |
| 192 | // continue. |
| 193 | bool GeneratePrologue(); |
| 194 | bool GenerateBody(); |
| 195 | bool GenerateDeferredCode(); |
| 196 | bool GenerateDeoptJumpTable(); |
| 197 | bool GenerateSafepointTable(); |
| 198 | |
| 199 | enum SafepointMode { |
| 200 | RECORD_SIMPLE_SAFEPOINT, |
| 201 | RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 202 | }; |
| 203 | |
| 204 | void CallCode(Handle<Code> code, |
| 205 | RelocInfo::Mode mode, |
| 206 | LInstruction* instr); |
| 207 | |
| 208 | void CallCodeGeneric(Handle<Code> code, |
| 209 | RelocInfo::Mode mode, |
| 210 | LInstruction* instr, |
| 211 | SafepointMode safepoint_mode); |
| 212 | |
| 213 | void CallRuntime(const Runtime::Function* function, |
| 214 | int num_arguments, |
| 215 | LInstruction* instr); |
| 216 | |
| 217 | void CallRuntime(Runtime::FunctionId id, |
| 218 | int num_arguments, |
| 219 | LInstruction* instr) { |
| 220 | const Runtime::Function* function = Runtime::FunctionForId(id); |
| 221 | CallRuntime(function, num_arguments, instr); |
| 222 | } |
| 223 | |
| 224 | void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 225 | int argc, |
| 226 | LInstruction* instr); |
| 227 | |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 228 | enum A1State { |
| 229 | A1_UNINITIALIZED, |
| 230 | A1_CONTAINS_TARGET |
| 231 | }; |
| 232 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 233 | // Generate a direct call to a known function. Expects the function |
| 234 | // to be in a1. |
| 235 | void CallKnownFunction(Handle<JSFunction> function, |
| 236 | int arity, |
| 237 | LInstruction* instr, |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 238 | CallKind call_kind, |
| 239 | A1State a1_state); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 240 | |
| 241 | void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 242 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 243 | void RecordSafepointWithLazyDeopt(LInstruction* instr, |
| 244 | SafepointMode safepoint_mode); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 245 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 246 | void RegisterEnvironmentForDeoptimization(LEnvironment* environment, |
| 247 | Safepoint::DeoptMode mode); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 248 | void DeoptimizeIf(Condition cc, |
| 249 | LEnvironment* environment, |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 250 | Register src1 = zero_reg, |
| 251 | const Operand& src2 = Operand(zero_reg)); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 252 | |
| 253 | void AddToTranslation(Translation* translation, |
| 254 | LOperand* op, |
| 255 | bool is_tagged); |
| 256 | void PopulateDeoptimizationData(Handle<Code> code); |
| 257 | int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 258 | |
| 259 | void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 260 | |
| 261 | Register ToRegister(int index) const; |
| 262 | DoubleRegister ToDoubleRegister(int index) const; |
| 263 | |
| 264 | // Specific math operations - used from DoUnaryMathOperation. |
| 265 | void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 266 | void DoMathAbs(LUnaryMathOperation* instr); |
| 267 | void DoMathFloor(LUnaryMathOperation* instr); |
| 268 | void DoMathRound(LUnaryMathOperation* instr); |
| 269 | void DoMathSqrt(LUnaryMathOperation* instr); |
| 270 | void DoMathPowHalf(LUnaryMathOperation* instr); |
| 271 | void DoMathLog(LUnaryMathOperation* instr); |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 272 | void DoMathTan(LUnaryMathOperation* instr); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 273 | void DoMathCos(LUnaryMathOperation* instr); |
| 274 | void DoMathSin(LUnaryMathOperation* instr); |
| 275 | |
| 276 | // Support for recording safepoint and position information. |
| 277 | void RecordSafepoint(LPointerMap* pointers, |
| 278 | Safepoint::Kind kind, |
| 279 | int arguments, |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 280 | Safepoint::DeoptMode mode); |
| 281 | void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); |
| 282 | void RecordSafepoint(Safepoint::DeoptMode mode); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 283 | void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 284 | int arguments, |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 285 | Safepoint::DeoptMode mode); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 286 | void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 287 | int arguments, |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 288 | Safepoint::DeoptMode mode); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 289 | void RecordPosition(int position); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 290 | |
| 291 | static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 292 | void EmitGoto(int block); |
| 293 | void EmitBranch(int left_block, |
| 294 | int right_block, |
| 295 | Condition cc, |
| 296 | Register src1, |
| 297 | const Operand& src2); |
| 298 | void EmitBranchF(int left_block, |
| 299 | int right_block, |
| 300 | Condition cc, |
| 301 | FPURegister src1, |
| 302 | FPURegister src2); |
| 303 | void EmitCmpI(LOperand* left, LOperand* right); |
| 304 | void EmitNumberUntagD(Register input, |
| 305 | DoubleRegister result, |
| 306 | bool deoptimize_on_undefined, |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 307 | bool deoptimize_on_minus_zero, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 308 | LEnvironment* env); |
| 309 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame^] | 310 | void DeoptIfTaggedButNotSmi(LEnvironment* environment, |
| 311 | HValue* value, |
| 312 | LOperand* operand); |
| 313 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 314 | // Emits optimized code for typeof x == "y". Modifies input register. |
| 315 | // Returns the condition on which a final split to |
| 316 | // true and false label should be made, to optimize fallthrough. |
| 317 | // Returns two registers in cmp1 and cmp2 that can be used in the |
| 318 | // Branch instruction after EmitTypeofIs. |
| 319 | Condition EmitTypeofIs(Label* true_label, |
| 320 | Label* false_label, |
| 321 | Register input, |
| 322 | Handle<String> type_name, |
| 323 | Register& cmp1, |
| 324 | Operand& cmp2); |
| 325 | |
| 326 | // Emits optimized code for %_IsObject(x). Preserves input register. |
| 327 | // Returns the condition on which a final split to |
| 328 | // true and false label should be made, to optimize fallthrough. |
| 329 | Condition EmitIsObject(Register input, |
| 330 | Register temp1, |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 331 | Register temp2, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 332 | Label* is_not_object, |
| 333 | Label* is_object); |
| 334 | |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 335 | // Emits optimized code for %_IsString(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 EmitIsString(Register input, |
| 339 | Register temp1, |
| 340 | Label* is_not_string); |
| 341 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 342 | // Emits optimized code for %_IsConstructCall(). |
| 343 | // Caller should branch on equal condition. |
| 344 | void EmitIsConstructCall(Register temp1, Register temp2); |
| 345 | |
| 346 | void EmitLoadFieldOrConstantFunction(Register result, |
| 347 | Register object, |
| 348 | Handle<Map> type, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 349 | Handle<String> name, |
| 350 | LEnvironment* env); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 351 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 352 | // Emits optimized code to deep-copy the contents of statically known |
| 353 | // object graphs (e.g. object literal boilerplate). |
| 354 | void EmitDeepCopy(Handle<JSObject> object, |
| 355 | Register result, |
| 356 | Register source, |
| 357 | int* offset); |
| 358 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 359 | struct JumpTableEntry { |
| 360 | explicit inline JumpTableEntry(Address entry) |
| 361 | : label(), |
| 362 | address(entry) { } |
| 363 | Label label; |
| 364 | Address address; |
| 365 | }; |
| 366 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 367 | void EnsureSpaceForLazyDeopt(); |
| 368 | |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 369 | Zone* zone_; |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 370 | LPlatformChunk* const chunk_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 371 | MacroAssembler* const masm_; |
| 372 | CompilationInfo* const info_; |
| 373 | |
| 374 | int current_block_; |
| 375 | int current_instruction_; |
| 376 | const ZoneList<LInstruction*>* instructions_; |
| 377 | ZoneList<LEnvironment*> deoptimizations_; |
| 378 | ZoneList<JumpTableEntry> deopt_jump_table_; |
| 379 | ZoneList<Handle<Object> > deoptimization_literals_; |
| 380 | int inlined_function_count_; |
| 381 | Scope* const scope_; |
| 382 | Status status_; |
| 383 | TranslationBuffer translations_; |
| 384 | ZoneList<LDeferredCode*> deferred_; |
| 385 | int osr_pc_offset_; |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 386 | int last_lazy_deopt_pc_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 387 | |
| 388 | // Builder that keeps track of safepoints in the code. The table |
| 389 | // itself is emitted at the end of the generated code. |
| 390 | SafepointTableBuilder safepoints_; |
| 391 | |
| 392 | // Compiler from a set of parallel moves to a sequential list of moves. |
| 393 | LGapResolver resolver_; |
| 394 | |
| 395 | Safepoint::Kind expected_safepoint_kind_; |
| 396 | |
| 397 | class PushSafepointRegistersScope BASE_EMBEDDED { |
| 398 | public: |
| 399 | PushSafepointRegistersScope(LCodeGen* codegen, |
| 400 | Safepoint::Kind kind) |
| 401 | : codegen_(codegen) { |
| 402 | ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 403 | codegen_->expected_safepoint_kind_ = kind; |
| 404 | |
| 405 | switch (codegen_->expected_safepoint_kind_) { |
| 406 | case Safepoint::kWithRegisters: |
| 407 | codegen_->masm_->PushSafepointRegisters(); |
| 408 | break; |
| 409 | case Safepoint::kWithRegistersAndDoubles: |
| 410 | codegen_->masm_->PushSafepointRegistersAndDoubles(); |
| 411 | break; |
| 412 | default: |
| 413 | UNREACHABLE(); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | ~PushSafepointRegistersScope() { |
| 418 | Safepoint::Kind kind = codegen_->expected_safepoint_kind_; |
| 419 | ASSERT((kind & Safepoint::kWithRegisters) != 0); |
| 420 | switch (kind) { |
| 421 | case Safepoint::kWithRegisters: |
| 422 | codegen_->masm_->PopSafepointRegisters(); |
| 423 | break; |
| 424 | case Safepoint::kWithRegistersAndDoubles: |
| 425 | codegen_->masm_->PopSafepointRegistersAndDoubles(); |
| 426 | break; |
| 427 | default: |
| 428 | UNREACHABLE(); |
| 429 | } |
| 430 | codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 431 | } |
| 432 | |
| 433 | private: |
| 434 | LCodeGen* codegen_; |
| 435 | }; |
| 436 | |
| 437 | friend class LDeferredCode; |
| 438 | friend class LEnvironment; |
| 439 | friend class SafepointGenerator; |
| 440 | DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
| 441 | }; |
| 442 | |
| 443 | |
| 444 | class LDeferredCode: public ZoneObject { |
| 445 | public: |
| 446 | explicit LDeferredCode(LCodeGen* codegen) |
| 447 | : codegen_(codegen), |
| 448 | external_exit_(NULL), |
| 449 | instruction_index_(codegen->current_instruction_) { |
| 450 | codegen->AddDeferredCode(this); |
| 451 | } |
| 452 | |
| 453 | virtual ~LDeferredCode() { } |
| 454 | virtual void Generate() = 0; |
| 455 | virtual LInstruction* instr() = 0; |
| 456 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 457 | void SetExit(Label* exit) { external_exit_ = exit; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 458 | Label* entry() { return &entry_; } |
| 459 | Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
| 460 | int instruction_index() const { return instruction_index_; } |
| 461 | |
| 462 | protected: |
| 463 | LCodeGen* codegen() const { return codegen_; } |
| 464 | MacroAssembler* masm() const { return codegen_->masm(); } |
| 465 | |
| 466 | private: |
| 467 | LCodeGen* codegen_; |
| 468 | Label entry_; |
| 469 | Label exit_; |
| 470 | Label* external_exit_; |
| 471 | int instruction_index_; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 472 | }; |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 473 | |
| 474 | } } // namespace v8::internal |
| 475 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 476 | #endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ |