mamcx 12 minutes ago

Question: For what else (apart from assembler) this could be a good idea?

I think WASM, but could be for a custom byte code? and more importantly, for a set of host-native functions (like I make some rust functions that somehow exploit this idea?)

anon-3988 an hour ago

This blog goes from 0 to 100 really, really quickly. I have no idea what I am looking. I suppose it is not meant for beginners but it claims to be a tutorial.

weinzierl 8 hours ago

I think this technique also lies at the heart of the Cranelift project.

https://cranelift.dev/

  • aw1621107 6 hours ago

    IIRC Cranelift doesn't use copy-and-patch. It uses e-graphs [0] as part of its optimization pipeline, though.

    Closest thing in (relatively) recent news that uses copy-and-patch I can think of is CPython's new JIT.

    [0]: https://github.com/bytecodealliance/rfcs/pull/27

    • weinzierl 6 hours ago

      My understanding is that e-graphs take care of selecting the best patch (by examining many options in parallel) but fundamentally it is still copy-and-patch.

      • aw1621107 5 hours ago

        Could you elaborate more on "fundamentally it is still copy-and-patch"? From what I can recall when I had first read about copy-and-patch a not-uncommon comparison was against Cranelift, which to me would imply that different approaches were taken. I don't recall any discussion about Cranelift's use of the technique, either, so your claim that it's at the heart of Cranelift is new information to me. Has Cranelift adopted copy-and-patch (maybe for a specific compilation stage?) in the meantime?