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 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 } | 1070 } |
1071 | 1071 |
1072 | 1072 |
1073 void CodeGenerator::AssemblePrologue() { | 1073 void CodeGenerator::AssemblePrologue() { |
1074 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1074 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1075 int stack_slots = frame()->GetSpillSlotCount(); | 1075 int stack_slots = frame()->GetSpillSlotCount(); |
1076 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1076 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1077 __ SetStackPointer(csp); | 1077 __ SetStackPointer(csp); |
1078 __ Push(lr, fp); | 1078 __ Push(lr, fp); |
1079 __ Mov(fp, csp); | 1079 __ Mov(fp, csp); |
1080 // TODO(dcarney): correct callee saved registers. | 1080 |
1081 __ PushCalleeSavedRegisters(); | 1081 // Save FP registers. |
1082 frame()->SetRegisterSaveAreaSize(20 * kPointerSize); | 1082 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
| 1083 descriptor->CalleeSavedFPRegisters()); |
| 1084 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list()); |
| 1085 int saved_count = saves_fp.Count(); |
| 1086 __ PushCPURegList(saves_fp); |
| 1087 // Save registers. |
| 1088 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
| 1089 descriptor->CalleeSavedRegisters()); |
| 1090 // TODO(palfia): TF save list is not in sync with |
| 1091 // CPURegList::GetCalleeSaved(): x30 is missing. |
| 1092 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list()); |
| 1093 saved_count += saves.Count(); |
| 1094 __ PushCPURegList(saves); |
| 1095 |
| 1096 frame()->SetRegisterSaveAreaSize(saved_count * kPointerSize); |
1083 } else if (descriptor->IsJSFunctionCall()) { | 1097 } else if (descriptor->IsJSFunctionCall()) { |
1084 CompilationInfo* info = this->info(); | 1098 CompilationInfo* info = this->info(); |
1085 __ SetStackPointer(jssp); | 1099 __ SetStackPointer(jssp); |
1086 __ Prologue(info->IsCodePreAgingActive()); | 1100 __ Prologue(info->IsCodePreAgingActive()); |
1087 frame()->SetRegisterSaveAreaSize( | 1101 frame()->SetRegisterSaveAreaSize( |
1088 StandardFrameConstants::kFixedFrameSizeFromFp); | 1102 StandardFrameConstants::kFixedFrameSizeFromFp); |
1089 } else if (needs_frame_) { | 1103 } else if (needs_frame_) { |
1090 __ SetStackPointer(jssp); | 1104 __ SetStackPointer(jssp); |
1091 __ StubPrologue(); | 1105 __ StubPrologue(); |
1092 frame()->SetRegisterSaveAreaSize( | 1106 frame()->SetRegisterSaveAreaSize( |
(...skipping 28 matching lines...) Expand all Loading... |
1121 | 1135 |
1122 void CodeGenerator::AssembleReturn() { | 1136 void CodeGenerator::AssembleReturn() { |
1123 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1137 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1124 int stack_slots = frame()->GetSpillSlotCount(); | 1138 int stack_slots = frame()->GetSpillSlotCount(); |
1125 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1139 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1126 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1140 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1127 // Remove this frame's spill slots first. | 1141 // Remove this frame's spill slots first. |
1128 if (stack_slots > 0) { | 1142 if (stack_slots > 0) { |
1129 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); | 1143 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); |
1130 } | 1144 } |
| 1145 |
1131 // Restore registers. | 1146 // Restore registers. |
1132 // TODO(dcarney): correct callee saved registers. | 1147 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
1133 __ PopCalleeSavedRegisters(); | 1148 descriptor->CalleeSavedRegisters()); |
| 1149 __ PopCPURegList(saves); |
| 1150 |
| 1151 CPURegList saves_fp = |
| 1152 CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
| 1153 descriptor->CalleeSavedFPRegisters()); |
| 1154 __ PopCPURegList(saves_fp); |
1134 } | 1155 } |
| 1156 |
1135 __ Mov(csp, fp); | 1157 __ Mov(csp, fp); |
1136 __ Pop(fp, lr); | 1158 __ Pop(fp, lr); |
1137 __ Ret(); | 1159 __ Ret(); |
1138 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1160 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1139 __ Mov(jssp, fp); | 1161 __ Mov(jssp, fp); |
1140 __ Pop(fp, lr); | 1162 __ Pop(fp, lr); |
1141 int pop_count = descriptor->IsJSFunctionCall() | 1163 int pop_count = descriptor->IsJSFunctionCall() |
1142 ? static_cast<int>(descriptor->JSParameterCount()) | 1164 ? static_cast<int>(descriptor->JSParameterCount()) |
1143 : 0; | 1165 : 0; |
1144 __ Drop(pop_count); | 1166 __ Drop(pop_count); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 } | 1351 } |
1330 } | 1352 } |
1331 } | 1353 } |
1332 } | 1354 } |
1333 | 1355 |
1334 #undef __ | 1356 #undef __ |
1335 | 1357 |
1336 } // namespace compiler | 1358 } // namespace compiler |
1337 } // namespace internal | 1359 } // namespace internal |
1338 } // namespace v8 | 1360 } // namespace v8 |
OLD | NEW |