Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding a common SourceInfo interface for CallSites

  • Loading branch information...
commit 1de4f0a06bfbcd06faabfd002610f10025ab7c1e 1 parent 6e3b651
@qmx qmx authored
View
2  src/org/jruby/runtime/invokedynamic/InvocationLinker.java
@@ -363,7 +363,7 @@ private static MethodHandle updateInvocationTarget(MethodHandle target, JRubyCal
} else {
// wipe out site with this new type and method
String bind = site.boundOnce() ? "rebind" : "bind";
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(name + "\ttriggered site #" + site.siteID() + " " + bind + " (" + site.file() + ":" + site.line() + ")");
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(name + "\ttriggered site #" + site.siteID() + " " + bind + site.sourceInfo());
fallback = (block?FALLBACKS_B:FALLBACKS)[arity];
site.clearTypes();
curry = true;
View
15 src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
@@ -420,13 +420,13 @@ public static IRubyObject getVariableFallback(VariableSite site, IRubyObject sel
// prepare fallback
MethodHandle fallback = null;
if (site.chainCount() > RubyInstanceConfig.MAX_POLY_COUNT) {
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tqet on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tqet on type " + self.getMetaClass().id + " failed (polymorphic)" + site.sourceInfo());
fallback = findStatic(InvokeDynamicSupport.class, "getVariableFail", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class));
fallback = fallback.bindTo(site);
site.setTarget(fallback);
return (IRubyObject)fallback.invokeWithArguments(self);
} else {
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tget on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tget on type " + self.getMetaClass().id + " added to PIC" + site.sourceInfo());
fallback = site.getTarget();
site.incrementChainCount();
}
@@ -437,7 +437,7 @@ public static IRubyObject getVariableFallback(VariableSite site, IRubyObject sel
getValue = guardWithTest(test, getValue, fallback);
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tget on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tget on class " + self.getMetaClass().id + " bound directly" + site.sourceInfo());
site.setTarget(getValue);
return (IRubyObject)getValue.invokeWithArguments(self);
@@ -463,13 +463,13 @@ public static IRubyObject setVariableFallback(VariableSite site, IRubyObject sel
// prepare fallback
MethodHandle fallback = null;
if (site.chainCount() > RubyInstanceConfig.MAX_POLY_COUNT) {
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " failed (polymorphic)" + site.sourceInfo());
fallback = findStatic(InvokeDynamicSupport.class, "setVariableFail", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class, IRubyObject.class));
fallback = fallback.bindTo(site);
site.setTarget(fallback);
return (IRubyObject)fallback.invokeWithArguments(self, value);
} else {
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " added to PIC" + site.sourceInfo());
fallback = site.getTarget();
site.incrementChainCount();
}
@@ -481,7 +481,7 @@ public static IRubyObject setVariableFallback(VariableSite site, IRubyObject sel
setValue = guardWithTest(test, setValue, fallback);
- if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
+ if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name + "\tset on class " + self.getMetaClass().id + " bound directly" + site.sourceInfo());
site.setTarget(setValue);
return (IRubyObject)setValue.invokeWithArguments(self, value);
@@ -688,7 +688,4 @@ public static MethodHandle findVirtual(Class target, String name, MethodType typ
}
}
- private static String extractSourceInfo(VariableSite site) {
- return " (" + site.file() + ":" + site.line() + ")";
- }
}
View
6 src/org/jruby/runtime/invokedynamic/JRubyCallSite.java
@@ -39,7 +39,7 @@
import org.jruby.runtime.CallType;
import org.jruby.runtime.callsite.CacheEntry;
-public class JRubyCallSite extends MutableCallSite {
+public class JRubyCallSite extends MutableCallSite implements SourceInfo {
private final Lookup lookup;
private final CallType callType;
public CacheEntry entry = CacheEntry.NULL_CACHE;
@@ -141,4 +141,8 @@ public void setTarget(MethodHandle target) {
public void setInitialTarget(MethodHandle target) {
super.setTarget(target);
}
+
+ public String sourceInfo() {
+ return " (" + file() + ":" + line() + ")";
+ }
}
View
5 src/org/jruby/runtime/invokedynamic/SourceInfo.java
@@ -0,0 +1,5 @@
+package org.jruby.runtime.invokedynamic;
+
+public interface SourceInfo {
+ String sourceInfo();
+}
View
6 src/org/jruby/runtime/invokedynamic/VariableSite.java
@@ -9,7 +9,7 @@
import java.lang.invoke.MethodType;
import java.lang.invoke.MutableCallSite;
-public class VariableSite extends MutableCallSite {
+public class VariableSite extends MutableCallSite implements SourceInfo {
public final String name;
private RubyClass.VariableAccessor accessor = RubyClass.VariableAccessor.DUMMY_ACCESSOR;
private final String file;
@@ -66,4 +66,8 @@ public String file() {
public int line() {
return line;
}
+
+ public String sourceInfo() {
+ return " (" + file() + ":" + line() + ")";
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.