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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1071 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1072 } | 1072 } |
1073 | 1073 |
1074 | 1074 |
1075 void CodeGenerator::AssemblePrologue() { | 1075 void CodeGenerator::AssemblePrologue() { |
1076 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1076 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1077 int stack_slots = frame()->GetSpillSlotCount(); | 1077 int stack_slots = frame()->GetSpillSlotCount(); |
1078 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1078 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1079 __ Push(ra, fp); | 1079 __ Push(ra, fp); |
1080 __ mov(fp, sp); | 1080 __ mov(fp, sp); |
| 1081 |
1081 const RegList saves = descriptor->CalleeSavedRegisters(); | 1082 const RegList saves = descriptor->CalleeSavedRegisters(); |
1082 if (saves != 0) { // Save callee-saved registers. | 1083 // Save callee-saved registers. |
1083 // TODO(plind): make callee save size const, possibly DCHECK it. | 1084 __ MultiPush(saves); |
1084 int register_save_area_size = 0; | 1085 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves)); |
1085 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1086 int register_save_area_size = kNumCalleeSaved * kPointerSize; |
1086 if (!((1 << i) & saves)) continue; | 1087 |
1087 register_save_area_size += kPointerSize; | 1088 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1088 } | 1089 // Save callee-saved FPU registers. |
1089 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1090 __ MultiPushFPU(saves_fpu); |
1090 __ MultiPush(saves); | 1091 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu)); |
1091 } | 1092 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize; |
| 1093 |
| 1094 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1092 } else if (descriptor->IsJSFunctionCall()) { | 1095 } else if (descriptor->IsJSFunctionCall()) { |
1093 CompilationInfo* info = this->info(); | 1096 CompilationInfo* info = this->info(); |
1094 __ Prologue(info->IsCodePreAgingActive()); | 1097 __ Prologue(info->IsCodePreAgingActive()); |
1095 frame()->SetRegisterSaveAreaSize( | 1098 frame()->SetRegisterSaveAreaSize( |
1096 StandardFrameConstants::kFixedFrameSizeFromFp); | 1099 StandardFrameConstants::kFixedFrameSizeFromFp); |
1097 } else if (needs_frame_) { | 1100 } else if (needs_frame_) { |
1098 __ StubPrologue(); | 1101 __ StubPrologue(); |
1099 frame()->SetRegisterSaveAreaSize( | 1102 frame()->SetRegisterSaveAreaSize( |
1100 StandardFrameConstants::kFixedFrameSizeFromFp); | 1103 StandardFrameConstants::kFixedFrameSizeFromFp); |
1101 } | 1104 } |
(...skipping 22 matching lines...) Expand all Loading... |
1124 | 1127 |
1125 void CodeGenerator::AssembleReturn() { | 1128 void CodeGenerator::AssembleReturn() { |
1126 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1129 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1127 int stack_slots = frame()->GetSpillSlotCount(); | 1130 int stack_slots = frame()->GetSpillSlotCount(); |
1128 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1131 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1129 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1132 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1130 // Remove this frame's spill slots first. | 1133 // Remove this frame's spill slots first. |
1131 if (stack_slots > 0) { | 1134 if (stack_slots > 0) { |
1132 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); | 1135 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); |
1133 } | 1136 } |
1134 // Restore registers. | 1137 // Restore FPU registers. |
| 1138 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 1139 __ MultiPopFPU(saves_fpu); |
| 1140 |
| 1141 // Restore GP registers. |
1135 const RegList saves = descriptor->CalleeSavedRegisters(); | 1142 const RegList saves = descriptor->CalleeSavedRegisters(); |
1136 if (saves != 0) { | 1143 __ MultiPop(saves); |
1137 __ MultiPop(saves); | |
1138 } | |
1139 } | 1144 } |
1140 __ mov(sp, fp); | 1145 __ mov(sp, fp); |
1141 __ Pop(ra, fp); | 1146 __ Pop(ra, fp); |
1142 __ Ret(); | 1147 __ Ret(); |
1143 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1148 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1144 // Canonicalize JSFunction return sites for now. | 1149 // Canonicalize JSFunction return sites for now. |
1145 if (return_label_.is_bound()) { | 1150 if (return_label_.is_bound()) { |
1146 __ Branch(&return_label_); | 1151 __ Branch(&return_label_); |
1147 } else { | 1152 } else { |
1148 __ bind(&return_label_); | 1153 __ bind(&return_label_); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 } | 1368 } |
1364 } | 1369 } |
1365 } | 1370 } |
1366 } | 1371 } |
1367 | 1372 |
1368 #undef __ | 1373 #undef __ |
1369 | 1374 |
1370 } // namespace compiler | 1375 } // namespace compiler |
1371 } // namespace internal | 1376 } // namespace internal |
1372 } // namespace v8 | 1377 } // namespace v8 |
OLD | NEW |