From 1dfdb9cf709be3234479cf4db089007fd63c3402 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Wed, 9 Nov 2016 22:59:34 -0800 Subject: [nomerge] SI-10037 ASR/LSR switched in ICodeReader Noticed when inlining from a class file. The test doesn't work because inlining fails with bytecode unavailable due to: ``` scala.reflect.internal.MissingRequirementError: object X in compiler mirror not found. ``` --- src/compiler/scala/tools/nsc/backend/icode/Primitives.scala | 2 +- src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala | 8 ++++---- test/files/run/t10037.check | 2 ++ test/files/run/t10037.flags | 1 + test/files/run/t10037/shifter_2.scala | 8 ++++++++ test/files/run/t10037/shifty_1.scala | 7 +++++++ 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 test/files/run/t10037.check create mode 100644 test/files/run/t10037.flags create mode 100644 test/files/run/t10037/shifter_2.scala create mode 100644 test/files/run/t10037/shifty_1.scala diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index 27bf836484..dd930ba52f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -210,7 +210,7 @@ trait Primitives { self: ICodes => case LSL => "LSL" case ASR => "ASR" case LSR => "LSR" - case _ => throw new RuntimeException("ShitOp unknown case") + case _ => throw new RuntimeException("ShiftOp unknown case") } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index b2f5a4119d..7f18565cdf 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -452,10 +452,10 @@ abstract class ICodeReader extends ClassfileParser { case JVM.ishl => code.emit(CALL_PRIMITIVE(Shift(LSL, INT))) case JVM.lshl => code.emit(CALL_PRIMITIVE(Shift(LSL, LONG))) - case JVM.ishr => code.emit(CALL_PRIMITIVE(Shift(LSR, INT))) - case JVM.lshr => code.emit(CALL_PRIMITIVE(Shift(LSR, LONG))) - case JVM.iushr => code.emit(CALL_PRIMITIVE(Shift(ASR, INT))) - case JVM.lushr => code.emit(CALL_PRIMITIVE(Shift(ASR, LONG))) + case JVM.ishr => code.emit(CALL_PRIMITIVE(Shift(ASR, INT))) + case JVM.lshr => code.emit(CALL_PRIMITIVE(Shift(ASR, LONG))) + case JVM.iushr => code.emit(CALL_PRIMITIVE(Shift(LSR, INT))) + case JVM.lushr => code.emit(CALL_PRIMITIVE(Shift(LSR, LONG))) case JVM.iand => code.emit(CALL_PRIMITIVE(Logical(AND, INT))) case JVM.land => code.emit(CALL_PRIMITIVE(Logical(AND, LONG))) case JVM.ior => code.emit(CALL_PRIMITIVE(Logical(OR, INT))) diff --git a/test/files/run/t10037.check b/test/files/run/t10037.check new file mode 100644 index 0000000000..94c07bddf5 --- /dev/null +++ b/test/files/run/t10037.check @@ -0,0 +1,2 @@ +-1073741824 +1073741824 diff --git a/test/files/run/t10037.flags b/test/files/run/t10037.flags new file mode 100644 index 0000000000..2a7be92cd4 --- /dev/null +++ b/test/files/run/t10037.flags @@ -0,0 +1 @@ +-optimise -Ybackend:GenASM -Yinline-warnings diff --git a/test/files/run/t10037/shifter_2.scala b/test/files/run/t10037/shifter_2.scala new file mode 100644 index 0000000000..901dd2a312 --- /dev/null +++ b/test/files/run/t10037/shifter_2.scala @@ -0,0 +1,8 @@ + +object Test extends App { + val i = shifty.X.f(Int.MinValue) + val j = shifty.X.g(Int.MinValue) + println(i) + println(j) +} + diff --git a/test/files/run/t10037/shifty_1.scala b/test/files/run/t10037/shifty_1.scala new file mode 100644 index 0000000000..2f28da01ca --- /dev/null +++ b/test/files/run/t10037/shifty_1.scala @@ -0,0 +1,7 @@ + +package shifty + +object X { + @inline def f(i: Int): Int = i >> 1 + @inline def g(i: Int): Int = i >>> 1 +} -- cgit v1.2.3