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 | 6 |
7 #include "src/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 int deopt_state_id = | 1083 int deopt_state_id = |
1084 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 1084 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
1085 Deoptimizer::BailoutType bailout_type = | 1085 Deoptimizer::BailoutType bailout_type = |
1086 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 1086 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
1087 CodeGenResult result = AssembleDeoptimizerCall( | 1087 CodeGenResult result = AssembleDeoptimizerCall( |
1088 deopt_state_id, bailout_type, current_source_position_); | 1088 deopt_state_id, bailout_type, current_source_position_); |
1089 if (result != kSuccess) return result; | 1089 if (result != kSuccess) return result; |
1090 break; | 1090 break; |
1091 } | 1091 } |
1092 case kArchRet: | 1092 case kArchRet: |
1093 AssembleReturn(); | 1093 AssembleReturn(instr->InputAt(0)); |
1094 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1094 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1095 break; | 1095 break; |
1096 case kArchStackPointer: | 1096 case kArchStackPointer: |
1097 __ mr(i.OutputRegister(), sp); | 1097 __ mr(i.OutputRegister(), sp); |
1098 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1098 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1099 break; | 1099 break; |
1100 case kArchFramePointer: | 1100 case kArchFramePointer: |
1101 __ mr(i.OutputRegister(), fp); | 1101 __ mr(i.OutputRegister(), fp); |
1102 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1102 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1103 break; | 1103 break; |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 const RegList saves = | 2167 const RegList saves = |
2168 FLAG_enable_embedded_constant_pool | 2168 FLAG_enable_embedded_constant_pool |
2169 ? descriptor->CalleeSavedRegisters() & ~kConstantPoolRegister.bit() | 2169 ? descriptor->CalleeSavedRegisters() & ~kConstantPoolRegister.bit() |
2170 : descriptor->CalleeSavedRegisters(); | 2170 : descriptor->CalleeSavedRegisters(); |
2171 if (saves != 0) { | 2171 if (saves != 0) { |
2172 __ MultiPush(saves); | 2172 __ MultiPush(saves); |
2173 // register save area does not include the fp or constant pool pointer. | 2173 // register save area does not include the fp or constant pool pointer. |
2174 } | 2174 } |
2175 } | 2175 } |
2176 | 2176 |
2177 | 2177 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
2178 void CodeGenerator::AssembleReturn() { | |
2179 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 2178 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
2180 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 2179 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
2181 | 2180 |
2182 // Restore registers. | 2181 // Restore registers. |
2183 const RegList saves = | 2182 const RegList saves = |
2184 FLAG_enable_embedded_constant_pool | 2183 FLAG_enable_embedded_constant_pool |
2185 ? descriptor->CalleeSavedRegisters() & ~kConstantPoolRegister.bit() | 2184 ? descriptor->CalleeSavedRegisters() & ~kConstantPoolRegister.bit() |
2186 : descriptor->CalleeSavedRegisters(); | 2185 : descriptor->CalleeSavedRegisters(); |
2187 if (saves != 0) { | 2186 if (saves != 0) { |
2188 __ MultiPop(saves); | 2187 __ MultiPop(saves); |
2189 } | 2188 } |
2190 | 2189 |
2191 // Restore double registers. | 2190 // Restore double registers. |
2192 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); | 2191 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); |
2193 if (double_saves != 0) { | 2192 if (double_saves != 0) { |
2194 __ MultiPopDoubles(double_saves); | 2193 __ MultiPopDoubles(double_saves); |
2195 } | 2194 } |
| 2195 PPCOperandConverter g(this, nullptr); |
2196 | 2196 |
2197 if (descriptor->IsCFunctionCall()) { | 2197 if (descriptor->IsCFunctionCall()) { |
2198 AssembleDeconstructFrame(); | 2198 AssembleDeconstructFrame(); |
2199 } else if (frame_access_state()->has_frame()) { | 2199 } else if (frame_access_state()->has_frame()) { |
2200 // Canonicalize JSFunction return sites for now. | 2200 // Canonicalize JSFunction return sites for now unless they have an variable |
2201 if (return_label_.is_bound()) { | 2201 // number of stack slot pops |
2202 __ b(&return_label_); | 2202 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { |
2203 return; | 2203 if (return_label_.is_bound()) { |
| 2204 __ b(&return_label_); |
| 2205 return; |
| 2206 } else { |
| 2207 __ bind(&return_label_); |
| 2208 AssembleDeconstructFrame(); |
| 2209 } |
2204 } else { | 2210 } else { |
2205 __ bind(&return_label_); | |
2206 AssembleDeconstructFrame(); | 2211 AssembleDeconstructFrame(); |
2207 } | 2212 } |
2208 } | 2213 } |
2209 __ Ret(pop_count); | 2214 if (pop->IsImmediate()) { |
| 2215 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); |
| 2216 pop_count += g.ToConstant(pop).ToInt32(); |
| 2217 } else { |
| 2218 __ Drop(g.ToRegister(pop)); |
| 2219 } |
| 2220 __ Drop(pop_count); |
| 2221 __ Ret(); |
2210 } | 2222 } |
2211 | 2223 |
2212 | 2224 |
2213 void CodeGenerator::AssembleMove(InstructionOperand* source, | 2225 void CodeGenerator::AssembleMove(InstructionOperand* source, |
2214 InstructionOperand* destination) { | 2226 InstructionOperand* destination) { |
2215 PPCOperandConverter g(this, nullptr); | 2227 PPCOperandConverter g(this, nullptr); |
2216 // Dispatch on the source and destination operand kinds. Not all | 2228 // Dispatch on the source and destination operand kinds. Not all |
2217 // combinations are possible. | 2229 // combinations are possible. |
2218 if (source->IsRegister()) { | 2230 if (source->IsRegister()) { |
2219 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 2231 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 padding_size -= v8::internal::Assembler::kInstrSize; | 2453 padding_size -= v8::internal::Assembler::kInstrSize; |
2442 } | 2454 } |
2443 } | 2455 } |
2444 } | 2456 } |
2445 | 2457 |
2446 #undef __ | 2458 #undef __ |
2447 | 2459 |
2448 } // namespace compiler | 2460 } // namespace compiler |
2449 } // namespace internal | 2461 } // namespace internal |
2450 } // namespace v8 | 2462 } // namespace v8 |
OLD | NEW |