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/arm64/macro-assembler-arm64.h" | 7 #include "src/arm64/macro-assembler-arm64.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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 case Constant::kRpoNumber: | 177 case Constant::kRpoNumber: |
178 UNREACHABLE(); // TODO(dcarney): RPO immediates on arm64. | 178 UNREACHABLE(); // TODO(dcarney): RPO immediates on arm64. |
179 break; | 179 break; |
180 } | 180 } |
181 UNREACHABLE(); | 181 UNREACHABLE(); |
182 return Operand(-1); | 182 return Operand(-1); |
183 } | 183 } |
184 | 184 |
185 MemOperand ToMemOperand(InstructionOperand* op, MacroAssembler* masm) const { | 185 MemOperand ToMemOperand(InstructionOperand* op, MacroAssembler* masm) const { |
186 DCHECK(op != NULL); | 186 DCHECK(op != NULL); |
| 187 DCHECK(!op->IsRegister()); |
| 188 DCHECK(!op->IsDoubleRegister()); |
187 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 189 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
188 FrameOffset offset = | 190 // The linkage computes where all spill slots are located. |
189 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); | 191 FrameOffset offset = linkage()->GetFrameOffset( |
| 192 AllocatedOperand::cast(op)->index(), frame(), 0); |
190 return MemOperand(offset.from_stack_pointer() ? masm->StackPointer() : fp, | 193 return MemOperand(offset.from_stack_pointer() ? masm->StackPointer() : fp, |
191 offset.offset()); | 194 offset.offset()); |
192 } | 195 } |
193 }; | 196 }; |
194 | 197 |
195 | 198 |
196 namespace { | 199 namespace { |
197 | 200 |
198 class OutOfLineLoadNaN32 final : public OutOfLineCode { | 201 class OutOfLineLoadNaN32 final : public OutOfLineCode { |
199 public: | 202 public: |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 CompilationInfo* info = this->info(); | 1111 CompilationInfo* info = this->info(); |
1109 __ SetStackPointer(jssp); | 1112 __ SetStackPointer(jssp); |
1110 __ Prologue(info->IsCodePreAgingActive()); | 1113 __ Prologue(info->IsCodePreAgingActive()); |
1111 frame()->SetRegisterSaveAreaSize( | 1114 frame()->SetRegisterSaveAreaSize( |
1112 StandardFrameConstants::kFixedFrameSizeFromFp); | 1115 StandardFrameConstants::kFixedFrameSizeFromFp); |
1113 } else if (needs_frame_) { | 1116 } else if (needs_frame_) { |
1114 __ SetStackPointer(jssp); | 1117 __ SetStackPointer(jssp); |
1115 __ StubPrologue(); | 1118 __ StubPrologue(); |
1116 frame()->SetRegisterSaveAreaSize( | 1119 frame()->SetRegisterSaveAreaSize( |
1117 StandardFrameConstants::kFixedFrameSizeFromFp); | 1120 StandardFrameConstants::kFixedFrameSizeFromFp); |
1118 } else { | |
1119 frame()->SetPCOnStack(false); | |
1120 } | 1121 } |
1121 | 1122 |
1122 if (info()->is_osr()) { | 1123 if (info()->is_osr()) { |
1123 // TurboFan OSR-compiled functions cannot be entered directly. | 1124 // TurboFan OSR-compiled functions cannot be entered directly. |
1124 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1125 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1125 | 1126 |
1126 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1127 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1127 // frame is still on the stack. Optimized code uses OSR values directly from | 1128 // frame is still on the stack. Optimized code uses OSR values directly from |
1128 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1129 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1129 // remaining stack slots. | 1130 // remaining stack slots. |
(...skipping 11 matching lines...) Expand all Loading... |
1141 __ Sub(sp, sp, stack_slots * kPointerSize); | 1142 __ Sub(sp, sp, stack_slots * kPointerSize); |
1142 } | 1143 } |
1143 __ Sub(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); | 1144 __ Sub(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); |
1144 } | 1145 } |
1145 } | 1146 } |
1146 | 1147 |
1147 | 1148 |
1148 void CodeGenerator::AssembleReturn() { | 1149 void CodeGenerator::AssembleReturn() { |
1149 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1150 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1150 int stack_slots = frame()->GetSpillSlotCount(); | 1151 int stack_slots = frame()->GetSpillSlotCount(); |
1151 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | |
1152 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1152 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1153 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1153 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1154 // Remove this frame's spill slots first. | 1154 // Remove this frame's spill slots first. |
1155 if (stack_slots > 0) { | 1155 if (stack_slots > 0) { |
1156 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); | 1156 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); |
1157 } | 1157 } |
1158 | 1158 |
1159 // Restore registers. | 1159 // Restore registers. |
1160 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, | 1160 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
1161 descriptor->CalleeSavedRegisters()); | 1161 descriptor->CalleeSavedRegisters()); |
1162 __ PopCPURegList(saves); | 1162 __ PopCPURegList(saves); |
1163 | 1163 |
1164 CPURegList saves_fp = | 1164 CPURegList saves_fp = |
1165 CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, | 1165 CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
1166 descriptor->CalleeSavedFPRegisters()); | 1166 descriptor->CalleeSavedFPRegisters()); |
1167 __ PopCPURegList(saves_fp); | 1167 __ PopCPURegList(saves_fp); |
1168 } | 1168 } |
1169 | 1169 |
1170 __ Mov(csp, fp); | 1170 __ Mov(csp, fp); |
1171 __ Pop(fp, lr); | 1171 __ Pop(fp, lr); |
| 1172 __ Ret(); |
1172 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1173 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1173 // Canonicalize JSFunction return sites for now. | 1174 // Canonicalize JSFunction return sites for now. |
1174 if (return_label_.is_bound()) { | 1175 if (return_label_.is_bound()) { |
1175 __ B(&return_label_); | 1176 __ B(&return_label_); |
1176 return; | |
1177 } else { | 1177 } else { |
1178 __ Bind(&return_label_); | 1178 __ Bind(&return_label_); |
1179 __ Mov(jssp, fp); | 1179 __ Mov(jssp, fp); |
1180 __ Pop(fp, lr); | 1180 __ Pop(fp, lr); |
| 1181 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| 1182 if (pop_count != 0) { |
| 1183 __ Drop(pop_count); |
| 1184 } |
| 1185 __ Ret(); |
1181 } | 1186 } |
| 1187 } else { |
| 1188 __ Ret(); |
1182 } | 1189 } |
1183 __ Drop(pop_count); | |
1184 __ Ret(); | |
1185 } | 1190 } |
1186 | 1191 |
1187 | 1192 |
1188 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1193 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1189 InstructionOperand* destination) { | 1194 InstructionOperand* destination) { |
1190 Arm64OperandConverter g(this, NULL); | 1195 Arm64OperandConverter g(this, NULL); |
1191 // Dispatch on the source and destination operand kinds. Not all | 1196 // Dispatch on the source and destination operand kinds. Not all |
1192 // combinations are possible. | 1197 // combinations are possible. |
1193 if (source->IsRegister()) { | 1198 if (source->IsRegister()) { |
1194 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1199 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 } | 1370 } |
1366 } | 1371 } |
1367 } | 1372 } |
1368 } | 1373 } |
1369 | 1374 |
1370 #undef __ | 1375 #undef __ |
1371 | 1376 |
1372 } // namespace compiler | 1377 } // namespace compiler |
1373 } // namespace internal | 1378 } // namespace internal |
1374 } // namespace v8 | 1379 } // namespace v8 |
OLD | NEW |