【问题标题】:Why bytecode sequence number are not continuous为什么字节码序列号不连续
【发布时间】:2019-04-02 08:35:02
【问题描述】:
 static void heapVar();
Code:
   0: iconst_3
   1: newarray       int
   3: dup
   4: iconst_0
   5: bipush        100
   7: iastore
   8: dup
   9: iconst_1
  10: sipush        200
  13: iastore
  14: dup
  15: iconst_2
  16: sipush        300
  19: iastore
  20: astore_0
  21: return

字节码在上面,为什么左边的数字是0 1 3 4 5 7 ...,而不是连续的,例如0 1 2 3 4 5 6 7...,缺少2和6是否意味着什么?

【问题讨论】:

  • byte 偏移量并且指令有不同的大小(参见herethere)。

标签: bytecode javap


【解决方案1】:

它不是一个序列,而是偏移量。因此取决于操作的物理大小(以字节为单位),例如 2、3、4 字节长度,然后下一个将从该偏移量开始。比如newarray int似乎占用了2个字节,这就是dup从3开始的原因,以此类推。

这是一篇文章,解释output format

【讨论】:

    猜你喜欢
    • 2020-09-30
    • 2013-01-14
    • 1970-01-01
    • 2016-12-20
    • 2017-12-28
    • 1970-01-01
    • 2013-06-15
    • 2011-10-26
    • 2019-12-13
    相关资源
    最近更新 更多