|
13 | 13 | va_list _vl; \ |
14 | 14 | va_start(_vl, callInfo); \ |
15 | 15 | Js::Var* va = (Js::Var*)_vl |
| 16 | +#elif defined(_ARM64_) && defined(__linux__) |
| 17 | +// AAPCS64 (Linux ARM64 ABI) reference: |
| 18 | +// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#appendix-variable-argument-lists |
| 19 | +#define DECLARE_ARGS_VARARRAY(va, ...) \ |
| 20 | + va_list _vl; \ |
| 21 | + va_start(_vl, callInfo); \ |
| 22 | + Js::Var* va = (Js::Var*)_vl.__stack + 2; \ |
| 23 | + Assert(*reinterpret_cast<Js::CallInfo*>(va - 1) == callInfo) |
16 | 24 | #else |
17 | 25 | // We use a custom calling convention to invoke JavascriptMethod based on |
18 | 26 | // System ABI. At entry of JavascriptMethod the stack layout is: |
@@ -84,8 +92,19 @@ inline int _count_args(const T1&, const T2&, const T3&, const T4&, const T5&, Js |
84 | 92 | #define CALL_ENTRYPOINT_NOASSERT(entryPoint, function, callInfo, ...) \ |
85 | 93 | entryPoint(function, callInfo, ##__VA_ARGS__) |
86 | 94 | #elif defined (_ARM64_) |
| 95 | +#ifdef __linux__ |
| 96 | +// Linux ARM64 uses AAPCS64: first 8 args in x0-x7, rest via stack. |
| 97 | +// Fill x2-x7 with nulls here to force the expected stack layout: |
| 98 | +// [RetAddr] [function] [callInfo] [args...] |
| 99 | +#define CALL_ENTRYPOINT_NOASSERT(entryPoint, function, callInfo, ...) \ |
| 100 | + entryPoint(function, callInfo, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, \ |
| 101 | + function, callInfo, ##__VA_ARGS__) |
| 102 | +#else |
| 103 | +// macOS has own bespoke vararg cc (DarwinPCS), varargs always passed via stack. |
| 104 | +// Duplicate function/callInfo so they are pushed onto stack as part of varargs. |
87 | 105 | #define CALL_ENTRYPOINT_NOASSERT(entryPoint, function, callInfo, ...) \ |
88 | 106 | entryPoint(function, callInfo, function, callInfo, ##__VA_ARGS__) |
| 107 | +#endif |
89 | 108 | #else |
90 | 109 | #error CALL_ENTRYPOINT_NOASSERT not yet implemented |
91 | 110 | #endif |
|
0 commit comments