Skip to content

Commit

Permalink
Showing 3 changed files with 29 additions and 15 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/ThreadPollInstr.java
Original file line number Diff line number Diff line change
@@ -2,8 +2,14 @@

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.interpreter.Profiler;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class ThreadPollInstr extends Instr implements FixedArityInstr {
public final boolean onBackEdge;
@@ -29,4 +35,11 @@ public Instr clone(CloneInfo ii) {
public void visit(IRVisitor visitor) {
visitor.ThreadPollInstr(this);
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (IRRuntimeHelpers.inProfileMode()) Profiler.clockTick();
context.callThreadPoll();
return null;
}
}
16 changes: 16 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/TraceInstr.java
Original file line number Diff line number Diff line change
@@ -2,7 +2,11 @@

import org.jruby.ir.Operation;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.RubyEvent;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

// FIXME: When presistence is revisited this should strip these out of code streams on save and add them in if
// tracing is on for load.
@@ -49,4 +53,16 @@ public int getLinenumber() {
public String[] toStringNonOperandArgs() {
return new String[] {"ev: " + event, "name: " + name, "file: " + filename, "line: " + linenumber};
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (context.runtime.hasEventHooks()) {
// FIXME: Try and statically generate END linenumber instead of hacking it.
int linenumber = getLinenumber() == -1 ? context.getLine()+1 : getLinenumber();

context.trace(getEvent(), getName(), context.getFrameKlazz(), getFilename(), linenumber);
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -194,21 +194,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
setResult(temp, currDynScope, gfi.getResult(), result);
break;
}
case TRACE: {
if (context.runtime.hasEventHooks()) {
TraceInstr trace = (TraceInstr) instr;
// FIXME: Try and statically generate END linenumber instead of hacking it.
int linenumber = trace.getLinenumber() == -1 ? context.getLine()+1 : trace.getLinenumber();

context.trace(trace.getEvent(), trace.getName(), context.getFrameKlazz(),
trace.getFilename(), linenumber);
}
break;
}
case THREAD_POLL:
if (IRRuntimeHelpers.inProfileMode()) Profiler.clockTick();
context.callThreadPoll();
break;
default:
if (instr.getOperation().opClass == OpClass.BRANCH_OP) {
ipc = instr.interpretAndGetNewIPC(context, currDynScope, currScope, self, temp, ipc);

0 comments on commit 730c677

Please sign in to comment.