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

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: Final tweaks 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
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 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 void CodeGenerator::AssembleDeoptimizerCall( 1062 void CodeGenerator::AssembleDeoptimizerCall(
1062 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1063 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1063 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1064 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1064 isolate(), deoptimization_id, bailout_type); 1065 isolate(), deoptimization_id, bailout_type);
1065 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1066 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1066 } 1067 }
1067 1068
1068 1069
1069 void CodeGenerator::AssemblePrologue() { 1070 void CodeGenerator::AssemblePrologue() {
1070 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1071 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1071 int stack_slots = frame()->GetSpillSlotCount(); 1072 int stack_shrink_slots = frame()->GetSpillSlotCount();
1072 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1073 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1073 __ Push(ra, fp); 1074 __ Push(ra, fp);
1074 __ mov(fp, sp); 1075 __ mov(fp, sp);
1075
1076 const RegList saves = descriptor->CalleeSavedRegisters();
1077 // Save callee-saved registers.
1078 __ MultiPush(saves);
1079 // kNumCalleeSaved includes the fp register, but the fp register
1080 // is saved separately in TF.
1081 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
1082 int register_save_area_size =
1083 base::bits::CountPopulation32(saves) * kPointerSize;
1084
1085 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1086 // Save callee-saved FPU registers.
1087 __ MultiPushFPU(saves_fpu);
1088 DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu));
1089 register_save_area_size += kNumCalleeSavedFPU * kDoubleSize;
1090
1091 frame()->SetRegisterSaveAreaSize(register_save_area_size);
1092 } else if (descriptor->IsJSFunctionCall()) { 1076 } else if (descriptor->IsJSFunctionCall()) {
1093 CompilationInfo* info = this->info(); 1077 CompilationInfo* info = this->info();
1094 __ Prologue(info->IsCodePreAgingActive()); 1078 __ Prologue(info->IsCodePreAgingActive());
1095 frame()->SetRegisterSaveAreaSize(
1096 StandardFrameConstants::kFixedFrameSizeFromFp);
1097 } else if (needs_frame_) { 1079 } else if (needs_frame_) {
1098 __ StubPrologue(); 1080 __ StubPrologue();
1099 frame()->SetRegisterSaveAreaSize(
1100 StandardFrameConstants::kFixedFrameSizeFromFp);
1101 } else { 1081 } else {
1102 frame()->SetPCOnStack(false); 1082 frame()->SetElidedFrameSizeInSlots(0);
1103 } 1083 }
1104 1084
1105 if (info()->is_osr()) { 1085 if (info()->is_osr()) {
1106 // TurboFan OSR-compiled functions cannot be entered directly. 1086 // TurboFan OSR-compiled functions cannot be entered directly.
1107 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1087 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1108 1088
1109 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1089 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1110 // frame is still on the stack. Optimized code uses OSR values directly from 1090 // frame is still on the stack. Optimized code uses OSR values directly from
1111 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1091 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1112 // remaining stack slots. 1092 // remaining stack slots.
1113 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1093 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1114 osr_pc_offset_ = __ pc_offset(); 1094 osr_pc_offset_ = __ pc_offset();
1115 // TODO(titzer): cannot address target function == local #-1 1095 // TODO(titzer): cannot address target function == local #-1
1116 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1096 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1117 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); 1097 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1118 stack_slots -= frame()->GetOsrStackSlotCount();
1119 } 1098 }
1120 1099
1121 if (stack_slots > 0) { 1100 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1122 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); 1101 if (saves_fpu != 0) {
1102 stack_shrink_slots += frame()->AlignSavedCalleeRegisterSlots();
1103 }
1104 if (stack_shrink_slots > 0) {
1105 __ Subu(sp, sp, Operand(stack_shrink_slots * kPointerSize));
1106 }
1107
1108 // Save callee-saved FPU registers.
1109 if (saves_fpu != 0) {
1110 __ MultiPushFPU(saves_fpu);
1111 int count = base::bits::CountPopulation32(saves_fpu);
1112 DCHECK(kNumCalleeSavedFPU == count);
1113 frame()->AllocateSavedCalleeRegisterSlots(count *
1114 (kDoubleSize / kPointerSize));
1115 }
1116
1117 const RegList saves = descriptor->CalleeSavedRegisters();
1118 if (saves != 0) {
1119 // Save callee-saved registers.
1120 __ MultiPush(saves);
1121 // kNumCalleeSaved includes the fp register, but the fp register
1122 // is saved separately in TF.
1123 int count = base::bits::CountPopulation32(saves);
1124 DCHECK(kNumCalleeSaved == count + 1);
1125 frame()->AllocateSavedCalleeRegisterSlots(count);
1123 } 1126 }
1124 } 1127 }
1125 1128
1126 1129
1127 void CodeGenerator::AssembleReturn() { 1130 void CodeGenerator::AssembleReturn() {
1128 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1131 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1129 int stack_slots = frame()->GetSpillSlotCount();
1130 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1132 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1133
1134 // Restore GP registers.
1135 const RegList saves = descriptor->CalleeSavedRegisters();
1136 if (saves != 0) {
1137 __ MultiPop(saves);
1138 }
1139
1140 // Restore FPU registers.
1141 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1142 if (saves_fpu != 0) {
1143 __ MultiPopFPU(saves_fpu);
1144 }
1145
1131 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1146 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1132 if (frame()->GetRegisterSaveAreaSize() > 0) {
1133 // Remove this frame's spill slots first.
1134 if (stack_slots > 0) {
1135 __ Addu(sp, sp, Operand(stack_slots * kPointerSize));
1136 }
1137 // Restore FPU registers.
1138 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1139 __ MultiPopFPU(saves_fpu);
1140
1141 // Restore GP registers.
1142 const RegList saves = descriptor->CalleeSavedRegisters();
1143 __ MultiPop(saves);
1144 }
1145 __ mov(sp, fp); 1147 __ mov(sp, fp);
1146 __ Pop(ra, fp); 1148 __ Pop(ra, fp);
1147 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { 1149 } else if (descriptor->IsJSFunctionCall() || needs_frame_) {
1148 // Canonicalize JSFunction return sites for now. 1150 // Canonicalize JSFunction return sites for now.
1149 if (return_label_.is_bound()) { 1151 if (return_label_.is_bound()) {
1150 __ Branch(&return_label_); 1152 __ Branch(&return_label_);
1151 return; 1153 return;
1152 } else { 1154 } else {
1153 __ bind(&return_label_); 1155 __ bind(&return_label_);
1154 __ mov(sp, fp); 1156 __ mov(sp, fp);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 } 1369 }
1368 } 1370 }
1369 } 1371 }
1370 } 1372 }
1371 1373
1372 #undef __ 1374 #undef __
1373 1375
1374 } // namespace compiler 1376 } // namespace compiler
1375 } // namespace internal 1377 } // namespace internal
1376 } // namespace v8 1378 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698