Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timing of expression evaluation in blocks #337

Merged
merged 5 commits into from
Oct 26, 2016
Merged

Commits on Oct 25, 2016

  1. Fix timing of expression evaluation in blocks

    This commit fixes a compiler bug where certain built-in syntaxes would
    re-evaluate its arguments when the block's assertion causes a re-entry
    into the append VM, instead of reusing the argument references that were
    created the first time.
    
    In practice, this is observable when a "stateful helper" is used as an
    argument to a syntax with an assertion (currently `#if`, `#unless`,
    `#with`, `#each`, `partial`, `InElementSyntax` and dynamic components).
    
    Because the argument references are created every time, any state stored
    on the original instance of the helper will be observably wiped away
    when used as an argument to an asserting block helper. Of course, it is
    also observable by comparing the JavaScript identity of the helper in
    question over time.
    
    This commit fixes the compiler bug by moving the evaluation of the
    expressions passed as arguments to the block syntaxes in question above
    the `Try` block, and capturing the relevant registers (args and operand,
    which store the results of evaluating the arguments) so they can be
    restored when the append VM is re-entered for the same block.
    Godhuda authored and chancancode committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    d2462a9 View commit details
    Browse the repository at this point in the history
  2. Move test opcode out of stored blocks

    The `condition` register is now saved and restored, like the operand
    and args registers.
    Godhuda authored and chancancode committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    6929e4e View commit details
    Browse the repository at this point in the history
  3. Improve {{partial}} implementation

    This commit:
    
    Switched partials to use the new opcode building style.
    
    Moved the evaluation of the test opcode, and the production of the
    condition register, outside of the block that could be re-entered. This
    means that when the expression passed to a {{partial expr}} becomes
    invalidated, we no longer generate a brand new reference for the
    to-boolean operation on the operand (which produces the condition).
    Godhuda authored and chancancode committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    8ed4599 View commit details
    Browse the repository at this point in the history
  4. Improve encapsulation of captured VM state

    Previously, the code that captured and restored VM state manually
    captured a few registers and manually restored them.
    
    This commit puts the Frame in charge of capturing and restoring, which
    means that if we want to capture more registers in the future, it will
    be easy to remember to update the restoring code at the same time.
    Godhuda authored and chancancode committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    540c9ff View commit details
    Browse the repository at this point in the history
  5. Fix lazy deopt to have the right captured state

    Now that we capture the conditional register, we have to also simulate
    that effect when we lazily deopt (since we are essentially doing an OSR)
    Godhuda authored and chancancode committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    1ed17a1 View commit details
    Browse the repository at this point in the history