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

Commits on Dec 16, 2016

  1. Copy the full SHA
    b35ec2f View commit details
  2. [Truffle] Check arity in Rubinius primitives too.

    * Fix Time.from_array instead.
    eregon committed Dec 16, 2016
    Copy the full SHA
    14fef0d View commit details
Original file line number Diff line number Diff line change
@@ -302,8 +302,6 @@ public class BodyTranslator extends Translator {

private boolean privately = false;

protected boolean usesRubiniusPrimitive = false;

public BodyTranslator(com.oracle.truffle.api.nodes.Node currentNode, RubyContext context, BodyTranslator parent, TranslatorEnvironment environment, Source source, boolean topLevel) {
super(currentNode, context, source);
parserSupport = new ParserSupport(context);
@@ -575,7 +573,7 @@ public RubyNode visitCallNode(CallParseNode node) {
&& ((ConstParseNode) ((Colon2ConstParseNode) receiver).getLeftNode()).getName().equals("Truffle")
&& ((Colon2ConstParseNode) receiver).getName().equals("Graal")) {
if (methodName.equals("assert_constant")) {
final RubyNode ret = AssertConstantNodeGen.create(context, fullSourceSection, node.getArgsNode().childNodes().get(0).accept(this));
final RubyNode ret = AssertConstantNodeGen.create(context, fullSourceSection, ((ArrayParseNode) node.getArgsNode()).get(0).accept(this));
return addNewlineIfNeeded(node, ret);
} else if (methodName.equals("assert_not_compiled")) {
final RubyNode ret = AssertNotCompiledNodeGen.create(context, fullSourceSection);
@@ -594,8 +592,6 @@ && getSourcePath(sourceSection).startsWith(corePath())
}

private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallParseNode node) {
usesRubiniusPrimitive = true;

/*
* Translates something that looks like
*
@@ -610,11 +606,12 @@ private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallPar
* keywords etc).
*/

if (node.getArgsNode().childNodes().size() != 1 || !(node.getArgsNode().childNodes().get(0) instanceof SymbolParseNode)) {
final ArrayParseNode argsNode = (ArrayParseNode) node.getArgsNode();
if (argsNode.size() != 1 || !(argsNode.get(0) instanceof SymbolParseNode)) {
throw new UnsupportedOperationException("Truffle.primitive must have a single literal symbol argument");
}

final String primitiveName = ((SymbolParseNode) node.getArgsNode().childNodes().get(0)).getName();
final String primitiveName = ((SymbolParseNode) argsNode.get(0)).getName();

final PrimitiveNodeConstructor primitive = context.getPrimitiveManager().getPrimitive(primitiveName);
final ReturnID returnID = environment.getReturnID();
@@ -632,7 +629,7 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, C
* InvokePrimitiveNode(FooNode(arg1, arg2, ..., argN))
*/

final List<ParseNode> args = node.getArgsNode().childNodes();
final ArrayParseNode args = (ArrayParseNode) node.getArgsNode();

if (args.size() < 1 || !(args.get(0) instanceof SymbolParseNode)) {
throw new UnsupportedOperationException("Truffle.invoke_primitive must have at least an initial literal symbol argument");
@@ -670,7 +667,8 @@ private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallPar
throw new UnsupportedOperationException("Truffle.privately needs a literal block");
}

if (node.getArgsNode() != null && node.getArgsNode().childNodes().size() > 0) {
final ArrayParseNode argsNode = (ArrayParseNode) node.getArgsNode();
if (argsNode != null && argsNode.size() > 0) {
throw new UnsupportedOperationException("Truffle.privately should not have any arguments");
}

Original file line number Diff line number Diff line change
@@ -239,18 +239,9 @@ public RubyNode doCompileMethodBody(RubySourceSection sourceSection, String meth
parentSourceSection.pop();
}

final RubyNode prelude;
final RubyNode checkArity = createCheckArityNode(context, source, sourceSection, arity);

if (usesRubiniusPrimitive) {
// Use Truffle.primitive seems to turn off arity checking. See Time.from_array for example.
prelude = loadArguments;
} else {
final RubyNode checkArity = createCheckArityNode(context, source, sourceSection, arity);

prelude = sequence(context, source, sourceSection, Arrays.asList(checkArity, loadArguments));
}

body = sequence(context, source, body.getRubySourceSection(), Arrays.asList(prelude, body));
body = sequence(context, source, body.getRubySourceSection(), Arrays.asList(checkArity, loadArguments, body));

if (environment.getFlipFlopStates().size() > 0) {
body = sequence(context, source, body.getRubySourceSection(), Arrays.asList(initFlipFlopStates(sourceSection), body));
10 changes: 1 addition & 9 deletions truffle/src/main/ruby/core/time.rb
Original file line number Diff line number Diff line change
@@ -132,15 +132,7 @@ def self.from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, u
sec += nsec / 1_000_000_000
nsec %= 1_000_000_000

if utc_offset
utc_offset_sec = utc_offset.to_i
utc_offset_nsec = ((utc_offset % 1.0) * 1_000_000_000 + 0.5).to_i
else
utc_offset_sec = 0
utc_offset_nsec = 0
end

from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset, utc_offset_sec, utc_offset_nsec)
from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset)
end

def self.new(year=undefined, month=nil, day=nil, hour=nil, minute=nil, second=nil, utc_offset=nil)