Open shirok opened 1 month ago
Inlining globally bound one is addressed in https://github.com/shirok/Gauche/commit/ebcbd534b6ae9e28b4ae2cb2fc052eddfd32a6d1 .
However, locally bound one isn't optimized yet.
(define (foo x)
(define bar (getter-with-setter (^y (car y)) (^[y v] (set-car y v))))
...)
This is uncommon case, but a macro may produce this kind of local definition and it is better to be optimized.
Another, completely different approach that can solve both global and local binding cases.
$LAMBDA
node to hold setter information (setter's IForm).$LAMBDA
forms, the compiler emits code to attach setter to the resulting closure. In this case we don't need to copy the closure.getter-with-setter
that translates (getter-with-setter (lambda ...) <setter>)
into ($LAMBDA ... (setter <setter-iform>))
.
If we use
getter-with-setter
as follows:Foo
is fully inlined:But if we do this:
It doesn't:
It's because defining inlinable procedure involves two distinct operations; (1) inset a global binding with 'inlinable' flag, and (2) attach packed IForm to the procedure object, so that the later reference can replace procedure call to its body. With the second example, the compiler failed to do (2).