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

Commits on Jun 21, 2016

  1. 3
    Copy the full SHA
    660cfec View commit details
  2. Copy the full SHA
    3fbd428 View commit details
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
@@ -266,6 +266,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval cache size.");
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_ENCODING_LOADED_CLASSES_CACHE = integer(TRUFFLE, "truffle.encoding_loaded_classes.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of encoding operations based on anticipated number of total active encodings.");
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<Integer> TRUFFLE_INTEROP_CONVERT_CACHE = integer(TRUFFLE, "truffle.interop.convert.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for converting values for interop.");
10 changes: 10 additions & 0 deletions test/truffle/compiler/pe/core/encoding_pe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "Encoding::US_ASCII.ascii_compatible?", true
example "Encoding::UTF_16BE.ascii_compatible?", false
1 change: 1 addition & 0 deletions test/truffle/compiler/pe/pe.rb
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ def counter(example)
require_relative 'core/block_given_pe.rb'
require_relative 'core/string_pe.rb'
require_relative 'core/class_pe'
require_relative 'core/encoding_pe'
require_relative 'interop/interop_pe'
require_relative 'macro/pushing_pixels_pe.rb'

Original file line number Diff line number Diff line change
@@ -56,9 +56,20 @@ public abstract class EncodingNodes {
private static final DynamicObject[] ENCODING_LIST = new DynamicObject[EncodingDB.getEncodings().size()];
private static final Map<String, DynamicObject> LOOKUP = new HashMap<>();

@TruffleBoundary
public static synchronized DynamicObject getEncoding(Encoding encoding) {
return LOOKUP.get(new String(encoding.getName(), StandardCharsets.UTF_8).toLowerCase(Locale.ENGLISH));
private static final DynamicObject[] ENCODING_LIST_BY_ENCODING_INDEX = new DynamicObject[EncodingDB.getEncodings().size()];

public static DynamicObject getEncoding(Encoding encoding) {
DynamicObject rubyEncoding = ENCODING_LIST_BY_ENCODING_INDEX[encoding.getIndex()];

if (rubyEncoding == null) {
// Bounded by the number of encodings
CompilerDirectives.transferToInterpreterAndInvalidate();

rubyEncoding = LOOKUP.get(new String(encoding.getName(), StandardCharsets.UTF_8).toLowerCase(Locale.ENGLISH));
ENCODING_LIST_BY_ENCODING_INDEX[encoding.getIndex()] = rubyEncoding;
}

return rubyEncoding;
}

@TruffleBoundary
@@ -102,8 +113,27 @@ public static DynamicObject createRubyEncoding(DynamicObject encodingClass, Enco
@CoreMethod(names = "ascii_compatible?")
public abstract static class AsciiCompatibleNode extends CoreMethodArrayArgumentsNode {

@Specialization
public Object isCompatible(DynamicObject encoding) {
@Specialization(guards = {
"encoding == cachedEncoding",
}, limit = "getCacheLimit()")
public boolean isCompatibleCached(DynamicObject encoding,
@Cached("encoding") DynamicObject cachedEncoding,
@Cached("isAsciiCompatible(encoding)") boolean isAsciiCompatible) {
return isAsciiCompatible;
}

@Specialization(contains = "isCompatibleCached")
public boolean isCompatibleUncached(DynamicObject encoding) {
return isAsciiCompatible(encoding);
}

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

protected static boolean isAsciiCompatible(DynamicObject encoding) {
assert RubyGuards.isRubyEncoding(encoding);

return EncodingOperations.getEncoding(encoding).isAsciiCompatible();
}
}
2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/language/Options.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import static org.jruby.util.cli.Options.TRUFFLE_COVERAGE_GLOBAL;
import static org.jruby.util.cli.Options.TRUFFLE_DISPATCH_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_ENCODING_LOADED_CLASSES_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_EVAL_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_EXCEPTIONS_PRINT_JAVA;
import static org.jruby.util.cli.Options.TRUFFLE_EXCEPTIONS_PRINT_UNCAUGHT_JAVA;
@@ -121,6 +122,7 @@ public class Options {
public final int EVAL_CACHE = TRUFFLE_EVAL_CACHE.load();
public final int CLASS_CACHE = TRUFFLE_CLASS_CACHE.load();
public final int ENCODING_COMPATIBILE_QUERY_CACHE = TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE.load();
public final int ENCODING_LOADED_CLASSES_CACHE = TRUFFLE_ENCODING_LOADED_CLASSES_CACHE.load();
public final int THREAD_CACHE = TRUFFLE_THREAD_CACHE.load();
public final int ROPE_CLASS_CACHE = TRUFFLE_ROPE_CLASS_CACHE.load();
public final int INTEROP_CONVERT_CACHE = TRUFFLE_INTEROP_CONVERT_CACHE.load();