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

Side by Side Diff: src/compiler/c-linkage.cc

Issue 1272883003: [turbofan] Remove architecture-specific linkage files and LinkageTraits. Use macro-assembler-define… (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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/assembler.h" 5 #include "src/assembler.h"
6 #include "src/macro-assembler.h" 6 #include "src/macro-assembler.h"
7 7
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/linkage-impl.h"
9 10
10 #include "src/zone.h" 11 #include "src/zone.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 namespace compiler { 15 namespace compiler {
15 16
16 namespace { 17 namespace {
17 // Platform-specific configuration for C calling convention. 18 // Platform-specific configuration for C calling convention.
18 LinkageLocation regloc(Register reg) {
19 return LinkageLocation::ForRegister(Register::ToAllocationIndex(reg));
20 }
21
22
23 LinkageLocation stackloc(int i) {
24 DCHECK_LT(i, 0);
25 return LinkageLocation::ForCallerFrameSlot(i);
26 }
27
28
29 #if V8_TARGET_ARCH_IA32 19 #if V8_TARGET_ARCH_IA32
30 // =========================================================================== 20 // ===========================================================================
31 // == ia32 =================================================================== 21 // == ia32 ===================================================================
32 // =========================================================================== 22 // ===========================================================================
33 #define RETURN_REGISTER_0 eax
34 #define RETURN_REGISTER_1 edx
35 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit() 23 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit()
36 24
37 #elif V8_TARGET_ARCH_X64 25 #elif V8_TARGET_ARCH_X64
38 // =========================================================================== 26 // ===========================================================================
39 // == x64 ==================================================================== 27 // == x64 ====================================================================
40 // =========================================================================== 28 // ===========================================================================
41 #define RETURN_REGISTER_0 rax
42 #define RETURN_REGISTER_1 rdx
43 29
44 #ifdef _WIN64 30 #ifdef _WIN64
45 // == x64 windows ============================================================ 31 // == x64 windows ============================================================
46 #define STACK_SHADOW_WORDS 4 32 #define STACK_SHADOW_WORDS 4
47 #define PARAM_REGISTERS rcx, rdx, r8, r9 33 #define PARAM_REGISTERS rcx, rdx, r8, r9
48 #define CALLEE_SAVE_REGISTERS \ 34 #define CALLEE_SAVE_REGISTERS \
49 rbx.bit() | rdi.bit() | rsi.bit() | r12.bit() | r13.bit() | r14.bit() | \ 35 rbx.bit() | rdi.bit() | rsi.bit() | r12.bit() | r13.bit() | r14.bit() | \
50 r15.bit() 36 r15.bit()
51 #define CALLEE_SAVE_FP_REGISTERS \ 37 #define CALLEE_SAVE_FP_REGISTERS \
52 (1 << xmm6.code()) | (1 << xmm7.code()) | (1 << xmm8.code()) | \ 38 (1 << xmm6.code()) | (1 << xmm7.code()) | (1 << xmm8.code()) | \
53 (1 << xmm9.code()) | (1 << xmm10.code()) | (1 << xmm11.code()) | \ 39 (1 << xmm9.code()) | (1 << xmm10.code()) | (1 << xmm11.code()) | \
54 (1 << xmm12.code()) | (1 << xmm13.code()) | (1 << xmm14.code()) | \ 40 (1 << xmm12.code()) | (1 << xmm13.code()) | (1 << xmm14.code()) | \
55 (1 << xmm15.code()) 41 (1 << xmm15.code())
56 #else 42 #else
57 // == x64 other ============================================================== 43 // == x64 other ==============================================================
58 #define PARAM_REGISTERS rdi, rsi, rdx, rcx, r8, r9 44 #define PARAM_REGISTERS rdi, rsi, rdx, rcx, r8, r9
59 #define CALLEE_SAVE_REGISTERS \ 45 #define CALLEE_SAVE_REGISTERS \
60 rbx.bit() | r12.bit() | r13.bit() | r14.bit() | r15.bit() 46 rbx.bit() | r12.bit() | r13.bit() | r14.bit() | r15.bit()
61 #endif 47 #endif
62 48
63 #elif V8_TARGET_ARCH_X87 49 #elif V8_TARGET_ARCH_X87
64 // =========================================================================== 50 // ===========================================================================
65 // == x87 ==================================================================== 51 // == x87 ====================================================================
66 // =========================================================================== 52 // ===========================================================================
67 #define RETURN_REGISTER_0 eax
68 #define RETURN_REGISTER_1 edx
69 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit() 53 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit()
70 54
71 #elif V8_TARGET_ARCH_ARM 55 #elif V8_TARGET_ARCH_ARM
72 // =========================================================================== 56 // ===========================================================================
73 // == arm ==================================================================== 57 // == arm ====================================================================
74 // =========================================================================== 58 // ===========================================================================
75 #define PARAM_REGISTERS r0, r1, r2, r3 59 #define PARAM_REGISTERS r0, r1, r2, r3
76 #define RETURN_REGISTER_0 r0
77 #define RETURN_REGISTER_1 r1
78 #define CALLEE_SAVE_REGISTERS \ 60 #define CALLEE_SAVE_REGISTERS \
79 r4.bit() | r5.bit() | r6.bit() | r7.bit() | r8.bit() | r9.bit() | r10.bit() 61 r4.bit() | r5.bit() | r6.bit() | r7.bit() | r8.bit() | r9.bit() | r10.bit()
80 #define CALLEE_SAVE_FP_REGISTERS \ 62 #define CALLEE_SAVE_FP_REGISTERS \
81 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \ 63 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \
82 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \ 64 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \
83 (1 << d14.code()) | (1 << d15.code()) 65 (1 << d14.code()) | (1 << d15.code())
84 66
85 67
86 #elif V8_TARGET_ARCH_ARM64 68 #elif V8_TARGET_ARCH_ARM64
87 // =========================================================================== 69 // ===========================================================================
88 // == arm64 ==================================================================== 70 // == arm64 ====================================================================
89 // =========================================================================== 71 // ===========================================================================
90 #define PARAM_REGISTERS x0, x1, x2, x3, x4, x5, x6, x7 72 #define PARAM_REGISTERS x0, x1, x2, x3, x4, x5, x6, x7
91 #define RETURN_REGISTER_0 x0
92 #define RETURN_REGISTER_1 x1
93 #define CALLEE_SAVE_REGISTERS \ 73 #define CALLEE_SAVE_REGISTERS \
94 (1 << x19.code()) | (1 << x20.code()) | (1 << x21.code()) | \ 74 (1 << x19.code()) | (1 << x20.code()) | (1 << x21.code()) | \
95 (1 << x22.code()) | (1 << x23.code()) | (1 << x24.code()) | \ 75 (1 << x22.code()) | (1 << x23.code()) | (1 << x24.code()) | \
96 (1 << x25.code()) | (1 << x26.code()) | (1 << x27.code()) | \ 76 (1 << x25.code()) | (1 << x26.code()) | (1 << x27.code()) | \
97 (1 << x28.code()) | (1 << x29.code()) | (1 << x30.code()) 77 (1 << x28.code()) | (1 << x29.code()) | (1 << x30.code())
98 78
99 79
100 #define CALLEE_SAVE_FP_REGISTERS \ 80 #define CALLEE_SAVE_FP_REGISTERS \
101 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \ 81 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \
102 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \ 82 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \
103 (1 << d14.code()) | (1 << d15.code()) 83 (1 << d14.code()) | (1 << d15.code())
104 84
105 #elif V8_TARGET_ARCH_MIPS 85 #elif V8_TARGET_ARCH_MIPS
106 // =========================================================================== 86 // ===========================================================================
107 // == mips =================================================================== 87 // == mips ===================================================================
108 // =========================================================================== 88 // ===========================================================================
109 #define PARAM_REGISTERS a0, a1, a2, a3 89 #define PARAM_REGISTERS a0, a1, a2, a3
110 #define RETURN_REGISTER_0 v0
111 #define RETURN_REGISTER_1 v1
112 #define CALLEE_SAVE_REGISTERS \ 90 #define CALLEE_SAVE_REGISTERS \
113 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ 91 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \
114 s7.bit() 92 s7.bit()
115 #define CALLEE_SAVE_FP_REGISTERS \ 93 #define CALLEE_SAVE_FP_REGISTERS \
116 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() 94 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit()
117 95
118 #elif V8_TARGET_ARCH_MIPS64 96 #elif V8_TARGET_ARCH_MIPS64
119 // =========================================================================== 97 // ===========================================================================
120 // == mips64 ================================================================= 98 // == mips64 =================================================================
121 // =========================================================================== 99 // ===========================================================================
122 #define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 100 #define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7
123 #define RETURN_REGISTER_0 v0
124 #define RETURN_REGISTER_1 v1
125 #define CALLEE_SAVE_REGISTERS \ 101 #define CALLEE_SAVE_REGISTERS \
126 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ 102 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \
127 s7.bit() 103 s7.bit()
128 #define CALLEE_SAVE_FP_REGISTERS \ 104 #define CALLEE_SAVE_FP_REGISTERS \
129 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() 105 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit()
130 106
131 #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 107 #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
132 // =========================================================================== 108 // ===========================================================================
133 // == ppc & ppc64 ============================================================ 109 // == ppc & ppc64 ============================================================
134 // =========================================================================== 110 // ===========================================================================
135 #define PARAM_REGISTERS r3, r4, r5, r6, r7, r8, r9, r10 111 #define PARAM_REGISTERS r3, r4, r5, r6, r7, r8, r9, r10
136 #define RETURN_REGISTER_0 r3
137 #define RETURN_REGISTER_1 r4
138 #define CALLEE_SAVE_REGISTERS \ 112 #define CALLEE_SAVE_REGISTERS \
139 r14.bit() | r15.bit() | r16.bit() | r17.bit() | r18.bit() | r19.bit() | \ 113 r14.bit() | r15.bit() | r16.bit() | r17.bit() | r18.bit() | r19.bit() | \
140 r20.bit() | r21.bit() | r22.bit() | r23.bit() | r24.bit() | r25.bit() | \ 114 r20.bit() | r21.bit() | r22.bit() | r23.bit() | r24.bit() | r25.bit() | \
141 r26.bit() | r27.bit() | r28.bit() | r29.bit() | r30.bit() 115 r26.bit() | r27.bit() | r28.bit() | r29.bit() | r30.bit()
142 #define CALLEE_SAVE_FP_REGISTERS \ 116 #define CALLEE_SAVE_FP_REGISTERS \
143 d14.bit() | d15.bit() | d16.bit() | d17.bit() | d18.bit() | d19.bit() | \ 117 d14.bit() | d15.bit() | d16.bit() | d17.bit() | d18.bit() | d19.bit() | \
144 d20.bit() | d21.bit() | d22.bit() | d23.bit() | d24.bit() | d25.bit() | \ 118 d20.bit() | d21.bit() | d22.bit() | d23.bit() | d24.bit() | d25.bit() | \
145 d26.bit() | d27.bit() | d28.bit() | d29.bit() | d30.bit() | d31.bit() 119 d26.bit() | d27.bit() | d28.bit() | d29.bit() | d30.bit() | d31.bit()
146 120
147 #else 121 #else
148 // =========================================================================== 122 // ===========================================================================
149 // == unknown ================================================================ 123 // == unknown ================================================================
150 // =========================================================================== 124 // ===========================================================================
151 // Don't define anything. The below code will dynamically fail. 125 #define UNSUPPORTED_C_LINKAGE 1
152 #endif 126 #endif
153 } // namespace 127 } // namespace
154 128
155 129
156 // General code uses the above configuration data. 130 // General code uses the above configuration data.
157 CallDescriptor* Linkage::GetSimplifiedCDescriptor( 131 CallDescriptor* Linkage::GetSimplifiedCDescriptor(
158 Zone* zone, const MachineSignature* msig) { 132 Zone* zone, const MachineSignature* msig) {
159 LocationSignature::Builder locations(zone, msig->return_count(), 133 LocationSignature::Builder locations(zone, msig->return_count(),
160 msig->parameter_count()); 134 msig->parameter_count());
161 #if 0 // TODO(titzer): instruction selector tests break here. 135 #if 0 // TODO(titzer): instruction selector tests break here.
162 // Check the types of the signature. 136 // Check the types of the signature.
163 // Currently no floating point parameters or returns are allowed because 137 // Currently no floating point parameters or returns are allowed because
164 // on x87 and ia32, the FP top of stack is involved. 138 // on x87 and ia32, the FP top of stack is involved.
165 139
166 for (size_t i = 0; i < msig->return_count(); i++) { 140 for (size_t i = 0; i < msig->return_count(); i++) {
167 MachineType type = RepresentationOf(msig->GetReturn(i)); 141 MachineType type = RepresentationOf(msig->GetReturn(i));
168 CHECK(type != kRepFloat32 && type != kRepFloat64); 142 CHECK(type != kRepFloat32 && type != kRepFloat64);
169 } 143 }
170 for (size_t i = 0; i < msig->parameter_count(); i++) { 144 for (size_t i = 0; i < msig->parameter_count(); i++) {
171 MachineType type = RepresentationOf(msig->GetParam(i)); 145 MachineType type = RepresentationOf(msig->GetParam(i));
172 CHECK(type != kRepFloat32 && type != kRepFloat64); 146 CHECK(type != kRepFloat32 && type != kRepFloat64);
173 } 147 }
174 #endif 148 #endif
175 149
176 #ifdef RETURN_REGISTER_0 150 #ifdef UNSUPPORTED_C_LINKAGE
177 // Add return location(s).
178 CHECK(locations.return_count_ <= 2);
179
180 if (locations.return_count_ > 0) {
181 locations.AddReturn(regloc(RETURN_REGISTER_0));
182 }
183 if (locations.return_count_ > 1) {
184 locations.AddReturn(regloc(RETURN_REGISTER_1));
185 }
186 #else
187 // This method should not be called on unknown architectures. 151 // This method should not be called on unknown architectures.
188 V8_Fatal(__FILE__, __LINE__, 152 V8_Fatal(__FILE__, __LINE__,
189 "requested C call descriptor on unsupported architecture"); 153 "requested C call descriptor on unsupported architecture");
190 return nullptr; 154 return nullptr;
191 #endif 155 #endif
192 156
157 // Add return location(s).
158 CHECK(locations.return_count_ <= 2);
159
160 if (locations.return_count_ > 0) {
161 locations.AddReturn(regloc(kReturnRegister0));
162 }
163 if (locations.return_count_ > 1) {
164 locations.AddReturn(regloc(kReturnRegister1));
165 }
166
193 const int parameter_count = static_cast<int>(msig->parameter_count()); 167 const int parameter_count = static_cast<int>(msig->parameter_count());
194 168
195 #ifdef PARAM_REGISTERS 169 #ifdef PARAM_REGISTERS
196 static const Register kParamRegisters[] = {PARAM_REGISTERS}; 170 static const Register kParamRegisters[] = {PARAM_REGISTERS};
197 static const int kParamRegisterCount = 171 static const int kParamRegisterCount =
198 static_cast<int>(arraysize(kParamRegisters)); 172 static_cast<int>(arraysize(kParamRegisters));
199 #else 173 #else
200 static const Register* kParamRegisters = nullptr; 174 static const Register* kParamRegisters = nullptr;
201 static const int kParamRegisterCount = 0; 175 static const int kParamRegisterCount = 0;
202 #endif 176 #endif
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 0, // stack_parameter_count 214 0, // stack_parameter_count
241 Operator::kNoProperties, // properties 215 Operator::kNoProperties, // properties
242 kCalleeSaveRegisters, // callee-saved registers 216 kCalleeSaveRegisters, // callee-saved registers
243 kCalleeSaveFPRegisters, // callee-saved fp regs 217 kCalleeSaveFPRegisters, // callee-saved fp regs
244 CallDescriptor::kNoFlags, // flags 218 CallDescriptor::kNoFlags, // flags
245 "c-call"); 219 "c-call");
246 } 220 }
247 } 221 }
248 } 222 }
249 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698