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