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: f7644456a3c8
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 01d20db5f21b
Choose a head ref
  • 20 commits
  • 21 files changed
  • 5 contributors

Commits on Mar 24, 2016

  1. Copy the full SHA
    032ff95 View commit details
  2. [Truffle] Optimized String#== for ropes with the same backing bytes b…

    …ut different encodings.
    nirvdrum committed Mar 24, 2016
    2
    Copy the full SHA
    07cee75 View commit details
  3. Copy the full SHA
    58b055e View commit details
  4. [Truffle] Added a node for altering the encoding of a rope.

    Also updated String#b to use this new node.
    nirvdrum committed Mar 24, 2016
    2
    Copy the full SHA
    5653941 View commit details
  5. Copy the full SHA
    1ba8d20 View commit details
  6. Copy the full SHA
    05c797b View commit details
  7. [Truffle] require blocks subsequent threads until the file is loaded

    - fixes autoload as well
    pitr-ch committed Mar 24, 2016
    Copy the full SHA
    aeead7c View commit details
  8. [Truffle] require may be redefined which may push the original requir…

    …ee further down on backtrace
    pitr-ch committed Mar 24, 2016
    Copy the full SHA
    16c21c3 View commit details
  9. Copy the full SHA
    2c8fe8a View commit details
  10. [Truffle] Make better use of shared byte arrays in RopeTable.

    This is a bit of an ugly approach, but it works, and we need to revisit the table key class already.
    nirvdrum committed Mar 24, 2016
    1
    Copy the full SHA
    54efdcd View commit details
  11. Copy the full SHA
    b2e01e3 View commit details
  12. Copy the full SHA
    02600cb View commit details
  13. Copy the full SHA
    fa11d87 View commit details
  14. Copy the full SHA
    f6ed52e View commit details
  15. Force MRI-style backtraces when using runner to run MRI tests.

    Several tests examine error output, which does not match using our
    normal backtrace style. See #3756.
    headius committed Mar 24, 2016
    Copy the full SHA
    c9a9f5c View commit details
  16. Fix a couple exception messages.

    The "assignment" warning fix almost gets MRI's TestRubyoptions#
    test_assignment_in_conditional, but there's a few cases where we
    differ from MRI in warning output. See #3757.
    headius committed Mar 24, 2016
    Copy the full SHA
    f43d140 View commit details

Commits on Mar 26, 2016

  1. Copy the full SHA
    8e71795 View commit details

Commits on Mar 27, 2016

  1. Copy the full SHA
    7bbbb07 View commit details

