| 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()); | |
| 189 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 187 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
| 190 // The linkage computes where all spill slots are located. | 188 FrameOffset offset = |
| 191 FrameOffset offset = linkage()->GetFrameOffset( | 189 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); |
| 192 AllocatedOperand::cast(op)->index(), frame(), 0); | |
| 193 return MemOperand(offset.from_stack_pointer() ? masm->StackPointer() : fp, | 190 return MemOperand(offset.from_stack_pointer() ? masm->StackPointer() : fp, |
| 194 offset.offset()); | 191 offset.offset()); |
| 195 } | 192 } |
| 196 }; | 193 }; |
| 197 | 194 |
| 198 | 195 |
| 199 namespace { | 196 namespace { |
| 200 | 197 |
| 201 class OutOfLineLoadNaN32 final : public OutOfLineCode { | 198 class OutOfLineLoadNaN32 final : public OutOfLineCode { |
| 202 public: | 199 public: |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 CompilationInfo* info = this->info(); | 1108 CompilationInfo* info = this->info(); |
| 1112 __ SetStackPointer(jssp); | 1109 __ SetStackPointer(jssp); |
| 1113 __ Prologue(info->IsCodePreAgingActive()); | 1110 __ Prologue(info->IsCodePreAgingActive()); |
| 1114 frame()->SetRegisterSaveAreaSize( | 1111 frame()->SetRegisterSaveAreaSize( |
| 1115 StandardFrameConstants::kFixedFrameSizeFromFp); | 1112 StandardFrameConstants::kFixedFrameSizeFromFp); |
| 1116 } else if (needs_frame_) { | 1113 } else if (needs_frame_) { |
| 1117 __ SetStackPointer(jssp); | 1114 __ SetStackPointer(jssp); |
| 1118 __ StubPrologue(); | 1115 __ StubPrologue(); |
| 1119 frame()->SetRegisterSaveAreaSize( | 1116 frame()->SetRegisterSaveAreaSize( |
| 1120 StandardFrameConstants::kFixedFrameSizeFromFp); | 1117 StandardFrameConstants::kFixedFrameSizeFromFp); |
| 1118 } else { |
| 1119 frame()->SetPCOnStack(false); |
| 1121 } | 1120 } |
| 1122 | 1121 |
| 1123 if (info()->is_osr()) { | 1122 if (info()->is_osr()) { |
| 1124 // TurboFan OSR-compiled functions cannot be entered directly. | 1123 // TurboFan OSR-compiled functions cannot be entered directly. |
| 1125 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1124 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
| 1126 | 1125 |
| 1127 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1126 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
| 1128 // frame is still on the stack. Optimized code uses OSR values directly from | 1127 // frame is still on the stack. Optimized code uses OSR values directly from |
| 1129 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1128 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
| 1130 // remaining stack slots. | 1129 // remaining stack slots. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1142 __ Sub(sp, sp, stack_slots * kPointerSize); | 1141 __ Sub(sp, sp, stack_slots * kPointerSize); |
| 1143 } | 1142 } |
| 1144 __ Sub(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); | 1143 __ Sub(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); |
| 1145 } | 1144 } |
| 1146 } | 1145 } |
| 1147 | 1146 |
| 1148 | 1147 |
| 1149 void CodeGenerator::AssembleReturn() { | 1148 void CodeGenerator::AssembleReturn() { |
| 1150 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1149 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1151 int stack_slots = frame()->GetSpillSlotCount(); | 1150 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(); | |
| 1173 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1172 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
| 1174 // Canonicalize JSFunction return sites for now. | 1173 // Canonicalize JSFunction return sites for now. |
| 1175 if (return_label_.is_bound()) { | 1174 if (return_label_.is_bound()) { |
| 1176 __ B(&return_label_); | 1175 __ 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(); | |
| 1186 } | 1181 } |
| 1187 } else { | |
| 1188 __ Ret(); | |
| 1189 } | 1182 } |
| 1183 __ Drop(pop_count); |
| 1184 __ Ret(); |
| 1190 } | 1185 } |
| 1191 | 1186 |
| 1192 | 1187 |
| 1193 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1188 void CodeGenerator::AssembleMove(InstructionOperand* source, |
| 1194 InstructionOperand* destination) { | 1189 InstructionOperand* destination) { |
| 1195 Arm64OperandConverter g(this, NULL); | 1190 Arm64OperandConverter g(this, NULL); |
| 1196 // Dispatch on the source and destination operand kinds. Not all | 1191 // Dispatch on the source and destination operand kinds. Not all |
| 1197 // combinations are possible. | 1192 // combinations are possible. |
| 1198 if (source->IsRegister()) { | 1193 if (source->IsRegister()) { |
| 1199 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1194 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 } | 1365 } |
| 1371 } | 1366 } |
| 1372 } | 1367 } |
| 1373 } | 1368 } |
| 1374 | 1369 |
| 1375 #undef __ | 1370 #undef __ |
| 1376 | 1371 |
| 1377 } // namespace compiler | 1372 } // namespace compiler |
| 1378 } // namespace internal | 1373 } // namespace internal |
| 1379 } // namespace v8 | 1374 } // namespace v8 |
| OLD | NEW |