Codegen may allocate and then never use slots. Free up those slots
and rewrite bytecode to be smaller. The resulting bytecode will be
slightly faster, result in better inlining, and be somewhat normalized
for further optimizations.
Currently very simple hueristic, and not supported
on many functions that instatiate closures or load/set upvalues.
We also now, more than ever, need a slot-compaction routine to reduce
the number of slots used by functions.
The goal of optimize=0 is both fast compilation and perfect debug info.
We would like to do some simple optimizations but the possibility of
breaking symbol mappings prevents it.
Dead code elimination and value numbering may remove
closures and constants from a function def - remove these from our
constant and defs buffers to avoid keeping phantom references and
bloating marshalled function size.
This exposes the optimization level for a few reasons.
First, Local value numbering exposed some bad codegen. Playing with
optimiaztion level exposes this more easily.
When compiling dead code in a known unused scope, we
would generate code that tried to load invalid slots.
Make sure that unused code will still pass `janet_verify()` as
invalid code could trigger bad behavior in our optimizer or garbage
collector.
Since the code was proven dead, this would not trigger any runtime
behavior issues though.
Second, even trivial optimizations tend to break debug information. For
example, constant propogation will eliminated symbol mappings which can
be useful for debugging. By default, don't eliminate any symbol map
debug info.
However, we will likely need to gate some of these optimizations
behind a switch as they are beginning to destruct debug info. For
example, local value number maybe should be off by default or at the
very least turned off for named loads.
How about we resolve through the special host name "localhost." instead of assuming that the loopback interface is bound to 127.0.0.1 (which might not be the case, especially in FreeBSD jails)?
See RFC6761 for how "localhost." is treated, especially:
Name resolution APIs and libraries SHOULD recognize localhost
names as special and SHOULD always return the IP loopback address
for address queries and negative responses for all other query
types. Name resolution APIs SHOULD NOT send queries for
localhost names to their configured caching DNS server(s).
It was not removed along with the function definition.
Fixes: ec48673f7c ("Revert float interface")
References: 23e4ad4bd3 ("Add ... float getters for consistency")
Use AF_INET6 for creating windows sockets by default. AF_INET6 on
windows will by default create dual-mode sockets that will support both
address families.
Use old behavior if IPV6 support is disabled, though.
Thanks to Pietro Cerutti for the investigation here.
elimination to our bytecode compiler. Also iterate it to a fixpoint.
Last, add a total instruction counter during bootstrap so we can easily
see how many instructions are in the core library.
These simple passes were factored out of some more involved bytecode
optimization work as easy wins without much code.