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 | |
1066 int register_save_area_size = 0; | |
1065 const RegList saves = descriptor->CalleeSavedRegisters(); | 1067 const RegList saves = descriptor->CalleeSavedRegisters(); |
1066 if (saves != 0) { // Save callee-saved registers. | 1068 if (saves != 0) { // Save callee-saved registers. |
1067 // TODO(plind): make callee save size const, possibly DCHECK it. | 1069 __ MultiPush(saves); |
1068 int register_save_area_size = 0; | 1070 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves)); |
paul.l...
2015/06/23 02:15:02
I really _like_ these DCHECKs to tie the new list
| |
1069 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1071 register_save_area_size += kNumCalleeSaved * kPointerSize; |
1070 if (!((1 << i) & saves)) continue; | 1072 } |
1071 register_save_area_size += kPointerSize; | 1073 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1072 } | 1074 if (saves_fpu != 0) { // Save callee-saved FPU registers. |
1075 __ MultiPushFPU(saves_fpu); | |
1076 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fp)); | |
1077 register_save_area_size += | |
1078 kNumCalleeSavedFPU * kDoubleSize * kPointerSize; | |
1079 } | |
1080 if (register_save_area_size > 0) { | |
1073 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1081 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1074 __ MultiPush(saves); | |
1075 } | 1082 } |
1076 } else if (descriptor->IsJSFunctionCall()) { | 1083 } else if (descriptor->IsJSFunctionCall()) { |
1077 CompilationInfo* info = this->info(); | 1084 CompilationInfo* info = this->info(); |
1078 __ Prologue(info->IsCodePreAgingActive()); | 1085 __ Prologue(info->IsCodePreAgingActive()); |
1079 frame()->SetRegisterSaveAreaSize( | 1086 frame()->SetRegisterSaveAreaSize( |
1080 StandardFrameConstants::kFixedFrameSizeFromFp); | 1087 StandardFrameConstants::kFixedFrameSizeFromFp); |
1081 } else if (needs_frame_) { | 1088 } else if (needs_frame_) { |
1082 __ StubPrologue(); | 1089 __ StubPrologue(); |
1083 frame()->SetRegisterSaveAreaSize( | 1090 frame()->SetRegisterSaveAreaSize( |
1084 StandardFrameConstants::kFixedFrameSizeFromFp); | 1091 StandardFrameConstants::kFixedFrameSizeFromFp); |
(...skipping 23 matching lines...) Expand all Loading... | |
1108 | 1115 |
1109 void CodeGenerator::AssembleReturn() { | 1116 void CodeGenerator::AssembleReturn() { |
1110 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1117 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1111 int stack_slots = frame()->GetSpillSlotCount(); | 1118 int stack_slots = frame()->GetSpillSlotCount(); |
1112 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1119 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1113 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1120 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1114 // Remove this frame's spill slots first. | 1121 // Remove this frame's spill slots first. |
1115 if (stack_slots > 0) { | 1122 if (stack_slots > 0) { |
1116 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); | 1123 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); |
1117 } | 1124 } |
1118 // Restore registers. | 1125 // Restore FPU registers. |
1126 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | |
1127 if (saves_fpu != 0) { | |
1128 __ MultiPopFPU(saves_fpu); | |
1129 } | |
1130 // Restore GP registers. | |
1119 const RegList saves = descriptor->CalleeSavedRegisters(); | 1131 const RegList saves = descriptor->CalleeSavedRegisters(); |
1120 if (saves != 0) { | 1132 if (saves != 0) { |
1121 __ MultiPop(saves); | 1133 __ MultiPop(saves); |
1122 } | 1134 } |
1123 } | 1135 } |
1124 __ mov(sp, fp); | 1136 __ mov(sp, fp); |
1125 __ Pop(ra, fp); | 1137 __ Pop(ra, fp); |
1126 __ Ret(); | 1138 __ Ret(); |
1127 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1139 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1128 __ mov(sp, fp); | 1140 __ mov(sp, fp); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1342 } | 1354 } |
1343 } | 1355 } |
1344 MarkLazyDeoptSite(); | 1356 MarkLazyDeoptSite(); |
1345 } | 1357 } |
1346 | 1358 |
1347 #undef __ | 1359 #undef __ |
1348 | 1360 |
1349 } // namespace compiler | 1361 } // namespace compiler |
1350 } // namespace internal | 1362 } // namespace internal |
1351 } // namespace v8 | 1363 } // namespace v8 |
OLD | NEW |