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

Commits on Dec 26, 2014

  1. 2
    Copy the full SHA
    ca856f6 View commit details
  2. [Truffle] Remove the print load option, remove loading from URIs, and…

    … simplify loading in general.
    chrisseaton committed Dec 26, 2014
    Copy the full SHA
    467a6f7 View commit details
  3. Copy the full SHA
    8844490 View commit details
Original file line number Diff line number Diff line change
@@ -64,6 +64,11 @@ public AddNode(AddNode prev) {
super(prev);
}

@Specialization(guards = {"isObject", "isOtherNull"})
public RubyArray addObjectNull(RubyArray a, RubyArray b) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOf((Object[]) a.getStore(), a.getSize()), a.getSize());
}

@Specialization(guards = "areBothIntegerFixnum")
public RubyArray addBothIntegerFixnum(RubyArray a, RubyArray b) {
final int combinedSize = a.getSize() + b.getSize();
18 changes: 18 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -861,6 +861,24 @@ public Object match(RubyString string, RubyRegexp regexp) {
}
}

@CoreMethod(names = "ord")
public abstract static class OrdNode extends CoreMethodNode {

public OrdNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public OrdNode(OrdNode prev) {
super(prev);
}

@Specialization
public int ord(RubyString string) {
notDesignedForCompilation();
return ((org.jruby.RubyFixnum) getContext().toJRuby(string).ord(getContext().getRuntime().getCurrentContext())).getIntValue();
}
}

@CoreMethod(names = "rjust", required = 1, optional = 1, lowerFixnumParameters = 0)
public abstract static class RjustNode extends CoreMethodNode {

2 changes: 0 additions & 2 deletions core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
Original file line number Diff line number Diff line change
@@ -163,8 +163,6 @@ private void loadFileAbsolute(String fileName, RubyNode currentNode) {
// Assume UTF-8 for the moment

final Source source = Source.fromBytes(bytes, fileName, new BytesDecoder.UTF8BytesDecoder());

coreLibrary.getLoadedFeatures().slowPush(makeString(fileName));
execute(this, source, UTF8Encoding.INSTANCE, TranslatorDriver.ParserContext.TOP_LEVEL, coreLibrary.getMainObject(), null, currentNode);
}

Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.*;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.cli.Options;

/**
@@ -114,30 +115,19 @@ public boolean requireInPath(String path, String feature, RubyNode currentNode)
return true;
}

if (requireFile(path + File.separator + feature, currentNode)) {
if (requireFile(new File(path, feature).getPath(), currentNode)) {
return true;
}

if (requireFile(path + File.separator + feature + ".rb", currentNode)) {
if (requireFile(new File(path, feature).getPath() + ".rb", currentNode)) {
return true;
}

return false;
}

private boolean requireFile(String fileName, RubyNode currentNode) throws IOException {
if (Arrays.asList(context.getCoreLibrary().getLoadedFeatures().slowToArray()).contains(fileName)) {
return true;
}

if (Options.TRUFFLE_LOAD_PRINT.load()) {
context.getWarnings().warn("%s being loaded", fileName);
}

/*
* There is unfortunately no way to check if a string is a file path, or a URL. file:foo.txt
* is a valid file name, as well as a valid URL. We try as a file path first.
*/
// Loading from core:/ always just goes ahead without a proper check

if (fileName.startsWith("core:/")) {
try {
@@ -147,35 +137,27 @@ private boolean requireFile(String fileName, RubyNode currentNode) throws IOExce
// TODO(CS): obviously not the best way to do this
return false;
}
} else if (new File(fileName).isFile()) {
context.loadFile(fileName, currentNode);
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(fileName));
return true;
} else {
URL url;
}

try {
url = new URL(fileName);
} catch (MalformedURLException e) {
return false;
}
final File file = new File(fileName);

InputStream inputStream;
if (!file.isFile()) {
return false;
}

