Permalink
Switch branches/tags
Commits on May 26, 2017
  1. Switch to binary mode before passing precomp to VM

    We have used char mode I/O to .get various things from the start of
    the file. This means some bytes will be hanging around in the decode
    stream. Switch the handle to binary mode, which will seek the file
    handle to the right place.
    jnthn committed with zoffixznet May 25, 2017
  2. Re-implement change of IO::Handle encoding.

    Allowing a type object to be passed to indicate "no encoding", and
    making an argument of 'bin' translate into that.
    
    The most common use for this is a switch of encoding prior to doing
    any I/O, but when passing it at `open` time is not an option. For all
    other cases, we try to cope. Binary mode to having an encoding is the
    straightforward case. Char mode to binary mode needs to "un-read" any
    content in the decode buffer, and for now will only be allowed on a
    handle that supports `seek`. Char mode to char mode with a different
    encoding takes the bytes unused by the previous decoder and gives them
    to the new one. In both of these cases, it's only generally safe to do
    this after a control character (like a newline), otherwise bytes may
    be hanging around inside of decode/normalization buffers if switching
    away from, say, UTF-8. (This is not a change of behavior; in fact, we
    allow *more* than we used to, given we get a couple of newly passing
    tests.)
    jnthn committed with zoffixznet May 25, 2017
  3. In char mode, make read go via. streaming decoder.

    To facilitate mixed char/binary mode I/O (with the usual caveats that
    one must be aware of things like normalization buffering, which isn't
    anything new). In binary mode, we fast-path it directly to the binary
    I/O, which is an optimization over what happens in MoarVM today.
    jnthn committed with zoffixznet May 25, 2017
  4. Fill out more of VMBackedDecoder.

    jnthn committed with zoffixznet May 25, 2017
  5. Re-work slurp[-rest] to use the streaming decoder.

    Introduces a temporary regression in one test file until .encoding is
    sorted out.
    jnthn committed with zoffixznet May 24, 2017
  6. Start to refactor IO::Handle encoding/bin mode.

    This introduces a $!decoder attribute to IO::Handle. The presence of
    this is now used internally to determine if the handle is in binary
    mode. The $.encoding attribute is now a `Str` rather than a `str`,
    and will be the Str type object in the case where the file is in
    binary mode.
    
    It is now an error to pass both :bin and :enc to `open`. It is also
    an error to do char-level operations on a handle opened in binary
    mode (we do support mixed binary/Str operations, provided you know
    and understand the caveats, but then the file must be opened in
    normal/character mode in order to do that; this is because it needs
    extra bookkeeping that we can skip in binary mode). Some places set
    a default utf-8 encoding in their signatures, and so triggered the
    new sanity check when passing those along to `open`; they now just
    pass an undefined `$enc` in that case, which also concentrates the
    choice of that default better in IO::Handle. There remain further
    places that we might wish to remove `= 'utf-8'` also; these ones
    removed were those that caused breakage.
    
    Along the way, the setup of IO::Pipe objects in Proc was refactored
    to eliminate various bits of poking into IO::Handle internals from
    Proc, and this happily also reduced duplicated setup code.
    jnthn committed with zoffixznet May 24, 2017
  7. Eliminate nqp::printfh use in IO::Handle.

    It goes away in favor of explicit calls to .encode and then calling
    nqp::writefh. This is, without further optimization effort, probably
    a slowdown, having glanced Str.encode. It's not enough to make any
    difference to spectest time, however, so it's likely not all that
    dramatic. This does regress one spectest, which seems to be trying
    to do string I/O with the encoding 'bin'.
    jnthn committed with zoffixznet May 23, 2017
  8. Simplify some forms of print/put/say.

    These cases all do some computation (evaluating a format or looping)
    to produce the string to output. Also have various forms produce a
    single concatenated string rather than making multiple calls down to
    the I/O layer. This will avoid multiple calls to the encoder.
    jnthn committed with zoffixznet May 23, 2017
  9. Use R:Q.MIX-IS-SUBSET

    So we don't need to coerce Bag(|Hash) to Mix anymore for (<=) and
    friends.
    lizmat committed with zoffixznet May 24, 2017
  10. Abstract Mix (<=) Mix logic into R:Q.MIX-IS-SUBSET

    Since all Baggy's share the same internal structure, we can
    actually use this logic for Bag(|Hash) (<=) Mix(|Hash) and
    Mix(|Hash) (<=) Bag(|Hash) as well.
    lizmat committed with zoffixznet May 24, 2017
  11. Use R:Q.SET-IN-SUBSET

    So we don't need to coerce QuantHash to Set anymore for (<=) and
    friends.
    lizmat committed with zoffixznet May 24, 2017
  12. Abstract Set (<=) Set logic into R:Q.SET-IN-SUBSET

    Since all Quanthashes share the same internal structure, we can
    actually use this logic for QuantHash (<=) Set and Set (<=) QuantHash
    as well.
    lizmat committed with zoffixznet May 24, 2017
  13. (>=) and (>) don't need to be multi's

    All handling is done by the (<=) and (<) ops respectively
    lizmat committed with zoffixznet May 24, 2017
  14. Don't use the generated !(<=) and !(<) ops

    We don't need them, we simple need a negation at the end.
    lizmat committed with zoffixznet May 24, 2017
  15. Remove useless code

    zoffixznet committed May 24, 2017
  16. Fix typo in error message

    zoffixznet committed May 24, 2017
  17. Fix inconsistency in .Int on zero-denominator rats

    In 0/0 and 1/0 cases we `fail` but in `-1/0` case we ended up
    throwing, because the path goes through .ceiling rather than
    .floor.
    
    Fix by detecting zero-denominator rats right in the .Int
    - Always `fail`
    - Improve the Failure's exception by including details that
        the division by zero happened during Rational -> Int coersion.
    zoffixznet committed May 24, 2017
  18. Add $.details to X::Numeric::DivideByZero

    We don't always end up dividing by zero in user's code, so the
    "using..." bit isn't always appropriate.
    
    Add $.details attribute that will allow us to specify details on
    why the divide by zero happened
    zoffixznet committed May 24, 2017
  19. Re-allow Inf as an argument to .recv.

    This got broken in recent refactoring, and the module ecosytem was
    relying on it.
    jnthn committed with zoffixznet May 24, 2017
  20. Add testing of (<=) and friends

    lizmat committed with zoffixznet May 24, 2017
  21. Make sure we handle Any (elem) Map:D correctly

    This can only work if the Map:D is actually an object hash, since
    it can only work on normal hashes if the Any is a Str:D, and that
    case is already handled in a separate candidate.
    
    Fixes a regression caused by e65800a
    lizmat committed with zoffixznet May 24, 2017
  22. Make Str:D (elem) Map:D 1.3x faster

    By using nqp::p6bool() rather than badly jitting .Bool
    lizmat committed with zoffixznet May 24, 2017
  23. Make Any (elem) Iterable:D between 1.3x and 110x faster

    - based on a 1000 elem array
    - 1.3x faster if matched on last array element or no match
    - 110x faster if matched on first array element
    - gain caused by not needing to coerce to Set, but check on the fly
    lizmat committed with zoffixznet May 24, 2017