| [#146] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Matthias | Michel | fixed | 2003-09-19 12:23:40.0 | |
| subject | Non-verifiable code for lshl instructions | |||
| code |
object Bug with Executable {
def shift32(x: Int): Long = x.asInstanceOf[Long] << 32;
} |
|||
| what happened | Yields a verifier error at runtime:
|
|||
| what expected | The generated code is:
Method long shift32(int) 0 iload 1 2 invokestatic #81 [Method scala.Int box(int)] 5 invokevirtual #86 [Method long asLong()] 8 ldc #87 [Integer 32] 10 i2l 11 lshl 12 lreturnThe instruction at address 10 is erroneous (or better superfluous). The second argument of lshl on the stack has to be an integer. I was also surprised that there was boxing involved in this expression. I believe programmers expect that such sort of expressions are really efficient, but in our case, it even involved method calls and object instantiations. |
|||
| [back to overview] | ||||
| Matthias edited on 2003-09-19 12:24:28.0 |
| Matthias edited on 2003-09-19 12:26:15.0 |
| Matthias edited on 2003-09-24 15:15:02.0 |
| I fixed this specific issue, but the code generation routine for operations on primitive types doesn't look good in general. |