Skip to content

Commit 672834f

Browse files
committed
Merge branch 'master' into truffle-head
2 parents e898e9c + 7179a58 commit 672834f

File tree

108 files changed

+2700
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2700
-580
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ nbproject/private
9494
# Eclipse files
9595
/.metadata
9696
/.recommenders
97+
core/.apt_generated
9798
core/.classpath
9899
core/.gitignore
99100
core/.project
100101
core/.settings
101-
core/.apt_generated
102+
core/build.eclipse
102103

103104
# Truffle findbugs
104105
truffle-findbugs-report.html

core/src/main/java/org/jruby/RubyTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static DateTimeZone getLocalTimeZone(Ruby runtime) {
151151
}
152152
}
153153

154-
private static DateTimeZone getTimeZoneFromTZString(Ruby runtime, String zone) {
154+
public static DateTimeZone getTimeZoneFromTZString(Ruby runtime, String zone) {
155155
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
156156
if (cachedZone != null) {
157157
return cachedZone;

core/src/main/java/org/jruby/ir/IRBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,14 @@ public Operand buildCase(CaseNode caseNode, IRScope s) {
10341034
Variable eqqResult = s.createTemporaryVariable();
10351035
labels.add(bodyLabel);
10361036
Operand v1, v2;
1037-
if (whenNode.getExpressionNodes() instanceof ListNode) {
1037+
if (whenNode.getExpressionNodes() instanceof DNode) {
1038+
// DNode produces a proper result, so we don't want the special ListNode handling below
1039+
// FIXME: This is obviously gross, and we need a better way to filter out non-expression ListNode here
1040+
// See GH #2423
1041+
s.addInstr(new EQQInstr(eqqResult, build(whenNode.getExpressionNodes(), s), value));
1042+
v1 = eqqResult;
1043+
v2 = manager.getTrue();
1044+
} else if (whenNode.getExpressionNodes() instanceof ListNode) {
10381045
// Note about refactoring:
10391046
// - BEQInstr has a quick implementation when the second operand is a boolean literal
10401047
// If it can be fixed to do this even on the first operand, we can switch around

core/src/main/java/org/jruby/ir/IRClosure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void addInstr(Instr i) {
195195
// FIXME: This lost encoding information when name was converted to string earlier in IRBuilder
196196
keywordArgs.add(new KeyValuePair<Operand, Operand>(new Symbol(rkai.argName, USASCIIEncoding.INSTANCE), rkai.getResult()));
197197
} else if (i instanceof ReceiveRestArgInstr) {
198-
blockArgs.add(new Splat(((ReceiveRestArgInstr)i).getResult()));
198+
blockArgs.add(new Splat(((ReceiveRestArgInstr)i).getResult(), true));
199199
} else if (i instanceof ReceiveArgBase) {
200200
blockArgs.add(((ReceiveArgBase) i).getResult());
201201
}

core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public void init() {
9292
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, StringNodesFactory.getFactories());
9393
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, SymbolNodesFactory.getFactories());
9494
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, ThreadNodesFactory.getFactories());
95-
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TimeNodesFactory.getFactories());
9695
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TrueClassNodesFactory.getFactories());
9796
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TruffleDebugNodesFactory.getFactories());
9897
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TrufflePrimitiveNodesFactory.getFactories());

