Really long if/loop statements cause Java assembly error
Original Reporter info from Mantis: bozox
-
Reporter name: Seva Alekseyev
Original Reporter info from Mantis: bozox
- Reporter name: Seva Alekseyev
Description:
When compiling Free Pascal to JVM, the compiler emits "goto" assembly statements for Pascal if statements and loops. The goto statement in Java is a near jump - it's limited to offsets of 32KB. When the body of the loop/if is large, the target of the goto can become more than 32KB of bytecode away from the point of goto. When the Jasmin assembler encounters that, it errors out with the message like this:
MyFile.j:50599: JAS Error: reference from line 10039 exceed size for short.
where the second number refers to the line in the generated .j file that's after the failed goto line.
For branch command that can work beyond the 32KB boundary, use the goto_w Java assembly command.
Steps to reproduce:
Install the FPC for Java from the following link:
http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19830-snapshot3/fpcjvmwin32-snapshot3.zip/download
as taken from http://wiki.freepascal.org/FPC_JVM
Compile the attached file with the following command:
ppcjvm -XP a.pas
See the error message.
Mantis conversion info:
- Mantis ID: 22807
- OS: Windows
- OS Build: 7
- Build: 19830
- Platform: JVM
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 22347 (#e7cb2e9a)