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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 int deopt_state_id = | 712 int deopt_state_id = |
713 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 713 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
714 Deoptimizer::BailoutType bailout_type = | 714 Deoptimizer::BailoutType bailout_type = |
715 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 715 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
716 CodeGenResult result = AssembleDeoptimizerCall( | 716 CodeGenResult result = AssembleDeoptimizerCall( |
717 deopt_state_id, bailout_type, current_source_position_); | 717 deopt_state_id, bailout_type, current_source_position_); |
718 if (result != kSuccess) return result; | 718 if (result != kSuccess) return result; |
719 break; | 719 break; |
720 } | 720 } |
721 case kArchRet: | 721 case kArchRet: |
722 AssembleReturn(instr->InputAt(0)); | 722 AssembleReturn(); |
723 break; | 723 break; |
724 case kArchStackPointer: | 724 case kArchStackPointer: |
725 __ mov(i.OutputRegister(), sp); | 725 __ mov(i.OutputRegister(), sp); |
726 break; | 726 break; |
727 case kArchFramePointer: | 727 case kArchFramePointer: |
728 __ mov(i.OutputRegister(), fp); | 728 __ mov(i.OutputRegister(), fp); |
729 break; | 729 break; |
730 case kArchParentFramePointer: | 730 case kArchParentFramePointer: |
731 if (frame_access_state()->has_frame()) { | 731 if (frame_access_state()->has_frame()) { |
732 __ ld(i.OutputRegister(), MemOperand(fp, 0)); | 732 __ ld(i.OutputRegister(), MemOperand(fp, 0)); |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 } | 2271 } |
2272 | 2272 |
2273 const RegList saves = descriptor->CalleeSavedRegisters(); | 2273 const RegList saves = descriptor->CalleeSavedRegisters(); |
2274 if (saves != 0) { | 2274 if (saves != 0) { |
2275 // Save callee-saved registers. | 2275 // Save callee-saved registers. |
2276 __ MultiPush(saves); | 2276 __ MultiPush(saves); |
2277 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); | 2277 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); |
2278 } | 2278 } |
2279 } | 2279 } |
2280 | 2280 |
2281 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { | 2281 |
| 2282 void CodeGenerator::AssembleReturn() { |
2282 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 2283 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
2283 | 2284 |
2284 // Restore GP registers. | 2285 // Restore GP registers. |
2285 const RegList saves = descriptor->CalleeSavedRegisters(); | 2286 const RegList saves = descriptor->CalleeSavedRegisters(); |
2286 if (saves != 0) { | 2287 if (saves != 0) { |
2287 __ MultiPop(saves); | 2288 __ MultiPop(saves); |
2288 } | 2289 } |
2289 | 2290 |
2290 // Restore FPU registers. | 2291 // Restore FPU registers. |
2291 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 2292 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
2292 if (saves_fpu != 0) { | 2293 if (saves_fpu != 0) { |
2293 __ MultiPopFPU(saves_fpu); | 2294 __ MultiPopFPU(saves_fpu); |
2294 } | 2295 } |
2295 | 2296 |
2296 MipsOperandConverter g(this, nullptr); | |
2297 if (descriptor->IsCFunctionCall()) { | 2297 if (descriptor->IsCFunctionCall()) { |
2298 AssembleDeconstructFrame(); | 2298 AssembleDeconstructFrame(); |
2299 } else if (frame_access_state()->has_frame()) { | 2299 } else if (frame_access_state()->has_frame()) { |
2300 // Canonicalize JSFunction return sites for now unless they have an variable | 2300 // Canonicalize JSFunction return sites for now. |
2301 // number of stack slot pops. | 2301 if (return_label_.is_bound()) { |
2302 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { | 2302 __ Branch(&return_label_); |
2303 if (return_label_.is_bound()) { | 2303 return; |
2304 __ Branch(&return_label_); | |
2305 return; | |
2306 } else { | |
2307 __ bind(&return_label_); | |
2308 AssembleDeconstructFrame(); | |
2309 } | |
2310 } else { | 2304 } else { |
| 2305 __ bind(&return_label_); |
2311 AssembleDeconstructFrame(); | 2306 AssembleDeconstructFrame(); |
2312 } | 2307 } |
2313 } | 2308 } |
2314 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 2309 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
2315 if (pop->IsImmediate()) { | |
2316 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); | |
2317 pop_count += g.ToConstant(pop).ToInt32(); | |
2318 } else { | |
2319 Register pop_reg = g.ToRegister(pop); | |
2320 __ dsll(pop_reg, pop_reg, kPointerSizeLog2); | |
2321 __ Daddu(sp, sp, pop_reg); | |
2322 } | |
2323 if (pop_count != 0) { | 2310 if (pop_count != 0) { |
2324 __ DropAndRet(pop_count); | 2311 __ DropAndRet(pop_count); |
2325 } else { | 2312 } else { |
2326 __ Ret(); | 2313 __ Ret(); |
2327 } | 2314 } |
2328 } | 2315 } |
2329 | 2316 |
2330 | 2317 |
2331 void CodeGenerator::AssembleMove(InstructionOperand* source, | 2318 void CodeGenerator::AssembleMove(InstructionOperand* source, |
2332 InstructionOperand* destination) { | 2319 InstructionOperand* destination) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 padding_size -= v8::internal::Assembler::kInstrSize; | 2526 padding_size -= v8::internal::Assembler::kInstrSize; |
2540 } | 2527 } |
2541 } | 2528 } |
2542 } | 2529 } |
2543 | 2530 |
2544 #undef __ | 2531 #undef __ |
2545 | 2532 |
2546 } // namespace compiler | 2533 } // namespace compiler |
2547 } // namespace internal | 2534 } // namespace internal |
2548 } // namespace v8 | 2535 } // namespace v8 |
OLD | NEW |