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
Fix build on Windows. #26
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a289465 broke get-scala-revision.bat.
retronym
referenced
this pull request
in retronym/scala
Nov 6, 2014
In Scala 2.8.2, an optimization was added to create a static cache for Symbol literals (ie, the results of `Symbol.apply("foo"))`. This saves the map lookup on the second pass through code. This actually was broken somewhere during the Scala 2.10 series, after the addition of an overloaded `apply` method to `Symbol`. The cache synthesis code was made aware of the overload and brought back to working condition recently, in scala#3149. However, this has uncovered a latent bug when the Symbol literals are defined with traits. One of the enclosed tests failed with: jvm > t8933b-run.log java.lang.IllegalAccessError: tried to access field MotherClass.symbol$1 from class MixinWithSymbol$class at MixinWithSymbol$class.symbolFromTrait(A.scala:3) at MotherClass.symbolFromTrait(Test.scala:1) This commit simply disables the optimization if we are in a trait. Alternative fixes might be: a) make the static Symbol cache field public / b) "mixin" the static symbol cache. Neither of these seem worth the effort and risk for an already fairly situational optimization. Here's how the optimization looks in a class: % cat sandbox/test.scala; qscalac sandbox/test.scala && echo ":javap C" | qscala; class C { 'a; 'b } Welcome to Scala version 2.11.5-20141106-145558-aa558dce6d (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> :javap C Size 722 bytes MD5 checksum 6bb00189166917254e8d40499ee7c887 Compiled from "test.scala" public class C { public static {}; descriptor: ()V flags: ACC_PUBLIC, ACC_STATIC Code: stack=2, locals=0, args_size=0 0: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 3: ldc #18 // String a 5: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 8: putstatic #26 // Field symbol$1:Lscala/Symbol; 11: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 14: ldc #28 // String b 16: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 19: putstatic #31 // Field symbol$2:Lscala/Symbol; 22: return public C(); descriptor: ()V flags: ACC_PUBLIC Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #34 // Method java/lang/Object."<init>":()V 4: getstatic #26 // Field symbol$1:Lscala/Symbol; 7: pop 8: getstatic #31 // Field symbol$2:Lscala/Symbol; 11: pop 12: return }
retronym
referenced
this pull request
in retronym/scala
Nov 6, 2014
In Scala 2.8.2, an optimization was added to create a static cache for Symbol literals (ie, the results of `Symbol.apply("foo"))`. This saves the map lookup on the second pass through code. This actually was broken somewhere during the Scala 2.10 series, after the addition of an overloaded `apply` method to `Symbol`. The cache synthesis code was made aware of the overload and brought back to working condition recently, in scala#3419. However, this has uncovered a latent bug when the Symbol literals are defined with traits. One of the enclosed tests failed with: jvm > t8933b-run.log java.lang.IllegalAccessError: tried to access field MotherClass.symbol$1 from class MixinWithSymbol$class at MixinWithSymbol$class.symbolFromTrait(A.scala:3) at MotherClass.symbolFromTrait(Test.scala:1) This commit simply disables the optimization if we are in a trait. Alternative fixes might be: a) make the static Symbol cache field public / b) "mixin" the static symbol cache. Neither of these seem worth the effort and risk for an already fairly situational optimization. Here's how the optimization looks in a class: % cat sandbox/test.scala; qscalac sandbox/test.scala && echo ":javap C" | qscala; class C { 'a; 'b } Welcome to Scala version 2.11.5-20141106-145558-aa558dce6d (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> :javap C Size 722 bytes MD5 checksum 6bb00189166917254e8d40499ee7c887 Compiled from "test.scala" public class C { public static {}; descriptor: ()V flags: ACC_PUBLIC, ACC_STATIC Code: stack=2, locals=0, args_size=0 0: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 3: ldc #18 // String a 5: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 8: putstatic #26 // Field symbol$1:Lscala/Symbol; 11: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 14: ldc #28 // String b 16: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 19: putstatic #31 // Field symbol$2:Lscala/Symbol; 22: return public C(); descriptor: ()V flags: ACC_PUBLIC Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #34 // Method java/lang/Object."<init>":()V 4: getstatic #26 // Field symbol$1:Lscala/Symbol; 7: pop 8: getstatic #31 // Field symbol$2:Lscala/Symbol; 11: pop 12: return } fixup
retronym
referenced
this pull request
in retronym/scala
Nov 7, 2014
In Scala 2.8.2, an optimization was added to create a static cache for Symbol literals (ie, the results of `Symbol.apply("foo"))`. This saves the map lookup on the second pass through code. This actually was broken somewhere during the Scala 2.10 series, after the addition of an overloaded `apply` method to `Symbol`. The cache synthesis code was made aware of the overload and brought back to working condition recently, in scala#3149. However, this has uncovered a latent bug when the Symbol literals are defined with traits. One of the enclosed tests failed with: jvm > t8933b-run.log java.lang.IllegalAccessError: tried to access field MotherClass.symbol$1 from class MixinWithSymbol$class at MixinWithSymbol$class.symbolFromTrait(A.scala:3) at MotherClass.symbolFromTrait(Test.scala:1) This commit simply disables the optimization if we are in a trait. Alternative fixes might be: a) make the static Symbol cache field public / b) "mixin" the static symbol cache. Neither of these seem worth the effort and risk for an already fairly situational optimization. Here's how the optimization looks in a class: % cat sandbox/test.scala; qscalac sandbox/test.scala && echo ":javap C" | qscala; class C { 'a; 'b } Welcome to Scala version 2.11.5-20141106-145558-aa558dce6d (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> :javap C Size 722 bytes MD5 checksum 6bb00189166917254e8d40499ee7c887 Compiled from "test.scala" public class C { public static {}; descriptor: ()V flags: ACC_PUBLIC, ACC_STATIC Code: stack=2, locals=0, args_size=0 0: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 3: ldc #18 // String a 5: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 8: putstatic #26 // Field symbol$1:Lscala/Symbol; 11: getstatic #16 // Field scala/Symbol$.MODULE$:Lscala/Symbol$; 14: ldc #28 // String b 16: invokevirtual #22 // Method scala/Symbol$.apply:(Ljava/lang/String;)Lscala/Symbol; 19: putstatic #31 // Field symbol$2:Lscala/Symbol; 22: return public C(); descriptor: ()V flags: ACC_PUBLIC Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #34 // Method java/lang/Object."<init>":()V 4: getstatic #26 // Field symbol$1:Lscala/Symbol; 7: pop 8: getstatic #31 // Field symbol$2:Lscala/Symbol; 11: pop 12: return } fixup
retronym
referenced
this pull request
in retronym/scala
May 19, 2015
See also: https://github.com/retronym/indy-structural ``` qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v warning: there was one feature warning; re-run with -feature for details one warning found QUACK! A QUICK! A Classfile /Users/jason/code/scala2/Test$.class { public static final Test$ MODULE$; descriptor: LTest$; flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL public void main(java.lang.String[]); descriptor: ([Ljava/lang/String;)V flags: ACC_PUBLIC Code: stack=4, locals=2, args_size=2 0: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 3: aload_0 4: new #21 // class C 7: dup 8: invokespecial #22 // Method C."<init>":()V 11: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 14: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 17: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 20: aload_0 21: new #32 // class D 24: dup 25: invokespecial #33 // Method D."<init>":()V 28: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 31: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 34: return public java.lang.String duckduck(java.lang.Object); descriptor: (Ljava/lang/Object;)Ljava/lang/String; flags: ACC_PUBLIC Code: stack=2, locals=2, args_size=2 0: aload_1 1: ldc #38 // String A 3: invokedynamic #49, 0 // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; 8: checkcast #51 // class java/lang/String 11: areturn } BootstrapMethods: 0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: ```
retronym
referenced
this pull request
in retronym/scala
May 19, 2015
See also: https://github.com/retronym/indy-structural ``` // sandbox/structural.scala object Test { def main(args: Array[String]): Unit = { println(duckduck(new C)) println(duckduck(new D)) } def duckduck(a: { def quack(a: String): String }): String = { a.quack("A") } } class C { def quack(a: String) = "QUACK! " + a } class D { def quack(a: String) = "QUICK! " + a } ``` ``` qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v warning: there was one feature warning; re-run with -feature for details one warning found QUACK! A QUICK! A Classfile /Users/jason/code/scala2/Test$.class { public static final Test$ MODULE$; descriptor: LTest$; flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL public void main(java.lang.String[]); descriptor: ([Ljava/lang/String;)V flags: ACC_PUBLIC Code: stack=4, locals=2, args_size=2 0: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 3: aload_0 4: new #21 // class C 7: dup 8: invokespecial #22 // Method C."<init>":()V 11: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 14: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 17: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 20: aload_0 21: new #32 // class D 24: dup 25: invokespecial #33 // Method D."<init>":()V 28: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 31: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 34: return public java.lang.String duckduck(java.lang.Object); descriptor: (Ljava/lang/Object;)Ljava/lang/String; flags: ACC_PUBLIC Code: stack=2, locals=2, args_size=2 0: aload_1 1: ldc #38 // String A 3: invokedynamic #49, 0 // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; 8: checkcast #51 // class java/lang/String 11: areturn } BootstrapMethods: 0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: ```
retronym
referenced
this pull request
in retronym/scala
May 19, 2015
See also: https://github.com/retronym/indy-structural ``` // sandbox/structural.scala object Test { def main(args: Array[String]): Unit = { println(duckduck(new C)) println(duckduck(new D)) } def duckduck(a: { def quack(a: String): String }): String = { a.quack("A") } } class C { def quack(a: String) = "QUACK! " + a } class D { def quack(a: String) = "QUICK! " + a } ``` ``` qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v warning: there was one feature warning; re-run with -feature for details one warning found QUACK! A QUICK! A Classfile /Users/jason/code/scala2/Test$.class { public static final Test$ MODULE$; descriptor: LTest$; flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL public void main(java.lang.String[]); descriptor: ([Ljava/lang/String;)V flags: ACC_PUBLIC Code: stack=4, locals=2, args_size=2 0: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 3: aload_0 4: new #21 // class C 7: dup 8: invokespecial #22 // Method C."<init>":()V 11: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 14: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 17: getstatic #19 // Field scala/Predef$.MODULE$:Lscala/Predef$; 20: aload_0 21: new #32 // class D 24: dup 25: invokespecial #33 // Method D."<init>":()V 28: invokevirtual #26 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String; 31: invokevirtual #30 // Method scala/Predef$.println:(Ljava/lang/Object;)V 34: return public java.lang.String duckduck(java.lang.Object); descriptor: (Ljava/lang/Object;)Ljava/lang/String; flags: ACC_PUBLIC Code: stack=2, locals=2, args_size=2 0: aload_1 1: ldc #38 // String A 3: invokedynamic #49, 0 // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; 8: checkcast #51 // class java/lang/String 11: areturn } BootstrapMethods: 0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: ```
lrytz
pushed a commit
to lrytz/scala
that referenced
this pull request
Nov 5, 2019
Rewritten from sbt/zinc@389c703
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
a289465 broke get-scala-revision.bat.