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

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

Issue 1261923007: [turbofan] Unify referencing of stack slots (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback 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/linkage.cc ('k') | src/compiler/mips64/code-generator-mips64.cc » ('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 #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/compiler/osr.h"
9 #include "src/mips/macro-assembler-mips.h" 10 #include "src/mips/macro-assembler-mips.h"
10 #include "src/scopes.h" 11 #include "src/scopes.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 namespace compiler { 15 namespace compiler {
15 16
16 #define __ masm()-> 17 #define __ masm()->
17 18
18 19
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 void CodeGenerator::AssembleDeoptimizerCall( 1071 void CodeGenerator::AssembleDeoptimizerCall(
1071 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1072 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1072 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1073 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1073 isolate(), deoptimization_id, bailout_type); 1074 isolate(), deoptimization_id, bailout_type);
1074 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1075 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1075 } 1076 }
1076 1077
1077 1078
1078 void CodeGenerator::AssemblePrologue() { 1079 void CodeGenerator::AssemblePrologue() {
1079 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1080 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1080 int stack_slots = frame()->GetSpillSlotCount(); 1081 int stack_shrink_slots = frame()->GetSpillSlotCount();
1081 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1082 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1082 __ Push(ra, fp); 1083 __ Push(ra, fp);
1083 __ mov(fp, sp); 1084 __ mov(fp, sp);
1084
1085 const RegList saves = descriptor->CalleeSavedRegisters();
1086 // Save callee-saved registers.
1087 __ MultiPush(saves);
1088 // kNumCalleeSaved includes the fp register, but the fp register
1089 // is saved separately in TF.
1090 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
1091 int register_save_area_size =
1092 base::bits::CountPopulation32(saves) * kPointerSize;
1093
1094 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1095 // Save callee-saved FPU registers.
1096 __ MultiPushFPU(saves_fpu);
1097 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu));
1098 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize;
1099
1100 frame()->SetRegisterSaveAreaSize(register_save_area_size);
1101 } else if (descriptor->IsJSFunctionCall()) { 1085 } else if (descriptor->IsJSFunctionCall()) {
1102 CompilationInfo* info = this->info(); 1086 CompilationInfo* info = this->info();
1103 __ Prologue(info->IsCodePreAgingActive()); 1087 __ Prologue(info->IsCodePreAgingActive());
1104 frame()->SetRegisterSaveAreaSize(
1105 StandardFrameConstants::kFixedFrameSizeFromFp);
1106 } else if (needs_frame_) { 1088 } else if (needs_frame_) {
1107 __ StubPrologue(); 1089 __ StubPrologue();
1108 frame()->SetRegisterSaveAreaSize(
1109 StandardFrameConstants::kFixedFrameSizeFromFp);
1110 } else { 1090 } else {
1111 frame()->SetPCOnStack(false); 1091 frame()->SetElidedFrameSizeInSlots(0);
1112 } 1092 }
1113 1093
1114 if (info()->is_osr()) { 1094 if (info()->is_osr()) {
1115 // TurboFan OSR-compiled functions cannot be entered directly. 1095 // TurboFan OSR-compiled functions cannot be entered directly.
1116 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1096 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1117 1097
1118 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1098 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1119 // frame is still on the stack. Optimized code uses OSR values directly from 1099 // frame is still on the stack. Optimized code uses OSR values directly from
1120 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1100 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1121 // remaining stack slots. 1101 // remaining stack slots.
1122 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1102 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1123 osr_pc_offset_ = __ pc_offset(); 1103 osr_pc_offset_ = __ pc_offset();
1124 // TODO(titzer): cannot address target function == local #-1 1104 // TODO(titzer): cannot address target function == local #-1
1125 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1105 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1126 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); 1106 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1127 stack_slots -= frame()->GetOsrStackSlotCount();
1128 } 1107 }
1129 1108
1130 if (stack_slots > 0) { 1109 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1131 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); 1110 if (saves_fpu != 0) {
1111 stack_shrink_slots += frame()->AlignSavedCalleeRegisterSlots();
1112 }
1113 if (stack_shrink_slots > 0) {
1114 __ Subu(sp, sp, Operand(stack_shrink_slots * kPointerSize));
1115 }
1116
1117 // Save callee-saved FPU registers.
1118 if (saves_fpu != 0) {
1119 __ MultiPushFPU(saves_fpu);
1120 int count = base::bits::CountPopulation32(saves_fpu);
1121 DCHECK(kNumCalleeSavedFPU == count);
1122 frame()->AllocateSavedCalleeRegisterSlots(count *
1123 (kDoubleSize / kPointerSize));
1124 }
1125
1126 const RegList saves = descriptor->CalleeSavedRegisters();
1127 if (saves != 0) {
1128 // Save callee-saved registers.
1129 __ MultiPush(saves);
1130 // kNumCalleeSaved includes the fp register, but the fp register
1131 // is saved separately in TF.
1132 int count = base::bits::CountPopulation32(saves);
1133 DCHECK(kNumCalleeSaved == count + 1);
1134 frame()->AllocateSavedCalleeRegisterSlots(count);
1132 } 1135 }
1133 } 1136 }
1134 1137
1135 1138
1136 void CodeGenerator::AssembleReturn() { 1139 void CodeGenerator::AssembleReturn() {
1137 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1140 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1138 int stack_slots = frame()->GetSpillSlotCount();
1139 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1141 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1142
1143 // Restore GP registers.
1144 const RegList saves = descriptor->CalleeSavedRegisters();
1145 if (saves != 0) {
1146 __ MultiPop(saves);
1147 }
1148
1149 // Restore FPU registers.
1150 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1151 if (saves_fpu != 0) {
1152 __ MultiPopFPU(saves_fpu);
1153 }
1154
1140 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1155 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1141 if (frame()->GetRegisterSaveAreaSize() > 0) {
1142 // Remove this frame's spill slots first.
1143 if (stack_slots > 0) {
1144 __ Addu(sp, sp, Operand(stack_slots * kPointerSize));
1145 }
1146 // Restore FPU registers.
1147 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1148 __ MultiPopFPU(saves_fpu);
1149
1150 // Restore GP registers.
1151 const RegList saves = descriptor->CalleeSavedRegisters();
1152 __ MultiPop(saves);
1153 }
1154 __ mov(sp, fp); 1156 __ mov(sp, fp);
1155 __ Pop(ra, fp); 1157 __ Pop(ra, fp);
1156 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { 1158 } else if (descriptor->IsJSFunctionCall() || needs_frame_) {
1157 // Canonicalize JSFunction return sites for now. 1159 // Canonicalize JSFunction return sites for now.
1158 if (return_label_.is_bound()) { 1160 if (return_label_.is_bound()) {
1159 __ Branch(&return_label_); 1161 __ Branch(&return_label_);
1160 return; 1162 return;
1161 } else { 1163 } else {
1162 __ bind(&return_label_); 1164 __ bind(&return_label_);
1163 __ mov(sp, fp); 1165 __ mov(sp, fp);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 } 1378 }
1377 } 1379 }
1378 } 1380 }
1379 } 1381 }
1380 1382
1381 #undef __ 1383 #undef __
1382 1384
1383 } // namespace compiler 1385 } // namespace compiler
1384 } // namespace internal 1386 } // namespace internal
1385 } // namespace v8 1387 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/linkage.cc ('k') | src/compiler/mips64/code-generator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698