Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erasing to object #51

Open
mkeskells opened this issue Feb 13, 2018 · 1 comment
Open

Erasing to object #51

mkeskells opened this issue Feb 13, 2018 · 1 comment

Comments

@mkeskells
Copy link
Collaborator

many of the collection method have a return type without bound, e.g. Repr

This means that the bytecode emitted is littered with class cast to the expected type

Not sure what the overhead is. We should measure and see what options there are to improve this

@mkeskells
Copy link
Collaborator Author

mkeskells commented Feb 13, 2018

e.g.

class demo {

  val in = List(1,2)

  def process1 = in.map (_+1).distinct.head
}

generates


  // access flags 0x1
  public process1()I
...
    GETSTATIC scala/collection/immutable/List$.MODULE$ : Lscala/collection/immutable/List$;
    INVOKEVIRTUAL scala/collection/immutable/List$.canBuildFrom ()Lscala/collection/generic/CanBuildFrom;
    INVOKEVIRTUAL scala/collection/immutable/List.map (Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
    CHECKCAST scala/collection/SeqLike
    INVOKEINTERFACE scala/collection/SeqLike.distinct ()Ljava/lang/Object;
    CHECKCAST scala/collection/IterableLike
    INVOKEINTERFACE scala/collection/IterableLike.head ()Ljava/lang/Object;
    INVOKESTATIC scala/runtime/BoxesRunTime.unboxToInt (Ljava/lang/Object;)I
    IRETURN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant