Details | Benchmarking code side by side - miniboxing/miniboxing-plugin GitHub Wiki

For the following method in MBResizableArray.scala (the ArrayBuffer class):

  def extend(): Unit = {
    if (elemCount == size) {
      var pos = 0
      newarray = mf.newArray(2 * size)
      while(pos < size) {
        newarray(pos) = array(pos)
        pos += 1
      }
      array = newarray
      size *= 2
    }
  }

We have the following specialized code generated by the plugin:

  def extend_J(T_TypeTag: Byte)(): Unit = if (MBResizableArray_J.this.elemCount_J(T_TypeTag).==(MBResizableArray_J.this.size_J(T_TypeTag)))
    {
      var pos: Int = 0;
      MBResizableArray_J.this.newarray_J_=(T_TypeTag)(MiniboxArray_FullSwitch.this.mbarray_new(2.*(MBResizableArray_J.this.size_J(T_TypeTag)), T_TypeTag));
      while$1(){
        if (pos.<(MBResizableArray_J.this.size_J(T_TypeTag)))
          {
            {
              MiniboxArray_FullSwitch.this.mbarray_update_minibox(MBResizableArray_J.this.newarray_J(T_TypeTag), pos, MiniboxArray_FullSwitch.this.mbarray_apply_minibox(MBResizableArray_J.this.array_J(T_TypeTag), pos, T_TypeTag), T_TypeTag);
              pos = pos.+(1)
            };
            while$1()
          }
        else
          ()
      };
      MBResizableArray_J.this.array_J_=(T_TypeTag)(MBResizableArray_J.this.newarray_J(T_TypeTag));
      MBResizableArray_J.this.size_J_=(T_TypeTag)(MBResizableArray_J.this.size_J(T_TypeTag).*(2))
    }
  else
    ();

Note that the above is not source code but a printout of the internal Scala AST after the miniboxing transformation phase (-Xprint:miniboxing). This explains the very detailed owner information and the expanded syntax for operators. which is exactly what we currently use to test the library implementation (in tests/benchmarks/src/miniboxing/benchmarks/hardcoded/fullswitch/MBResizableArray.scala):

  def extend_J(): Unit = {
    if (mboxed_eqeq(elemCount_J, size_J)) {
      var pos = 0
      newarray_J = mbarray_new(2 * size, T_TypeTag).asInstanceOf[Array[Tsp]]
      while(pos < size_J) {
        mbarray_update_minibox(newarray_J, pos, mbarray_apply_minibox(array_J, pos, T_TypeTag), T_TypeTag)
        pos += 1
      }
      array_J = newarray_J
      size_J *= 2
    }
  }

To check out the program output, in the virtual machine: TODO