Live data from Hacker News

Copy-and-Patch: A Copy-and-Patch Tutorial

transactional.blog

21–22 of 22 posts

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#21
This is really interesting, and I'm surprised that I had never looked at JIT compiling as self-modifying code (SMC). Also that I had never heard of copy-and-patch.

There are whole classes of problems that can be more easily solved with SMC. That's part of what got me into FPGAs back in the 90s, before I abandoned them due to their lack of exponential growth and proprietary placement and routing tools.

This could have implications for faster in-app scripting like in games. Also for building more powerful shaders. I wonder if there are analogs of the article's mprotect(ret, 256, PROT_READ | PROT_EXEC) calls for GPUs.

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#22
post #10

Earlier quoted context omitted.

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 ado…

Indeed, the original copy-and-patch paper explicitly compares against Cranelift: https://fredrikbk.com/publications/copy-and-patch.pdf

But not that is conceptually related, only that the copy-and-patch is faster than cranelift in that particular scenario.
Post reply on HN