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

Commits on May 25, 2016

  1. Copy the full SHA
    856edba View commit details
  2. Copy the full SHA
    0443c1d View commit details
2 changes: 2 additions & 0 deletions tool/jruby_eclipse
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ TRUFFLEJARS = %W[

SNAKEYAMLJAR = "#{M2REPO}/org/yaml/snakeyaml/1.14/snakeyaml-1.14.jar"
ANTLR4JAR = "#{M2REPO}/org/antlr/antlr4-runtime/4.5.1-1/antlr4-runtime-4.5.1-1.jar"
JLINE = "#{M2REPO}/jline/jline/2.11/jline-2.11.jar"

GRAAL_OPTIONS_PREFIX = "graal."

@@ -62,6 +63,7 @@ if rest.include?('-X+T')
bootclasspath += TRUFFLEJARS
classpath << SNAKEYAMLJAR
classpath << ANTLR4JAR
classpath << JLINE
classpath << "#{JRUBY}/truffle/build.eclipse"
java_flags << "-Djruby.truffle.core.load_path=#{JRUBY}/truffle/src/main/ruby"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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
*/
package org.jruby.truffle.core.array;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;

@NodeChild(value = "array", type = RubyNode.class)
@ImportStatic(ArrayGuards.class)
public abstract class ArrayToObjectArrayNode extends RubyNode {

public Object[] unsplat(Object[] arguments) {
assert arguments.length == 1;
assert RubyGuards.isRubyArray(arguments[0]);
return executeToObjectArray((DynamicObject) arguments[0]);
}

public abstract Object[] executeToObjectArray(DynamicObject array);

@Specialization(guards = "isNullArray(array)")
public Object[] toObjectArrayNull(DynamicObject array) {
return new Object[0];
}

@Specialization(guards = "strategy.matches(array)", limit = "ARRAY_STRATEGIES")
public Object[] toObjectArrayOther(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
final int size = Layouts.ARRAY.getSize(array);
return strategy.newMirror(array).getBoxedCopy(size);
}

}
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@
package org.jruby.truffle.language.supercall;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.array.ArrayToObjectArrayNode;
import org.jruby.truffle.core.array.ArrayToObjectArrayNodeGen;
import org.jruby.truffle.language.RubyNode;

/**
@@ -24,6 +25,8 @@
public class ReadSuperArgumentsNode extends RubyNode {

@Children private final RubyNode[] arguments;
@Child private ArrayToObjectArrayNode unsplatNode;

private final boolean isSplatted;

public ReadSuperArgumentsNode(RubyContext context, SourceSection sourceSection, RubyNode[] arguments, boolean isSplatted) {
@@ -45,11 +48,18 @@ public final Object execute(VirtualFrame frame) {
}

if (isSplatted) {
// TODO(CS): need something better to splat the arguments array
return ArrayOperations.toObjectArray((DynamicObject) argumentsObjects[0]);
return unsplat(argumentsObjects);
} else {
return argumentsObjects;
}
}

private Object[] unsplat(Object[] argumentsObjects) {
if (unsplatNode == null) {
CompilerDirectives.transferToInterpreter();
unsplatNode = insert(ArrayToObjectArrayNodeGen.create(null));
}
return unsplatNode.unsplat(argumentsObjects);
}

}
Original file line number Diff line number Diff line change
@@ -10,12 +10,14 @@
package org.jruby.truffle.language.supercall;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.array.ArrayToObjectArrayNode;
import org.jruby.truffle.core.array.ArrayToObjectArrayNodeGen;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
@@ -25,8 +27,10 @@
*/
public class ReadZSuperArgumentsNode extends RubyNode {

private final boolean hasRestParameter;
@Children private final RubyNode[] reloadNodes;
@Child private ArrayToObjectArrayNode unsplatNode;

private final boolean hasRestParameter;

public ReadZSuperArgumentsNode(RubyContext context, SourceSection sourceSection, boolean hasRestParameter, RubyNode[] reloadNodes) {
super(context, sourceSection);
@@ -51,12 +55,20 @@ public final Object execute(VirtualFrame frame) {
final int restArgIndex = reloadNodes.length - 1;
final Object restArg = superArguments[restArgIndex];
assert RubyGuards.isRubyArray(restArg);
final Object[] restArgs = ArrayOperations.toObjectArray((DynamicObject) restArg);
final Object[] restArgs = unsplat((DynamicObject) restArg);
superArguments = ArrayUtils.copyOf(superArguments, restArgIndex + restArgs.length);
ArrayUtils.arraycopy(restArgs, 0, superArguments, restArgIndex, restArgs.length);
}

return superArguments;
}

private Object[] unsplat(DynamicObject array) {
if (unsplatNode == null) {
CompilerDirectives.transferToInterpreter();
unsplatNode = insert(ArrayToObjectArrayNodeGen.create(null));
}
return unsplatNode.executeToObjectArray(array);
}

}
Original file line number Diff line number Diff line change
@@ -10,14 +10,14 @@
package org.jruby.truffle.language.yield;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.array.ArrayToObjectArrayNode;
import org.jruby.truffle.core.array.ArrayToObjectArrayNodeGen;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
@@ -29,6 +29,7 @@ public class YieldExpressionNode extends RubyNode {

@Children private final RubyNode[] arguments;
@Child private YieldNode yieldNode;
@Child private ArrayToObjectArrayNode unsplatNode;

private final BranchProfile useCapturedBlock = BranchProfile.create();
private final BranchProfile noCapturedBlock = BranchProfile.create();
@@ -69,11 +70,12 @@ public final Object execute(VirtualFrame frame) {
return getYieldNode().dispatch(frame, block, argumentsObjects);
}

@TruffleBoundary
private Object[] unsplat(Object[] argumentsObjects) {
assert argumentsObjects.length == 1;
assert RubyGuards.isRubyArray(argumentsObjects[0]);
return ArrayOperations.toObjectArray(((DynamicObject) argumentsObjects[0]));
if (unsplatNode == null) {
CompilerDirectives.transferToInterpreter();
unsplatNode = insert(ArrayToObjectArrayNodeGen.create(null));
}
return unsplatNode.unsplat(argumentsObjects);
}

@Override