가입 후 초대 링크를 공유하면 동영상 재생 및 초대 보상을 받을 수 있습니다.

Ryan Lopopolo
@_lopopolo
Principal Engineer, Agentic GCP @googlecloud • prev @OpenAI • Building the future of work. Harness engineering. As an agent influencer, • opinions mine
가입 January 2022
1.2K 팔로잉 중    10.8K 팬
So in order to get Fiber yields across native frames working (for example, inside Integer#times#) without using ASM and respecting that Artichoke is meant to be embeddable, Ruby frames are actually interpreter heap data; this allows Fiber stack and subsequent locals to be collected like any other heap objects during GC. In Artichoke’s VM, the Ruby stack is just a Vec; Fiber parking splits frames off from that Vec and stashes them; Fiber resumption reattaches them. But Artichoke’s “Ruby semantic layer” (how to do implicit conversions, delegate to blocks, map to specific exceptions, etc) is written in Rust; they are native frames so we can’t do the split off from the VM stack trick. So, like code is free. So using a nightly Rust compiler, we can extract the MIR for the Ruby semantic layer and lower it into Artichoke’s IR and literally execute Rust code as if it were Ruby. Artichoke’s data structures are pure Rust and never call back into Ruby, so once the semantic layer bottoms out at native code, the VM invokes a native Rust routine and we bottom out. Combined with Artichoke’s Ruby semantic layer also providing specialized routines when operands are known or blocks are not passed, this permits the VM to optimize across native calls. 6 * 5 + 4 is able to avoid any intermediate Ruby value boxing and directly do a multiplication and an add (but actually this would just get folded to a constant). Pretty fuckin’ rad. It is as they say, simply a matter of tokens. About 75% of these native Rust routines lower and link today.
더 보기