core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public RubyCallNode(RubyContext context, SourceSection section, String methodNam
8282
this.isSplatted = isSplatted;
8383
this.isVCall = isVCall;
8484

85-
dispatchHead = new DispatchHeadNode(context, ignoreVisibility, false, rubiniusPrimitive, Dispatch.MissingBehavior.CALL_METHOD_MISSING);
85+
dispatchHead = new DispatchHeadNode(context, ignoreVisibility, false, Dispatch.MissingBehavior.CALL_METHOD_MISSING);
8686
respondToMissing = new DispatchHeadNode(context, true, Dispatch.MissingBehavior.RETURN_MISSING);
8787
respondToMissingCast = BooleanCastNodeFactory.create(context, section, null);
8888

core/src/main/java/org/jruby/truffle/nodes/core/BasicObjectNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public abstract static class SendNode extends CoreMethodNode {
314314
public SendNode(RubyContext context, SourceSection sourceSection) {
315315
super(context, sourceSection);
316316

317-
dispatchNode = new DispatchHeadNode(context, true, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), false, Dispatch.MissingBehavior.CALL_METHOD_MISSING);
317+
dispatchNode = new DispatchHeadNode(context, true, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), Dispatch.MissingBehavior.CALL_METHOD_MISSING);
318318

319319
if (Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_UNCACHED.load()) {
320320
dispatchNode.forceUncached();

core/src/main/java/org/jruby/truffle/nodes/core/BignumNodes.java

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -191,7 +191,7 @@ public RubyBignum pow(RubyBignum a, RubyBignum b) {
191191

192192
}
193193

194-
@CoreMethod(names = "/", required = 1)
194+
@CoreMethod(names = {"/", "__slash__"}, required = 1)
195195
public abstract static class DivNode extends BignumCoreMethodNode {
196196

197197
public DivNode(RubyContext context, SourceSection sourceSection) {
@@ -245,36 +245,9 @@ public Object mod(RubyBignum a, long b) {
245245
return fixnumOrBignum(a.mod(b));
246246
}
247247

248-
}
249-
250-
@CoreMethod(names = "divmod", required = 1)
251-
public abstract static class DivModNode extends CoreMethodNode {
252-
253-
@Child protected GeneralDivModNode divModNode;
254-
255-
public DivModNode(RubyContext context, SourceSection sourceSection) {
256-
super(context, sourceSection);
257-
divModNode = new GeneralDivModNode(context, sourceSection);
258-
}
259-
260-
public DivModNode(DivModNode prev) {
261-
super(prev);
262-
divModNode = prev.divModNode;
263-
}
264-
265-
@Specialization
266-
public RubyArray divMod(RubyBignum a, int b) {
267-
return divModNode.execute(a, b);
268-
}
269-
270248
@Specialization
271-
public RubyArray divMod(RubyBignum a, long b) {
272-
return divModNode.execute(a, b);
273-
}
274-
275-
@Specialization
276-
public RubyArray divMod(RubyBignum a, RubyBignum b) {
277-
return divModNode.execute(a, b);
249+
public Object mod(RubyBignum a, RubyBignum b) {
250+
return fixnumOrBignum(a.mod(b));
278251
}
279252

280253
}
@@ -602,6 +575,75 @@ public Object leftShift(RubyBignum a, int b) {
602575

603576
}
604577

578+
@CoreMethod(names = "abs")
579+
public abstract static class AbsNode extends BignumCoreMethodNode {
580+
581+
public AbsNode(RubyContext context, SourceSection sourceSection) {
582+
super(context, sourceSection);
583+
}
584+
585+
public AbsNode(AbsNode prev) {
586+
super(prev);
587+
}
588+
589+
@Specialization
590+
public RubyBignum abs(RubyBignum value) {
591+
return value.abs();
592+
}
593+
594+
}
595+
596+
@CoreMethod(names = "even?")
597+
public abstract static class EvenNode extends BignumCoreMethodNode {
598+
599+
public EvenNode(RubyContext context, SourceSection sourceSection) {
600+
super(context, sourceSection);
601+
}
602+
603+
public EvenNode(EvenNode prev) {
604+
super(prev);
605+
}
606+
607+
@CompilerDirectives.TruffleBoundary
608+
@Specialization
609+
public boolean even(RubyBignum value) {
610+
return value.bigIntegerValue().getLowestSetBit() != 0;
611+
}
612+
613+
}
614+
615+
@CoreMethod(names = "divmod", required = 1)
616+
public abstract static class DivModNode extends CoreMethodNode {
617+
618+
@Child protected GeneralDivModNode divModNode;
619+
620+
public DivModNode(RubyContext context, SourceSection sourceSection) {
621+
super(context, sourceSection);
622+
divModNode = new GeneralDivModNode(context, sourceSection);
623+
}
624+
625+
public DivModNode(DivModNode prev) {
626+
super(prev);
627+
divModNode = prev.divModNode;
628+
}
629+
630+
@Specialization
631+
public RubyArray divMod(RubyBignum a, int b) {
632+
return divModNode.execute(a, b);
633+
}
634+
635+
@Specialization
636+
public RubyArray divMod(RubyBignum a, long b) {
637+
return divModNode.execute(a, b);
638+
}
639+
640+
@Specialization
641+
public RubyArray divMod(RubyBignum a, RubyBignum b) {
642+
return divModNode.execute(a, b);
643+
}
644+
645+
}
646+
605647
@CoreMethod(names = {"to_s", "inspect"})
606648
public abstract static class ToSNode extends CoreMethodNode {
607649

core/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -21,6 +21,8 @@
2121
import org.jruby.truffle.runtime.core.RubyBignum;
2222
import org.jruby.truffle.runtime.core.RubyString;
2323

24+
import java.math.BigInteger;
25+
2426
@CoreClass(name = "Fixnum")
2527
public abstract class FixnumNodes {
2628

@@ -319,7 +321,7 @@ protected static boolean canShiftIntoInt(int a, int b) {
319321

320322
}
321323

322-
@CoreMethod(names = "/", required = 1)
324+
@CoreMethod(names = {"/", "__slash__"}, required = 1)
323325
public abstract static class DivNode extends CoreMethodNode {
324326

325327
private final BranchProfile bGreaterZero = BranchProfile.create();
@@ -545,6 +547,27 @@ public long mod(long a, long b) {
545547
return mod;
546548
}
547549

550+
@Specialization
551+
public Object mod(int a, RubyBignum b) {
552+
return mod((long) a, b);
553+
}
554+
555+
@Specialization
556+
public Object mod(long a, RubyBignum b) {
557+
notDesignedForCompilation();
558+
559+
// TODO(CS): why are we getting this case?
560+
561+
long mod = BigInteger.valueOf(a).mod(b.bigIntegerValue()).longValue();
562+
563+
if (mod < 0 && b.bigIntegerValue().compareTo(BigInteger.ZERO) > 0 || mod > 0 && b.bigIntegerValue().compareTo(BigInteger.ZERO) < 0) {
564+
adjustProfile.enter();
565+
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), BigInteger.valueOf(mod).add(b.bigIntegerValue()));
566+
}
567+
568+
return mod;
569+
}
570+
548571
}
549572

550573
@CoreMethod(names = "divmod", required = 1)
@@ -1231,6 +1254,29 @@ public long abs(long n) {
12311254

12321255
}
12331256

1257+
@CoreMethod(names = "floor")
1258+
public abstract static class FloorNode extends CoreMethodNode {
1259+
1260+
public FloorNode(RubyContext context, SourceSection sourceSection) {
1261+
super(context, sourceSection);
1262+
}
1263+
1264+
public FloorNode(FloorNode prev) {
1265+
super(prev);
1266+
}
1267+
1268+
@Specialization
1269+
public int floor(int n) {
1270+
return n;
1271+
}
1272+
1273+
@Specialization
1274+
public long floor(long n) {
1275+
return n;
1276+
}
1277+
1278+
}
1279+
12341280
@CoreMethod(names = "size", needsSelf = false)
12351281
public abstract static class SizeNode extends CoreMethodNode {
12361282

core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -171,7 +171,7 @@ public double pow(double a, RubyBignum b) {
171171

172172
}
173173

174-
@CoreMethod(names = "/", required = 1)
174+
@CoreMethod(names = {"/", "__slash__"}, required = 1)
175175
public abstract static class DivNode extends CoreMethodNode {
176176

177177
public DivNode(RubyContext context, SourceSection sourceSection) {
@@ -507,6 +507,46 @@ public double abs(double n) {
507507

508508
}
509509

510+
@CoreMethod(names = "ceil")
511+
public abstract static class CeilNode extends CoreMethodNode {
512+
513+
public CeilNode(RubyContext context, SourceSection sourceSection) {
514+
super(context, sourceSection);
515+
}
516+
517+
public CeilNode(CeilNode prev) {
518+
super(prev);
519+
}
520+
521+
@Specialization
522+
public double ceil(double n) {
523+
return Math.ceil(n);
524+
}
525+
526+
}
527+
528+
@CoreMethod(names = "floor")
529+
public abstract static class FloorNode extends CoreMethodNode {
530+
531+
@Child protected FixnumOrBignumNode fixnumOrBignum;
532+
533+
public FloorNode(RubyContext context, SourceSection sourceSection) {
534+
super(context, sourceSection);
535+
fixnumOrBignum = new FixnumOrBignumNode(context, sourceSection);
536+
}
537+
538+
public FloorNode(FloorNode prev) {
539+
super(prev);
540+
fixnumOrBignum = prev.fixnumOrBignum;
541+
}
542+
543+
@Specialization
544+
public Object floor(double n) {
545+
return fixnumOrBignum.fixnumOrBignum(Math.floor(n));
546+
}
547+
548+
}
549+
510550
@CoreMethod(names = "infinite?")
511551
public abstract static class InfiniteNode extends CoreMethodNode {
512552

0 commit comments

Comments
 (0)