เพิ่งรู้ว่า WebAssembly ไม่ได้ใช้ call stack
ตอนแรกเข้าใจว่า WebAssembly น่าจะมี stack frames เหมือนกับ stack-based machines แบบอื่น แต่จริงๆ wasm ใช้วิธีการสร้าง control flow graph บวกกับใช้ operand stack แทน
ความน่าสนใจคือ การออกแบบแบบนี้มันก็มีข้อจำกัดอยู่เหมือนกัน คือมันจะไม่รองรับ "Irreducible control flow" แปลว่าเราต้องสามารถ map การทำงานของโปรแกรมมาเป็น control flow graph ให้ได้
"Can partition all edges into “forward” and “backward” sets, such that forward edges form a rooted DAG, and for all backward edges (A,B), node B dominates node A."
เมื่อวานคิดว่ากะจะทำโปรเจค From Opcodes to Algorithms เอามันส์ แต่แค่วันเดียวรู้สึกเข้าใจอะไรขึ้นพอสมควร ตั้งแต่เรื่อง register versus stack machines, call stack versus operand stack รู้สึกว่ามันมีการตัดสินใจเยอะพอสมควรในการสร้าง VM
Part of the From Opcodes to Algorithms daily write-up. Original post on FB.