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 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/mips/macro-assembler-mips.h" | 9 #include "src/mips/macro-assembler-mips.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1055 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1056 } | 1056 } |
1057 | 1057 |
1058 | 1058 |
1059 void CodeGenerator::AssemblePrologue() { | 1059 void CodeGenerator::AssemblePrologue() { |
1060 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1060 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1061 int stack_slots = frame()->GetSpillSlotCount(); | 1061 int stack_slots = frame()->GetSpillSlotCount(); |
1062 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1062 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1063 __ Push(ra, fp); | 1063 __ Push(ra, fp); |
1064 __ mov(fp, sp); | 1064 __ mov(fp, sp); |
| 1065 |
1065 const RegList saves = descriptor->CalleeSavedRegisters(); | 1066 const RegList saves = descriptor->CalleeSavedRegisters(); |
1066 if (saves != 0) { // Save callee-saved registers. | 1067 // Save callee-saved registers. |
1067 // TODO(plind): make callee save size const, possibly DCHECK it. | 1068 __ MultiPush(saves); |
1068 int register_save_area_size = 0; | 1069 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves)); |
1069 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1070 int register_save_area_size = kNumCalleeSaved * kPointerSize; |
1070 if (!((1 << i) & saves)) continue; | 1071 |
1071 register_save_area_size += kPointerSize; | 1072 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1072 } | 1073 // Save callee-saved FPU registers. |
1073 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1074 __ MultiPushFPU(saves_fpu); |
1074 __ MultiPush(saves); | 1075 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu)); |
1075 } | 1076 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize; |
| 1077 |
| 1078 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1076 } else if (descriptor->IsJSFunctionCall()) { | 1079 } else if (descriptor->IsJSFunctionCall()) { |
1077 CompilationInfo* info = this->info(); | 1080 CompilationInfo* info = this->info(); |
1078 __ Prologue(info->IsCodePreAgingActive()); | 1081 __ Prologue(info->IsCodePreAgingActive()); |
1079 frame()->SetRegisterSaveAreaSize( | 1082 frame()->SetRegisterSaveAreaSize( |
1080 StandardFrameConstants::kFixedFrameSizeFromFp); | 1083 StandardFrameConstants::kFixedFrameSizeFromFp); |
1081 } else if (needs_frame_) { | 1084 } else if (needs_frame_) { |
1082 __ StubPrologue(); | 1085 __ StubPrologue(); |
1083 frame()->SetRegisterSaveAreaSize( | 1086 frame()->SetRegisterSaveAreaSize( |
1084 StandardFrameConstants::kFixedFrameSizeFromFp); | 1087 StandardFrameConstants::kFixedFrameSizeFromFp); |
1085 } | 1088 } |
(...skipping 22 matching lines...) Expand all Loading... |
1108 | 1111 |
1109 void CodeGenerator::AssembleReturn() { | 1112 void CodeGenerator::AssembleReturn() { |
1110 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1113 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1111 int stack_slots = frame()->GetSpillSlotCount(); | 1114 int stack_slots = frame()->GetSpillSlotCount(); |
1112 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1115 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1113 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1116 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1114 // Remove this frame's spill slots first. | 1117 // Remove this frame's spill slots first. |
1115 if (stack_slots > 0) { | 1118 if (stack_slots > 0) { |
1116 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); | 1119 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); |
1117 } | 1120 } |
1118 // Restore registers. | 1121 // Restore FPU registers. |
| 1122 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 1123 __ MultiPopFPU(saves_fpu); |
| 1124 |
| 1125 // Restore GP registers. |
1119 const RegList saves = descriptor->CalleeSavedRegisters(); | 1126 const RegList saves = descriptor->CalleeSavedRegisters(); |
1120 if (saves != 0) { | 1127 __ MultiPop(saves); |
1121 __ MultiPop(saves); | |
1122 } | |
1123 } | 1128 } |
1124 __ mov(sp, fp); | 1129 __ mov(sp, fp); |
1125 __ Pop(ra, fp); | 1130 __ Pop(ra, fp); |
1126 __ Ret(); | 1131 __ Ret(); |
1127 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1132 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1128 __ mov(sp, fp); | 1133 __ mov(sp, fp); |
1129 __ Pop(ra, fp); | 1134 __ Pop(ra, fp); |
1130 int pop_count = descriptor->IsJSFunctionCall() | 1135 int pop_count = descriptor->IsJSFunctionCall() |
1131 ? static_cast<int>(descriptor->JSParameterCount()) | 1136 ? static_cast<int>(descriptor->JSParameterCount()) |
1132 : 0; | 1137 : 0; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 } | 1346 } |
1342 } | 1347 } |
1343 } | 1348 } |
1344 } | 1349 } |
1345 | 1350 |
1346 #undef __ | 1351 #undef __ |
1347 | 1352 |
1348 } // namespace compiler | 1353 } // namespace compiler |
1349 } // namespace internal | 1354 } // namespace internal |
1350 } // namespace v8 | 1355 } // namespace v8 |
OLD | NEW |