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

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

Issue 2825393003: [sim] Consistent support for C calls with up to 9 args (Closed)
Patch Set: enum -> const variable Created 3 years, 8 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/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_ARM 9 #if V8_TARGET_ARCH_ARM
10 10
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 } 1699 }
1700 } 1700 }
1701 1701
1702 1702
1703 // Calls into the V8 runtime are based on this very simple interface. 1703 // Calls into the V8 runtime are based on this very simple interface.
1704 // Note: To be able to return two values from some calls the code in runtime.cc 1704 // Note: To be able to return two values from some calls the code in runtime.cc
1705 // uses the ObjectPair which is essentially two 32-bit values stuffed into a 1705 // uses the ObjectPair which is essentially two 32-bit values stuffed into a
1706 // 64-bit value. With the code below we assume that all runtime calls return 1706 // 64-bit value. With the code below we assume that all runtime calls return
1707 // 64 bits of result. If they don't, the r1 result register contains a bogus 1707 // 64 bits of result. If they don't, the r1 result register contains a bogus
1708 // value, which is fine because it is caller-saved. 1708 // value, which is fine because it is caller-saved.
1709 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, 1709 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, int32_t arg1,
1710 int32_t arg1, 1710 int32_t arg2, int32_t arg3,
1711 int32_t arg2, 1711 int32_t arg4, int32_t arg5,
1712 int32_t arg3, 1712 int32_t arg6, int32_t arg7,
1713 int32_t arg4, 1713 int32_t arg8);
1714 int32_t arg5);
1715 1714
1716 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int32_t arg0, int32_t arg1, 1715 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int32_t arg0, int32_t arg1,
1717 int32_t arg2, int32_t arg3, 1716 int32_t arg2, int32_t arg3,
1718 int32_t arg4); 1717 int32_t arg4);
1719 1718
1720 // These prototypes handle the four types of FP calls. 1719 // These prototypes handle the four types of FP calls.
1721 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); 1720 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1);
1722 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); 1721 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1);
1723 typedef double (*SimulatorRuntimeFPCall)(double darg0); 1722 typedef double (*SimulatorRuntimeFPCall)(double darg0);
1724 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); 1723 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0);
(...skipping 20 matching lines...) Expand all
1745 (get_register(sp) 1744 (get_register(sp)
1746 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; 1745 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0;
1747 Redirection* redirection = Redirection::FromSwiInstruction(instr); 1746 Redirection* redirection = Redirection::FromSwiInstruction(instr);
1748 int32_t arg0 = get_register(r0); 1747 int32_t arg0 = get_register(r0);
1749 int32_t arg1 = get_register(r1); 1748 int32_t arg1 = get_register(r1);
1750 int32_t arg2 = get_register(r2); 1749 int32_t arg2 = get_register(r2);
1751 int32_t arg3 = get_register(r3); 1750 int32_t arg3 = get_register(r3);
1752 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp)); 1751 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp));
1753 int32_t arg4 = stack_pointer[0]; 1752 int32_t arg4 = stack_pointer[0];
1754 int32_t arg5 = stack_pointer[1]; 1753 int32_t arg5 = stack_pointer[1];
1754 int32_t arg6 = stack_pointer[2];
1755 int32_t arg7 = stack_pointer[3];
1756 int32_t arg8 = stack_pointer[4];
1757 STATIC_ASSERT(kMaxCParameters == 9);
1758
1755 bool fp_call = 1759 bool fp_call =
1756 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || 1760 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) ||
1757 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || 1761 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) ||
1758 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || 1762 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) ||
1759 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); 1763 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL);
1760 // This is dodgy but it works because the C entry stubs are never moved. 1764 // This is dodgy but it works because the C entry stubs are never moved.
1761 // See comment in codegen-arm.cc and bug 1242173. 1765 // See comment in codegen-arm.cc and bug 1242173.
1762 int32_t saved_lr = get_register(lr); 1766 int32_t saved_lr = get_register(lr);
1763 intptr_t external = 1767 intptr_t external =
1764 reinterpret_cast<intptr_t>(redirection->external_function()); 1768 reinterpret_cast<intptr_t>(redirection->external_function());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 set_register(r0, arg0); 1936 set_register(r0, arg0);
1933 } else { 1937 } else {
1934 // builtin call. 1938 // builtin call.
1935 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || 1939 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL ||
1936 redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); 1940 redirection->type() == ExternalReference::BUILTIN_CALL_PAIR);
1937 SimulatorRuntimeCall target = 1941 SimulatorRuntimeCall target =
1938 reinterpret_cast<SimulatorRuntimeCall>(external); 1942 reinterpret_cast<SimulatorRuntimeCall>(external);
1939 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { 1943 if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1940 PrintF( 1944 PrintF(
1941 "Call to host function at %p " 1945 "Call to host function at %p "
1942 "args %08x, %08x, %08x, %08x, %08x, %08x", 1946 "args %08x, %08x, %08x, %08x, %08x, %08x, %08x, %08x, %08x",
1943 static_cast<void*>(FUNCTION_ADDR(target)), arg0, arg1, arg2, arg3, 1947 static_cast<void*>(FUNCTION_ADDR(target)), arg0, arg1, arg2, arg3,
1944 arg4, arg5); 1948 arg4, arg5, arg6, arg7, arg8);
1945 if (!stack_aligned) { 1949 if (!stack_aligned) {
1946 PrintF(" with unaligned stack %08x\n", get_register(sp)); 1950 PrintF(" with unaligned stack %08x\n", get_register(sp));
1947 } 1951 }
1948 PrintF("\n"); 1952 PrintF("\n");
1949 } 1953 }
1950 CHECK(stack_aligned); 1954 CHECK(stack_aligned);
1951 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); 1955 int64_t result =
1956 target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
1952 int32_t lo_res = static_cast<int32_t>(result); 1957 int32_t lo_res = static_cast<int32_t>(result);
1953 int32_t hi_res = static_cast<int32_t>(result >> 32); 1958 int32_t hi_res = static_cast<int32_t>(result >> 32);
1954 if (::v8::internal::FLAG_trace_sim) { 1959 if (::v8::internal::FLAG_trace_sim) {
1955 PrintF("Returned %08x\n", lo_res); 1960 PrintF("Returned %08x\n", lo_res);
1956 } 1961 }
1957 set_register(r0, lo_res); 1962 set_register(r0, lo_res);
1958 set_register(r1, hi_res); 1963 set_register(r1, hi_res);
1959 } 1964 }
1960 set_register(lr, saved_lr); 1965 set_register(lr, saved_lr);
1961 set_pc(get_register(lr)); 1966 set_pc(get_register(lr));
(...skipping 4082 matching lines...) Expand 10 before | Expand all | Expand 10 after
6044 processor->prev_ = nullptr; 6049 processor->prev_ = nullptr;
6045 processor->next_ = nullptr; 6050 processor->next_ = nullptr;
6046 } 6051 }
6047 6052
6048 } // namespace internal 6053 } // namespace internal
6049 } // namespace v8 6054 } // namespace v8
6050 6055
6051 #endif // USE_SIMULATOR 6056 #endif // USE_SIMULATOR
6052 6057
6053 #endif // V8_TARGET_ARCH_ARM 6058 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698