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(instr->InputAt(0)); | 712 AssembleReturn(); |
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 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { | 1963 |
| 1964 void CodeGenerator::AssembleReturn() { |
1964 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1965 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1965 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 1966 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
1966 | 1967 |
1967 // Restore GP registers. | 1968 // Restore GP registers. |
1968 const RegList saves = descriptor->CalleeSavedRegisters(); | 1969 const RegList saves = descriptor->CalleeSavedRegisters(); |
1969 if (saves != 0) { | 1970 if (saves != 0) { |
1970 __ MultiPop(saves); | 1971 __ MultiPop(saves); |
1971 } | 1972 } |
1972 | 1973 |
1973 // Restore FPU registers. | 1974 // Restore FPU registers. |
1974 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1975 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1975 if (saves_fpu != 0) { | 1976 if (saves_fpu != 0) { |
1976 __ MultiPopFPU(saves_fpu); | 1977 __ MultiPopFPU(saves_fpu); |
1977 } | 1978 } |
1978 | 1979 |
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 unless they have an variable | 1983 // Canonicalize JSFunction return sites for now. |
1984 // number of stack slot pops. | 1984 if (return_label_.is_bound()) { |
1985 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { | 1985 __ Branch(&return_label_); |
1986 if (return_label_.is_bound()) { | 1986 return; |
1987 __ Branch(&return_label_); | |
1988 return; | |
1989 } else { | |
1990 __ bind(&return_label_); | |
1991 AssembleDeconstructFrame(); | |
1992 } | |
1993 } else { | 1987 } else { |
| 1988 __ bind(&return_label_); |
1994 AssembleDeconstructFrame(); | 1989 AssembleDeconstructFrame(); |
1995 } | 1990 } |
1996 } | 1991 } |
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 } | |
2005 if (pop_count != 0) { | 1992 if (pop_count != 0) { |
2006 __ DropAndRet(pop_count); | 1993 __ DropAndRet(pop_count); |
2007 } else { | 1994 } else { |
2008 __ Ret(); | 1995 __ Ret(); |
2009 } | 1996 } |
2010 } | 1997 } |
2011 | 1998 |
2012 | 1999 |
2013 void CodeGenerator::AssembleMove(InstructionOperand* source, | 2000 void CodeGenerator::AssembleMove(InstructionOperand* source, |
2014 InstructionOperand* destination) { | 2001 InstructionOperand* destination) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 padding_size -= v8::internal::Assembler::kInstrSize; | 2251 padding_size -= v8::internal::Assembler::kInstrSize; |
2265 } | 2252 } |
2266 } | 2253 } |
2267 } | 2254 } |
2268 | 2255 |
2269 #undef __ | 2256 #undef __ |
2270 | 2257 |
2271 } // namespace compiler | 2258 } // namespace compiler |
2272 } // namespace internal | 2259 } // namespace internal |
2273 } // namespace v8 | 2260 } // namespace v8 |
OLD | NEW |