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

Side by Side Diff: src/compiler/mips64/code-generator-mips64.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/mips/code-generator-mips.cc ('k') | src/compiler/osr.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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 void CodeGenerator::AssembleDeoptimizerCall( 1141 void CodeGenerator::AssembleDeoptimizerCall(
1141 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1142 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1142 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1143 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1143 isolate(), deoptimization_id, bailout_type); 1144 isolate(), deoptimization_id, bailout_type);
1144 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1145 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1145 } 1146 }
1146 1147
1147 1148
1148 void CodeGenerator::AssemblePrologue() { 1149 void CodeGenerator::AssemblePrologue() {
1149 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1150 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
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
1155 const RegList saves = descriptor->CalleeSavedRegisters();
1156 // Save callee-saved registers.
1157 __ MultiPush(saves);
1158 // kNumCalleeSaved includes the fp register, but the fp register
1159 // is saved separately in TF.
1160 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
1161 int register_save_area_size =
1162 base::bits::CountPopulation32(saves) * kPointerSize;
1163
1164 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1165 // Save callee-saved FPU registers.
1166 __ MultiPushFPU(saves_fpu);
1167 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu));
1168 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize;
1169
1170 frame()->SetRegisterSaveAreaSize(register_save_area_size);
1171 } else if (descriptor->IsJSFunctionCall()) { 1154 } else if (descriptor->IsJSFunctionCall()) {
1172 CompilationInfo* info = this->info(); 1155 CompilationInfo* info = this->info();
1173 __ Prologue(info->IsCodePreAgingActive()); 1156 __ Prologue(info->IsCodePreAgingActive());
1174 frame()->SetRegisterSaveAreaSize(
1175 StandardFrameConstants::kFixedFrameSizeFromFp);
1176 } else if (needs_frame_) { 1157 } else if (needs_frame_) {
1177 __ StubPrologue(); 1158 __ StubPrologue();
1178 frame()->SetRegisterSaveAreaSize(
1179 StandardFrameConstants::kFixedFrameSizeFromFp);
1180 } else { 1159 } else {
1181 frame()->SetPCOnStack(false); 1160 frame()->SetElidedFrameSizeInSlots(0);
1182 } 1161 }
1183 1162
1163 int stack_shrink_slots = frame()->GetSpillSlotCount();
1184 if (info()->is_osr()) { 1164 if (info()->is_osr()) {
1185 // TurboFan OSR-compiled functions cannot be entered directly. 1165 // TurboFan OSR-compiled functions cannot be entered directly.
1186 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1166 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1187 1167
1188 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1168 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1189 // frame is still on the stack. Optimized code uses OSR values directly from 1169 // frame is still on the stack. Optimized code uses OSR values directly from
1190 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1170 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1191 // remaining stack slots. 1171 // remaining stack slots.
1192 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1172 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1193 osr_pc_offset_ = __ pc_offset(); 1173 osr_pc_offset_ = __ pc_offset();
1194 // TODO(titzer): cannot address target function == local #-1 1174 // TODO(titzer): cannot address target function == local #-1
1195 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1175 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1196 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); 1176 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1197 stack_slots -= frame()->GetOsrStackSlotCount();
1198 } 1177 }
1199 1178
1200 if (stack_slots > 0) { 1179 if (stack_shrink_slots > 0) {
1201 __ Dsubu(sp, sp, Operand(stack_slots * kPointerSize)); 1180 __ Dsubu(sp, sp, Operand(stack_shrink_slots * kPointerSize));
1181 }
1182
1183 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1184 if (saves_fpu != 0) {
1185 // Save callee-saved FPU registers.
1186 __ MultiPushFPU(saves_fpu);
1187 int count = base::bits::CountPopulation32(saves_fpu);
1188 DCHECK(kNumCalleeSavedFPU == count);
1189 frame()->AllocateSavedCalleeRegisterSlots(count *
1190 (kDoubleSize / kPointerSize));
1191 }
1192
1193 const RegList saves = descriptor->CalleeSavedRegisters();
1194 if (saves != 0) {
1195 // Save callee-saved registers.
1196 __ MultiPush(saves);
1197 // kNumCalleeSaved includes the fp register, but the fp register
1198 // is saved separately in TF.
1199 int count = base::bits::CountPopulation32(saves);
1200 DCHECK(kNumCalleeSaved == count + 1);
1201 frame()->AllocateSavedCalleeRegisterSlots(count);
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 1205
1206 void CodeGenerator::AssembleReturn() { 1206 void CodeGenerator::AssembleReturn() {
1207 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1207 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1208 int stack_slots = frame()->GetSpillSlotCount(); 1208
1209 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1209 // Restore GP registers.
1210 const RegList saves = descriptor->CalleeSavedRegisters();
1211 if (saves != 0) {
1212 __ MultiPop(saves);
1213 }
1214
1215 // Restore FPU registers.
1216 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1217 if (saves_fpu != 0) {
1218 __ MultiPopFPU(saves_fpu);
1219 }
1220
1210 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1221 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1211 if (frame()->GetRegisterSaveAreaSize() > 0) {
1212 // Remove this frame's spill slots first.
1213 if (stack_slots > 0) {
1214 __ Daddu(sp, sp, Operand(stack_slots * kPointerSize));
1215 }
1216 // Restore FPU registers.
1217 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1218 __ MultiPopFPU(saves_fpu);
1219
1220 // Restore GP registers.
1221 const RegList saves = descriptor->CalleeSavedRegisters();
1222 __ MultiPop(saves);
1223 }
1224 __ mov(sp, fp); 1222 __ mov(sp, fp);
1225 __ Pop(ra, fp); 1223 __ Pop(ra, fp);
1226 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { 1224 } else if (descriptor->IsJSFunctionCall() || needs_frame_) {
1227 // Canonicalize JSFunction return sites for now. 1225 // Canonicalize JSFunction return sites for now.
1228 if (return_label_.is_bound()) { 1226 if (return_label_.is_bound()) {
1229 __ Branch(&return_label_); 1227 __ Branch(&return_label_);
1230 return; 1228 return;
1231 } else { 1229 } else {
1232 __ bind(&return_label_); 1230 __ bind(&return_label_);
1233 __ mov(sp, fp); 1231 __ mov(sp, fp);
1234 __ Pop(ra, fp); 1232 __ Pop(ra, fp);
1235 } 1233 }
1236 } 1234 }
1235 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1237 if (pop_count != 0) { 1236 if (pop_count != 0) {
1238 __ DropAndRet(pop_count); 1237 __ DropAndRet(pop_count);
1239 } else { 1238 } else {
1240 __ Ret(); 1239 __ Ret();
1241 } 1240 }
1242 } 1241 }
1243 1242
1244 1243
1245 void CodeGenerator::AssembleMove(InstructionOperand* source, 1244 void CodeGenerator::AssembleMove(InstructionOperand* source,
1246 InstructionOperand* destination) { 1245 InstructionOperand* destination) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 } 1445 }
1447 } 1446 }
1448 } 1447 }
1449 } 1448 }
1450 1449
1451 #undef __ 1450 #undef __
1452 1451
1453 } // namespace compiler 1452 } // namespace compiler
1454 } // namespace internal 1453 } // namespace internal
1455 } // namespace v8 1454 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips/code-generator-mips.cc ('k') | src/compiler/osr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698