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 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1128 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
1132 void CodeGenerator::AssemblePrologue() { | 1132 void CodeGenerator::AssemblePrologue() { |
1133 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1133 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1134 int stack_slots = frame()->GetSpillSlotCount(); | 1134 int stack_slots = frame()->GetSpillSlotCount(); |
1135 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1135 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1136 __ Push(ra, fp); | 1136 __ Push(ra, fp); |
1137 __ mov(fp, sp); | 1137 __ mov(fp, sp); |
| 1138 |
1138 const RegList saves = descriptor->CalleeSavedRegisters(); | 1139 const RegList saves = descriptor->CalleeSavedRegisters(); |
1139 if (saves != 0) { // Save callee-saved registers. | 1140 // Save callee-saved registers. |
1140 // TODO(plind): make callee save size const, possibly DCHECK it. | 1141 __ MultiPush(saves); |
1141 int register_save_area_size = 0; | 1142 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves)); |
1142 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1143 int register_save_area_size = kNumCalleeSaved * kPointerSize; |
1143 if (!((1 << i) & saves)) continue; | 1144 |
1144 register_save_area_size += kPointerSize; | 1145 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1145 } | 1146 // Save callee-saved FPU registers. |
1146 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1147 __ MultiPushFPU(saves_fpu); |
1147 __ MultiPush(saves); | 1148 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu)); |
1148 } | 1149 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize; |
| 1150 |
| 1151 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1149 } else if (descriptor->IsJSFunctionCall()) { | 1152 } else if (descriptor->IsJSFunctionCall()) { |
1150 CompilationInfo* info = this->info(); | 1153 CompilationInfo* info = this->info(); |
1151 __ Prologue(info->IsCodePreAgingActive()); | 1154 __ Prologue(info->IsCodePreAgingActive()); |
1152 frame()->SetRegisterSaveAreaSize( | 1155 frame()->SetRegisterSaveAreaSize( |
1153 StandardFrameConstants::kFixedFrameSizeFromFp); | 1156 StandardFrameConstants::kFixedFrameSizeFromFp); |
1154 } else if (needs_frame_) { | 1157 } else if (needs_frame_) { |
1155 __ StubPrologue(); | 1158 __ StubPrologue(); |
1156 frame()->SetRegisterSaveAreaSize( | 1159 frame()->SetRegisterSaveAreaSize( |
1157 StandardFrameConstants::kFixedFrameSizeFromFp); | 1160 StandardFrameConstants::kFixedFrameSizeFromFp); |
1158 } | 1161 } |
(...skipping 22 matching lines...) Expand all Loading... |
1181 | 1184 |
1182 void CodeGenerator::AssembleReturn() { | 1185 void CodeGenerator::AssembleReturn() { |
1183 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1186 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1184 int stack_slots = frame()->GetSpillSlotCount(); | 1187 int stack_slots = frame()->GetSpillSlotCount(); |
1185 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1188 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1186 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1189 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1187 // Remove this frame's spill slots first. | 1190 // Remove this frame's spill slots first. |
1188 if (stack_slots > 0) { | 1191 if (stack_slots > 0) { |
1189 __ Daddu(sp, sp, Operand(stack_slots * kPointerSize)); | 1192 __ Daddu(sp, sp, Operand(stack_slots * kPointerSize)); |
1190 } | 1193 } |
1191 // Restore registers. | 1194 // Restore FPU registers. |
| 1195 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 1196 __ MultiPopFPU(saves_fpu); |
| 1197 |
| 1198 // Restore GP registers. |
1192 const RegList saves = descriptor->CalleeSavedRegisters(); | 1199 const RegList saves = descriptor->CalleeSavedRegisters(); |
1193 if (saves != 0) { | 1200 __ MultiPop(saves); |
1194 __ MultiPop(saves); | |
1195 } | |
1196 } | 1201 } |
1197 __ mov(sp, fp); | 1202 __ mov(sp, fp); |
1198 __ Pop(ra, fp); | 1203 __ Pop(ra, fp); |
1199 __ Ret(); | 1204 __ Ret(); |
1200 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1205 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1201 __ mov(sp, fp); | 1206 __ mov(sp, fp); |
1202 __ Pop(ra, fp); | 1207 __ Pop(ra, fp); |
1203 int pop_count = descriptor->IsJSFunctionCall() | 1208 int pop_count = descriptor->IsJSFunctionCall() |
1204 ? static_cast<int>(descriptor->JSParameterCount()) | 1209 ? static_cast<int>(descriptor->JSParameterCount()) |
1205 : 0; | 1210 : 0; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 } | 1419 } |
1415 } | 1420 } |
1416 } | 1421 } |
1417 } | 1422 } |
1418 | 1423 |
1419 #undef __ | 1424 #undef __ |
1420 | 1425 |
1421 } // namespace compiler | 1426 } // namespace compiler |
1422 } // namespace internal | 1427 } // namespace internal |
1423 } // namespace v8 | 1428 } // namespace v8 |
OLD | NEW |