5 #include "src/assembler-inl.h" 6 #include "src/macro-assembler.h" 8 #include "src/compiler/linkage.h" 10 #include "src/zone/zone.h" 19 #if V8_TARGET_ARCH_IA32 23 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit() 25 #elif V8_TARGET_ARCH_X64 32 #define STACK_SHADOW_WORDS 4 33 #define PARAM_REGISTERS rcx, rdx, r8, r9 34 #define CALLEE_SAVE_REGISTERS \ 35 rbx.bit() | rdi.bit() | rsi.bit() | r12.bit() | r13.bit() | r14.bit() | \ 37 #define CALLEE_SAVE_FP_REGISTERS \ 38 (1 << xmm6.code()) | (1 << xmm7.code()) | (1 << xmm8.code()) | \ 39 (1 << xmm9.code()) | (1 << xmm10.code()) | (1 << xmm11.code()) | \ 40 (1 << xmm12.code()) | (1 << xmm13.code()) | (1 << xmm14.code()) | \ 44 #define PARAM_REGISTERS rdi, rsi, rdx, rcx, r8, r9 45 #define CALLEE_SAVE_REGISTERS \ 46 rbx.bit() | r12.bit() | r13.bit() | r14.bit() | r15.bit() 49 #elif V8_TARGET_ARCH_ARM 53 #define PARAM_REGISTERS r0, r1, r2, r3 54 #define CALLEE_SAVE_REGISTERS \ 55 r4.bit() | r5.bit() | r6.bit() | r7.bit() | r8.bit() | r9.bit() | r10.bit() 56 #define CALLEE_SAVE_FP_REGISTERS \ 57 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \ 58 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \ 59 (1 << d14.code()) | (1 << d15.code()) 62 #elif V8_TARGET_ARCH_ARM64 66 #define PARAM_REGISTERS x0, x1, x2, x3, x4, x5, x6, x7 67 #define CALLEE_SAVE_REGISTERS \ 68 (1 << x19.code()) | (1 << x20.code()) | (1 << x21.code()) | \ 69 (1 << x22.code()) | (1 << x23.code()) | (1 << x24.code()) | \ 70 (1 << x25.code()) | (1 << x26.code()) | (1 << x27.code()) | \ 71 (1 << x28.code()) | (1 << x29.code()) | (1 << x30.code()) 74 #define CALLEE_SAVE_FP_REGISTERS \ 75 (1 << d8.code()) | (1 << d9.code()) | (1 << d10.code()) | \ 76 (1 << d11.code()) | (1 << d12.code()) | (1 << d13.code()) | \ 77 (1 << d14.code()) | (1 << d15.code()) 79 #elif V8_TARGET_ARCH_MIPS 83 #define STACK_SHADOW_WORDS 4 84 #define PARAM_REGISTERS a0, a1, a2, a3 85 #define CALLEE_SAVE_REGISTERS \ 86 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ 88 #define CALLEE_SAVE_FP_REGISTERS \ 89 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() 91 #elif V8_TARGET_ARCH_MIPS64 95 #define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 96 #define CALLEE_SAVE_REGISTERS \ 97 s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ 99 #define CALLEE_SAVE_FP_REGISTERS \ 100 f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() 102 #elif V8_TARGET_ARCH_PPC64 106 #ifdef V8_TARGET_LITTLE_ENDIAN // ppc64le linux 107 #define STACK_SHADOW_WORDS 12 109 #define STACK_SHADOW_WORDS 14 111 #define PARAM_REGISTERS r3, r4, r5, r6, r7, r8, r9, r10 112 #define CALLEE_SAVE_REGISTERS \ 113 r14.bit() | r15.bit() | r16.bit() | r17.bit() | r18.bit() | r19.bit() | \ 114 r20.bit() | r21.bit() | r22.bit() | r23.bit() | r24.bit() | r25.bit() | \ 115 r26.bit() | r27.bit() | r28.bit() | r29.bit() | r30.bit() 116 #define CALLEE_SAVE_FP_REGISTERS \ 117 d14.bit() | d15.bit() | d16.bit() | d17.bit() | d18.bit() | d19.bit() | \ 118 d20.bit() | d21.bit() | d22.bit() | d23.bit() | d24.bit() | d25.bit() | \ 119 d26.bit() | d27.bit() | d28.bit() | d29.bit() | d30.bit() | d31.bit() 121 #elif V8_TARGET_ARCH_S390X 125 #define STACK_SHADOW_WORDS 20 126 #define PARAM_REGISTERS r2, r3, r4, r5, r6 127 #define CALLEE_SAVE_REGISTERS \ 128 r6.bit() | r7.bit() | r8.bit() | r9.bit() | r10.bit() | ip.bit() | r13.bit() 129 #define CALLEE_SAVE_FP_REGISTERS \ 130 d8.bit() | d9.bit() | d10.bit() | d11.bit() | d12.bit() | d13.bit() | \ 131 d14.bit() | d15.bit() 137 #define UNSUPPORTED_C_LINKAGE 1 143 CallDescriptor* Linkage::GetSimplifiedCDescriptor(
144 Zone* zone,
const MachineSignature* msig,
bool set_initialize_root_flag) {
145 DCHECK_LE(msig->parameter_count(),
static_cast<size_t>(kMaxCParameters));
147 LocationSignature::Builder locations(zone, msig->return_count(),
148 msig->parameter_count());
152 for (
size_t i = 0;
i < msig->return_count();
i++) {
153 MachineRepresentation rep = msig->GetReturn(
i).representation();
154 CHECK_NE(MachineRepresentation::kFloat32, rep);
155 CHECK_NE(MachineRepresentation::kFloat64, rep);
157 for (
size_t i = 0;
i < msig->parameter_count();
i++) {
158 MachineRepresentation rep = msig->GetParam(
i).representation();
159 CHECK_NE(MachineRepresentation::kFloat32, rep);
160 CHECK_NE(MachineRepresentation::kFloat64, rep);
163 #ifdef UNSUPPORTED_C_LINKAGE 165 FATAL(
"requested C call descriptor on unsupported architecture");
170 CHECK_GE(2, locations.return_count_);
172 if (locations.return_count_ > 0) {
173 locations.AddReturn(LinkageLocation::ForRegister(kReturnRegister0.code(),
174 msig->GetReturn(0)));
176 if (locations.return_count_ > 1) {
177 locations.AddReturn(LinkageLocation::ForRegister(kReturnRegister1.code(),
178 msig->GetReturn(1)));
181 const int parameter_count =
static_cast<int>(msig->parameter_count());
183 #ifdef PARAM_REGISTERS 185 const int kParamRegisterCount =
static_cast<int>(arraysize(kParamRegisters));
188 const int kParamRegisterCount = 0;
191 #ifdef STACK_SHADOW_WORDS 192 int stack_offset = STACK_SHADOW_WORDS;
194 int stack_offset = 0;
197 for (
int i = 0;
i < parameter_count;
i++) {
198 if (
i < kParamRegisterCount) {
199 locations.AddParam(LinkageLocation::ForRegister(kParamRegisters[
i].code(),
202 locations.AddParam(LinkageLocation::ForCallerFrameSlot(
203 -1 - stack_offset, msig->GetParam(
i)));
208 #ifdef CALLEE_SAVE_REGISTERS 209 const RegList kCalleeSaveRegisters = CALLEE_SAVE_REGISTERS;
211 const RegList kCalleeSaveRegisters = 0;
214 #ifdef CALLEE_SAVE_FP_REGISTERS 215 const RegList kCalleeSaveFPRegisters = CALLEE_SAVE_FP_REGISTERS;
217 const RegList kCalleeSaveFPRegisters = 0;
221 MachineType target_type = MachineType::Pointer();
222 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
223 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
224 if (set_initialize_root_flag) {
225 flags |= CallDescriptor::kInitializeRootRegister;
228 return new (zone) CallDescriptor(
229 CallDescriptor::kCallAddress,
235 kCalleeSaveRegisters,
236 kCalleeSaveFPRegisters,