1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 13:00:26 +02:00

64-bit intrinsic args and return values passed indirectly on 32-bit

* libguile/intrinsics.h (INDIRECT_INT64_INTRINSICS): New definition.  If
  true, int64 args and return values are passed by reference.  Here to
  make JIT easier.
* libguile/intrinsics.c (indirect_scm_to_int64, indirect_scm_to_uint64):
  (indirect_scm_to_uint64_truncate, indirect_scm_from_int64):
  (indirect_scm_from_uint64, indirect_lsh, indirect_rsh): New indirect
  variants.
  (scm_bootstrap_intrinsics): Use indirect variants as appropriate.
* libguile/vm-engine.c: Update to call indirect intrinsics if
  appropriate.
This commit is contained in:
Andy Wingo 2018-08-13 16:27:11 +02:00
parent d4abe8bbed
commit 0188bd3816
3 changed files with 113 additions and 10 deletions

View file

@ -1420,16 +1420,24 @@ VM_NAME (scm_thread *thread)
VM_DEFINE_OP (56, call_u64_from_scm, "call-u64<-scm", DOP2 (X8_S12_S12, C32))
{
uint16_t dst, src;
uint64_t res;
scm_t_u64_from_scm_intrinsic intrinsic;
UNPACK_12_12 (op, dst, src);
intrinsic = intrinsics[ip[1]];
SYNC_IP ();
res = intrinsic (SP_REF (src));
CACHE_SP ();
SP_SET_U64 (dst, res);
#if INDIRECT_INT64_INTRINSICS
intrinsic (& SP_REF_U64 (dst), SP_REF (src));
#else
{
uint64_t res = intrinsic (SP_REF (src));
SP_SET_U64 (dst, res);
}
#endif
/* No CACHE_SP () after the intrinsic, as the indirect variants
have an out argument that points at the stack; stack relocation
during this kind of intrinsic is not supported! */
NEXT (2);
}
@ -1677,16 +1685,24 @@ VM_NAME (scm_thread *thread)
VM_DEFINE_OP (77, call_s64_from_scm, "call-s64<-scm", DOP2 (X8_S12_S12, C32))
{
uint16_t dst, src;
int64_t res;
scm_t_s64_from_scm_intrinsic intrinsic;
UNPACK_12_12 (op, dst, src);
intrinsic = intrinsics[ip[1]];
SYNC_IP ();
res = intrinsic (SP_REF (src));
CACHE_SP ();
SP_SET_S64 (dst, res);
#if INDIRECT_INT64_INTRINSICS
intrinsic (& SP_REF_S64 (dst), SP_REF (src));
#else
{
int64_t res = intrinsic (SP_REF (src));
SP_SET_S64 (dst, res);
}
#endif
/* No CACHE_SP () after the intrinsic, as the indirect variants
have an out argument that points at the stack; stack relocation
during this kind of intrinsic is not supported! */
NEXT (2);
}
@ -1701,10 +1717,17 @@ VM_NAME (scm_thread *thread)
intrinsic = intrinsics[ip[1]];
SYNC_IP ();
#if INDIRECT_INT64_INTRINSICS
res = intrinsic (& SP_REF_U64 (src));
#else
res = intrinsic (SP_REF_U64 (src));
CACHE_SP ();
#endif
SP_SET (dst, res);
/* No CACHE_SP () after the intrinsic, as the indirect variants
pass stack pointers directly; stack relocation during this kind
of intrinsic is not supported! */
NEXT (2);
}
@ -1718,7 +1741,11 @@ VM_NAME (scm_thread *thread)
intrinsic = intrinsics[ip[1]];
SYNC_IP ();
#if INDIRECT_INT64_INTRINSICS
res = intrinsic (& SP_REF_S64 (src));
#else
res = intrinsic (SP_REF_S64 (src));
#endif
CACHE_SP ();
SP_SET (dst, res);
@ -1872,7 +1899,11 @@ VM_NAME (scm_thread *thread)
intrinsic = intrinsics[ip[1]];
SYNC_IP ();
#if INDIRECT_INT64_INTRINSICS
res = intrinsic (SP_REF (a), & SP_REF_U64 (b));
#else
res = intrinsic (SP_REF (a), SP_REF_U64 (b));
#endif
CACHE_SP ();
SP_SET (dst, res);