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/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 if (FLAG_enable_embedded_constant_pool) { | 955 if (FLAG_enable_embedded_constant_pool) { |
956 __ Push(lr, fp, pp); | 956 __ Push(lr, fp, pp); |
957 // Adjust FP to point to saved FP. | 957 // Adjust FP to point to saved FP. |
958 __ sub(fp, sp, Operand(StandardFrameConstants::kConstantPoolOffset)); | 958 __ sub(fp, sp, Operand(StandardFrameConstants::kConstantPoolOffset)); |
959 saved_pp = true; | 959 saved_pp = true; |
960 } else { | 960 } else { |
961 __ Push(lr, fp); | 961 __ Push(lr, fp); |
962 __ mov(fp, sp); | 962 __ mov(fp, sp); |
963 saved_pp = false; | 963 saved_pp = false; |
964 } | 964 } |
| 965 int register_save_area_size = saved_pp ? kPointerSize : 0; |
965 const RegList saves = descriptor->CalleeSavedRegisters(); | 966 const RegList saves = descriptor->CalleeSavedRegisters(); |
966 if (saves != 0 || saved_pp) { | 967 if (saves != 0 || saved_pp) { |
967 // Save callee-saved registers. | 968 // Save callee-saved registers. |
968 int register_save_area_size = saved_pp ? kPointerSize : 0; | 969 __ stm(db_w, sp, saves); |
969 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 970 register_save_area_size += |
970 if (!((1 << i) & saves)) continue; | 971 kPointerSize * base::bits::CountPopulation32(saves); |
971 register_save_area_size += kPointerSize; | 972 } |
972 } | 973 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
| 974 if (saves_fp != 0) { |
| 975 // Save callee-saved FP registers. |
| 976 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
| 977 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
| 978 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
| 979 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); |
| 980 |
| 981 __ vstm(db_w, sp, DwVfpRegister::from_code(first), |
| 982 DwVfpRegister::from_code(last)); |
| 983 register_save_area_size += 2 * kPointerSize * (last - first + 1); |
| 984 } |
| 985 if (register_save_area_size > 0) { |
973 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 986 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
974 __ stm(db_w, sp, saves); | |
975 } | 987 } |
976 } else if (descriptor->IsJSFunctionCall()) { | 988 } else if (descriptor->IsJSFunctionCall()) { |
977 CompilationInfo* info = this->info(); | 989 CompilationInfo* info = this->info(); |
978 __ Prologue(info->IsCodePreAgingActive()); | 990 __ Prologue(info->IsCodePreAgingActive()); |
979 frame()->SetRegisterSaveAreaSize( | 991 frame()->SetRegisterSaveAreaSize( |
980 StandardFrameConstants::kFixedFrameSizeFromFp); | 992 StandardFrameConstants::kFixedFrameSizeFromFp); |
981 } else if (needs_frame_) { | 993 } else if (needs_frame_) { |
982 __ StubPrologue(); | 994 __ StubPrologue(); |
983 frame()->SetRegisterSaveAreaSize( | 995 frame()->SetRegisterSaveAreaSize( |
984 StandardFrameConstants::kFixedFrameSizeFromFp); | 996 StandardFrameConstants::kFixedFrameSizeFromFp); |
(...skipping 23 matching lines...) Expand all Loading... |
1008 | 1020 |
1009 void CodeGenerator::AssembleReturn() { | 1021 void CodeGenerator::AssembleReturn() { |
1010 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1022 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1011 int stack_slots = frame()->GetSpillSlotCount(); | 1023 int stack_slots = frame()->GetSpillSlotCount(); |
1012 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1024 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1013 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1025 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1014 // Remove this frame's spill slots first. | 1026 // Remove this frame's spill slots first. |
1015 if (stack_slots > 0) { | 1027 if (stack_slots > 0) { |
1016 __ add(sp, sp, Operand(stack_slots * kPointerSize)); | 1028 __ add(sp, sp, Operand(stack_slots * kPointerSize)); |
1017 } | 1029 } |
| 1030 // Restore FP registers. |
| 1031 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
| 1032 if (saves_fp != 0) { |
| 1033 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
| 1034 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
| 1035 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
| 1036 __ vldm(ia_w, sp, DwVfpRegister::from_code(first), |
| 1037 DwVfpRegister::from_code(last)); |
| 1038 } |
1018 // Restore registers. | 1039 // Restore registers. |
1019 const RegList saves = descriptor->CalleeSavedRegisters(); | 1040 const RegList saves = descriptor->CalleeSavedRegisters(); |
1020 if (saves != 0) { | 1041 if (saves != 0) { |
1021 __ ldm(ia_w, sp, saves); | 1042 __ ldm(ia_w, sp, saves); |
1022 } | 1043 } |
1023 } | 1044 } |
1024 __ LeaveFrame(StackFrame::MANUAL); | 1045 __ LeaveFrame(StackFrame::MANUAL); |
1025 __ Ret(); | 1046 __ Ret(); |
1026 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1047 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1027 // Canonicalize JSFunction return sites for now. | 1048 // Canonicalize JSFunction return sites for now. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 } | 1266 } |
1246 } | 1267 } |
1247 } | 1268 } |
1248 } | 1269 } |
1249 | 1270 |
1250 #undef __ | 1271 #undef __ |
1251 | 1272 |
1252 } // namespace compiler | 1273 } // namespace compiler |
1253 } // namespace internal | 1274 } // namespace internal |
1254 } // namespace v8 | 1275 } // namespace v8 |
OLD | NEW |