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

Side by Side Diff: src/compiler/arm64/code-generator-arm64.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/arm/code-generator-arm.cc ('k') | src/compiler/code-generator.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 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/arm64/macro-assembler-arm64.h" 8 #include "src/arm64/macro-assembler-arm64.h"
9 #include "src/compiler/code-generator-impl.h" 9 #include "src/compiler/code-generator-impl.h"
10 #include "src/compiler/gap-resolver.h" 10 #include "src/compiler/gap-resolver.h"
11 #include "src/compiler/node-matchers.h" 11 #include "src/compiler/node-matchers.h"
12 #include "src/compiler/osr.h"
12 #include "src/scopes.h" 13 #include "src/scopes.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 namespace compiler { 17 namespace compiler {
17 18
18 #define __ masm()-> 19 #define __ masm()->
19 20
20 21
21 // Adds Arm64-specific methods to convert InstructionOperands. 22 // Adds Arm64-specific methods to convert InstructionOperands.
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1077
1077 // TODO(dcarney): increase stack slots in frame once before first use. 1078 // TODO(dcarney): increase stack slots in frame once before first use.
1078 static int AlignedStackSlots(int stack_slots) { 1079 static int AlignedStackSlots(int stack_slots) {
1079 if (stack_slots & 1) stack_slots++; 1080 if (stack_slots & 1) stack_slots++;
1080 return stack_slots; 1081 return stack_slots;
1081 } 1082 }
1082 1083
1083 1084
1084 void CodeGenerator::AssemblePrologue() { 1085 void CodeGenerator::AssemblePrologue() {
1085 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1086 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1086 int stack_slots = frame()->GetSpillSlotCount();
1087 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1087 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1088 __ SetStackPointer(csp); 1088 __ SetStackPointer(csp);
1089 __ Push(lr, fp); 1089 __ Push(lr, fp);
1090 __ Mov(fp, csp); 1090 __ Mov(fp, csp);
1091
1092 // Save FP registers.
1093 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1094 descriptor->CalleeSavedFPRegisters());
1095 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1096 int saved_count = saves_fp.Count();
1097 __ PushCPURegList(saves_fp);
1098 // Save registers.
1099 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1100 descriptor->CalleeSavedRegisters());
1101 // TODO(palfia): TF save list is not in sync with
1102 // CPURegList::GetCalleeSaved(): x30 is missing.
1103 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list());
1104 saved_count += saves.Count();
1105 __ PushCPURegList(saves);
1106
1107 frame()->SetRegisterSaveAreaSize(saved_count * kPointerSize);
1108 } else if (descriptor->IsJSFunctionCall()) { 1091 } else if (descriptor->IsJSFunctionCall()) {
1109 CompilationInfo* info = this->info(); 1092 CompilationInfo* info = this->info();
1110 __ SetStackPointer(jssp); 1093 __ SetStackPointer(jssp);
1111 __ Prologue(info->IsCodePreAgingActive()); 1094 __ Prologue(info->IsCodePreAgingActive());
1112 frame()->SetRegisterSaveAreaSize(
1113 StandardFrameConstants::kFixedFrameSizeFromFp);
1114 } else if (needs_frame_) { 1095 } else if (needs_frame_) {
1115 __ SetStackPointer(jssp); 1096 __ SetStackPointer(jssp);
1116 __ StubPrologue(); 1097 __ StubPrologue();
1117 frame()->SetRegisterSaveAreaSize(
1118 StandardFrameConstants::kFixedFrameSizeFromFp);
1119 } else { 1098 } else {
1120 frame()->SetPCOnStack(false); 1099 frame()->SetElidedFrameSizeInSlots(0);
1121 } 1100 }
1122 1101
1102 int stack_shrink_slots = frame()->GetSpillSlotCount();
1123 if (info()->is_osr()) { 1103 if (info()->is_osr()) {
1124 // TurboFan OSR-compiled functions cannot be entered directly. 1104 // TurboFan OSR-compiled functions cannot be entered directly.
1125 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1105 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1126 1106
1127 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1107 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1128 // frame is still on the stack. Optimized code uses OSR values directly from 1108 // frame is still on the stack. Optimized code uses OSR values directly from
1129 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1109 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1130 // remaining stack slots. 1110 // remaining stack slots.
1131 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1111 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1132 osr_pc_offset_ = __ pc_offset(); 1112 osr_pc_offset_ = __ pc_offset();
1133 // TODO(titzer): cannot address target function == local #-1 1113 // TODO(titzer): cannot address target function == local #-1
1134 __ ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1114 __ ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1135 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); 1115 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1136 stack_slots -= frame()->GetOsrStackSlotCount();
1137 } 1116 }
1138 1117
1139 if (stack_slots > 0) { 1118 if (stack_shrink_slots > 0) {
1140 Register sp = __ StackPointer(); 1119 Register sp = __ StackPointer();
1141 if (!sp.Is(csp)) { 1120 if (!sp.Is(csp)) {
1142 __ Sub(sp, sp, stack_slots * kPointerSize); 1121 __ Sub(sp, sp, stack_shrink_slots * kPointerSize);
1143 } 1122 }
1144 __ Sub(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize); 1123 __ Sub(csp, csp, AlignedStackSlots(stack_shrink_slots) * kPointerSize);
1124 }
1125
1126 // Save FP registers.
1127 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1128 descriptor->CalleeSavedFPRegisters());
1129 int saved_count = saves_fp.Count();
1130 if (saved_count != 0) {
1131 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1132 __ PushCPURegList(saves_fp);
1133 frame()->AllocateSavedCalleeRegisterSlots(saved_count *
1134 (kDoubleSize / kPointerSize));
1135 }
1136 // Save registers.
1137 // TODO(palfia): TF save list is not in sync with
1138 // CPURegList::GetCalleeSaved(): x30 is missing.
1139 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list());
1140 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1141 descriptor->CalleeSavedRegisters());
1142 saved_count = saves.Count();
1143 if (saved_count != 0) {
1144 __ PushCPURegList(saves);
1145 frame()->AllocateSavedCalleeRegisterSlots(saved_count);
1145 } 1146 }
1146 } 1147 }
1147 1148
1148 1149
1149 void CodeGenerator::AssembleReturn() { 1150 void CodeGenerator::AssembleReturn() {
1150 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1151 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1151 int stack_slots = frame()->GetSpillSlotCount(); 1152
1153 // Restore registers.
1154 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1155 descriptor->CalleeSavedRegisters());
1156 if (saves.Count() != 0) {
1157 __ PopCPURegList(saves);
1158 }
1159
1160 // Restore fp registers.
1161 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1162 descriptor->CalleeSavedFPRegisters());
1163 if (saves_fp.Count() != 0) {
1164 __ PopCPURegList(saves_fp);
1165 }
1166
1152 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1167 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1153 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1168 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1154 if (frame()->GetRegisterSaveAreaSize() > 0) {
1155 // Remove this frame's spill slots first.
1156 if (stack_slots > 0) {
1157 __ Add(csp, csp, AlignedStackSlots(stack_slots) * kPointerSize);
1158 }
1159
1160 // Restore registers.
1161 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1162 descriptor->CalleeSavedRegisters());
1163 __ PopCPURegList(saves);
1164
1165 CPURegList saves_fp =
1166 CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1167 descriptor->CalleeSavedFPRegisters());
1168 __ PopCPURegList(saves_fp);
1169 }
1170
1171 __ Mov(csp, fp); 1169 __ Mov(csp, fp);
1172 __ Pop(fp, lr); 1170 __ Pop(fp, lr);
1173 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { 1171 } else if (descriptor->IsJSFunctionCall() || needs_frame_) {
1174 // Canonicalize JSFunction return sites for now. 1172 // Canonicalize JSFunction return sites for now.
1175 if (return_label_.is_bound()) { 1173 if (return_label_.is_bound()) {
1176 __ B(&return_label_); 1174 __ B(&return_label_);
1177 return; 1175 return;
1178 } else { 1176 } else {
1179 __ Bind(&return_label_); 1177 __ Bind(&return_label_);
1180 __ Mov(jssp, fp); 1178 __ Mov(jssp, fp);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 } 1364 }
1367 } 1365 }
1368 } 1366 }
1369 } 1367 }
1370 1368
1371 #undef __ 1369 #undef __
1372 1370
1373 } // namespace compiler 1371 } // namespace compiler
1374 } // namespace internal 1372 } // namespace internal
1375 } // namespace v8 1373 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm/code-generator-arm.cc ('k') | src/compiler/code-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698