Closed davazp closed 4 years ago
Right now, some words like again produces IR components that are unreachable
again
https://github.com/ams-hackers/gbforth/blob/ad56fcac4e1f77d5edf7efb74ac3577ef1542f28/src/compiler/cross.fs#L221
That is to say, an IR component is created, code is emitted to it, but it will never be actually emitted, as no other IR component references it.
For example,
: f begin ." hello" again drop ;
the last drop will never be executed.
drop
The problem is that IR components are released by traversing the graph of IRs. Being unreachable means that they will never be released.
This can be solved by having a special value or special IR where all unreachable code can be emitted and ensuring that this is released at some point.
A warning could also be emitted if some code is compiled into the unreachable IR.
Right now, some words like
again
produces IR components that are unreachablehttps://github.com/ams-hackers/gbforth/blob/ad56fcac4e1f77d5edf7efb74ac3577ef1542f28/src/compiler/cross.fs#L221
That is to say, an IR component is created, code is emitted to it, but it will never be actually emitted, as no other IR component references it.
For example,
the last
drop
will never be executed.The problem is that IR components are released by traversing the graph of IRs. Being unreachable means that they will never be released.
This can be solved by having a special value or special IR where all unreachable code can be emitted and ensuring that this is released at some point.
A warning could also be emitted if some code is compiled into the unreachable IR.