diff options
Diffstat (limited to 'src/lj_ccall.c')
-rw-r--r-- | src/lj_ccall.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c index 499a01d8..5ac1b4da 100644 --- a/src/lj_ccall.c +++ b/src/lj_ccall.c | |||
@@ -391,7 +391,8 @@ | |||
391 | #define CCALL_HANDLE_GPR \ | 391 | #define CCALL_HANDLE_GPR \ |
392 | /* Try to pass argument in GPRs. */ \ | 392 | /* Try to pass argument in GPRs. */ \ |
393 | if (n > 1) { \ | 393 | if (n > 1) { \ |
394 | lua_assert(n == 2 || n == 4); /* int64_t or complex (float). */ \ | 394 | /* int64_t or complex (float). */ \ |
395 | lj_assertL(n == 2 || n == 4, "bad GPR size %d", n); \ | ||
395 | if (ctype_isinteger(d->info) || ctype_isfp(d->info)) \ | 396 | if (ctype_isinteger(d->info) || ctype_isfp(d->info)) \ |
396 | ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ | 397 | ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ |
397 | else if (ngpr + n > maxgpr) \ | 398 | else if (ngpr + n > maxgpr) \ |
@@ -642,7 +643,8 @@ static void ccall_classify_ct(CTState *cts, CType *ct, int *rcl, CTSize ofs) | |||
642 | ccall_classify_struct(cts, ct, rcl, ofs); | 643 | ccall_classify_struct(cts, ct, rcl, ofs); |
643 | } else { | 644 | } else { |
644 | int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; | 645 | int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; |
645 | lua_assert(ctype_hassize(ct->info)); | 646 | lj_assertCTS(ctype_hassize(ct->info), |
647 | "classify ctype %08x without size", ct->info); | ||
646 | if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ | 648 | if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ |
647 | rcl[(ofs >= 8)] |= cl; | 649 | rcl[(ofs >= 8)] |= cl; |
648 | } | 650 | } |
@@ -667,12 +669,13 @@ static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs) | |||
667 | } | 669 | } |
668 | 670 | ||
669 | /* Try to split up a small struct into registers. */ | 671 | /* Try to split up a small struct into registers. */ |
670 | static int ccall_struct_reg(CCallState *cc, GPRArg *dp, int *rcl) | 672 | static int ccall_struct_reg(CCallState *cc, CTState *cts, GPRArg *dp, int *rcl) |
671 | { | 673 | { |
672 | MSize ngpr = cc->ngpr, nfpr = cc->nfpr; | 674 | MSize ngpr = cc->ngpr, nfpr = cc->nfpr; |
673 | uint32_t i; | 675 | uint32_t i; |
676 | UNUSED(cts); | ||
674 | for (i = 0; i < 2; i++) { | 677 | for (i = 0; i < 2; i++) { |
675 | lua_assert(!(rcl[i] & CCALL_RCL_MEM)); | 678 | lj_assertCTS(!(rcl[i] & CCALL_RCL_MEM), "pass mem struct in reg"); |
676 | if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ | 679 | if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ |
677 | if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ | 680 | if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ |
678 | cc->gpr[ngpr++] = dp[i]; | 681 | cc->gpr[ngpr++] = dp[i]; |
@@ -693,7 +696,8 @@ static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, | |||
693 | dp[0] = dp[1] = 0; | 696 | dp[0] = dp[1] = 0; |
694 | /* Convert to temp. struct. */ | 697 | /* Convert to temp. struct. */ |
695 | lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); | 698 | lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); |
696 | if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ | 699 | if (ccall_struct_reg(cc, cts, dp, rcl)) { |
700 | /* Register overflow? Pass on stack. */ | ||
697 | MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; | 701 | MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; |
698 | if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ | 702 | if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ |
699 | cc->nsp = nsp + n; | 703 | cc->nsp = nsp + n; |
@@ -990,7 +994,7 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, | |||
990 | if (fid) { /* Get argument type from field. */ | 994 | if (fid) { /* Get argument type from field. */ |
991 | CType *ctf = ctype_get(cts, fid); | 995 | CType *ctf = ctype_get(cts, fid); |
992 | fid = ctf->sib; | 996 | fid = ctf->sib; |
993 | lua_assert(ctype_isfield(ctf->info)); | 997 | lj_assertL(ctype_isfield(ctf->info), "field expected"); |
994 | did = ctype_cid(ctf->info); | 998 | did = ctype_cid(ctf->info); |
995 | } else { | 999 | } else { |
996 | if (!(ct->info & CTF_VARARG)) | 1000 | if (!(ct->info & CTF_VARARG)) |
@@ -1138,7 +1142,8 @@ static int ccall_get_results(lua_State *L, CTState *cts, CType *ct, | |||
1138 | CCALL_HANDLE_RET | 1142 | CCALL_HANDLE_RET |
1139 | #endif | 1143 | #endif |
1140 | /* No reference types end up here, so there's no need for the CTypeID. */ | 1144 | /* No reference types end up here, so there's no need for the CTypeID. */ |
1141 | lua_assert(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info))); | 1145 | lj_assertL(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info)), |
1146 | "unexpected reference ctype"); | ||
1142 | return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); | 1147 | return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); |
1143 | } | 1148 | } |
1144 | 1149 | ||