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 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1144 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1145 } | 1145 } |
1146 | 1146 |
1147 | 1147 |
1148 void CodeGenerator::AssemblePrologue() { | 1148 void CodeGenerator::AssemblePrologue() { |
1149 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1149 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1150 int stack_slots = frame()->GetSpillSlotCount(); | 1150 int stack_slots = frame()->GetSpillSlotCount(); |
1151 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1151 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1152 __ Push(ra, fp); | 1152 __ Push(ra, fp); |
1153 __ mov(fp, sp); | 1153 __ mov(fp, sp); |
| 1154 |
1154 const RegList saves = descriptor->CalleeSavedRegisters(); | 1155 const RegList saves = descriptor->CalleeSavedRegisters(); |
1155 if (saves != 0) { // Save callee-saved registers. | 1156 // Save callee-saved registers. |
1156 // TODO(plind): make callee save size const, possibly DCHECK it. | 1157 __ MultiPush(saves); |
1157 int register_save_area_size = 0; | 1158 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves)); |
1158 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1159 int register_save_area_size = kNumCalleeSaved * kPointerSize; |
1159 if (!((1 << i) & saves)) continue; | 1160 |
1160 register_save_area_size += kPointerSize; | 1161 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1161 } | 1162 // Save callee-saved FPU registers. |
1162 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1163 __ MultiPushFPU(saves_fpu); |
1163 __ MultiPush(saves); | 1164 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu)); |
1164 } | 1165 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize; |
| 1166 |
| 1167 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1165 } else if (descriptor->IsJSFunctionCall()) { | 1168 } else if (descriptor->IsJSFunctionCall()) { |
1166 CompilationInfo* info = this->info(); | 1169 CompilationInfo* info = this->info(); |
1167 __ Prologue(info->IsCodePreAgingActive()); | 1170 __ Prologue(info->IsCodePreAgingActive()); |
1168 frame()->SetRegisterSaveAreaSize( | 1171 frame()->SetRegisterSaveAreaSize( |
1169 StandardFrameConstants::kFixedFrameSizeFromFp); | 1172 StandardFrameConstants::kFixedFrameSizeFromFp); |
1170 } else if (needs_frame_) { | 1173 } else if (needs_frame_) { |
1171 __ StubPrologue(); | 1174 __ StubPrologue(); |
1172 frame()->SetRegisterSaveAreaSize( | 1175 frame()->SetRegisterSaveAreaSize( |
1173 StandardFrameConstants::kFixedFrameSizeFromFp); | 1176 StandardFrameConstants::kFixedFrameSizeFromFp); |
1174 } | 1177 } |
(...skipping 22 matching lines...) Expand all Loading... |
1197 | 1200 |
1198 void CodeGenerator::AssembleReturn() { | 1201 void CodeGenerator::AssembleReturn() { |
1199 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1202 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1200 int stack_slots = frame()->GetSpillSlotCount(); | 1203 int stack_slots = frame()->GetSpillSlotCount(); |
1201 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1204 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1202 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1205 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1203 // Remove this frame's spill slots first. | 1206 // Remove this frame's spill slots first. |
1204 if (stack_slots > 0) { | 1207 if (stack_slots > 0) { |
1205 __ Daddu(sp, sp, Operand(stack_slots * kPointerSize)); | 1208 __ Daddu(sp, sp, Operand(stack_slots * kPointerSize)); |
1206 } | 1209 } |
1207 // Restore registers. | 1210 // Restore FPU registers. |
| 1211 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 1212 __ MultiPopFPU(saves_fpu); |
| 1213 |
| 1214 // Restore GP registers. |
1208 const RegList saves = descriptor->CalleeSavedRegisters(); | 1215 const RegList saves = descriptor->CalleeSavedRegisters(); |
1209 if (saves != 0) { | 1216 __ MultiPop(saves); |
1210 __ MultiPop(saves); | |
1211 } | |
1212 } | 1217 } |
1213 __ mov(sp, fp); | 1218 __ mov(sp, fp); |
1214 __ Pop(ra, fp); | 1219 __ Pop(ra, fp); |
1215 __ Ret(); | 1220 __ Ret(); |
1216 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1221 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1217 // Canonicalize JSFunction return sites for now. | 1222 // Canonicalize JSFunction return sites for now. |
1218 if (return_label_.is_bound()) { | 1223 if (return_label_.is_bound()) { |
1219 __ Branch(&return_label_); | 1224 __ Branch(&return_label_); |
1220 } else { | 1225 } else { |
1221 __ bind(&return_label_); | 1226 __ bind(&return_label_); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 } | 1441 } |
1437 } | 1442 } |
1438 } | 1443 } |
1439 } | 1444 } |
1440 | 1445 |
1441 #undef __ | 1446 #undef __ |
1442 | 1447 |
1443 } // namespace compiler | 1448 } // namespace compiler |
1444 } // namespace internal | 1449 } // namespace internal |
1445 } // namespace v8 | 1450 } // namespace v8 |
OLD | NEW |