Skip to content

Commit 730c677

Browse files
committed
Make Trace and ThreadPoll have their own interpret methods.
These are both rarely encountered in scope bodies so it would be nice to remove an explicit impl from the in the body interpreter.
1 parent eadb23f commit 730c677

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

core/src/main/java/org/jruby/ir/instructions/ThreadPollInstr.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
import org.jruby.ir.IRVisitor;
44
import org.jruby.ir.Operation;
5+
import org.jruby.ir.interpreter.Profiler;
6+
import org.jruby.ir.runtime.IRRuntimeHelpers;
57
import org.jruby.ir.transformations.inlining.CloneInfo;
68
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
9+
import org.jruby.parser.StaticScope;
10+
import org.jruby.runtime.DynamicScope;
11+
import org.jruby.runtime.ThreadContext;
12+
import org.jruby.runtime.builtin.IRubyObject;
713

814
public class ThreadPollInstr extends Instr implements FixedArityInstr {
915
public final boolean onBackEdge;
@@ -29,4 +35,11 @@ public Instr clone(CloneInfo ii) {
2935
public void visit(IRVisitor visitor) {
3036
visitor.ThreadPollInstr(this);
3137
}
38+
39+
@Override
40+
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
41+
if (IRRuntimeHelpers.inProfileMode()) Profiler.clockTick();
42+
context.callThreadPoll();
43+
return null;
44+
}
3245
}

core/src/main/java/org/jruby/ir/instructions/TraceInstr.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import org.jruby.ir.Operation;
44
import org.jruby.ir.transformations.inlining.CloneInfo;
5+
import org.jruby.parser.StaticScope;
6+
import org.jruby.runtime.DynamicScope;
57
import org.jruby.runtime.RubyEvent;
8+
import org.jruby.runtime.ThreadContext;
9+
import org.jruby.runtime.builtin.IRubyObject;
610

711
// FIXME: When presistence is revisited this should strip these out of code streams on save and add them in if
812
// tracing is on for load.
@@ -49,4 +53,16 @@ public int getLinenumber() {
4953
public String[] toStringNonOperandArgs() {
5054
return new String[] {"ev: " + event, "name: " + name, "file: " + filename, "line: " + linenumber};
5155
}
56+
57+
@Override
58+
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
59+
if (context.runtime.hasEventHooks()) {
60+
// FIXME: Try and statically generate END linenumber instead of hacking it.
61+
int linenumber = getLinenumber() == -1 ? context.getLine()+1 : getLinenumber();
62+
63+
context.trace(getEvent(), getName(), context.getFrameKlazz(), getFilename(), linenumber);
64+
}
65+
66+
return null;
67+
}
5268
}

core/src/main/java/org/jruby/ir/interpreter/BodyInterpreterEngine.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
194194
setResult(temp, currDynScope, gfi.getResult(), result);
195195
break;
196196
}
197-
case TRACE: {
198-
if (context.runtime.hasEventHooks()) {
199-
TraceInstr trace = (TraceInstr) instr;
200-
// FIXME: Try and statically generate END linenumber instead of hacking it.
201-
int linenumber = trace.getLinenumber() == -1 ? context.getLine()+1 : trace.getLinenumber();
202-
203-
context.trace(trace.getEvent(), trace.getName(), context.getFrameKlazz(),
204-
trace.getFilename(), linenumber);
205-
}
206-
break;
207-
}
208-
case THREAD_POLL:
209-
if (IRRuntimeHelpers.inProfileMode()) Profiler.clockTick();
210-
context.callThreadPoll();
211-
break;
212197
default:
213198
if (instr.getOperation().opClass == OpClass.BRANCH_OP) {
214199
ipc = instr.interpretAndGetNewIPC(context, currDynScope, currScope, self, temp, ipc);

0 commit comments

Comments
 (0)