Types in Bytecode

Posted by HH on Stack Overflow See other posts from Stack Overflow or by HH
Published on 2010-04-14T13:50:07Z Indexed on 2010/04/14 13:53 UTC
Read the original article Hit count: 279

Filed under:
|

Hey everyone,

I've been working for some time on (Java) Bytecode, however, it had never occurred to me to ask why are some instructions typed? I understand that in an ADD operation, we need to distinguish between an integer addition and a FP addition (that's why we have IADD and FADD). However, why do we need to distinguish between ISTORE and FSTORE? They both involve the exact same operation, which is moving 32 bits from the stack to a local variable position?

The only answer I can think of is for type-safety, to prevent this: (ILOAD, ILOAD, FADD). However, I believe that type-safety is already enforced at the Java language level. OK, the Class file format is not directly coupled with Java, so is this a way to enforce type-safety for languages that do not support it? Any thought? Thank you.

© Stack Overflow or respective owner

Related posts about bytecode

Related posts about java