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

Side by Side Diff: src/s390/simulator-s390.cc

Issue 2841693003: PPC/s390: [sim] Consistent support for C calls with up to 9 args (Closed)
Patch Set: rebased and addressed comments Created 3 years, 7 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/s390/macro-assembler-s390.cc ('k') | no next file » | 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #if V8_TARGET_ARCH_S390 9 #if V8_TARGET_ARCH_S390
10 10
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 #else 1927 #else
1928 *x = static_cast<int32_t>(*pair); 1928 *x = static_cast<int32_t>(*pair);
1929 *y = static_cast<int32_t>(*pair >> 32); 1929 *y = static_cast<int32_t>(*pair >> 32);
1930 #endif 1930 #endif
1931 } 1931 }
1932 #endif 1932 #endif
1933 1933
1934 // Calls into the V8 runtime. 1934 // Calls into the V8 runtime.
1935 typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, 1935 typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1,
1936 intptr_t arg2, intptr_t arg3, 1936 intptr_t arg2, intptr_t arg3,
1937 intptr_t arg4, intptr_t arg5); 1937 intptr_t arg4, intptr_t arg5,
1938 intptr_t arg6, intptr_t arg7,
1939 intptr_t arg8);
1938 typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, 1940 typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1,
1939 intptr_t arg2, intptr_t arg3, 1941 intptr_t arg2, intptr_t arg3,
1940 intptr_t arg4, intptr_t arg5); 1942 intptr_t arg4, intptr_t arg5);
1941 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, 1943 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1,
1942 intptr_t arg2, intptr_t arg3, 1944 intptr_t arg2, intptr_t arg3,
1943 intptr_t arg4, 1945 intptr_t arg4,
1944 intptr_t arg5); 1946 intptr_t arg5);
1945 1947
1946 // These prototypes handle the four types of FP calls. 1948 // These prototypes handle the four types of FP calls.
1947 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); 1949 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1);
(...skipping 16 matching lines...) Expand all
1964 void Simulator::SoftwareInterrupt(Instruction* instr) { 1966 void Simulator::SoftwareInterrupt(Instruction* instr) {
1965 int svc = instr->SvcValue(); 1967 int svc = instr->SvcValue();
1966 switch (svc) { 1968 switch (svc) {
1967 case kCallRtRedirected: { 1969 case kCallRtRedirected: {
1968 // Check if stack is aligned. Error if not aligned is reported below to 1970 // Check if stack is aligned. Error if not aligned is reported below to
1969 // include information on the function called. 1971 // include information on the function called.
1970 bool stack_aligned = 1972 bool stack_aligned =
1971 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 1973 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) ==
1972 0; 1974 0;
1973 Redirection* redirection = Redirection::FromSwiInstruction(instr); 1975 Redirection* redirection = Redirection::FromSwiInstruction(instr);
1974 const int kArgCount = 6; 1976 const int kArgCount = 9;
1977 const int kRegisterArgCount = 5;
1975 int arg0_regnum = 2; 1978 int arg0_regnum = 2;
1976 intptr_t result_buffer = 0; 1979 intptr_t result_buffer = 0;
1977 bool uses_result_buffer = 1980 bool uses_result_buffer =
1978 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || 1981 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE ||
1979 (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && 1982 (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR &&
1980 !ABI_RETURNS_OBJECTPAIR_IN_REGS); 1983 !ABI_RETURNS_OBJECTPAIR_IN_REGS);
1981 if (uses_result_buffer) { 1984 if (uses_result_buffer) {
1982 result_buffer = get_register(r2); 1985 result_buffer = get_register(r2);
1983 arg0_regnum++; 1986 arg0_regnum++;
1984 } 1987 }
1985 intptr_t arg[kArgCount]; 1988 intptr_t arg[kArgCount];
1986 for (int i = 0; i < kArgCount - 1; i++) { 1989 // First 5 arguments in registers r2-r6.
1990 for (int i = 0; i < kRegisterArgCount; i++) {
1987 arg[i] = get_register(arg0_regnum + i); 1991 arg[i] = get_register(arg0_regnum + i);
1988 } 1992 }
1993 // Remaining arguments on stack
1989 intptr_t* stack_pointer = reinterpret_cast<intptr_t*>(get_register(sp)); 1994 intptr_t* stack_pointer = reinterpret_cast<intptr_t*>(get_register(sp));
1990 arg[5] = stack_pointer[kCalleeRegisterSaveAreaSize / kPointerSize]; 1995 for (int i = kRegisterArgCount; i < kArgCount; i++) {
1996 arg[i] = stack_pointer[(kCalleeRegisterSaveAreaSize / kPointerSize) +
1997 (i - kRegisterArgCount)];
1998 }
1999 STATIC_ASSERT(kArgCount == kRegisterArgCount + 4);
2000 STATIC_ASSERT(kMaxCParameters == 9);
1991 bool fp_call = 2001 bool fp_call =
1992 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || 2002 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) ||
1993 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || 2003 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) ||
1994 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || 2004 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) ||
1995 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); 2005 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL);
1996 2006
1997 // Place the return address on the stack, making the call GC safe. 2007 // Place the return address on the stack, making the call GC safe.
1998 *reinterpret_cast<intptr_t*>(get_register(sp) + 2008 *reinterpret_cast<intptr_t*>(get_register(sp) +
1999 kStackFrameRASlot * kPointerSize) = 2009 kStackFrameRASlot * kPointerSize) =
2000 get_register(r14); 2010 get_register(r14);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 } 2168 }
2159 target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); 2169 target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2]));
2160 } else { 2170 } else {
2161 // builtin call. 2171 // builtin call.
2162 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { 2172 if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
2163 SimulatorRuntimeCall target = 2173 SimulatorRuntimeCall target =
2164 reinterpret_cast<SimulatorRuntimeCall>(external); 2174 reinterpret_cast<SimulatorRuntimeCall>(external);
2165 PrintF( 2175 PrintF(
2166 "Call to host function at %p,\n" 2176 "Call to host function at %p,\n"
2167 "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR 2177 "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR
2178 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR
2168 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, 2179 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR,
2169 static_cast<void*>(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], 2180 static_cast<void*>(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2],
2170 arg[3], arg[4], arg[5]); 2181 arg[3], arg[4], arg[5], arg[6], arg[7], arg[8]);
2171 if (!stack_aligned) { 2182 if (!stack_aligned) {
2172 PrintF(" with unaligned stack %08" V8PRIxPTR "\n", 2183 PrintF(" with unaligned stack %08" V8PRIxPTR "\n",
2173 static_cast<intptr_t>(get_register(sp))); 2184 static_cast<intptr_t>(get_register(sp)));
2174 } 2185 }
2175 PrintF("\n"); 2186 PrintF("\n");
2176 } 2187 }
2177 CHECK(stack_aligned); 2188 CHECK(stack_aligned);
2178 if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { 2189 if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) {
2179 SimulatorRuntimeTripleCall target = 2190 SimulatorRuntimeTripleCall target =
2180 reinterpret_cast<SimulatorRuntimeTripleCall>(external); 2191 reinterpret_cast<SimulatorRuntimeTripleCall>(external);
(...skipping 26 matching lines...) Expand all
2207 set_register(r3, y); 2218 set_register(r3, y);
2208 } else { 2219 } else {
2209 memcpy(reinterpret_cast<void*>(result_buffer), &result, 2220 memcpy(reinterpret_cast<void*>(result_buffer), &result,
2210 sizeof(ObjectPair)); 2221 sizeof(ObjectPair));
2211 set_register(r2, result_buffer); 2222 set_register(r2, result_buffer);
2212 } 2223 }
2213 } else { 2224 } else {
2214 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); 2225 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL);
2215 SimulatorRuntimeCall target = 2226 SimulatorRuntimeCall target =
2216 reinterpret_cast<SimulatorRuntimeCall>(external); 2227 reinterpret_cast<SimulatorRuntimeCall>(external);
2217 intptr_t result = 2228 intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4],
2218 target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); 2229 arg[5], arg[6], arg[7], arg[8]);
2219 if (::v8::internal::FLAG_trace_sim) { 2230 if (::v8::internal::FLAG_trace_sim) {
2220 PrintF("Returned %08" V8PRIxPTR "\n", result); 2231 PrintF("Returned %08" V8PRIxPTR "\n", result);
2221 } 2232 }
2222 set_register(r2, result); 2233 set_register(r2, result);
2223 } 2234 }
2224 } 2235 }
2225 // #if !V8_TARGET_ARCH_S390X 2236 // #if !V8_TARGET_ARCH_S390X
2226 // DCHECK(redirection->type() == 2237 // DCHECK(redirection->type() ==
2227 // ExternalReference::BUILTIN_CALL); 2238 // ExternalReference::BUILTIN_CALL);
2228 // SimulatorRuntimeCall target = 2239 // SimulatorRuntimeCall target =
(...skipping 7616 matching lines...) Expand 10 before | Expand all | Expand 10 after
9845 return 0; 9856 return 0;
9846 } 9857 }
9847 9858
9848 #undef EVALUATE 9859 #undef EVALUATE
9849 9860
9850 } // namespace internal 9861 } // namespace internal
9851 } // namespace v8 9862 } // namespace v8
9852 9863
9853 #endif // USE_SIMULATOR 9864 #endif // USE_SIMULATOR
9854 #endif // V8_TARGET_ARCH_S390 9865 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/s390/macro-assembler-s390.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698