miniboxing / miniboxing-plugin

Miniboxing is a program transformation that improves the performance of Scala generics when used with primitive types. It can speed up generic collections by factors between 1.5x and 22x, while maintaining bytecode duplication to a minimum. You can easily add miniboxing to your sbt project:
http://scala-miniboxing.org
Other
121 stars 17 forks source link

Array translation issue: #246

Closed VladUreche closed 8 years ago

VladUreche commented 8 years ago

Array translation issue:

$ cat mb_array_05.scala 
object Test {
  def test[@miniboxed T](a: Array[T]) =
    // these should be rewired to mbarray_{apply, update}
    a(0) = a(1)
}

$ mb-scalac mb_array_05.scala -Xprint:minibox-commit
[[syntax trees at end of            minibox-commit]] // mb_array_05.scala
package <empty> {
  object Test extends Object {
    def <init>(): Test.type = {
      Test.super.<init>();
      ()
    };
    def test[@miniboxed T](a: Array[T]): Unit = a.update(0, a.apply(1));
    def test$n$D[T](T$TypeTag: Byte, a: Array[T]): Unit = a.update(0, a.apply(1));
    def test$n$J[T](T$TypeTag: Byte, a: Array[T]): Unit = a.update(0, a.apply(1))
  }
}

The a.update and a.apply calls should go through mbarray_{update,apply}.