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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 int deopt_state_id = | 702 int deopt_state_id = |
703 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 703 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
704 Deoptimizer::BailoutType bailout_type = | 704 Deoptimizer::BailoutType bailout_type = |
705 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 705 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
706 CodeGenResult result = AssembleDeoptimizerCall( | 706 CodeGenResult result = AssembleDeoptimizerCall( |
707 deopt_state_id, bailout_type, current_source_position_); | 707 deopt_state_id, bailout_type, current_source_position_); |
708 if (result != kSuccess) return result; | 708 if (result != kSuccess) return result; |
709 break; | 709 break; |
710 } | 710 } |
711 case kArchRet: | 711 case kArchRet: |
712 AssembleReturn(); | 712 AssembleReturn(instr->InputAt(0)); |
713 break; | 713 break; |
714 case kArchStackPointer: | 714 case kArchStackPointer: |
715 __ mov(i.OutputRegister(), sp); | 715 __ mov(i.OutputRegister(), sp); |
716 break; | 716 break; |
717 case kArchFramePointer: | 717 case kArchFramePointer: |
718 __ mov(i.OutputRegister(), fp); | 718 __ mov(i.OutputRegister(), fp); |
719 break; | 719 break; |
720 case kArchParentFramePointer: | 720 case kArchParentFramePointer: |
721 if (frame_access_state()->has_frame()) { | 721 if (frame_access_state()->has_frame()) { |
722 __ lw(i.OutputRegister(), MemOperand(fp, 0)); | 722 __ lw(i.OutputRegister(), MemOperand(fp, 0)); |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 } | 1953 } |
1954 | 1954 |
1955 const RegList saves = descriptor->CalleeSavedRegisters(); | 1955 const RegList saves = descriptor->CalleeSavedRegisters(); |
1956 if (saves != 0) { | 1956 if (saves != 0) { |
1957 // Save callee-saved registers. | 1957 // Save callee-saved registers. |
1958 __ MultiPush(saves); | 1958 __ MultiPush(saves); |
1959 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); | 1959 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1); |
1960 } | 1960 } |
1961 } | 1961 } |
1962 | 1962 |
1963 | 1963 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
1964 void CodeGenerator::AssembleReturn() { | |
1965 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1964 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1966 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 1965 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
1967 | 1966 |
1968 // Restore GP registers. | 1967 // Restore GP registers. |
1969 const RegList saves = descriptor->CalleeSavedRegisters(); | 1968 const RegList saves = descriptor->CalleeSavedRegisters(); |
1970 if (saves != 0) { | 1969 if (saves != 0) { |
1971 __ MultiPop(saves); | 1970 __ MultiPop(saves); |
1972 } | 1971 } |
1973 | 1972 |
1974 // Restore FPU registers. | 1973 // Restore FPU registers. |
1975 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1974 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1976 if (saves_fpu != 0) { | 1975 if (saves_fpu != 0) { |
1977 __ MultiPopFPU(saves_fpu); | 1976 __ MultiPopFPU(saves_fpu); |
1978 } | 1977 } |
1979 | 1978 |
| 1979 MipsOperandConverter g(this, nullptr); |
1980 if (descriptor->IsCFunctionCall()) { | 1980 if (descriptor->IsCFunctionCall()) { |
1981 AssembleDeconstructFrame(); | 1981 AssembleDeconstructFrame(); |
1982 } else if (frame_access_state()->has_frame()) { | 1982 } else if (frame_access_state()->has_frame()) { |
1983 // Canonicalize JSFunction return sites for now. | 1983 // Canonicalize JSFunction return sites for now unless they have an variable |
1984 if (return_label_.is_bound()) { | 1984 // number of stack slot pops. |
1985 __ Branch(&return_label_); | 1985 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { |
1986 return; | 1986 if (return_label_.is_bound()) { |
| 1987 __ Branch(&return_label_); |
| 1988 return; |
| 1989 } else { |
| 1990 __ bind(&return_label_); |
| 1991 AssembleDeconstructFrame(); |
| 1992 } |
1987 } else { | 1993 } else { |
1988 __ bind(&return_label_); | |
1989 AssembleDeconstructFrame(); | 1994 AssembleDeconstructFrame(); |
1990 } | 1995 } |
1991 } | 1996 } |
| 1997 if (pop->IsImmediate()) { |
| 1998 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); |
| 1999 pop_count += g.ToConstant(pop).ToInt32(); |
| 2000 } else { |
| 2001 Register pop_reg = g.ToRegister(pop); |
| 2002 __ sll(pop_reg, pop_reg, kPointerSizeLog2); |
| 2003 __ Addu(sp, sp, Operand(pop_reg)); |
| 2004 } |
1992 if (pop_count != 0) { | 2005 if (pop_count != 0) { |
1993 __ DropAndRet(pop_count); | 2006 __ DropAndRet(pop_count); |
1994 } else { | 2007 } else { |
1995 __ Ret(); | 2008 __ Ret(); |
1996 } | 2009 } |
1997 } | 2010 } |
1998 | 2011 |
1999 | 2012 |
2000 void CodeGenerator::AssembleMove(InstructionOperand* source, | 2013 void CodeGenerator::AssembleMove(InstructionOperand* source, |
2001 InstructionOperand* destination) { | 2014 InstructionOperand* destination) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 padding_size -= v8::internal::Assembler::kInstrSize; | 2264 padding_size -= v8::internal::Assembler::kInstrSize; |
2252 } | 2265 } |
2253 } | 2266 } |
2254 } | 2267 } |
2255 | 2268 |
2256 #undef __ | 2269 #undef __ |
2257 | 2270 |
2258 } // namespace compiler | 2271 } // namespace compiler |
2259 } // namespace internal | 2272 } // namespace internal |
2260 } // namespace v8 | 2273 } // namespace v8 |
OLD | NEW |