try {
inputStream = url.openConnection().getInputStream();
} catch (IOException e) {
return false;
final String canonicalFileName = file.getCanonicalPath();

for (Object loaded : Arrays.asList(context.getCoreLibrary().getLoadedFeatures().slowToArray())) {
if (loaded.toString().equals(canonicalFileName)) {
return true;
}
}

// TODO(CS): can probably simplify this with the new Source API in Truffle
context.loadFile(fileName, currentNode);

context.load(Source.fromReader(new InputStreamReader(inputStream), url.toString()), currentNode);
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(fileName));
((RubyArray) context.getCoreLibrary().getGlobalVariablesObject().getInstanceVariable("$LOADED_FEATURES")).slowPush(context.makeString(fileName));
return true;
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(canonicalFileName));

}
return true;
}

}
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -143,7 +143,6 @@ public class Options {
public static final Option<Integer> TRUFFLE_BACKTRACE_MAX_VALUE_LENGTH = integer(TRUFFLE, "truffle.backtrace.max_value_length", 20, "Max length for values when displayed in a backtrace.");
public static final Option<Boolean> TRUFFLE_BACKTRACE_GENERATE = bool(TRUFFLE, "truffle.backtrace.generate", true, "Generate backtraces on exceptions.");
public static final Option<Integer> TRUFFLE_DISPATCH_POLYMORPHIC_MAX = integer(TRUFFLE, "truffle.dispatch.polymorphic.max", 8, "Maximum size of a polymorphic call site cache.");
public static final Option<Boolean> TRUFFLE_LOAD_PRINT = bool(TRUFFLE, "truffle.load.print", false, "Print the name of files as they're loaded.");
public static final Option<Boolean> TRUFFLE_DEBUG_ENABLE_ASSERT_CONSTANT = bool(TRUFFLE, "truffle.debug.enable_assert_constant", false, "Enable special 'truffle_assert_constant' form.");
public static final Option<Boolean> TRUFFLE_PANIC_ON_JAVA_ASSERT = bool(TRUFFLE, "truffle.debug.panic_on_java_assert", false, "Panic as soon as a Java assertion failure is found.");
public static final Option<Boolean> TRUFFLE_INLINER_ALWAYS_CLONE_YIELD = bool(TRUFFLE, "truffle.inliner.always_clone_yield", true, "Always clone yield call targets.");
13 changes: 13 additions & 0 deletions spec/truffle/tags/core/regexp/union_tags.txt
Original file line number Diff line number Diff line change
@@ -11,3 +11,16 @@ fails:Regexp.union returns a Regexp with UTF-8 if one part is UTF-8
fails:Regexp.union returns a Regexp if an array of string with special characters is passed
fails:Regexp.union uses to_str to convert arguments (if not Regexp)
fails:Regexp.union accepts a single array of patterns as arguments
fails:Regexp.union raises ArgumentError if the arguments include conflicting ASCII-incompatible Strings
fails:Regexp.union raises ArgumentError if the arguments include conflicting ASCII-incompatible Regexps
fails:Regexp.union raises ArgumentError if the arguments include conflicting fixed encoding Regexps
fails:Regexp.union raises ArgumentError if the arguments include a fixed encoding Regexp and a String containing non-ASCII-compatible characters in a different encoding
fails:Regexp.union raises ArgumentError if the arguments include a String containing non-ASCII-compatible characters and a fixed encoding Regexp in a different encoding
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only String
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only String
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only Regexp
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only Regexp
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible String and a String containing non-ASCII-compatible characters in a different encoding
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a String containing non-ASCII-compatible characters in a different encoding
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible String and a Regexp containing non-ASCII-compatible characters in a different encoding
fails:Regexp.union raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a Regexp containing non-ASCII-compatible characters in a different encoding
2 changes: 0 additions & 2 deletions spec/truffle/tags/language/string_tags.txt

This file was deleted.