Skip to content

tests/pos/Map.scala does not produce idempotent bytecode #2274

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

Closed
nicolasstucki opened this issue Apr 19, 2017 · 7 comments
Closed

tests/pos/Map.scala does not produce idempotent bytecode #2274

nicolasstucki opened this issue Apr 19, 2017 · 7 comments
Labels

Comments

@nicolasstucki
Copy link
Contributor

After compiling this file twice in #2272 the two bytecodes differed in the order of some bridges.

Printing the contents of the Map.classs with javap -c -v -p -s showed the following diff:

101c101
<    #92 = Utf8               ()Lscala/collection/Traversable;
---
>    #92 = Utf8               ()Lscala/collection/immutable/Traversable;
104,107c104,107
<    #95 = Utf8               ()Lscala/collection/immutable/Traversable;
<    #96 = Utf8               ()Lscala/collection/TraversableOnce;
<    #97 = Utf8               ()Lscala/collection/Iterable;
<    #98 = Utf8               ()Lscala/collection/immutable/Iterable;
---
>    #95 = Utf8               ()Lscala/collection/immutable/Iterable;
>    #96 = Utf8               ()Lscala/collection/Iterable;
>    #97 = Utf8               ()Lscala/collection/TraversableOnce;
>    #98 = Utf8               ()Lscala/collection/Traversable;
260,261c260,261
<   public scala.collection.Traversable seq();
<     descriptor: ()Lscala/collection/Traversable;
---
>   public scala.collection.immutable.Traversable seq();
>     descriptor: ()Lscala/collection/immutable/Traversable;
274,275c274,275
<   public scala.collection.immutable.Traversable seq();
<     descriptor: ()Lscala/collection/immutable/Traversable;
---
>   public scala.collection.immutable.Iterable seq();
>     descriptor: ()Lscala/collection/immutable/Iterable;
288,289c288,289
<   public scala.collection.TraversableOnce seq();
<     descriptor: ()Lscala/collection/TraversableOnce;
---
>   public scala.collection.Iterable seq();
>     descriptor: ()Lscala/collection/Iterable;
302,303c302,303
<   public scala.collection.Iterable seq();
<     descriptor: ()Lscala/collection/Iterable;
---
>   public scala.collection.Map seq();
>     descriptor: ()Lscala/collection/Map;
316,317c316,317
<   public scala.collection.Map seq();
<     descriptor: ()Lscala/collection/Map;
---
>   public scala.collection.TraversableOnce seq();
>     descriptor: ()Lscala/collection/TraversableOnce;
330,331c330,331
<   public scala.collection.immutable.Iterable seq();
<     descriptor: ()Lscala/collection/immutable/Iterable;
---
>   public scala.collection.Traversable seq();
>     descriptor: ()Lscala/collection/Traversable;

The same issue is present in the AbstractMap.classs.

@nicolasstucki
Copy link
Contributor Author

Same issue is also present compiling tests/pos/t1203a.scala in NodeSeq.class

@smarter
Copy link
Member

smarter commented Apr 19, 2017

After compiling this file twice in #2272 the two bytecodes differed in the order of some bridges.

scalac has some infrastructure to dump bytecode with sorted members using ASM: https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala#L95 It's used to make better bytecode diffs.

@nicolasstucki
Copy link
Contributor Author

If I understand correctly, that tool would hide the issue that I'm trying to show.

@smarter
Copy link
Member

smarter commented Apr 19, 2017

Yes, but since the order of members in the bytecode doesn't matter for anything, I think that's fine.

@nicolasstucki
Copy link
Contributor Author

I would try to make this order idempotent as it is the only thing that has shown .class files that are not idempotent byte wise.

@nicolasstucki
Copy link
Contributor Author

This can only be reproduced when recompiling classes that already exist in the standard library while also loading symbols from the scala2 compiled version.

@nicolasstucki nicolasstucki removed this from the 0.1 Tech Preview milestone Apr 20, 2017
@nicolasstucki
Copy link
Contributor Author

This is just an artifact of the test framework loading classes compiled by scala2. It will disappear when we bootstrap.

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

No branches or pull requests

2 participants