Commits on Mar 28, 2016

  1. Merge branch 'master' into truffle-head

    # Conflicts:
    #	truffle/src/main/java/org/jruby/truffle/core/rope/RopeTable.java
    chrisseaton committed Mar 28, 2016
    Copy the full SHA
    2867b1a View commit details
  2. Copy the full SHA
    01d20db View commit details
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -545,11 +545,11 @@ public void checkUselessStatements(BlockNode blockNode) {
**/
private boolean checkAssignmentInCondition(Node node) {
if (node instanceof MultipleAsgnNode) {
lexer.compile_error(PID.MULTIPLE_ASSIGNMENT_IN_CONDITIONAL, "Multiple assignment in conditional.");
lexer.compile_error(PID.MULTIPLE_ASSIGNMENT_IN_CONDITIONAL, "multiple assignment in conditional");
} else if (node instanceof LocalAsgnNode || node instanceof DAsgnNode || node instanceof GlobalAsgnNode || node instanceof InstAsgnNode) {
Node valueNode = ((AssignableNode) node).getValueNode();
if (valueNode instanceof ILiteralNode || valueNode instanceof NilNode || valueNode instanceof TrueNode || valueNode instanceof FalseNode) {
warnings.warn(ID.ASSIGNMENT_IN_CONDITIONAL, node.getPosition(), "Found '=' in conditional, should be '=='.");
warnings.warn(ID.ASSIGNMENT_IN_CONDITIONAL, node.getPosition(), "found = in conditional, should be ==");
}
return true;
}
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -251,6 +251,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_CLASS_CACHE = integer(TRUFFLE, "truffle.class.cache", TRUFFLE_DEFAULT_CACHE.load(), ".class and .metaclass cache size");
public static final Option<Integer> TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE = integer(TRUFFLE, "truffle.encoding_compatible_query.cache", TRUFFLE_DEFAULT_CACHE.load(), "Encoding.compatible? cache size");
public static final Option<Integer> TRUFFLE_THREAD_CACHE = integer(TRUFFLE, "truffle.thread.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of operations that depend on a particular thread");
public static final Option<Integer> TRUFFLE_ROPE_CLASS_CACHE = integer(TRUFFLE, "truffle.rope_class.cache", 6, "Cache size for rope operations that depend on a concrete rope implementation to avoid virtual calls");

public static final Option<Boolean> TRUFFLE_CLONE_DEFAULT = bool(TRUFFLE, "truffle.clone.default", true, "Default option for cloning.");
public static final Option<Boolean> TRUFFLE_INLINE_DEFAULT = bool(TRUFFLE, "truffle.inline.default", true, "Default option for inlining.");
12 changes: 0 additions & 12 deletions spec/truffle/tags/core/kernel/require_tags.txt
Original file line number Diff line number Diff line change
@@ -32,15 +32,3 @@ fails:Kernel.require ($LOAD_FEATURES) when a non-extensioned file is in $LOADED_
fails:Kernel.require ($LOAD_FEATURES) when a non-extensioned file is in $LOADED_FEATURES returns false when passed a path and the file is not found
fails:Kernel.require (shell expansion) performs tilde expansion on a .rb file before storing paths in $LOADED_FEATURES
fails:Kernel.require (shell expansion) performs tilde expansion on a non-extensioned file before storing paths in $LOADED_FEATURES
fails:Kernel#require stores the missing path in a LoadError object
fails:Kernel.require stores the missing path in a LoadError object
fails:Kernel#require (concurrently) blocks a second thread from returning while the 1st is still requiring
fails:Kernel.require (concurrently) blocks a second thread from returning while the 1st is still requiring
fails:Kernel#require (concurrently) blocks based on the path
fails:Kernel.require (concurrently) blocks based on the path
fails:Kernel#require (concurrently) allows a 2nd require if the 1st raised an exception
fails:Kernel.require (concurrently) allows a 2nd require if the 1st raised an exception
fails:Kernel#require (concurrently) blocks a 3rd require if the 1st raises an exception and the 2nd is still running
fails:Kernel.require (concurrently) blocks a 3rd require if the 1st raises an exception and the 2nd is still running
slow:Kernel#require (concurrently) blocks based on the path
slow:Kernel.require (concurrently) blocks based on the path
3 changes: 3 additions & 0 deletions test/mri/runner.rb
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ class Gem::TestCase < MiniTest::Unit::TestCase

ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze

# Use MRI backtraces for tests that verify error output
ENV["JRUBY_OPTS"] += ENV["JRUBY_OPTS"].to_s + " -Xbacktrace.style=mri"

require_relative 'lib/profile_test_all' if ENV.has_key?('RUBY_TEST_ALL_PROFILE')
#require_relative 'lib/tracepointchecker'
require_relative 'lib/zombie_hunter'
14 changes: 14 additions & 0 deletions test/truffle/compiler/pe/core/string_pe.rb
Original file line number Diff line number Diff line change
@@ -23,6 +23,14 @@
example "x = 'abc'; x == x.dup", true
example "x = 'abc'; 'abc' == x.dup", true

example "'A' == String.from_codepoint(65, Encoding::US_ASCII)", true
example "'A' == 65.chr", true
example "'A'.ord == 65", true

example "'aba'[0] == 'aca'[-1]", true

example "x = 'abc'; x == x.b", true

example "'abc'.ascii_only?", true
example "'こにちわ'.ascii_only?", false

@@ -35,3 +43,9 @@
example "''.empty?", true
example "'abc'.empty?", false
example "'こにちわ'.empty?", false

example "x = 'abc'; y = 'xyz'; x.replace(y) == y", true

example "'abc'.getbyte(0) == 97", true
example "'abc'.getbyte(-1) == 99", true
example "'abc'.getbyte(10_000) == nil", true
10 changes: 5 additions & 5 deletions test/truffle/compiler/pe/language/defined_pe.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

tagged_example "defined?(true) == 'true'", true
tagged_example "defined?(false) == 'false'", true
tagged_example "defined?(self) == 'self'", true
tagged_example "defined?(14) == 'expression'", true
tagged_example "defined?(14 + 2) == 'expression'", true
example "defined?(true) == 'true'", true
example "defined?(false) == 'false'", true
example "defined?(self) == 'self'", true
example "defined?(14) == 'expression'", true
tagged_example "defined?(14 + 2) == 'method'", true
19 changes: 9 additions & 10 deletions tool/truffle/bisect.rb
Original file line number Diff line number Diff line change
@@ -13,10 +13,11 @@
Then choose a THRESHOLD (between the number from the compare and 100%) and
$ git bisect start BADCOMMIT GOODCOMMIT
$ git bisect run ruby tool/truffle-bisect.rb BENCH THRESHOLD
$ git bisect run ruby tool/truffle/bisect.rb BENCH THRESHOLD
=end

def jt(cmd)
puts "jt #{cmd}"
cmd = "ruby tool/jt.rb #{cmd}"
output = `#{cmd}`
raise "#{cmd} failed: #{$?}" unless $?.success?
@@ -31,26 +32,24 @@ def jt(cmd)
bench = String(ARGV[0])
threshold = Integer(ARGV[1])

jt 'build' rescue nil
unless $?.success?
puts "Normal build failed, doing a rebuild"
begin
jt 'rebuild'
rescue
puts "rebuild failed, skipping revision"
exit 125
end

output = (jt("bench compare #{bench}") rescue nil)
unless $?.success?
puts "Benchmark failed, trying a rebuild"
jt 'rebuild'
output = jt("bench compare #{bench}")
end
output = jt("bench compare #{bench}")

/^#{Regexp.escape bench} (\d+)\./ =~ output
raise "Unexpected output:\n#{output}" unless $1
percents = Integer($1)
puts percents

if percents < threshold
puts "bad"
exit 1
else
puts "good"
exit 0
end
2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
repository( :url => 'http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/',
:id => 'truffle' )

truffle_version = '1645cfe49997e03f40681d18f45d2ea6841df0b1-SNAPSHOT'
truffle_version = '47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT'
jar 'com.oracle.truffle:truffle-api:' + truffle_version
jar 'com.oracle.truffle:truffle-debug:' + truffle_version
jar 'com.oracle.truffle:truffle-dsl-processor:' + truffle_version, :scope => 'provided'
8 changes: 4 additions & 4 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -41,23 +41,23 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>1645cfe49997e03f40681d18f45d2ea6841df0b1-SNAPSHOT</version>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-debug</artifactId>
<version>1645cfe49997e03f40681d18f45d2ea6841df0b1-SNAPSHOT</version>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>1645cfe49997e03f40681d18f45d2ea6841df0b1-SNAPSHOT</version>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>1645cfe49997e03f40681d18f45d2ea6841df0b1-SNAPSHOT</version>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
lexer grammar PrintfLexer;

FORMAT : '%' -> mode(FORMAT_MODE);
LITERAL : (~'%')* ;
LITERAL : (~'%')+ ;

mode FORMAT_MODE;

Original file line number Diff line number Diff line change
@@ -1590,22 +1590,30 @@ public boolean require(VirtualFrame frame, DynamicObject featureString, @Cached(
final String feature = featureString.toString();

// Pysch loads either the jar or the so - we need to intercept
if (feature.equals("psych.so") && callerIs("psych.rb")) {
if (feature.equals("psych.so") && callerIs("stdlib/psych.rb")) {
getContext().getFeatureLoader().require(frame, "truffle/psych.rb", callNode);
return true;
}

// TODO CS 1-Mar-15 ERB will use strscan if it's there, but strscan is not yet complete, so we need to hide it
if (feature.equals("strscan") && callerIs("erb.rb")) {
if (feature.equals("strscan") && callerIs("stdlib/erb.rb")) {
throw new RaiseException(coreLibrary().loadErrorCannotLoad(feature, this));
}

return getContext().getFeatureLoader().require(frame, feature, callNode);
}

private boolean callerIs(String caller) {
return getContext().getCallStack().getCallerFrameIgnoringSend().getCallNode()
.getEncapsulatingSourceSection().getSource().getName().endsWith(caller);
for (Activation activation : getContext().getCallStack().getBacktrace(this).getActivations()) {

final Source source = activation.getCallNode().getEncapsulatingSourceSection().getSource();

if (source != null && source.getName().endsWith(caller)) {
return true;
}
}

return false;
}
}

@@ -2003,17 +2011,17 @@ private DynamicObject finishFormat(int formatLength, PackResult result) {
final DynamicObject string = createString(new ByteList((byte[]) result.getOutput(), 0, result.getOutputLength()));

if (formatLength == 0) {
StringOperations.forceEncoding(string, USASCIIEncoding.INSTANCE);
StringOperations.forceEncodingVerySlow(string, USASCIIEncoding.INSTANCE);
} else {
switch (result.getEncoding()) {
case DEFAULT:
case ASCII_8BIT:
break;
case US_ASCII:
StringOperations.forceEncoding(string, USASCIIEncoding.INSTANCE);
StringOperations.forceEncodingVerySlow(string, USASCIIEncoding.INSTANCE);
break;
case UTF_8:
StringOperations.forceEncoding(string, UTF8Encoding.INSTANCE);
StringOperations.forceEncodingVerySlow(string, UTF8Encoding.INSTANCE);
break;
default:
throw new UnsupportedOperationException();
Original file line number Diff line number Diff line change
@@ -56,9 +56,9 @@ public Object execute(VirtualFrame frame) {
final Rope source = Layouts.REGEXP.getSource(regexp);

if (!BodyTranslator.all7Bit(preprocessed.getByteList().bytes())) {
Layouts.REGEXP.setSource(regexp, RopeOperations.withEncoding(source, getContext().getJRubyRuntime().getEncodingService().getAscii8bitEncoding()));
Layouts.REGEXP.setSource(regexp, RopeOperations.withEncodingVerySlow(source, getContext().getJRubyRuntime().getEncodingService().getAscii8bitEncoding()));
} else {
Layouts.REGEXP.setSource(regexp, RopeOperations.withEncoding(source, getContext().getJRubyRuntime().getEncodingService().getUSAsciiEncoding()));
Layouts.REGEXP.setSource(regexp, RopeOperations.withEncodingVerySlow(source, getContext().getJRubyRuntime().getEncodingService().getUSAsciiEncoding()));
}
}

Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@ public static Regex compile(Node currentNode, RubyContext context, Rope bytes, R
//if (regexpOptions.isEncodingNone()) setEncodingNone();

Regex ret = new Regex(unescaped.getUnsafeBytes(), unescaped.getBegin(), unescaped.getBegin() + unescaped.getRealSize(), options.toJoniOptions(), enc, Syntax.RUBY);
ret.setUserObject(RopeOperations.withEncoding(bytes, enc));
ret.setUserObject(RopeOperations.withEncodingVerySlow(bytes, enc));

return ret;
} catch (ValueException e) {
72 changes: 68 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
@@ -29,7 +28,7 @@
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.numeric.FixnumLowerNodeGen;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;
@@ -76,7 +75,7 @@ public Rope substringZeroBytes(Rope base, int offset, int byteLength,
return RopeConstants.EMPTY_ASCII_8BIT_ROPE;
}

return RopeOperations.withEncoding(RopeConstants.EMPTY_UTF8_ROPE, base.getEncoding());
return RopeOperations.withEncodingVerySlow(RopeConstants.EMPTY_UTF8_ROPE, base.getEncoding());
}

@Specialization(guards = "byteLength == 1")
@@ -98,7 +97,7 @@ public Rope substringOneByte(Rope base, int offset, int byteLength,
return RopeConstants.ASCII_8BIT_SINGLE_BYTE_ROPES[index];
}

return RopeOperations.withEncoding(RopeConstants.ASCII_8BIT_SINGLE_BYTE_ROPES[index], base.getEncoding());
return RopeOperations.withEncodingVerySlow(RopeConstants.ASCII_8BIT_SINGLE_BYTE_ROPES[index], base.getEncoding());
}

@Specialization(guards = { "byteLength > 1", "sameAsBase(base, offset, byteLength)" })
@@ -298,6 +297,10 @@ protected static boolean isMutableRope(Rope rope) {
})
public abstract static class MakeLeafRopeNode extends RubyNode {

public static MakeLeafRopeNode create(RubyContext context, SourceSection sourceSection) {
return RopeNodesFactory.MakeLeafRopeNodeGen.create(context, sourceSection, null, null, null, null);
}

public MakeLeafRopeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -563,4 +566,65 @@ private void printPreamble(int level) {
}

}

@NodeChildren({
@NodeChild(type = RubyNode.class, value = "rope"),
@NodeChild(type = RubyNode.class, value = "encoding"),
@NodeChild(type = RubyNode.class, value = "codeRange")
})
public abstract static class WithEncodingNode extends RubyNode {

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

public abstract Rope executeWithEncoding(Rope rope, Encoding encoding, CodeRange codeRange);

@Specialization(guards = "rope.getEncoding() == encoding")
public Rope withEncodingSameEncoding(Rope rope, Encoding encoding, CodeRange codeRange) {
return rope;
}

@Specialization(guards = {
"rope.getEncoding() != encoding",
"rope.getCodeRange() == codeRange"
})
public Rope withEncodingSameCodeRange(Rope rope, Encoding encoding, CodeRange codeRange) {
return rope.withEncoding(encoding, codeRange);
}

@Specialization(guards = {
"rope.getEncoding() != encoding",
"rope.getCodeRange() != codeRange",
"isAsciiCompatbileChange(rope, encoding)",
"rope.getClass() == cachedRopeClass"
}, limit = "getCacheLimit()")
public Rope withEncodingCr7Bit(Rope rope, Encoding encoding, CodeRange codeRange,
@Cached("rope.getClass()") Class<? extends Rope> cachedRopeClass) {
return cachedRopeClass.cast(rope).withEncoding(encoding, CodeRange.CR_7BIT);
}

@Specialization(guards = {
"rope.getEncoding() != encoding",
"rope.getCodeRange() != codeRange",
"!isAsciiCompatbileChange(rope, encoding)"
})
public Rope withEncoding(Rope rope, Encoding encoding, CodeRange codeRange,
@Cached("create(getContext(), getSourceSection())") MakeLeafRopeNode makeLeafRopeNode) {
return makeLeafRopeNode.executeMake(rope.getBytes(), encoding, codeRange, NotProvided.INSTANCE);
}

protected static boolean isAsciiCompatbileChange(Rope rope, Encoding encoding) {
return rope.getCodeRange() == CR_7BIT && encoding.isAsciiCompatible();
}

protected static boolean is7Bit(Rope rope) {
return rope.getCodeRange() == CR_7BIT;
}

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

}
}
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ public static LeafRope create(byte[] bytes, Encoding encoding, CodeRange codeRan
}
}

public static Rope withEncoding(Rope originalRope, Encoding newEncoding, CodeRange newCodeRange) {
public static Rope withEncodingVerySlow(Rope originalRope, Encoding newEncoding, CodeRange newCodeRange) {
if ((originalRope.getEncoding() == newEncoding) && (originalRope.getCodeRange() == newCodeRange)) {
return originalRope;
}
@@ -101,8 +101,8 @@ public static Rope withEncoding(Rope originalRope, Encoding newEncoding, CodeRan
return create(originalRope.getBytes(), newEncoding, newCodeRange);
}

public static Rope withEncoding(Rope originalRope, Encoding newEncoding) {
return withEncoding(originalRope, newEncoding, originalRope.getCodeRange());
public static Rope withEncodingVerySlow(Rope originalRope, Encoding newEncoding) {
return withEncodingVerySlow(originalRope, newEncoding, originalRope.getCodeRange());
}

@TruffleBoundary
Loading