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