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 registers. |
paul.l...
2015/06/23 02:15:02
This looks a bit messy to me, but luckily there ar
akos.palfi.imgtec
2015/06/23 19:48:57
Thanks, it's much cleaner now.
| |
1082 frame()->SetRegisterSaveAreaSize(20 * kPointerSize); | 1082 MemOperand tos(csp, -2 * static_cast<int>(kXRegSize), PreIndex); |
1083 int saved_count = 0; | |
1084 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); | |
1085 if (saves_fp != 0) { | |
1086 // Save callee-saved FP registers. | |
1087 int prev_reg = -1; | |
1088 for (int i = FPRegister::kMaxNumRegisters - 1; i >= 0; i--) { | |
1089 if (((1 << i) & saves_fp)) { | |
1090 if (prev_reg != -1) { | |
1091 __ stp(FPRegister::from_code(i), FPRegister::from_code(prev_reg), | |
1092 tos); | |
1093 saved_count += 2; | |
1094 prev_reg = -1; | |
1095 } else { | |
1096 prev_reg = i; | |
1097 } | |
1098 } | |
1099 } | |
1100 CHECK(prev_reg == -1); | |
1101 } | |
1102 const RegList saves = descriptor->CalleeSavedRegisters(); | |
1103 if (saves != 0) { | |
1104 // Save callee-saved registers. | |
1105 int prev_reg = -1; | |
1106 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | |
1107 if (((1 << i) & saves)) { | |
1108 if (prev_reg != -1) { | |
1109 __ stp(Register::from_code(i), Register::from_code(prev_reg), tos); | |
1110 saved_count += 2; | |
1111 prev_reg = -1; | |
1112 } else { | |
1113 prev_reg = i; | |
1114 } | |
1115 } | |
1116 } | |
1117 CHECK(prev_reg == -1); | |
1118 } | |
1119 frame()->SetRegisterSaveAreaSize(saved_count * kPointerSize); | |
1083 } else if (descriptor->IsJSFunctionCall()) { | 1120 } else if (descriptor->IsJSFunctionCall()) { |
1084 CompilationInfo* info = this->info(); | 1121 CompilationInfo* info = this->info(); |
1085 __ SetStackPointer(jssp); | 1122 __ SetStackPointer(jssp); |
1086 __ Prologue(info->IsCodePreAgingActive()); | 1123 __ Prologue(info->IsCodePreAgingActive()); |
1087 frame()->SetRegisterSaveAreaSize( | 1124 frame()->SetRegisterSaveAreaSize( |
1088 StandardFrameConstants::kFixedFrameSizeFromFp); | 1125 StandardFrameConstants::kFixedFrameSizeFromFp); |
1089 } else if (needs_frame_) { | 1126 } else if (needs_frame_) { |
1090 __ SetStackPointer(jssp); | 1127 __ SetStackPointer(jssp); |
1091 __ StubPrologue(); | 1128 __ StubPrologue(); |
1092 frame()->SetRegisterSaveAreaSize( | 1129 frame()->SetRegisterSaveAreaSize( |
(...skipping 28 matching lines...) Expand all Loading... | |
1121 | 1158 |
1122 void CodeGenerator::AssembleReturn() { | 1159 void CodeGenerator::AssembleReturn() { |
1123 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1160 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1124 int stack_slots = frame()->GetSpillSlotCount(); | 1161 int stack_slots = frame()->GetSpillSlotCount(); |
1125 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1162 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1126 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1163 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1127 // Remove this frame's spill slots first. | 1164 // Remove this frame's spill slots first. |
1128 if (stack_slots > 0) { | 1165 if (stack_slots > 0) { |
1129 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); | 1166 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); |
1130 } | 1167 } |
1168 | |
1131 // Restore registers. | 1169 // Restore registers. |
1132 // TODO(dcarney): correct callee saved registers. | 1170 MemOperand tos(csp, 2 * kXRegSize, PostIndex); |
1133 __ PopCalleeSavedRegisters(); | 1171 const RegList saves = descriptor->CalleeSavedRegisters(); |
1172 if (saves != 0) { | |
1173 // Restore callee-saved registers. | |
1174 int prev_reg = -1; | |
1175 for (int i = 0; i < Register::kNumRegisters; i++) { | |
1176 if (((1 << i) & saves)) { | |
1177 if (prev_reg != -1) { | |
1178 __ ldp(Register::from_code(prev_reg), Register::from_code(i), | |
1179 tos); | |
1180 prev_reg = -1; | |
1181 } else { | |
1182 prev_reg = i; | |
1183 } | |
1184 } | |
1185 } | |
1186 CHECK(prev_reg == -1); | |
1187 } | |
1188 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); | |
1189 if (saves_fp != 0) { | |
1190 // Restore callee-saved FP registers. | |
1191 int prev_reg = -1; | |
1192 for (int i = 0; i < FPRegister::kMaxNumRegisters; i++) { | |
1193 if (((1 << i) & saves_fp)) { | |
1194 if (prev_reg != -1) { | |
1195 __ ldp(FPRegister::from_code(prev_reg), FPRegister::from_code(i), | |
1196 tos); | |
1197 prev_reg = -1; | |
1198 } else { | |
1199 prev_reg = i; | |
1200 } | |
1201 } | |
1202 } | |
1203 CHECK(prev_reg == -1); | |
1204 } | |
1134 } | 1205 } |
1206 | |
1135 __ Mov(csp, fp); | 1207 __ Mov(csp, fp); |
1136 __ Pop(fp, lr); | 1208 __ Pop(fp, lr); |
1137 __ Ret(); | 1209 __ Ret(); |
1138 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1210 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1139 __ Mov(jssp, fp); | 1211 __ Mov(jssp, fp); |
1140 __ Pop(fp, lr); | 1212 __ Pop(fp, lr); |
1141 int pop_count = descriptor->IsJSFunctionCall() | 1213 int pop_count = descriptor->IsJSFunctionCall() |
1142 ? static_cast<int>(descriptor->JSParameterCount()) | 1214 ? static_cast<int>(descriptor->JSParameterCount()) |
1143 : 0; | 1215 : 0; |
1144 __ Drop(pop_count); | 1216 __ Drop(pop_count); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 } | 1402 } |
1331 } | 1403 } |
1332 MarkLazyDeoptSite(); | 1404 MarkLazyDeoptSite(); |
1333 } | 1405 } |
1334 | 1406 |
1335 #undef __ | 1407 #undef __ |
1336 | 1408 |
1337 } // namespace compiler | 1409 } // namespace compiler |
1338 } // namespace internal | 1410 } // namespace internal |
1339 } // namespace v8 | 1411 } // namespace v8 |
OLD | NEW |