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: a6450735dee3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1b5ee39a4c52
Choose a head ref
  • 4 commits
  • 26 files changed
  • 1 contributor

Commits on Jun 9, 2015

  1. Copy the full SHA
    c2f0785 View commit details
  2. Copy the full SHA
    b58bbf9 View commit details
  3. Copy the full SHA
    2eae47d View commit details
  4. Copy the full SHA
    1b5ee39 View commit details
Showing with 300 additions and 246 deletions.
  1. +6 −5 truffle/src/main/java/org/jruby/truffle/nodes/RubyGuards.java
  2. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/conversion/ToJavaStringNode.java
  3. +3 −4 truffle/src/main/java/org/jruby/truffle/nodes/conversion/ToSymbolNode.java
  4. +2 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/BasicObjectNodes.java
  5. +23 −17 truffle/src/main/java/org/jruby/truffle/nodes/core/BindingNodes.java
  6. +12 −9 truffle/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java
  7. +44 −46 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  8. +6 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/MatchDataNodes.java
  9. +26 −30 truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  10. +12 −10 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcessNodes.java
  11. +10 −7 truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  12. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  13. +101 −24 truffle/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java
  14. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/TruffleInteropNodes.java
  15. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java
  16. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedDispatchNode.java
  17. +1 −3 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
  18. +6 −7 truffle/src/main/java/org/jruby/truffle/nodes/interop/InteropNode.java
  19. +10 −19 truffle/src/main/java/org/jruby/truffle/nodes/interop/RubyToIndexLabelNode.java
  20. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/EncodingPrimitiveNodes.java
  21. +4 −5 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  22. +0 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  23. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  24. +0 −30 truffle/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java
  25. +5 −3 truffle/src/main/java/org/jruby/truffle/runtime/core/SymbolCodeRangeableWrapper.java
  26. +13 −2 truffle/src/main/java/org/jruby/truffle/runtime/core/SymbolTable.java
11 changes: 6 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyGuards.java
Original file line number Diff line number Diff line change
@@ -10,10 +10,7 @@
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.interop.TruffleObject;
import org.jruby.truffle.nodes.core.BignumNodes;
import org.jruby.truffle.nodes.core.MethodNodes;
import org.jruby.truffle.nodes.core.StringNodes;
import org.jruby.truffle.nodes.core.UnboundMethodNodes;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.core.hash.HashNodes;
import org.jruby.truffle.nodes.ext.BigDecimalNodes;
import org.jruby.truffle.runtime.NotProvided;
@@ -108,7 +105,11 @@ public static boolean isRubyEncoding(Object value) {
}

public static boolean isRubySymbol(Object value) {
return value instanceof RubySymbol;
return (value instanceof RubyBasicObject) && isRubySymbol((RubyBasicObject) value);
}

public static boolean isRubySymbol(RubyBasicObject value) {
return value.getDynamicObject().getShape().getObjectType() == SymbolNodes.SYMBOL_TYPE;
}

