Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7ed20518b159
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ba40478f9cba
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Oct 15, 2015

  1. Copy the full SHA
    6e3cca6 View commit details
  2. Copy the full SHA
    ba40478 View commit details
Showing with 19 additions and 15 deletions.
  1. +19 −15 truffle/src/main/java/org/jruby/truffle/nodes/constants/GetConstantNode.java
Original file line number Diff line number Diff line change
@@ -68,33 +68,33 @@ protected Object autoloadConstant(VirtualFrame frame, DynamicObject module, Stri

@Specialization(guards = {
"constant == null",
"guardName(name, cachedName, sameNameProfile)" })
protected Object missingConstant(VirtualFrame frame, DynamicObject module, String name, Object constant,
@Cached("name") String cachedName,
@Cached("isValidConstantName(name)") boolean isValidConstantName,
@Cached("createConstMissingNode()") CallDispatchHeadNode constMissingNode,
@Cached("getSymbol(name)") DynamicObject symbolName,
@Cached("createBinaryProfile()") ConditionProfile sameNameProfile) {
return missingConstantBody(frame, module, name, isValidConstantName, constMissingNode, symbolName);
"guardName(name, cachedName, sameNameProfile)"
}, limit = "getCacheLimit()")
protected Object missingConstantCached(VirtualFrame frame, DynamicObject module, String name, Object constant,
@Cached("name") String cachedName,
@Cached("isValidConstantName(name)") boolean isValidConstantName,
@Cached("getSymbol(name)") DynamicObject symbolName,
@Cached("createBinaryProfile()") ConditionProfile sameNameProfile) {
return doMissingConstant(frame, module, name, isValidConstantName, symbolName);
}

@Specialization(guards = "constant == null")
protected Object missingConstantUncached(VirtualFrame frame, DynamicObject module, String name, Object constant) {
final boolean isValidConstantName = isValidConstantName(name);
if (constMissingNode == null) {
CompilerDirectives.transferToInterpreter();
constMissingNode = insert(createConstMissingNode());
}

return missingConstantBody(frame, module, name, isValidConstantName, constMissingNode, getSymbol(name));
return doMissingConstant(frame, module, name, isValidConstantName, getSymbol(name));
}

private Object missingConstantBody(VirtualFrame frame, DynamicObject module, String name, boolean isValidConstantName, CallDispatchHeadNode constMissingNode, DynamicObject symbolName) {
private Object doMissingConstant(VirtualFrame frame, DynamicObject module, String name, boolean isValidConstantName, DynamicObject symbolName) {
if (!isValidConstantName) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().nameError(String.format("wrong constant name %s", name), name, this));
}

if (constMissingNode == null) {
CompilerDirectives.transferToInterpreter();
constMissingNode = insert(createConstMissingNode());
}

return constMissingNode.call(frame, module, "const_missing", null, symbolName);
}

@@ -123,4 +123,8 @@ protected boolean guardName(String name, String cachedName, ConditionProfile sam
}
}

protected int getCacheLimit() {
return getContext().getOptions().CONSTANT_LOOKUP_CACHE;
}

}