Skip to content

Commit

Permalink
[Truffle] Simplify the trace node and remove the abstraction of the w…
Browse files Browse the repository at this point in the history
…rapper node.
  • Loading branch information
chrisseaton committed Jan 4, 2015
1 parent ef7826e commit b1e646a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 642 deletions.
56 changes: 24 additions & 32 deletions core/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
Expand All @@ -13,19 +13,21 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrument.KillException;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.core.*;

public class TraceNode extends WrapperNode {
public class TraceNode extends RubyNode {

private final RubyContext context;
@Child protected RubyNode child;

@CompilerDirectives.CompilationFinal private Assumption traceAssumption;
@CompilerDirectives.CompilationFinal private RubyProc traceFunc;
Expand All @@ -36,7 +38,8 @@ public class TraceNode extends WrapperNode {
private final int line;

public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection, child);
super(context, sourceSection);
this.child = child;
this.context = context;
traceAssumption = context.getTraceManager().getTraceAssumption();
traceFunc = null;
Expand All @@ -47,7 +50,19 @@ public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode chil
}

@Override
public void enter(VirtualFrame frame) {
public Object execute(VirtualFrame frame) {
trace(frame);
return child.execute(frame);
}


@Override
public void executeVoid(VirtualFrame frame) {
trace(frame);
child.executeVoid(frame);
}

public void trace(VirtualFrame frame) {
try {
traceAssumption.check();
} catch (InvalidAssumptionException e) {
Expand Down Expand Up @@ -84,30 +99,7 @@ public void enter(VirtualFrame frame) {
}

@Override
void leave(VirtualFrame frame) {
}

@Override
void leave(VirtualFrame frame, boolean result) {
}

@Override
void leave(VirtualFrame frame, int result) {
}

@Override
void leave(VirtualFrame frame, long result) {
}

@Override
void leave(VirtualFrame frame, double result) {
}

@Override
void leave(VirtualFrame frame, Object result) {
}

@Override
void leaveExceptional(VirtualFrame frame, Exception e) {
public Object isDefined(VirtualFrame frame) {
return child.isDefined(frame);
}
}
Loading

0 comments on commit b1e646a

Please sign in to comment.