Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: src/compiler/ppc/code-generator-ppc.cc

Issue 1271583002: PPC: Clean up register save/restore logic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/c-linkage.cc ('k') | src/ppc/code-stubs-ppc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/ppc/macro-assembler-ppc.h" 10 #include "src/ppc/macro-assembler-ppc.h"
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 isolate(), deoptimization_id, bailout_type); 1289 isolate(), deoptimization_id, bailout_type);
1290 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1290 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1291 } 1291 }
1292 1292
1293 1293
1294 void CodeGenerator::AssemblePrologue() { 1294 void CodeGenerator::AssemblePrologue() {
1295 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1295 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1296 int stack_slots = frame()->GetSpillSlotCount(); 1296 int stack_slots = frame()->GetSpillSlotCount();
1297 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1297 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1298 __ function_descriptor(); 1298 __ function_descriptor();
1299 int register_save_area_size = 0; 1299 RegList frame_saves = 0;
1300 RegList frame_saves = fp.bit();
1301 __ mflr(r0); 1300 __ mflr(r0);
1302 if (FLAG_enable_embedded_constant_pool) { 1301 if (FLAG_enable_embedded_constant_pool) {
1303 __ Push(r0, fp, kConstantPoolRegister); 1302 __ Push(r0, fp, kConstantPoolRegister);
1304 // Adjust FP to point to saved FP. 1303 // Adjust FP to point to saved FP.
1305 __ subi(fp, sp, Operand(StandardFrameConstants::kConstantPoolOffset)); 1304 __ subi(fp, sp, Operand(StandardFrameConstants::kConstantPoolOffset));
1306 register_save_area_size += kPointerSize;
1307 frame_saves |= kConstantPoolRegister.bit(); 1305 frame_saves |= kConstantPoolRegister.bit();
1308 } else { 1306 } else {
1309 __ Push(r0, fp); 1307 __ Push(r0, fp);
1310 __ mr(fp, sp); 1308 __ mr(fp, sp);
1311 } 1309 }
1310
1312 // Save callee-saved registers. 1311 // Save callee-saved registers.
1313 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves; 1312 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves;
1314 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { 1313 __ MultiPush(saves);
1315 if (!((1 << i) & saves)) continue; 1314 // register save area does not include the fp.
1316 register_save_area_size += kPointerSize; 1315 DCHECK(kNumCalleeSaved - 1 ==
1317 } 1316 base::bits::CountPopulation32(saves | frame_saves));
1317 int register_save_area_size = (kNumCalleeSaved - 1) * kPointerSize;
1318
1319 // Save callee-saved Double registers.
1320 const RegList double_saves = descriptor->CalleeSavedFPRegisters();
1321 __ MultiPushDoubles(double_saves);
1322 DCHECK(kNumCalleeSavedDoubles ==
1323 base::bits::CountPopulation32(double_saves));
1324 register_save_area_size += kNumCalleeSavedDoubles * kDoubleSize;
1325
1318 frame()->SetRegisterSaveAreaSize(register_save_area_size); 1326 frame()->SetRegisterSaveAreaSize(register_save_area_size);
1319 __ MultiPush(saves);
1320 } else if (descriptor->IsJSFunctionCall()) { 1327 } else if (descriptor->IsJSFunctionCall()) {
1321 CompilationInfo* info = this->info(); 1328 CompilationInfo* info = this->info();
1322 __ Prologue(info->IsCodePreAgingActive()); 1329 __ Prologue(info->IsCodePreAgingActive());
1323 frame()->SetRegisterSaveAreaSize( 1330 frame()->SetRegisterSaveAreaSize(
1324 StandardFrameConstants::kFixedFrameSizeFromFp); 1331 StandardFrameConstants::kFixedFrameSizeFromFp);
1325 } else if (needs_frame_) { 1332 } else if (needs_frame_) {
1326 __ StubPrologue(); 1333 __ StubPrologue();
1327 frame()->SetRegisterSaveAreaSize( 1334 frame()->SetRegisterSaveAreaSize(
1328 StandardFrameConstants::kFixedFrameSizeFromFp); 1335 StandardFrameConstants::kFixedFrameSizeFromFp);
1329 } 1336 }
(...skipping 22 matching lines...) Expand all
1352 1359
1353 void CodeGenerator::AssembleReturn() { 1360 void CodeGenerator::AssembleReturn() {
1354 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1361 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1355 int stack_slots = frame()->GetSpillSlotCount(); 1362 int stack_slots = frame()->GetSpillSlotCount();
1356 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1363 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1357 if (frame()->GetRegisterSaveAreaSize() > 0) { 1364 if (frame()->GetRegisterSaveAreaSize() > 0) {
1358 // Remove this frame's spill slots first. 1365 // Remove this frame's spill slots first.
1359 if (stack_slots > 0) { 1366 if (stack_slots > 0) {
1360 __ Add(sp, sp, stack_slots * kPointerSize, r0); 1367 __ Add(sp, sp, stack_slots * kPointerSize, r0);
1361 } 1368 }
1369 // Restore double registers.
1370 const RegList double_saves = descriptor->CalleeSavedFPRegisters();
1371 __ MultiPopDoubles(double_saves);
1372
1362 // Restore registers. 1373 // Restore registers.
1363 RegList frame_saves = fp.bit(); 1374 RegList frame_saves = 0;
1364 if (FLAG_enable_embedded_constant_pool) { 1375 if (FLAG_enable_embedded_constant_pool) {
1365 frame_saves |= kConstantPoolRegister.bit(); 1376 frame_saves |= kConstantPoolRegister.bit();
1366 } 1377 }
1367 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves; 1378 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves;
1368 if (saves != 0) { 1379 __ MultiPop(saves);
1369 __ MultiPop(saves);
1370 }
1371 } 1380 }
1372 __ LeaveFrame(StackFrame::MANUAL); 1381 __ LeaveFrame(StackFrame::MANUAL);
1373 __ Ret(); 1382 __ Ret();
1374 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { 1383 } else if (descriptor->IsJSFunctionCall() || needs_frame_) {
1375 // Canonicalize JSFunction return sites for now. 1384 // Canonicalize JSFunction return sites for now.
1376 if (return_label_.is_bound()) { 1385 if (return_label_.is_bound()) {
1377 __ b(&return_label_); 1386 __ b(&return_label_);
1378 } else { 1387 } else {
1379 __ bind(&return_label_); 1388 __ bind(&return_label_);
1380 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1389 int pop_count = static_cast<int>(descriptor->StackParameterCount());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 } 1594 }
1586 } 1595 }
1587 } 1596 }
1588 } 1597 }
1589 1598
1590 #undef __ 1599 #undef __
1591 1600
1592 } // namespace compiler 1601 } // namespace compiler
1593 } // namespace internal 1602 } // namespace internal
1594 } // namespace v8 1603 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/c-linkage.cc ('k') | src/ppc/code-stubs-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698