Skip to content

Add a get_value operator to duplicate a value from the expression stack. #685

@ghost

Description

Would there be any immediate interest in adding an operator, say get_value, to duplicate a value from the expression stack?

With the post-order encoding there is already the issue that expression results accumulate in blocks to be discarded at the block exits. It seems consistent with the SSA decoder to allow re-use of these, so why not take advantage of them. Each of these could be viewed as binding a block local variable that could be accessed. So rather than block we could effective have let:

(let (($v1 (f64.load ...))
      ($v2 (i32.load ...))
      (_ (f64.store :offset 8 (get_value $v2) (get_value $v1)))
      (_ (f64.store :offset 16 (get_value $v2) (get_value $v1))))
  ;; The fall through result.
  (get_value $v1))

Adding this now might allow some experimentation with the tooling, to take advantage of this.

It's not necessary to land this change, and it can be explored in local work, and local tools can rewrite the wast into this encoding, but might there happen to be any interesting in such an incremental change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions