Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix compile errors in unused code I broke.
  • Loading branch information
headius committed Oct 24, 2014
1 parent ffbb14e commit 8da3a82
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 55 deletions.
Expand Up @@ -11,7 +11,7 @@
import java.lang.invoke.MutableCallSite;

public class GlobalSite extends MutableCallSite {
public final String name;
private final String name;
private final String file;
private final int line;
private volatile int failures;
Expand Down Expand Up @@ -43,4 +43,8 @@ public int failures() {
public void incrementFailures() {
failures += 1;
}

public String name() {
return name;
}
}
Expand Up @@ -492,7 +492,7 @@ public static CallSite variableBootstrap(Lookup lookup, String name, MethodType

public static IRubyObject getVariableFallback(VariableSite site, IRubyObject self) throws Throwable {
RubyClass realClass = self.getMetaClass().getRealClass();
VariableAccessor accessor = realClass.getVariableAccessorForRead(site.name);
VariableAccessor accessor = realClass.getVariableAccessorForRead(site.name());

// produce nil if the variable has not been initialize
MethodHandle nullToNil = findStatic(Helpers.class, "nullToNil", methodType(IRubyObject.class, IRubyObject.class, IRubyObject.class));
Expand Down Expand Up @@ -520,17 +520,17 @@ public static IRubyObject getVariableFallback(VariableSite site, IRubyObject sel
// prepare fallback
MethodHandle fallback = null;
if (site.chainCount() + 1 > Options.INVOKEDYNAMIC_MAXPOLY.load()) {
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name + "\tqet on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name() + "\tqet on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
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 (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
if (direct) {
LOG.info(site.name + "\tget field on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
LOG.info(site.name() + "\tget field on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
} else {
LOG.info(site.name + "\tget on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
LOG.info(site.name() + "\tget on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
}
}
fallback = site.getTarget();
Expand All @@ -543,7 +543,7 @@ public static IRubyObject getVariableFallback(VariableSite site, IRubyObject sel

getValue = guardWithTest(test, getValue, fallback);

if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name + "\tget on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name() + "\tget on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
site.setTarget(getValue);

return (IRubyObject)getValue.invokeWithArguments(self);
Expand All @@ -568,7 +568,7 @@ public static IRubyObject getVariableFail(VariableSite site, IRubyObject self) t

public static IRubyObject setVariableFallback(VariableSite site, IRubyObject self, IRubyObject value) throws Throwable {
RubyClass realClass = self.getMetaClass().getRealClass();
VariableAccessor accessor = realClass.getVariableAccessorForWrite(site.name);
VariableAccessor accessor = realClass.getVariableAccessorForWrite(site.name());

// return provided value
MethodHandle returnValue = identity(IRubyObject.class);
Expand All @@ -595,17 +595,17 @@ public static IRubyObject setVariableFallback(VariableSite site, IRubyObject sel
// prepare fallback
MethodHandle fallback = null;
if (site.chainCount() + 1 > Options.INVOKEDYNAMIC_MAXPOLY.load()) {
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name() + "\tset on type " + self.getMetaClass().id + " failed (polymorphic)" + extractSourceInfo(site));
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 (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
if (direct) {
LOG.info(site.name + "\tset field on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
LOG.info(site.name() + "\tset field on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
} else {
LOG.info(site.name + "\tset on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
LOG.info(site.name() + "\tset on type " + self.getMetaClass().id + " added to PIC" + extractSourceInfo(site));
}
}
fallback = site.getTarget();
Expand All @@ -619,7 +619,7 @@ public static IRubyObject setVariableFallback(VariableSite site, IRubyObject sel

setValue = guardWithTest(test, setValue, fallback);

if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name + "\tset on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) LOG.info(site.name() + "\tset on class " + self.getMetaClass().id + " bound directly" + extractSourceInfo(site));
site.setTarget(setValue);

return (IRubyObject)setValue.invokeWithArguments(self, value);
Expand Down Expand Up @@ -688,13 +688,13 @@ public static CallSite loadBooleanBootstrap(Lookup lookup, String name, MethodTy

public static IRubyObject getGlobalFallback(GlobalSite site, ThreadContext context) throws Throwable {
Ruby runtime = context.runtime;
GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name);
GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name());

if (site.failures() > Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() ||
variable.getScope() != GlobalVariable.Scope.GLOBAL) {

// use uncached logic forever
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name + " (" + site.file() + ":" + site.line() + ") rebound > " + Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() + " times, reverting to simple lookup");
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") rebound > " + Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() + " times, reverting to simple lookup");

MethodHandle uncached = lookup().findStatic(InvokeDynamicSupport.class, "getGlobalUncached", methodType(IRubyObject.class, GlobalVariable.class));
uncached = uncached.bindTo(variable);
Expand All @@ -715,7 +715,7 @@ public static IRubyObject getGlobalFallback(GlobalSite site, ThreadContext conte

site.setTarget(target);

if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name + " (" + site.file() + ":" + site.line() + ") cached");
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") cached");

return value;
}
Expand All @@ -726,13 +726,13 @@ public static IRubyObject getGlobalUncached(GlobalVariable variable) throws Thro

public static boolean getGlobalBooleanFallback(GlobalSite site, ThreadContext context) throws Throwable {
Ruby runtime = context.runtime;
GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name);
GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name());

if (site.failures() > Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() ||
variable.getScope() != GlobalVariable.Scope.GLOBAL) {

// use uncached logic forever
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name + " (" + site.file() + ":" + site.line() + ") rebound > " + Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() + " times, reverting to simple lookup");
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") rebound > " + Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() + " times, reverting to simple lookup");

MethodHandle uncached = lookup().findStatic(InvokeDynamicSupport.class, "getGlobalBooleanUncached", methodType(boolean.class, GlobalVariable.class));
uncached = uncached.bindTo(variable);
Expand All @@ -753,7 +753,7 @@ public static boolean getGlobalBooleanFallback(GlobalSite site, ThreadContext co

site.setTarget(target);

if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name + " (" + site.file() + ":" + site.line() + ") cached as boolean");
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") cached as boolean");

return value;
}
Expand Down
76 changes: 38 additions & 38 deletions core/src/main/java/org/jruby/runtime/invokedynamic/MathLinker.java
Expand Up @@ -51,44 +51,44 @@
public class MathLinker {
private static final Logger LOG = LoggerFactory.getLogger("MathLinker");

public static CallSite fixnumOperatorBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumOperator",
methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
target = insertArguments(target, 3, site, value);
site.setTarget(target);
return site;
}
public static CallSite fixnumBooleanBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumBoolean",
methodType(boolean.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
target = insertArguments(target, 3, site, value);
site.setTarget(target);
return site;
}
public static CallSite floatOperatorBootstrap(Lookup lookup, String name, MethodType type, double value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
MethodHandle target = lookup.findStatic(MathLinker.class, "floatOperator",
methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, double.class));
target = insertArguments(target, 3, site, value);
site.setTarget(target);
return site;
}
// public static CallSite fixnumOperatorBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
// String[] names = name.split(":");
// String operator = JavaNameMangler.demangleMethodName(names[1]);
// JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
//
// MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumOperator",
// methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
// target = insertArguments(target, 3, site, value);
//
// site.setTarget(target);
// return site;
// }
//
// public static CallSite fixnumBooleanBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
// String[] names = name.split(":");
// String operator = JavaNameMangler.demangleMethodName(names[1]);
// JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
//
// MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumBoolean",
// methodType(boolean.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
// target = insertArguments(target, 3, site, value);
//
// site.setTarget(target);
// return site;
// }
//
// public static CallSite floatOperatorBootstrap(Lookup lookup, String name, MethodType type, double value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
// String[] names = name.split(":");
// String operator = JavaNameMangler.demangleMethodName(names[1]);
// JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, false, false, true);
//
// MethodHandle target = lookup.findStatic(MathLinker.class, "floatOperator",
// methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, double.class));
// target = insertArguments(target, 3, site, value);
//
// site.setTarget(target);
// return site;
// }

public static IRubyObject fixnumOperator(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, long value) throws Throwable {
String operator = site.name();
Expand Down

0 comments on commit 8da3a82

Please sign in to comment.