public static boolean isRubyMethod(Object value) {
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.SymbolNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;

@NodeChild(value="child", type=RubyNode.class)
public abstract class ToJavaStringNode extends RubyNode {
@@ -32,8 +32,8 @@ public ToJavaStringNode(RubyContext context, SourceSection sourceSection) {
// TODO(CS): cache the conversion to a Java String? Or should the user do that themselves?

@TruffleBoundary
@Specialization
protected String toJavaString(RubySymbol symbol) {
@Specialization(guards = "isRubySymbol(symbol)")
protected String toJavaString(RubyBasicObject symbol) {
return SymbolNodes.getString(symbol);
}

Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;

@NodeChild(value="child", type=RubyNode.class)
public abstract class ToSymbolNode extends RubyNode {
@@ -27,12 +26,12 @@ public ToSymbolNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract RubySymbol executeRubySymbol(VirtualFrame frame, Object object);
public abstract RubyBasicObject executeRubySymbol(VirtualFrame frame, Object object);

// TODO(CS): cache the conversion to a symbol? Or should the user do that themselves?

@Specialization
protected RubyBasicObject toSymbol(RubySymbol symbol) {
@Specialization(guards = "isRubySymbol(symbol)")
protected RubyBasicObject toSymbol(RubyBasicObject symbol) {
return symbol;
}

Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;

@CoreClass(name = "BasicObject")
public abstract class BasicObjectNodes {
@@ -233,12 +232,12 @@ public Object methodMissing(Object self, Object[] args, NotProvided block) {
public Object methodMissing(Object self, Object[] args, RubyProc block) {
CompilerDirectives.transferToInterpreter();

final RubySymbol name = (RubySymbol) args[0];
final RubyBasicObject name = (RubyBasicObject) args[0];
final Object[] sentArgs = ArrayUtils.extractRange(args, 1, args.length);
return methodMissing(self, name, sentArgs, block);
}

private Object methodMissing(Object self, RubySymbol name, Object[] args, RubyProc block) {
private Object methodMissing(Object self, RubyBasicObject name, Object[] args, RubyProc block) {
CompilerDirectives.transferToInterpreter();
// TODO: should not be a call to Java toString(), but rather sth like name_err_mesg_to_str() in MRI error.c
if (lastCallWasVCall()) {
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.locals.ReadFrameSlotNode;
import org.jruby.truffle.nodes.locals.ReadFrameSlotNodeGen;
@@ -30,7 +31,6 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.InternalMethod;

@CoreClass(name = "Binding")
@@ -76,13 +76,14 @@ public LocalVariableGetNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = {
"isRubySymbol(symbol)",
"symbol == cachedSymbol",
"!isLastLine(cachedSymbol)",
"getFrameDescriptor(binding) == cachedFrameDescriptor"

})
public Object localVariableGetCached(RubyBinding binding, RubySymbol symbol,
@Cached("symbol") RubySymbol cachedSymbol,
public Object localVariableGetCached(RubyBinding binding, RubyBasicObject symbol,
@Cached("symbol") RubyBasicObject cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@Cached("findFrameSlot(binding, symbol)") FrameSlot cachedFrameSlot,
@Cached("createReadNode(cachedFrameSlot)") ReadFrameSlotNode readLocalVariableNode) {
@@ -95,8 +96,8 @@ public Object localVariableGetCached(RubyBinding binding, RubySymbol symbol,
}

@TruffleBoundary
@Specialization(guards = "!isLastLine(symbol)")
public Object localVariableGetUncached(RubyBinding binding, RubySymbol symbol) {
@Specialization(guards = {"isRubySymbol(symbol)", "!isLastLine(symbol)"})
public Object localVariableGetUncached(RubyBinding binding, RubyBasicObject symbol) {
final MaterializedFrame frame = binding.getFrame();
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(SymbolNodes.getString(symbol));

@@ -108,8 +109,8 @@ public Object localVariableGetUncached(RubyBinding binding, RubySymbol symbol) {
}

@TruffleBoundary
@Specialization(guards = "isLastLine(symbol)")
public Object localVariableGetLastLine(RubyBinding binding, RubySymbol symbol) {
@Specialization(guards = {"isRubySymbol(symbol)", "isLastLine(symbol)"})
public Object localVariableGetLastLine(RubyBinding binding, RubyBasicObject symbol) {
final MaterializedFrame frame = binding.getFrame();
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(SymbolNodes.getString(symbol));

@@ -129,7 +130,9 @@ protected FrameDescriptor getFrameDescriptor(RubyBinding binding) {
return binding.getFrame().getFrameDescriptor();
}

protected FrameSlot findFrameSlot(RubyBinding binding, RubySymbol symbol) {
protected FrameSlot findFrameSlot(RubyBinding binding, RubyBasicObject symbol) {
assert RubyGuards.isRubySymbol(symbol);

final String symbolString = SymbolNodes.getString(symbol);

MaterializedFrame frame = binding.getFrame();
@@ -155,7 +158,7 @@ protected ReadFrameSlotNode createReadNode(FrameSlot frameSlot) {
}
}

protected boolean isLastLine(RubySymbol symbol) {
protected boolean isLastLine(RubyBasicObject symbol) {
return symbol == dollarUnderscore;
}

@@ -172,29 +175,30 @@ public LocalVariableSetNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = {
"isRubySymbol(symbol)",
"!isLastLine(symbol)",
"getFrameDescriptor(binding) == cachedFrameDescriptor",
"symbol == cachedSymbol"
})
public Object localVariableSetCached(RubyBinding binding, RubySymbol symbol, Object value,
@Cached("symbol") RubySymbol cachedSymbol,
public Object localVariableSetCached(RubyBinding binding, RubyBasicObject symbol, Object value,
@Cached("symbol") RubyBasicObject cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@Cached("createWriteNode(findFrameSlot(binding, symbol))") WriteFrameSlotNode writeLocalVariableNode) {
return writeLocalVariableNode.executeWrite(binding.getFrame(), value);
}

@TruffleBoundary
@Specialization(guards = "!isLastLine(symbol)")
public Object localVariableSetUncached(RubyBinding binding, RubySymbol symbol, Object value) {
@Specialization(guards = {"isRubySymbol(symbol)", "!isLastLine(symbol)"})
public Object localVariableSetUncached(RubyBinding binding, RubyBasicObject symbol, Object value) {
final MaterializedFrame frame = binding.getFrame();
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(SymbolNodes.getString(symbol));
frame.setObject(frameSlot, value);
return value;
}

@TruffleBoundary
@Specialization(guards = "isLastLine(symbol)")
public Object localVariableSetLastLine(RubyBinding binding, RubySymbol symbol, Object value) {
@Specialization(guards = {"isRubySymbol(symbol)", "isLastLine(symbol)"})
public Object localVariableSetLastLine(RubyBinding binding, RubyBasicObject symbol, Object value) {
final MaterializedFrame frame = binding.getFrame();
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(SymbolNodes.getString(symbol));
frame.setObject(frameSlot, ThreadLocalObject.wrap(getContext(), value));
@@ -205,7 +209,9 @@ protected FrameDescriptor getFrameDescriptor(RubyBinding binding) {
return binding.getFrame().getFrameDescriptor();
}

protected FrameSlot findFrameSlot(RubyBinding binding, RubySymbol symbol) {
protected FrameSlot findFrameSlot(RubyBinding binding, RubyBasicObject symbol) {
assert RubyGuards.isRubySymbol(symbol);

final String symbolString = SymbolNodes.getString(symbol);

MaterializedFrame frame = binding.getFrame();
@@ -227,7 +233,7 @@ protected WriteFrameSlotNode createWriteNode(FrameSlot frameSlot) {
return WriteFrameSlotNodeGen.create(frameSlot);
}

protected boolean isLastLine(RubySymbol symbol) {
protected boolean isLastLine(RubyBasicObject symbol) {
return symbol == dollarUnderscore;
}
}
Original file line number Diff line number Diff line change
@@ -25,7 +25,10 @@
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyEncoding;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.ByteList;

@CoreClass(name = "Encoding")
@@ -113,8 +116,8 @@ public Object isCompatible(RubyRegexp first, RubyRegexp second) {
}

@TruffleBoundary
@Specialization
public Object isCompatible(RubyRegexp first, RubySymbol second) {
@Specialization(guards = "isRubySymbol(second)")
public Object isCompatible(RubyRegexp first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(first.getRegex().getEncoding(), SymbolNodes.getByteList(second).getEncoding());

if (compatibleEncoding != null) {
@@ -125,8 +128,8 @@ public Object isCompatible(RubyRegexp first, RubySymbol second) {
}

@TruffleBoundary
@Specialization
public Object isCompatible(RubySymbol first, RubyRegexp second) {
@Specialization(guards = "isRubySymbol(first)")
public Object isCompatible(RubyBasicObject first, RubyRegexp second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(SymbolNodes.getByteList(first).getEncoding(), second.getRegex().getEncoding());

if (compatibleEncoding != null) {
@@ -137,8 +140,8 @@ public Object isCompatible(RubySymbol first, RubyRegexp second) {
}

@TruffleBoundary
@Specialization
public Object isCompatible(RubyString first, RubySymbol second) {
@Specialization(guards = "isRubySymbol(second)")
public Object isCompatible(RubyString first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(StringNodes.getCodeRangeable(first), SymbolNodes.getCodeRangeable(second));

if (compatibleEncoding != null) {
@@ -149,8 +152,8 @@ public Object isCompatible(RubyString first, RubySymbol second) {
}

@TruffleBoundary
@Specialization
public Object isCompatible(RubySymbol first, RubySymbol second) {
@Specialization(guards = {"isRubySymbol(first)", "isRubySymbol(second)"})
public Object isCompatible(RubyBasicObject first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(SymbolNodes.getCodeRangeable(first), SymbolNodes.getCodeRangeable(second));

if (compatibleEncoding != null) {
Loading