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

TruffleDSL Specialization causes broken code generation (related to not operator use , "!") #198

Closed
smarr opened this issue Aug 9, 2016 · 3 comments

Comments

@smarr
Copy link
Contributor

smarr commented Aug 9, 2016

The following node definition causes the DSL to generated invalid code:

public abstract class BreakpointNode extends Node {

  public abstract boolean executeCheckIsSetAndEnabled();

  protected BreakpointInfo getBreakpointStatus() {
    return null;
  }

  @Specialization(guards = "!info.hasBreakpoint")
  public boolean noBreakpoint(@Cached("getBreakpointStatus()") final BreakpointInfo info) {
    return false;
  }

  @Specialization(guards = {"info.hasBreakpoint", "!info.breakpoint.isEnabled()"})
  public boolean breakpointDisabled(@Cached("getBreakpointStatus()") final BreakpointInfo info) {
    return false;
  }
}

Specifically, this generates the following createNext(.) method:

        @Override
        protected final SpecializationNode createNext(Frame frameValue) {
            BreakpointInfo info1 = (root.getBreakpointStatus());
            if ((!(info1.hasBreakpoint))) {
                return NoBreakpointNode_.create(root, info1);
            }
            BreakpointInfo info2 = (root.getBreakpointStatus()); else if ((!(info2.breakpoint.isEnabled()))) {
                return BreakpointDisabledNode_.create(root, info2);
            }
            return null;
        }
@chumer
Copy link
Member

chumer commented Aug 9, 2016

This issue is a known issue. its fixed in the new layout, so I don't really want to fix it anymore.
You can workaround it by not using the ! operator.

@chumer
Copy link
Member

chumer commented Aug 9, 2016

public abstract class BreakpointNode extends Node {

  public abstract boolean executeCheckIsSetAndEnabled();

  protected BreakpointInfo getBreakpointStatus() {
    return null;
  }

  @Specialization(guards = "not(info.hasBreakpoint)")
  public boolean noBreakpoint(@Cached("getBreakpointStatus()") final BreakpointInfo info) {
    return false;
  }

  @Specialization(guards = {"info.hasBreakpoint", "!info.breakpoint.isEnabled()"})
  public boolean breakpointDisabled(@Cached("getBreakpointStatus()") final BreakpointInfo info) {
    return false;
  }
  public static boolean not(boolean value) {return !value;}

@smarr
Copy link
Contributor Author

smarr commented Aug 9, 2016

Ah, good, thanks for the work around!

Will close the issue.

@smarr smarr closed this as completed Aug 9, 2016
@smarr smarr changed the title TruffleDSL Specialization causes broken code generation TruffleDSL Specialization causes broken code generation (related to not operator use , "!") Aug 9, 2016
dougxc pushed a commit that referenced this issue Sep 14, 2016
… master

* commit 'ac3e429934fea3089cb97271c16e94b92eaf53a7':
  Improve the error message when giving an incorrect number of arguments to a DynamicObjectFactory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants