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

Commits on Jan 4, 2017

  1. Copy the full SHA
    db858ac View commit details
  2. 2
    Copy the full SHA
    ae04269 View commit details
  3. Copy the full SHA
    e38e135 View commit details
  4. Copy the full SHA
    3bb8b83 View commit details
  5. [Truffle] Don't use indirect log method, as it pollutes the log with …

    …the wrong class. Only use when you need a boundary.
    chrisseaton committed Jan 4, 2017
    Copy the full SHA
    ae8afa6 View commit details
  6. Copy the full SHA
    e67f8bf View commit details
  7. Copy the full SHA
    590151c View commit details
  8. Copy the full SHA
    887a1d3 View commit details
  9. Copy the full SHA
    e6ac118 View commit details
  10. Copy the full SHA
    56ee1cf View commit details
6 changes: 3 additions & 3 deletions samples/truffle/logging.properties
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
# will be unset. You can add it back by name -
# org.jruby.truffle.Log$RubyHandler.

org.jruby.truffle.handlers=java.util.logging.FileHandler
#org.jruby.truffle.handlers=java.util.logging.FileHandler

# Say where to send file output.

java.util.logging.FileHandler.pattern=ruby.log
#java.util.logging.FileHandler.pattern=ruby.log

# Configure the logging level.

org.jruby.truffle.level=WARNING
org.jruby.truffle.level=CONFIG
14 changes: 14 additions & 0 deletions tool/truffle/generate-options.rb
Original file line number Diff line number Diff line change
@@ -96,6 +96,14 @@
<% options.each do |o| %> <%= o.constant %> = builder.getOrDefault(OptionsCatalog.<%= o.constant %><%= o.reference_default ? ', ' + o.default : '' %>);
<% end %>}
public Object fromDescription(OptionDescription description) {
switch (description.getName()) {
<% options.each do |o| %>case "<%= o.name %>":
return <%= o.constant %>;
<% end %>default:
return null;
}
}
}
JAVA

