:) Just a few minor comments:
It's better to keep the code for strings and bytes in sync, so an
"easy" project is to add the equivalents optimizations for strings.
("easy" because I think that using this as a template, there won't be
any surprise.)
The problem with string/bytes is that too many interesting functions
return a string/bytes, and it's painful to add them to
rator_implies_predicate (
https://github.com/racket/racket/blob/cf70c4a24168643f8871d655f1700a813d68a28e/racket/src/racket/src/optimize.c#L2563
) because they are compared to a global variable that most of the time
has to be created. But I think it should not be a problem to compare
them by name. (I actually prefer the comparison that use the global,
but the other method is used many times.)
With a small variation of the code that changes bytes-length to
unsafe-bytes-length (
https://github.com/racket/racket/blob/cf70c4a24168643f8871d655f1700a813d68a28e/racket/src/racket/src/optimize.c#L3730
), it's possible to add a check of the type of the variable and save
the type for later. Just use NULL as the unsafe replacement. There are
a lot of interesting functions here again.
Gustavo
On Tue, Apr 5, 2016 at 4:53 PM, Jay McCarthy <[email protected]> wrote:
> After the Inside Racket Seminar with Matthew [1], I was struck by how
> easy it looked to add transformations to the optimizer to turn safe
> calls into the unsafe calls if they are already protected by a
> predicate.
>
> So, I made a really small commit that demonstrates this cf70c4a241.
> Please look at it on Github. The commit adds a simple transform of
> bytes-length to unsafe-bytes-length on (a) literal bytes and (b)
> identifiers previously checked by bytes?.
>
> The Github has comments about how each part works. This is in the
> commit, rather than the source, so as to not clutter it.
>
> Please try it yourself! It's super easy!
>
> Jay
>
> 1.
> https://github.com/racket/racket/wiki/Inside-Racket-Seminar-2.-Matthew-Flatt-on-Bytecode-Compiler
> 2.
> https://github.com/racket/racket/commit/cf70c4a24168643f8871d655f1700a813d68a28e
>
> --
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
>
> "Wherefore, be not weary in well-doing,
> for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
> - D&C 64:33
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/CAJYbDanguzVzhKHfA6jbYX42y_P_OTfj5A_7uwde7nQ5G%3Dd%2B6A%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/CAPaha9N6ZkfU9wmwt5eU9yMdDvgOLCmnq5yhok5EWP%3DAm-j6bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.