Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadBacktraceLocationNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
	truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
	truffle/src/main/java/org/jruby/truffle/runtime/backtrace/BacktraceFormatter.java
chrisseaton committed Aug 22, 2015
2 parents c33d16f + 4fd99e3 commit 08f77c6
Showing 120 changed files with 1,377 additions and 1,154 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ matrix:
fast_finish: true
allow_failures:
- env: COMMAND=test/truffle/run.sh
- env: PHASE='-Ptruffle-mri-tests'


branches:
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -1378,7 +1378,9 @@ public String internalId() {
return "";
}

private static final String TRUFFLE_CORE_LOAD_PATH = Options.TRUFFLE_CORE_LOAD_PATH.load();

public static boolean skipTruffleRubiniusWarnings(RubyLexer lexer) {
return lexer.getFile().startsWith("core:/");
return lexer.getFile().startsWith(TRUFFLE_CORE_LOAD_PATH);
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -125,6 +125,8 @@ public class Options {
public static final Option<Boolean> IR_WRITING_DEBUG = bool(IR, "ir.writing.debug", false, "Debug writing JRuby IR file.");
public static final Option<String> IR_INLINE_COMPILER_PASSES = string(IR, "ir.inline_passes", "Specify comma delimeted list of passes to run after inlining a method.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/", "Directory to load the Truffle core library from.");

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<Integer> TRUFFLE_ARRAYS_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.arrays.uninitialized_size", 32, "How large an array to allocate when we have no other information to go on.");
public static final Option<Integer> TRUFFLE_ARRAYS_SMALL = integer(TRUFFLE, "truffle.arrays.small", 3, "Maximum size of an Array to consider small for optimisations.");
1 change: 1 addition & 0 deletions spec/truffle/tags/core/argf/gets_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@ fails:ARGF.gets sets $_ global variable with each line read
fails:ARGF.gets modifies the files when in place edit mode is on
fails:ARGF.gets modifies and backups two files when in place edit mode is on
slow:ARGF.gets reads all lines of stdin
fails:ARGF.gets reads all lines of stdin
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/argf/read_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
slow:ARGF.read reads the contents of stdin
slow:ARGF.read reads a number of bytes from stdin
slow:ARGF.read reads the contents of one file and stdin
fails:ARGF.read reads the contents of stdin
fails:ARGF.read reads a number of bytes from stdin
fails:ARGF.read reads the contents of one file and stdin
1 change: 1 addition & 0 deletions spec/truffle/tags/core/argf/readline_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@ fails:ARGF.readline sets $_ global variable with each line read
fails:ARGF.readline modifies the files when in place edit mode is on
fails:ARGF.readline modifies and backups two files when in place edit mode is on
slow:ARGF.readline reads all lines of stdin
fails:ARGF.readline reads all lines of stdin
4 changes: 4 additions & 0 deletions spec/truffle/tags/core/argf/set_encoding_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,7 @@ slow:ARGF.set_encoding sets the external encoding when passed an encoding instan
slow:ARGF.set_encoding sets the external encoding when passed an encoding name
slow:ARGF.set_encoding sets the external, internal encoding when passed two encoding instances
slow:ARGF.set_encoding sets the external, internal encoding when passed 'ext:int' String
fails:ARGF.set_encoding sets the external encoding when passed an encoding instance
fails:ARGF.set_encoding sets the external encoding when passed an encoding name
fails:ARGF.set_encoding sets the external, internal encoding when passed two encoding instances
fails:ARGF.set_encoding sets the external, internal encoding when passed 'ext:int' String
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/encoding/default_external_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,6 @@ windows:Encoding.default_external with command line options returns the encoding
slow:Encoding.default_external with command line options is not changed by the -U option
slow:Encoding.default_external with command line options returns the encoding specified by '-E external'
slow:Encoding.default_external with command line options returns the encoding specified by '-E external:'
fails:Encoding.default_external with command line options is not changed by the -U option
fails:Encoding.default_external with command line options returns the encoding specified by '-E external'
fails:Encoding.default_external with command line options returns the encoding specified by '-E external:'
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/encoding/default_internal_tags.txt
Original file line number Diff line number Diff line change
@@ -4,3 +4,6 @@ windows:Encoding.default_internal with command line options uses the encoding sp
slow:Encoding.default_internal with command line options returns Encoding::UTF_8 if ruby was invoked with -U
slow:Encoding.default_internal with command line options uses the encoding specified when ruby is invoked with an '-E :internal' argument
slow:Encoding.default_internal with command line options uses the encoding specified when ruby is invoked with an '-E external:internal' argument
fails:Encoding.default_internal with command line options returns Encoding::UTF_8 if ruby was invoked with -U
fails:Encoding.default_internal with command line options uses the encoding specified when ruby is invoked with an '-E :internal' argument
fails:Encoding.default_internal with command line options uses the encoding specified when ruby is invoked with an '-E external:internal' argument
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/kernel/at_exit_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,6 @@ slow:Kernel.at_exit runs in reverse order of registration
slow:Kernel.at_exit allows calling exit inside at_exit handler
slow:Kernel.at_exit gives access to the last raised exception
fails:Kernel.at_exit gives access to the last raised exception
fails:Kernel.at_exit runs after all other code
fails:Kernel.at_exit runs in reverse order of registration
fails:Kernel.at_exit allows calling exit inside at_exit handler
1 change: 1 addition & 0 deletions spec/truffle/tags/core/kernel/autoload_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
slow:Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant
fails:Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/kernel/caller_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Kernel#caller returns an Array of caller locations using a custom offset
fails:Kernel#caller returns the locations as String instances
6 changes: 6 additions & 0 deletions spec/truffle/tags/core/kernel/exec_tags.txt
Original file line number Diff line number Diff line change
@@ -72,3 +72,9 @@ slow:Kernel.exec with a command array uses the first element as the command name
slow:Kernel.exec with a command array coerces the argument using to_ary
slow:Kernel.exec with a command array raises an ArgumentError if the Array does not have exactly two elements
slow:Kernel.exec with an options Hash with Integer option keys maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value
fails:Kernel#exec flushes STDOUT upon exit when it's not set to sync
fails:Kernel#exec flushes STDERR upon exit when it's not set to sync
fails:Kernel#exec with multiple arguments does not subject the arguments to shell expansion
fails:Kernel.exec flushes STDOUT upon exit when it's not set to sync
fails:Kernel.exec flushes STDERR upon exit when it's not set to sync
fails:Kernel.exec with multiple arguments does not subject the arguments to shell expansion
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/process/exec_tags.txt
Original file line number Diff line number Diff line change
@@ -37,3 +37,5 @@ slow:Process.exec with a command array coerces the argument using to_ary
slow:Process.exec with a command array raises an ArgumentError if the Array does not have exactly two elements
slow:Process.exec with an options Hash with Integer option keys maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value
fails:Process.exec flushes STDOUT upon exit when it's not set to sync
fails:Process.exec with multiple arguments does not subject the arguments to shell expansion

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Thread::Backtrace::Location#inspect converts the call frame to a String
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Thread::Backtrace::Location#to_s converts the call frame to a String
1 change: 1 addition & 0 deletions spec/truffle/tags/language/predefined/data_tags.txt
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ windows:The DATA constant exists when the main script contains __END__
windows:The DATA constant does not exist when the main script contains no __END__
windows:The DATA constant does not change when an included files also has a __END__
fails:The DATA constant exists when the main script contains __END__
fails:The DATA constant does not exist when the main script contains no __END__
4 changes: 4 additions & 0 deletions spec/truffle/tags/language/predefined_tags.txt
Original file line number Diff line number Diff line change
@@ -10,3 +10,7 @@ windows:The predefined global constant STDERR has the encodings set by #set_enco
fails:Predefined global $_ is set to the last line read by e.g. StringIO#gets
fails:Predefined global $_ is set at the method-scoped level rather than block-scoped
fails:Global variable $0 actually sets the program name
fails:The predefined global constant STDIN has the encodings set by #set_encoding
fails:The predefined global constant STDIN retains the encoding set by #set_encoding when Encoding.default_external is changed
fails:The predefined global constant STDOUT has the encodings set by #set_encoding
fails:The predefined global constant STDERR has the encodings set by #set_encoding
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -249,7 +249,7 @@ def rebuild

def run(*args)
env_vars = args.first.is_a?(Hash) ? args.shift : {}
jruby_args = %w[-X+T]
jruby_args = %w[-X+T -Xtruffle.core.load_path=truffle/src/main/ruby]

{ '--asm' => '--graal', '--igv' => '--graal' }.each_pair do |arg, dep|
args.unshift dep if args.include?(arg)
50 changes: 4 additions & 46 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@
import com.oracle.truffle.api.source.SourceSection;
import jnr.ffi.provider.MemoryManager;
import jnr.posix.POSIX;
import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.RubyString;
import org.jruby.truffle.nodes.core.BindingNodes;
import org.jruby.truffle.nodes.core.StringNodes;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.instrument.RubyWrapperNode;
import org.jruby.truffle.runtime.NotProvided;
@@ -34,9 +34,7 @@
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.sockets.NativeSockets;
import org.jruby.util.ByteList;

import java.math.BigInteger;
import java.nio.ByteBuffer;
import org.jruby.util.StringSupport;

@TypeSystemReference(RubyTypes.class)
@ImportStatic(RubyGuards.class)
@@ -62,7 +60,7 @@ public RubyNode(RubyContext context, SourceSection sourceSection) {
public abstract Object execute(VirtualFrame frame);

public Object isDefined(VirtualFrame frame) {
return StringNodes.createString(getContext().getCoreLibrary().getStringClass(), "expression");
return Layouts.STRING.createString(Layouts.CLASS.getInstanceFactory(getContext().getCoreLibrary().getStringClass()), RubyString.encodeBytelist("expression", UTF8Encoding.INSTANCE), StringSupport.CR_UNKNOWN, null);
}

// Execute without returning the result
@@ -167,46 +165,6 @@ public DynamicObject getSymbol(ByteList name) {
return getContext().getSymbol(name);
}

protected DynamicObject createEmptyString() {
return StringNodes.createEmptyString(getContext().getCoreLibrary().getStringClass());
}

protected DynamicObject createString(String string) {
return StringNodes.createString(getContext().getCoreLibrary().getStringClass(), string);
}

protected DynamicObject createString(String string, Encoding encoding) {
return StringNodes.createString(getContext().getCoreLibrary().getStringClass(), string, encoding);
}

protected DynamicObject createString(byte[] bytes) {
return StringNodes.createString(getContext().getCoreLibrary().getStringClass(), bytes);
}

protected DynamicObject createString(ByteBuffer bytes) {
return StringNodes.createString(getContext().getCoreLibrary().getStringClass(), bytes);
}

protected DynamicObject createString(ByteList bytes) {
return StringNodes.createString(getContext().getCoreLibrary().getStringFactory(), bytes);
}

protected DynamicObject createEmptyArray() {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);
}

protected DynamicObject createArrayWith(Object... store) {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), store, store.length);
}

