| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 #include "src/compilation-info.h" | 6 #include "src/compilation-info.h" |
| 7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/osr.h" | 10 #include "src/compiler/osr.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 int deopt_state_id = | 715 int deopt_state_id = |
| 716 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 716 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
| 717 Deoptimizer::BailoutType bailout_type = | 717 Deoptimizer::BailoutType bailout_type = |
| 718 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 718 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
| 719 CodeGenResult result = AssembleDeoptimizerCall( | 719 CodeGenResult result = AssembleDeoptimizerCall( |
| 720 deopt_state_id, bailout_type, current_source_position_); | 720 deopt_state_id, bailout_type, current_source_position_); |
| 721 if (result != kSuccess) return result; | 721 if (result != kSuccess) return result; |
| 722 break; | 722 break; |
| 723 } | 723 } |
| 724 case kArchRet: | 724 case kArchRet: |
| 725 AssembleReturn(); | 725 AssembleReturn(instr->InputAt(0)); |
| 726 break; | 726 break; |
| 727 case kArchStackPointer: | 727 case kArchStackPointer: |
| 728 __ mov(i.OutputRegister(), sp); | 728 __ mov(i.OutputRegister(), sp); |
| 729 break; | 729 break; |
| 730 case kArchFramePointer: | 730 case kArchFramePointer: |
| 731 __ mov(i.OutputRegister(), fp); | 731 __ mov(i.OutputRegister(), fp); |
| 732 break; | 732 break; |
| 733 case kArchParentFramePointer: | 733 case kArchParentFramePointer: |
| 734 if (frame_access_state()->has_frame()) { | 734 if (frame_access_state()->has_frame()) { |
| 735 __ ld(i.OutputRegister(), MemOperand(fp, 0)); | 735 __ ld(i.OutputRegister(), MemOperand(fp, 0)); |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 } | 2274 } |
| 2275 | 2275 |
| 2276 const RegList saves = descriptor->CalleeSavedRegisters(); | 2276 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 2277 if (saves != 0) { | 2277 if (saves != 0) { |
| 2278 // Save callee-saved registers. | 2278 // Save callee-saved registers. |
| 2279 __ MultiPush(saves); | 2279 __ MultiPush(saves); |
| 2280 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); | 2280 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); |
| 2281 } | 2281 } |
| 2282 } | 2282 } |
| 2283 | 2283 |
| 2284 | 2284 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
| 2285 void CodeGenerator::AssembleReturn() { | |
| 2286 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 2285 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 2287 | 2286 |
| 2288 // Restore GP registers. | 2287 // Restore GP registers. |
| 2289 const RegList saves = descriptor->CalleeSavedRegisters(); | 2288 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 2290 if (saves != 0) { | 2289 if (saves != 0) { |
| 2291 __ MultiPop(saves); | 2290 __ MultiPop(saves); |
| 2292 } | 2291 } |
| 2293 | 2292 |
| 2294 // Restore FPU registers. | 2293 // Restore FPU registers. |
| 2295 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 2294 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 2296 if (saves_fpu != 0) { | 2295 if (saves_fpu != 0) { |
| 2297 __ MultiPopFPU(saves_fpu); | 2296 __ MultiPopFPU(saves_fpu); |
| 2298 } | 2297 } |
| 2299 | 2298 |
| 2300 if (descriptor->IsCFunctionCall()) { | 2299 if (descriptor->IsCFunctionCall()) { |
| 2301 AssembleDeconstructFrame(); | 2300 AssembleDeconstructFrame(); |
| 2302 } else if (frame_access_state()->has_frame()) { | 2301 } else if (frame_access_state()->has_frame()) { |
| 2303 // Canonicalize JSFunction return sites for now. | 2302 // Canonicalize JSFunction return sites for now. |
| 2304 if (return_label_.is_bound()) { | 2303 if (return_label_.is_bound()) { |
| 2305 __ Branch(&return_label_); | 2304 __ Branch(&return_label_); |
| 2306 return; | 2305 return; |
| 2307 } else { | 2306 } else { |
| 2308 __ bind(&return_label_); | 2307 __ bind(&return_label_); |
| 2309 AssembleDeconstructFrame(); | 2308 AssembleDeconstructFrame(); |
| 2310 } | 2309 } |
| 2311 } | 2310 } |
| 2312 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 2311 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| 2312 MipsOperandConverter g(this, nullptr); |
| 2313 if (pop->IsImmediate()) { |
| 2314 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); |
| 2315 pop_count += g.ToConstant(pop).ToInt32(); |
| 2316 } else { |
| 2317 Register pop_reg = g.ToRegister(pop); |
| 2318 __ dsll(pop_reg, pop_reg, kPointerSizeLog2); |
| 2319 __ Daddu(sp, sp, pop_reg); |
| 2320 } |
| 2313 if (pop_count != 0) { | 2321 if (pop_count != 0) { |
| 2314 __ DropAndRet(pop_count); | 2322 __ DropAndRet(pop_count); |
| 2315 } else { | 2323 } else { |
| 2316 __ Ret(); | 2324 __ Ret(); |
| 2317 } | 2325 } |
| 2318 } | 2326 } |
| 2319 | 2327 |
| 2320 | 2328 |
| 2321 void CodeGenerator::AssembleMove(InstructionOperand* source, | 2329 void CodeGenerator::AssembleMove(InstructionOperand* source, |
| 2322 InstructionOperand* destination) { | 2330 InstructionOperand* destination) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2529 padding_size -= v8::internal::Assembler::kInstrSize; | 2537 padding_size -= v8::internal::Assembler::kInstrSize; |
| 2530 } | 2538 } |
| 2531 } | 2539 } |
| 2532 } | 2540 } |
| 2533 | 2541 |
| 2534 #undef __ | 2542 #undef __ |
| 2535 | 2543 |
| 2536 } // namespace compiler | 2544 } // namespace compiler |
| 2537 } // namespace internal | 2545 } // namespace internal |
| 2538 } // namespace v8 | 2546 } // namespace v8 |
| OLD | NEW |