You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First the tree Double's are boxed and pushed onto the stack, and then a tuple of size 3 is created and picks up the boxed doubles from the stack. After that the three Doubles are extracted from the tuple, and then unboxed so that they can be added together. I doubt hotspot is sophisticated enough to clean this whole mess up. (Does hotspot know that boxing and unboxing cancel each other out.)
One would expect to get the same code as with the following fragment:
defbugRep2(x : Double, y : Double) :Double=
{
vala= x + y
valb= x - y
valc= x / y
a + b + c
}
For which scala produces perfectly reasonable code:
High level languages carry with them an abstraction cost but this is a case when we should not have to pay anything -- recognizing this idiom and producing the same code as in the second example should be an easy thing for the compiler.
The text was updated successfully, but these errors were encountered:
The usage of pairs in variable initialization pessimizes the code abysmally:
For the simple program below:
Scala 2.7.3.final produces the bytecode below:
First the tree Double's are boxed and pushed onto the stack, and then a tuple of size 3 is created and picks up the boxed doubles from the stack. After that the three Doubles are extracted from the tuple, and then unboxed so that they can be added together. I doubt hotspot is sophisticated enough to clean this whole mess up. (Does hotspot know that boxing and unboxing cancel each other out.)
One would expect to get the same code as with the following fragment:
For which scala produces perfectly reasonable code:
High level languages carry with them an abstraction cost but this is a case when we should not have to pay anything -- recognizing this idiom and producing the same code as in the second example should be an easy thing for the compiler.
The text was updated successfully, but these errors were encountered: