Skip to content

Flonums are not unboxed properly when passed to foreign procedures/ftypes #921

@williewillus

Description

@williewillus

I have this code to draw a ring using raylib: https://git.sr.ht/~williewillus/thdawn/tree/bb3ebf2b4b49d20b8fe235a6c1f5f23b8c88b0a8/item/main.ss#L1861

It's numeric all around, all the inputs are flonums besides texture (an ftype) and rgba (currently unused).
The raylib: calls are all foreign procedures that take floats, except again for set-texture which takes the texture ftype and reads a fixnum out of it to forward to a foreign procedure.

When I added calls to this code to my render loop, I was surprised to see allocation pressure increase pretty sharply, I was expecting pretty minimal allocation. I'm not actually sure if the allocation pressure is due to flonum ops not being boxed, or overhead with all of the foreign calls.

I'm not too proficient at reading the Chez assembly output, and I wasn't sure if flonum optimizations have improved since #248, so I thought I'd log this in case anyone spots something easy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions