登録して招待リンクを共有すると、動画再生報酬と紹介報酬を獲得できます。

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.
もっと見る