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