Different behaviour of java bytecode

巧了我就是萌 提交于 2019-11-30 06:50:50

iconst can push constant values -1 to 5. It is a single-byte instruction.

bipush can push constant values between -128 and 127. It is a two-byte instruction.

To push 9 you cannot use iconst. There is no iconst_9 instruction.

Haile

iconst_n is defined for n from 0 to 5

There's no iconst_9, so you have to use the equivalent (but less efficent) bipush

there is no iconst_9 instruction

the i_const instruction only range from 0~5, so it must spit the instuction by push and store

The instructions iconst_* are optimised to work with small and specific numbers while bipush (push a byte onto the stack as an integer value) works for bigger numbers.

There is no iconst_9 instruction. So to push 9 you cannot use iconst. You must go for bipush

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!