protected DynamicObject createArray(Object store, int size) {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), store, size);
}

protected DynamicObject createBignum(BigInteger value) {
return Layouts.BIGNUM.createBignum(getContext().getCoreLibrary().getBignumFactory(), value);
}

protected POSIX posix() {
return getContext().getPosix();
}
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.hash.HashNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.methods.Arity;

import java.util.Map;
@@ -68,7 +68,7 @@ public void executeVoid(VirtualFrame frame) {
}

if (!keywordsRest && keywordArguments != null) {
for (Map.Entry<Object, Object> keyValue : HashNodes.iterableKeyValues(keywordArguments)) {
for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(keywordArguments)) {
if (!keywordAllowed(keyValue.getKey().toString())) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError("unknown keyword: " + keyValue.getKey().toString(), this));
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@
import com.oracle.truffle.api.utilities.ValueProfile;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.hash.HashNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.hash.HashOperations;

import java.util.Map;

@@ -76,7 +76,7 @@ public Object execute(VirtualFrame frame) {
private Object lookupKeywordInHash(DynamicObject hash) {
assert RubyGuards.isRubyHash(hash);

for (Map.Entry<Object, Object> keyValue : HashNodes.iterableKeyValues(hash)) {
for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(hash)) {
if (keyValue.getKey().toString().equals(name)) {
return keyValue.getValue();
}
Original file line number Diff line number Diff line change
@@ -15,11 +15,11 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.hash.HashLiteralNode;
import org.jruby.truffle.nodes.core.hash.HashNodes;
import org.jruby.truffle.nodes.methods.MarkerNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.hash.BucketsStrategy;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.layouts.Layouts;

import java.util.ArrayList;
@@ -63,12 +63,12 @@ private Object lookupRestKeywordArgumentHash(VirtualFrame frame) {
final DynamicObject hash = RubyArguments.getUserKeywordsHash(frame.getArguments(), minimum);

if (hash == null) {
return HashNodes.createEmptyHash(getContext().getCoreLibrary().getHashClass());
return Layouts.HASH.createHash(getContext().getCoreLibrary().getHashFactory(), null, null, null, 0, null, null, false);
}

final List<Map.Entry<Object, Object>> entries = new ArrayList<>();

outer: for (Map.Entry<Object, Object> keyValue : HashNodes.iterableKeyValues(hash)) {
outer: for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(hash)) {
for (String excludedKeyword : excludedKeywords) {
if (excludedKeyword.equals(keyValue.getKey().toString())) {
continue outer;
@@ -78,7 +78,7 @@ private Object lookupRestKeywordArgumentHash(VirtualFrame frame) {
entries.add(keyValue);
}

return BucketsStrategy.create(getContext().getCoreLibrary().getHashClass(), entries, Layouts.HASH.getCompareByIdentity(hash));
return BucketsStrategy.create(getContext(), entries, Layouts.HASH.getCompareByIdentity(hash));
}

}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.array.ArrayUtils;
import org.jruby.truffle.runtime.layouts.Layouts;

/**
* Read the rest of arguments after a certain point into an array.
@@ -41,8 +42,6 @@ public ReadRestArgumentNode(RubyContext context, SourceSection sourceSection, in

@Override
public Object execute(VirtualFrame frame) {
final DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();

int count = RubyArguments.getUserArgumentsCount(frame.getArguments());

int endIndex = count + negativeEndIndex;
@@ -57,19 +56,26 @@ public Object execute(VirtualFrame frame) {

final int length = endIndex - startIndex;

final Object resultStore;
final int resultLength;

if (startIndex == 0) {
final Object[] arguments = RubyArguments.extractUserArguments(frame.getArguments());
return ArrayNodes.createGeneralArray(arrayClass, arguments, length);
resultStore = arguments;
resultLength = length;
} else {
if (startIndex >= endIndex) {
noArgumentsLeftProfile.enter();
return ArrayNodes.createGeneralArray(arrayClass, null, 0);
resultStore = null;
resultLength = 0;
} else {
subsetOfArgumentsProfile.enter();
final Object[] arguments = RubyArguments.extractUserArguments(frame.getArguments());
// TODO(CS): risk here of widening types too much - always going to be Object[] - does seem to be something that does happen
return ArrayNodes.createGeneralArray(arrayClass, ArrayUtils.extractRange(arguments, startIndex, endIndex), length);
resultStore = ArrayUtils.extractRange(arguments, startIndex, endIndex);
resultLength = length;
}
}

return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), resultStore, resultLength);
}
}
Original file line number Diff line number Diff line change
@@ -17,13 +17,13 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.layouts.Layouts;

/*
* TODO(CS): could probably unify this with SplatCastNode with some final configuration options.
@@ -81,10 +81,10 @@ public DynamicObject castArray(DynamicObject array) {
public Object cast(Object nil) {
switch (nilBehavior) {
case EMPTY_ARRAY:
return createEmptyArray();
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

case ARRAY_WITH_NIL:
return ArrayNodes.createGeneralArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{nil()}, 1);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{nil()}, 1);

case NIL:
return nil;
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

@NodeChild(value = "child", type = RubyNode.class)
public abstract class SingleValueCastNode extends RubyNode {
@@ -41,8 +42,7 @@ protected Object castSingle(Object[] args) {
@TruffleBoundary
@Specialization(guards = { "!noArguments(args)", "!singleArgument(args)" })
protected DynamicObject castMany(Object[] args) {
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
return ArrayNodes.createGeneralArray(arrayClass, args, args.length);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), args, args.length);
}

protected boolean noArguments(Object[] args) {
Loading

0 comments on commit 08f77c6

Please sign in to comment.