// We always have to spill registers xmm12-xmm15 which are callee-save // in managed ABI but caller-save in native ABI.
constexpr size_t kMmxSpillSize = 8u;
constexpr size_t kAlwaysSpilledMmxRegisters = 4;
// XMM0..XMM7 can be used to pass the first 8 floating args. The rest must go on the stack. // -- Managed and JNI calling conventions.
constexpr size_t kMaxFloatOrDoubleRegisterArguments = 8u; // Up to how many integer-like (pointers, objects, longs, int, short, bool, etc) args can be // enregistered. The rest of the args must go on the stack. // -- JNI calling convention only (Managed excludes RDI, so it's actually 5).
constexpr size_t kMaxIntLikeRegisterArguments = 6u;
// Get the size of the arguments for a native call. inline size_t GetNativeOutArgsSize(size_t num_fp_args, size_t num_non_fp_args) { // Account for FP arguments passed through Xmm0..Xmm7.
size_t num_stack_fp_args =
num_fp_args - std::min(kMaxFloatOrDoubleRegisterArguments, num_fp_args); // Account for other (integer) arguments passed through GPR (RDI, RSI, RDX, RCX, R8, R9).
size_t num_stack_non_fp_args =
num_non_fp_args - std::min(kMaxIntLikeRegisterArguments, num_non_fp_args);
static_assert(kFramePointerSize == kMmxSpillSize); return (num_stack_fp_args + num_stack_non_fp_args) * kFramePointerSize;
}
// Get stack args size for @CriticalNative method calls. inline size_t GetCriticalNativeCallArgsSize(std::string_view shorty) {
size_t num_fp_args =
std::count_if(shorty.begin() + 1, shorty.end(), [](char c) { return c == 'F' || c == 'D'; });
size_t num_non_fp_args = shorty.length() - 1u - num_fp_args;
// Get the frame size for @CriticalNative method stub. // This must match the size of the frame emitted by the JNI compiler at the native call site. inline size_t GetCriticalNativeStubFrameSize(std::string_view shorty) { // The size of outgoing arguments.
size_t size = GetCriticalNativeCallArgsSize(shorty);
// We always need to spill xmm12-xmm15 as they are managed callee-saves // but not native callee-saves.
size += kAlwaysSpilledMmxRegisters * kMmxSpillSize; // Add return address size.
size += kFramePointerSize;
return RoundUp(size, kNativeStackAlignment);
}
// Get the frame size for direct call to a @CriticalNative method. // This must match the size of the extra frame emitted by the compiler at the native call site. inline size_t GetCriticalNativeDirectCallFrameSize(std::string_view shorty) { // The size of outgoing arguments.
size_t size = GetCriticalNativeCallArgsSize(shorty);
// No return PC to save, zero- and sign-extension are handled by the caller. return RoundUp(size, kNativeStackAlignment);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.