Skip to content

Examine the inliner log from compiling the scala project #424

Open
@lrytz

Description

@lrytz

Compiling the scala project with -opt-warnings:_ (or even just -opt-warnings) gives plenty of output.

There is probably some useful data in there.

For example:

/Users/luc/scala/scala13/src/library/scala/math/BigDecimal.scala:448: scala/Option::exists(Lscala/Function1;)Z is annotated @inline but could not be inlined:
Failed to check if scala/Option::exists(Lscala/Function1;)Z can be safely inlined to scala/math/BigDecimal without causing an IllegalAccessError. Checking instruction INVOKESTATIC scala/runtime/BoxesRunTime.unboxToBoolean (Ljava/lang/Object;)Z failed:
The method unboxToBoolean(Ljava/lang/Object;)Z could not be found in the class scala/runtime/BoxesRunTime or any of its parents.
Note that class scala/runtime/BoxesRunTime is defined in a Java source (mixed compilation), no bytecode is available.
      this.toBigIntExact.exists(that equals _)
                               ^

The reason is that Option.exists has a call to BoxesRunTime.unboxToBoolean:

    public final boolean exists(Function1<A, Object> p) {
        if (!this.isEmpty() && BoxesRunTime.unboxToBoolean(p.apply(this.get()))) {
            return true;
        }
        return false;
    }

This method is defined in Java, and in mixed compilation we don't have bytecode available. So we don't know if we can inline it into a different class, because we can't check if that's safe in terms of not causing an IllegalAccessError at run-time.

Another potentially useful one (just from random scanning):

/Users/luc/scala/scala13/src/library/scala/collection/immutable/RedBlackTree.scala:399: scala/collection/immutable/RedBlackTree$Tree::value()Ljava/lang/Object; is annotated @inline but could not be inlined:
The callee scala/collection/immutable/RedBlackTree$Tree::value()Ljava/lang/Object; contains the instruction GETFIELD scala/collection/immutable/RedBlackTree$Tree.value : Ljava/lang/Object;
that would cause an IllegalAccessError when inlined into class scala/collection/immutable/RedBlackTree$.
          balanceRight(isBlackTree(node), node.key, node.value, node.left, tree)
                                                         ^

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions