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

Commits on Jul 15, 2015

  1. Copy the full SHA
    8780aec View commit details
  2. Copy the full SHA
    02daf39 View commit details
  3. Copy the full SHA
    3edc296 View commit details
15 changes: 4 additions & 11 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -30,7 +30,10 @@
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyHash;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyRange;
import org.jruby.truffle.runtime.sockets.NativeSockets;
import org.jruby.util.ByteList;

@@ -141,16 +144,6 @@ public double executeDouble(VirtualFrame frame) throws UnexpectedResultException
}
}

public RubyRegexp executeRubyRegexp(VirtualFrame frame) throws UnexpectedResultException {
final Object value = execute(frame);

if (value instanceof RubyRegexp) {
return (RubyRegexp) value;
} else {
throw new UnexpectedResultException(value);
}
}

public RubyModule executeRubyModule(VirtualFrame frame) throws UnexpectedResultException {
final Object value = execute(frame);

Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeUtil;

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyEncoding;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.util.ByteList;

@CoreClass(name = "Encoding")
@@ -79,9 +78,9 @@ public Object isCompatibleEncodingEncoding(RubyEncoding first, RubyEncoding seco
}

@TruffleBoundary
@Specialization(guards = "isRubyString(first)")
public Object isCompatibleStringRegexp(RubyBasicObject first, RubyRegexp second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(StringNodes.getByteList(first).getEncoding(), second.getRegex().getEncoding());
@Specialization(guards = {"isRubyString(first)", "isRubyRegexp(second)"})
public Object isCompatibleStringRegexp(RubyBasicObject first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(StringNodes.getByteList(first).getEncoding(), RegexpNodes.getRegex(second).getEncoding());

if (compatibleEncoding != null) {
return RubyEncoding.getEncoding(compatibleEncoding);
@@ -91,9 +90,9 @@ public Object isCompatibleStringRegexp(RubyBasicObject first, RubyRegexp second)
}

@TruffleBoundary
@Specialization(guards = "isRubyString(second)")
public Object isCompatibleRegexpString(RubyRegexp first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(first.getRegex().getEncoding(), StringNodes.getByteList(second).getEncoding());
@Specialization(guards = {"isRubyRegexp(first)", "isRubyString(second)"})
public Object isCompatibleRegexpString(RubyBasicObject first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(RegexpNodes.getRegex(first).getEncoding(), StringNodes.getByteList(second).getEncoding());

if (compatibleEncoding != null) {
return RubyEncoding.getEncoding(compatibleEncoding);
@@ -103,9 +102,9 @@ public Object isCompatibleRegexpString(RubyRegexp first, RubyBasicObject second)
}

@TruffleBoundary
@Specialization
public Object isCompatibleRegexpRegexp(RubyRegexp first, RubyRegexp second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(first.getRegex().getEncoding(), second.getRegex().getEncoding());
@Specialization(guards = {"isRubyRegexp(first)", "isRubyRegexp(second)"})
public Object isCompatibleRegexpRegexp(RubyBasicObject first, RubyBasicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(RegexpNodes.getRegex(first).getEncoding(), RegexpNodes.getRegex(second).getEncoding());

if (compatibleEncoding != null) {
return RubyEncoding.getEncoding(compatibleEncoding);
@@ -115,9 +114,9 @@ public Object isCompatibleRegexpRegexp(RubyRegexp first, RubyRegexp second) {
}

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

if (compatibleEncoding != null) {
return RubyEncoding.getEncoding(compatibleEncoding);
@@ -127,9 +126,9 @@ public Object isCompatibleRegexpSymbol(RubyRegexp first, RubyBasicObject second)
}

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

if (compatibleEncoding != null) {
return RubyEncoding.getEncoding(compatibleEncoding);
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.truffle.translator.BodyTranslator;
import org.jruby.util.RegexpOptions;

@@ -35,7 +34,7 @@ public InterpolatedRegexpNode(RubyContext context, SourceSection sourceSection,
}

@Override
public RubyRegexp executeRubyRegexp(VirtualFrame frame) {
public Object execute(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();

final org.jruby.RubyString[] strings = new org.jruby.RubyString[children.length];
@@ -47,21 +46,16 @@ public RubyRegexp executeRubyRegexp(VirtualFrame frame) {

final org.jruby.RubyString preprocessed = org.jruby.RubyRegexp.preprocessDRegexp(getContext().getRuntime(), strings, options);

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), preprocessed.getByteList(), options);
final RubyBasicObject regexp = RegexpNodes.createRubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), preprocessed.getByteList(), options);

if (options.isEncodingNone()) {
if (!BodyTranslator.all7Bit(preprocessed.getByteList().bytes())) {
regexp.getSource().setEncoding(getContext().getRuntime().getEncodingService().getAscii8bitEncoding());
RegexpNodes.getSource(regexp).setEncoding(getContext().getRuntime().getEncodingService().getAscii8bitEncoding());
} else {
regexp.getSource().setEncoding(getContext().getRuntime().getEncodingService().getUSAsciiEncoding());
RegexpNodes.getSource(regexp).setEncoding(getContext().getRuntime().getEncodingService().getUSAsciiEncoding());
}
}

return regexp;
}

@Override
public Object execute(VirtualFrame frame) {
return executeRubyRegexp(frame);
}
}
Original file line number Diff line number Diff line change
@@ -11,17 +11,16 @@
package org.jruby.truffle.nodes.core;

import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.util.StringSupport;

public class RegexpGuards {

public static boolean isInitialized(RubyRegexp regexp) {
return regexp.getRegex() != null;
public static boolean isInitialized(RubyBasicObject regexp) {
return RegexpNodes.getRegex(regexp) != null;
}

public static boolean isRegexpLiteral(RubyRegexp regexp) {
return regexp.getOptions().isLiteral();
public static boolean isRegexpLiteral(RubyBasicObject regexp) {
return RegexpNodes.getOptions(regexp).isLiteral();
}

public static boolean isValidEncoding(RubyBasicObject string) {
Loading