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.
* Fix a couple of imprecisions in the file/ docs
The `+` flag to `(file/open)` was incorrectly documented as being for
appending. Instead, this allows to read to files opened with `:w` or
`:a`, and to write to files opened with `:r`. This is the same as the
`+` flag in `fopen(3)`.
The `(file/seek)` function was documented as having both `whence` and
`n` as optional arguments. It also didn't say what the default for `n`
was. Anyway, this doesn't make sense, as a default of `:cur` and `0`
would effectively make `(file/seek f)` a no-op. I also amended a test so
both `(file/seek f :set 0)` and `(file/seek f :set)` are covered and
checked to move to the beginning of the file.
* Remove useless check for argc >= 2
We already determined it is between 2 and 3 with `janet_arity(argc, 2, 3)`.
* Dump args in assertion
* Unroll loop in test
* Differentiate failure messages