Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.jruby.internal.runtime.methods.TraceableJittedMethod Maven / Gradle / Ivy
package org.jruby.internal.runtime.methods;
import org.jruby.Ruby;
import org.jruby.RubyModule;
import org.jruby.ast.executable.Script;
import org.jruby.exceptions.JumpException;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.RubyEvent;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
public class TraceableJittedMethod extends DynamicMethod {
private final StaticScope staticScope;
private final Script jitCompiledScript;
private final ISourcePosition position;
private final Arity arity;
private final DefaultMethod realMethod;
public TraceableJittedMethod (RubyModule implementationClass, StaticScope staticScope, Script jitCompiledScript,
String name, CallConfiguration jitCallConfig, Visibility visibility, Arity arity, ISourcePosition position,
DefaultMethod realMethod) {
super (implementationClass, visibility, jitCallConfig, name);
this .position = position;
this .jitCompiledScript = jitCompiledScript;
this .staticScope = staticScope;
this .arity = arity;
this .realMethod = realMethod;
}
public StaticScope getStaticScope () {
return staticScope;
}
@Override
public DynamicMethod getRealMethod () {
return realMethod;
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, block, args.length);
return jitCompiledScript.__file__(context, self, args, block);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, Block.NULL_BLOCK, args.length);
return jitCompiledScript.__file__(context, self, args, Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime,context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, Block.NULL_BLOCK, 0 );
return jitCompiledScript.__file__(context, self, Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, block, 0 );
return jitCompiledScript.__file__(context, self, block);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, Block.NULL_BLOCK, 1 );
return jitCompiledScript.__file__(context, self, arg0, Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, block, 1 );
return jitCompiledScript.__file__(context, self, arg0, block);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, Block.NULL_BLOCK, 2 );
return jitCompiledScript.__file__(context, self, arg0, arg1, Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, block, 2 );
return jitCompiledScript.__file__(context, self, arg0, arg1, block);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, Block.NULL_BLOCK, 3 );
return jitCompiledScript.__file__(context, self, arg0, arg1, arg2, Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
@Override
public IRubyObject call (ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
Ruby runtime = context.runtime;
int callNumber = context.callNumber;
try {
pre(context, self, name, block, 3 );
return jitCompiledScript.__file__(context, self, arg0, arg1, arg2, block);
} catch (JumpException.ReturnJump rj) {
return handleReturn(context, rj, callNumber);
} catch (JumpException.RedoJump rj) {
return handleRedo(runtime);
} finally {
post(runtime, context, name);
}
}
protected void pre (ThreadContext context, IRubyObject self, String name, Block block, int argsLength) {
Ruby runtime = context.runtime;
callConfig.pre(context, self, getImplementationClass(), name, block, staticScope);
getArity().checkArity(runtime, argsLength);
if (runtime.hasEventHooks()) traceCall(context, runtime, name);
}
protected void post (Ruby runtime, ThreadContext context, String name) {
if (runtime.hasEventHooks()) traceReturn(context, runtime, name);
callConfig.post(context);
}
private void traceReturn (ThreadContext context, Ruby runtime, String name) {
runtime.callEventHooks(context, RubyEvent.RETURN, context.getFile(), context.getLine(), name, getImplementationClass());
}
private void traceCall (ThreadContext context, Ruby runtime, String name) {
runtime.callEventHooks(context, RubyEvent.CALL, position.getFile(), position.getStartLine(), name, getImplementationClass());
}
public ISourcePosition getPosition () {
return position;
}
@Override
public Arity getArity () {
return arity;
}
public DynamicMethod dup () {
return new TraceableJittedMethod(getImplementationClass(), staticScope, jitCompiledScript, name, callConfig, getVisibility(), arity, position, realMethod);
}
}