fix compiler bug related to lifting and unbox flonums
As variables are dropped for lifted functions, the bitmap for flonum closure variables was not shifted down by the number of dropped variables. Closes PR 12259
This commit is contained in:
parent
58fbc20294
commit
7680adf486
|
@ -111,12 +111,15 @@
|
|||
(case (check-bit i)
|
||||
[(0) 'val]
|
||||
[(1) 'ref]
|
||||
[(2) 'flonum])))]
|
||||
[(2) 'flonum]
|
||||
[else (error "both 'ref and 'flonum argument?")])))]
|
||||
[(closure-types) (for/list ([i (in-range closure-size)]
|
||||
[j (in-naturals num-params)])
|
||||
(case (check-bit j)
|
||||
[(0) 'val/ref]
|
||||
[(2) 'flonum]))])
|
||||
[(1) (error "invalid 'ref closure variable")]
|
||||
[(2) 'flonum]
|
||||
[else (error "both 'ref and 'flonum closure var?")]))])
|
||||
(make-lam name
|
||||
(append
|
||||
(if (zero? (bitwise-and flags flags CLOS_PRESERVES_MARKS)) null '(preserves-marks))
|
||||
|
|
|
@ -672,6 +672,16 @@ static Scheme_Object *write_compiled_closure(Scheme_Object *obj)
|
|||
svec_size = data->closure_size;
|
||||
if (SCHEME_CLOSURE_DATA_FLAGS(data) & CLOS_HAS_TYPED_ARGS) {
|
||||
svec_size += ((2 * (data->num_params + data->closure_size)) + BITS_PER_MZSHORT - 1) / BITS_PER_MZSHORT;
|
||||
{
|
||||
int k, mv;
|
||||
for (k = data->num_params + data->closure_size; --k; ) {
|
||||
mv = ((data->closure_map[data->closure_size + ((2 * k) / BITS_PER_MZSHORT)]
|
||||
>> ((2 * k) % BITS_PER_MZSHORT))
|
||||
& 0x3);
|
||||
if (mv == 0x3)
|
||||
scheme_signal_error("internal error: inconsistent closure/argument type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SCHEME_RPAIRP(data->code)) {
|
||||
|
|
|
@ -1927,6 +1927,13 @@ resolve_closure_compilation(Scheme_Object *_data, Resolve_Info *info,
|
|||
offset++;
|
||||
}
|
||||
|
||||
if (!convert && !just_compute_lift && (offset < data->closure_size) && expanded_already) {
|
||||
/* shift boxmap down, since we're dropping closure elements */
|
||||
int bsz;
|
||||
bsz = boxmap_size(data->num_params + offset);
|
||||
memmove(closure_map + offset, closure_map + data->closure_size, sizeof(mzshort) * bsz);
|
||||
}
|
||||
|
||||
/* Reset closure_size, in case a lifted variable was removed: */
|
||||
closure_size = offset;
|
||||
if (!just_compute_lift) {
|
||||
|
@ -1959,7 +1966,7 @@ resolve_closure_compilation(Scheme_Object *_data, Resolve_Info *info,
|
|||
? SCHEME_INFO_FLONUM_ARG
|
||||
: 0)),
|
||||
NULL);
|
||||
if (cl->flonum_map && cl->flonum_map[i])
|
||||
if (cl->flonum_map && cl->flonum_map[i] && !just_compute_lift)
|
||||
boxmap_set(closure_map, i + convert_size, 2, closure_size);
|
||||
}
|
||||
if (expanded_already && !just_compute_lift)
|
||||
|
|
Loading…
Reference in New Issue
Block a user