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

Commits on Jan 9, 2017

  1. Copy the full SHA
    973ab20 View commit details
  2. Copy the full SHA
    e9d732b View commit details
Showing with 92 additions and 237 deletions.
  1. +0 −1 core/src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector
  2. +6 −6 truffle/src/main/java/org/jruby/truffle/Main.java
  3. +4 −12 truffle/src/main/java/org/jruby/truffle/RubyContext.java
  4. +14 −7 ...src/main/java/org/jruby/util → truffle/src/main/java/org/jruby/truffle}/RubyFileTypeDetector.java
  5. +3 −3 truffle/src/main/java/org/jruby/truffle/builtins/AmbiguousOptionalArgumentChecker.java
  6. +6 −5 truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
  7. +2 −1 truffle/src/main/java/org/jruby/truffle/builtins/LowerFixnumChecker.java
  8. +2 −1 truffle/src/main/java/org/jruby/truffle/cext/CExtNodes.java
  9. +5 −1 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  10. +6 −3 truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java
  11. +0 −11 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
  12. +5 −7 truffle/src/main/java/org/jruby/truffle/debug/TruffleDebugNodes.java
  13. +9 −3 truffle/src/main/java/org/jruby/truffle/language/TruffleSafeNodes.java
  14. +1 −1 truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
  15. +3 −2 truffle/src/main/java/org/jruby/truffle/language/objects/shared/SharedObjects.java
  16. +4 −4 truffle/src/main/java/org/jruby/truffle/options/ArgumentProcessor.java
  17. +0 −10 truffle/src/main/java/org/jruby/truffle/options/RubyInstanceConfig.java
  18. +2 −1 truffle/src/main/java/org/jruby/truffle/parser/ReloadArgumentsTranslator.java
  19. +0 −149 truffle/src/main/java/org/jruby/truffle/parser/lexer/RubyLexer.java
  20. +1 −1 truffle/src/main/java/org/jruby/truffle/platform/java/JavaPlatform.java
  21. +16 −6 truffle/src/main/java/org/jruby/truffle/platform/java/JavaTrufflePosix.java
  22. +2 −2 truffle/src/main/java/org/jruby/truffle/tools/InstrumentationServerManager.java
  23. +1 −0 truffle/src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector

This file was deleted.

12 changes: 6 additions & 6 deletions truffle/src/main/java/org/jruby/truffle/Main.java
Original file line number Diff line number Diff line change
@@ -78,20 +78,20 @@ public static void main(String[] args) {
processArguments(config, args);
} catch (MainExitException mee) {
if (!mee.isAborted()) {
config.getError().println(mee.getMessage());
System.err.println(mee.getMessage());
if (mee.isUsageError()) {
config.getOutput().print(OutputStrings.getBasicUsageHelp());
System.out.print(OutputStrings.getBasicUsageHelp());
}
}
System.exit(mee.getStatus());
}

if (config.isShowVersion()) {
config.getOutput().println(OutputStrings.getVersionString());
System.out.println(OutputStrings.getVersionString());
}

if (config.isShowCopyright()) {
config.getOutput().println(OutputStrings.getCopyrightString());
System.out.println(OutputStrings.getCopyrightString());
}