@@ -129,5 +137,11 @@
}
}
public static OptionDescription[] allDescriptions() {
return new OptionDescription[] {<% options.each do |o| %>
<%= o.constant %>,<% end %>
};
}
}
JAVA
2 changes: 2 additions & 0 deletions tool/truffle/options.yml
Original file line number Diff line number Diff line change
@@ -109,3 +109,5 @@ SHARED_OBJECTS_SHARE_ALL: [shared.objects.share_all, boolean, false, Consider al

CEXTS_LOG_LOAD: [cexts.log.load, boolean, false, Log loading of cexts]
LOG_DYNAMIC_CONSTANT_LOOKUP: [constant.dynamic_lookup.log, boolean, false, Log source code positions where dynamic constant lookup is performed]

OPTIONS_LOG: [options.log, boolean, false, Log the final value of all options]
24 changes: 3 additions & 21 deletions truffle/src/main/java/org/jruby/truffle/Log.java
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public RubyLevel(String name, Level parent) {

public static final Level PERFORMANCE = new RubyLevel("PERFORMANCE", Level.WARNING);

private static final Logger LOGGER = createLogger();
public static final Logger LOGGER = createLogger();

public static class RubyHandler extends Handler {

@@ -87,31 +87,13 @@ public static void notOptimizedOnce(String message) {
@TruffleBoundary
public static void performanceOnce(String message) {
if (displayedWarnings.add(message)) {
performance(message);
LOGGER.log(PERFORMANCE, message);
}
}

/**
* Warn about something that has lower performance than might be expected.
*/
@TruffleBoundary
public static void performance(String message) {
LOGGER.log(PERFORMANCE, message);
}

@TruffleBoundary
public static void warning(String message) {
LOGGER.warning(message);
}

@TruffleBoundary
public static void info(String message) {
LOGGER.info(message);
}

@TruffleBoundary
public static void info(String format, Object... args) {
info(String.format(format, args));
LOGGER.info(String.format(format, args));
}

}
32 changes: 16 additions & 16 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public class RubyContext extends ExecutionContext {

private final Options options;

private final String jrubyHome;
private final String rubyHome;
private String originalInputFile;

private InputStream syntaxCheckInputStream;
@@ -124,9 +124,11 @@ public RubyContext(TruffleLanguage.Env env) {
optionsBuilder.set(System.getProperties());
options = optionsBuilder.build();

this.jrubyHome = findJRubyHome();
this.currentDirectory = System.getProperty("user.dir");
this.verbose = options.VERBOSITY.equals(Verbosity.TRUE);
rubyHome = findRubyHome();
Log.LOGGER.config(() -> String.format("ruby home: %s", rubyHome));

currentDirectory = System.getProperty("user.dir");
verbose = options.VERBOSITY.equals(Verbosity.TRUE);

if (options.CALL_GRAPH) {
callGraph = new CallGraph();
@@ -220,15 +222,7 @@ public RubyContext(TruffleLanguage.Env env) {
}
}

private CodeSource getCodeSource() {
try {
return Class.forName("org.jruby.Ruby").getProtectionDomain().getCodeSource();
} catch (Exception e) {
throw new RuntimeException("Error getting the classic code source", e);
}
}

private String findJRubyHome() {
private String findRubyHome() {
if (options.HOME != null) {
return options.HOME;
}
@@ -245,7 +239,13 @@ private String findJRubyHome() {

if (!TruffleOptions.AOT) {
// Set JRuby home automatically for GraalVM and mx from the current jar path
final CodeSource codeSource = getCodeSource();
CodeSource result;
try {
result = Class.forName("org.jruby.Ruby").getProtectionDomain().getCodeSource();
} catch (Exception e1) {
throw new RuntimeException("Error getting the classic code source", e1);
}
final CodeSource codeSource = result;
if (codeSource != null) {
final File currentJarFile;
try {
@@ -470,8 +470,8 @@ public String getOriginalInputFile() {
return originalInputFile;
}

public String getJRubyHome() {
return jrubyHome;
public String getRubyHome() {
return rubyHome;
}

public void setVerbose(boolean verbose) {
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.loader.CodeLoader;
import org.jruby.truffle.language.loader.SourceLoader;
import org.jruby.truffle.language.methods.DeclarationContext;
import org.jruby.truffle.parser.ParserContext;
import org.jruby.truffle.parser.TranslatorDriver;
@@ -40,48 +39,21 @@
@CoreClass("Truffle::Boot")
public abstract class TruffleBootNodes {

@CoreMethod(names = "jruby_home_directory", onSingleton = true)
public abstract static class JRubyHomeDirectoryNode extends CoreMethodNode {
@CoreMethod(names = "ruby_home", onSingleton = true)
public abstract static class RubyHomeNode extends CoreMethodNode {

@TruffleBoundary
@Specialization
public DynamicObject jrubyHomeDirectory() {
if (getContext().getJRubyHome() == null) {
public DynamicObject ruby_home() {
if (getContext().getRubyHome() == null) {
return nil();
} else {
return createString(StringOperations.encodeRope(getContext().getJRubyHome(), UTF8Encoding.INSTANCE));
return createString(StringOperations.encodeRope(getContext().getRubyHome(), UTF8Encoding.INSTANCE));
}
}

}

@CoreMethod(names = "jruby_home_directory_protocol", onSingleton = true)
public abstract static class JRubyHomeDirectoryProtocolNode extends CoreMethodNode {

@TruffleBoundary
@Specialization
public DynamicObject jrubyHomeDirectoryProtocol() {
String home = getContext().getJRubyHome();

if (home == null) {
return nil();
}

if (home.startsWith("uri:classloader:")) {
home = home.substring("uri:classloader:".length());

while (home.startsWith("/")) {
home = home.substring(1);
}

home = SourceLoader.JRUBY_SCHEME + "/" + home;
}

return createString(StringOperations.encodeRope(home, UTF8Encoding.INSTANCE));
}

}

@CoreMethod(names = "context", onSingleton = true)
public abstract static class ContextNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -151,10 +151,10 @@ public void ensureCExtImplementationLoaded(VirtualFrame frame, String feature, I

@TruffleBoundary
private CallTarget getCExtLibRuby(String feature) {
final String path = context.getJRubyHome() + "/lib/ruby/truffle/cext/ruby.su";
final String path = context.getRubyHome() + "/lib/ruby/truffle/cext/ruby.su";

if (context.getOptions().CEXTS_LOG_LOAD) {
Log.info("loading cext implementation %s", path);
Log.LOGGER.info(() -> String.format("loading cext implementation %s", path));
}

if (!new File(path).exists()) {
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
***** END LICENSE BLOCK *****/
package org.jruby.truffle.options;

import org.jruby.truffle.Log;
import org.jruby.truffle.core.string.KCode;
import org.jruby.truffle.core.string.StringSupport;

@@ -41,6 +42,7 @@
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.regex.Pattern;

/**
@@ -396,6 +398,18 @@ private void processArgument() {
throw new UnsupportedOperationException();
} else if (extendedOption.endsWith("?")) {
throw new UnsupportedOperationException();
} else if (extendedOption.startsWith("log=")) {
final String levelString = extendedOption.substring("log=".length());

final Level level;

if (levelString.equals("PERFORMANCE")) {
level = Log.PERFORMANCE;
} else {
level = Level.parse(levelString.toUpperCase());
}

Log.LOGGER.setLevel(level);
} else {
MainExitException mee = new MainExitException(1, "jruby: invalid extended option " + extendedOption + " (-X will list valid options)\n");
mee.setUsageError(true);
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.options;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class ByteStringOptionDescription extends OptionDescription {

@@ -38,4 +39,9 @@ public Object checkValue(Object value) {
}
}

@Override
public String toString(Object value) {
return new String((byte[]) value, StandardCharsets.US_ASCII);
}

}
Original file line number Diff line number Diff line change
@@ -31,4 +31,12 @@ public String getDescription() {

public abstract Object checkValue(Object value);

public String toString(Object value) {
if (value == null) {
return "null";
} else {
return value.toString();
}
}

}
Loading