final int exitCode;
@@ -121,7 +121,7 @@ public static void main(String[] args) {
try {
if (config.isXFlag()) {
// no shebang was found and x option is set
config.getError().println("jruby: no Ruby script found in input (LoadError)");
System.err.println("jruby: no Ruby script found in input (LoadError)");
exitCode = 1;
} else if (config.getShouldCheckSyntax()) {
// check syntax only and exit
@@ -146,7 +146,7 @@ public static void main(String[] args) {
}
} else {
if (config.getShouldPrintUsage()) {
config.getOutput().print(OutputStrings.getBasicUsageHelp());
System.out.print(OutputStrings.getBasicUsageHelp());
}
exitCode = 1;
}
16 changes: 4 additions & 12 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -103,7 +103,6 @@ public class RubyContext extends ExecutionContext {
private final LexicalScope rootLexicalScope;
private final InstrumentationServerManager instrumentationServerManager;
private final CallGraph callGraph;
private final PrintStream debugStandardOut;
private final CoverageManager coverageManager;
private final ConsoleHolder consoleHolder;

@@ -198,9 +197,6 @@ public RubyContext(TruffleLanguage.Env env) {

// Load other subsystems

final PrintStream configStandardOut = System.out;
debugStandardOut = (configStandardOut == System.out) ? null : configStandardOut;

// The instrumentation server can't be run with AOT because com.sun.net.httpserver.spi.HttpServerProvider uses runtime class loading.
if (!TruffleOptions.AOT && options.INSTRUMENTATION_SERVER_PORT != 0) {
instrumentationServerManager = new InstrumentationServerManager(this, options.INSTRUMENTATION_SERVER_PORT);
@@ -280,10 +276,10 @@ public Object send(Object object, String methodName, DynamicObject block, Object

public void shutdown() {
if (options.ROPE_PRINT_INTERN_STATS) {
System.out.println("Ropes re-used: " + getRopeTable().getRopesReusedCount());
System.out.println("Rope byte arrays re-used: " + getRopeTable().getByteArrayReusedCount());
System.out.println("Rope bytes saved: " + getRopeTable().getRopeBytesSaved());
System.out.println("Total ropes interned: " + getRopeTable().totalRopes());
Log.LOGGER.info("ropes re-used: " + getRopeTable().getRopesReusedCount());
Log.LOGGER.info("rope byte arrays re-used: " + getRopeTable().getByteArrayReusedCount());
Log.LOGGER.info("rope bytes saved: " + getRopeTable().getRopeBytesSaved());
Log.LOGGER.info("total ropes interned: " + getRopeTable().totalRopes());
}

atExitManager.runSystemExitHooks();
@@ -331,10 +327,6 @@ public CoreMethods getCoreMethods() {
return coreMethods;
}

public PrintStream getDebugStandardOut() {
return debugStandardOut;
}

public FeatureLoader getFeatureLoader() {
return featureLoader;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package org.jruby.util;
/*
* Copyright (c) 2016, 2017 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
*/
package org.jruby.truffle;

import java.io.BufferedReader;
import java.io.IOException;
@@ -12,8 +21,7 @@
public final class RubyFileTypeDetector extends FileTypeDetector {

private static final String[] KNOWN_RUBY_FILES = new String[]{ "Gemfile", "Rakefile", "Mavenfile" };
private static final String[] KNOWN_RUBY_SUFFIXES = new String[]{ ".rb", ".rake", ".gemspec" };
private static final String RUBY_MIME = "application/x-ruby";
private static final String[] KNOWN_RUBY_SUFFIXES = new String[]{ RubyLanguage.EXTENSION, ".rake", ".gemspec" };
private static final Pattern SHEBANG_REGEXP = Pattern.compile("^#! ?/usr/bin/(env +ruby|ruby).*");

@Override
@@ -28,20 +36,20 @@ public String probeContentType(Path path) throws IOException {

for (String candidate : KNOWN_RUBY_SUFFIXES) {
if (lowerCaseFileName.endsWith(candidate)) {
return RUBY_MIME;
return RubyLanguage.MIME_TYPE;
}
}

for (String candidate : KNOWN_RUBY_FILES) {
if (fileName.equals(candidate)) {
return RUBY_MIME;
return RubyLanguage.MIME_TYPE;
}
}

try (BufferedReader fileContent = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
final String firstLine = fileContent.readLine();
if (firstLine != null && SHEBANG_REGEXP.matcher(firstLine).matches()) {
return RUBY_MIME;
return RubyLanguage.MIME_TYPE;
}
} catch (IOException e) {
// Reading random files as UTF-8 could cause all sorts of errors
@@ -50,4 +58,3 @@ public String probeContentType(Path path) throws IOException {
return null;
}
}

Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.builtins;

import com.oracle.truffle.api.dsl.Specialization;
import org.jruby.truffle.Log;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
@@ -59,7 +60,7 @@ private static void verifyNoAmbiguousOptionalArgumentsWithReflection(CoreMethodN
boolean isNamePresent = parameter.isNamePresent();
if (!isNamePresent) {
AVAILABLE = SUCCESS = false;
System.err.println("Method parameters names are not available for " + method);
Log.LOGGER.warning("Method parameters names are not available for " + method);
return;
}
String name = parameter.getName();
@@ -76,8 +77,7 @@ private static void verifyNoAmbiguousOptionalArgumentsWithReflection(CoreMethodN

if (unguardedObjectArgument) {
SUCCESS = false;
System.err.println("Ambiguous optional argument in " + node.getCanonicalName() + ":");
System.err.println(errors);
Log.LOGGER.warning("Ambiguous optional argument in " + node.getCanonicalName() + ":\n" + errors);
}
}
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.Log;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.RaiseIfFrozenNode;
import org.jruby.truffle.core.array.ArrayUtils;
@@ -124,20 +125,20 @@ private void addCoreMethod(DynamicObject module, MethodDetails methodDetails) {

if (method.isModuleFunction()) {
if (visibility != Visibility.PUBLIC) {
System.err.println("WARNING: visibility ignored when isModuleFunction in " + methodDetails.getIndicativeName());
Log.LOGGER.warning("visibility ignored when isModuleFunction in " + methodDetails.getIndicativeName());
}
if (method.onSingleton()) {
System.err.println("WARNING: Either onSingleton or isModuleFunction for " + methodDetails.getIndicativeName());
Log.LOGGER.warning("either onSingleton or isModuleFunction for " + methodDetails.getIndicativeName());
}
if (method.constructor()) {
System.err.println("WARNING: Either constructor or isModuleFunction for " + methodDetails.getIndicativeName());
Log.LOGGER.warning("either constructor or isModuleFunction for " + methodDetails.getIndicativeName());
}
if (RubyGuards.isRubyClass(module)) {
System.err.println("WARNING: Using isModuleFunction on a Class for " + methodDetails.getIndicativeName());
Log.LOGGER.warning("using isModuleFunction on a Class for " + methodDetails.getIndicativeName());
}
}
if (method.onSingleton() && method.constructor()) {
System.err.println("WARNING: Either onSingleton or constructor for " + methodDetails.getIndicativeName());
Log.LOGGER.warning("either onSingleton or constructor for " + methodDetails.getIndicativeName());
}

final SharedMethodInfo sharedMethodInfo = makeSharedMethodInfo(context, module, methodDetails);
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.Log;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.language.RubyNode;

@@ -68,7 +69,7 @@ public static void checkLowerFixnumArguments(NodeFactory<? extends RubyNode> nod
boolean shouldLower = lowerArgs[i] == 0b01; // int without long
if (shouldLower && !ArrayUtils.contains(lowerFixnum, i + 1)) {
SUCCESS = false;
System.err.println("Node " + nodeFactory.getNodeClass().getCanonicalName() + " should use lowerFixnum for argument " + (i + 1));
Log.LOGGER.warning("Node " + nodeFactory.getNodeClass().getCanonicalName() + " should use lowerFixnum for argument " + (i + 1));
}
}
}
3 changes: 2 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/cext/CExtNodes.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.Log;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
@@ -404,7 +405,7 @@ public long toNativeHandle(DynamicObject object) {
return toNative.computeIfAbsent(object, (k) -> {
final long handle = getContext().getNativePlatform().getMallocFree().malloc(Long.BYTES);
memoryManager().newPointer(handle).putLong(0, 0xdeadbeef);
System.err.printf("native handle 0x%x -> %s%n", handle, object);
Log.LOGGER.info(String.format("native handle 0x%x -> %s", handle, object));
toManaged.put(handle, object);
return handle;
});
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
@@ -146,6 +147,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;

@@ -1113,6 +1115,7 @@ public boolean isNil() {
}

// A basic Kernel#p for debugging core, overridden later in kernel.rb
@NonStandard
@CoreMethod(names = "p", needsSelf = false, required = 1, unsafe = UnsafeGroup.IO)
public abstract static class DebugPrintNode extends CoreMethodArrayArgumentsNode {

@@ -1127,7 +1130,8 @@ public Object p(VirtualFrame frame, Object value) {

@TruffleBoundary
private void print(Object inspected) {
System.out.println(inspected.toString());
final PrintStream stream = new PrintStream(getContext().getEnv().out(), true);
stream.println(inspected.toString());
}
}

Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.Log;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.klass.ClassNodes;
import org.jruby.truffle.core.method.MethodFilter;
@@ -47,15 +48,17 @@ public class ModuleFields implements ModuleChain, ObjectGraphNode {
public static void debugModuleChain(DynamicObject module) {
assert RubyGuards.isRubyModule(module);
ModuleChain chain = Layouts.MODULE.getFields(module);
final StringBuilder builder = new StringBuilder();
while (chain != null) {
System.err.print(chain.getClass());
builder.append(chain.getClass());
if (!(chain instanceof PrependMarker)) {
DynamicObject real = chain.getActualModule();
System.err.print(" " + Layouts.MODULE.getFields(real).getName());
builder.append(" " + Layouts.MODULE.getFields(real).getName());
}
System.err.println();
builder.append(System.lineSeparator());
chain = chain.getParentModule();
}
Log.LOGGER.info(builder.toString());
}

public DynamicObject rubyModuleObject;
Original file line number Diff line number Diff line change
@@ -665,11 +665,6 @@ public int write(DynamicObject file, DynamicObject string) {

final Rope rope = rope(string);

if (getContext().getDebugStandardOut() != null && fd == STDOUT) {
getContext().getDebugStandardOut().write(rope.getBytes(), 0, rope.byteLength());
return rope.byteLength();
}

RopeOperations.visitBytes(rope, (bytes, offset, length) -> {
final ByteBuffer buffer = ByteBuffer.wrap(bytes, offset, length);

@@ -707,12 +702,6 @@ public int writeNonBlock(DynamicObject io, DynamicObject string) {
final int fd = Layouts.IO.getDescriptor(io);
final Rope rope = rope(string);

if (getContext().getDebugStandardOut() != null && fd == STDOUT) {
// TODO (eregon, 13 May 2015): this looks like it would block
getContext().getDebugStandardOut().write(rope.getBytes(), 0, rope.byteLength());
return rope.byteLength();
}

final IOWriteNonBlockPrimitiveNode currentNode = this;

try {
Original file line number Diff line number Diff line change
@@ -30,13 +30,15 @@
import org.jruby.truffle.builtins.CoreMethodNode;
import org.jruby.truffle.core.array.ArrayStrategy;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.backtrace.Backtrace;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
import org.jruby.truffle.language.methods.InternalMethod;
import org.jruby.truffle.language.objects.shared.SharedObjects;
import org.jruby.truffle.language.yield.YieldNode;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.tools.simpleshell.SimpleShell;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

@@ -115,13 +117,9 @@ public abstract static class PrintBacktraceNode extends CoreMethodNode {
@TruffleBoundary
@Specialization
public DynamicObject printBacktrace() {
final List<String> rubyBacktrace = BacktraceFormatter.createDefaultFormatter(getContext())
.formatBacktrace(getContext(), null, getContext().getCallStack().getBacktrace(this));

for (String line : rubyBacktrace) {
System.err.println(line);
}

final Backtrace backtrace = getContext().getCallStack().getBacktrace(this);
final BacktraceFormatter formatter = BacktraceFormatter.createDefaultFormatter(getContext());
formatter.printBacktrace(getContext(), null, backtrace);
return nil();
}

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
import org.jruby.truffle.builtins.CoreMethodNode;
import org.jruby.truffle.platform.UnsafeGroup;

import java.io.PrintStream;

@CoreClass("Truffle::Safe")
public abstract class TruffleSafeNodes {

@@ -27,15 +29,19 @@ public abstract static class PutsNode extends CoreMethodArrayArgumentsNode {
@TruffleBoundary
@Specialization(guards = "isRubyString(string)")
public DynamicObject puts(DynamicObject string) {
final StringBuilder builder = new StringBuilder();

for (char c : string.toString().toCharArray()) {
if (isAsciiPrintable(c)) {
System.out.print(c);
builder.append(c);
} else {
System.out.print('?');
builder.append('?');
}
}

System.out.println();
builder.append(System.lineSeparator());

new PrintStream(getContext().getEnv().out(), true).print(builder.toString());

return nil();
}
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ public BacktraceFormatter(RubyContext context, EnumSet<FormattingFlags> flags) {

@TruffleBoundary
public void printBacktrace(RubyContext context, DynamicObject exception, Backtrace backtrace) {
printBacktrace(context, exception, backtrace, new PrintWriter(System.err, true));
printBacktrace(context, exception, backtrace, new PrintWriter(context.getEnv().err(), true));
}

@TruffleBoundary
Loading