我在内联多方法调用后生成了一个字节码序列。内联开始时,我首先将现有变量索引弹出到一个新的局部变量编号,以防内联方法出现任何异常。这个操作会在最终的字节码中产生一些 xLOAD 和 xStore 序列。样本是:
GETFIELD DYNGuardWithTestHandle1456194204777.guard : Ljava/lang/invoke/MethodHandle;
INVOKEVIRTUAL java/lang/invoke/MethodHandle.invokeExact ()Z
IFEQ L0
ALOAD 0
ALOAD 1
ALOAD 2
ALOAD 3
ALOAD 4
ASTORE 5
ASTORE 6
ASTORE 7
ASTORE 8
ASTORE 9
ALOAD 9
ALOAD 8
ALOAD 7
ALOAD 6
ALOAD 5
ASTORE 10
ASTORE 11
ASTORE 12
ASTORE 13
ASTORE 14
ALOAD 14
GETFIELD DYNGuardWithTestHandle1456194204777.trueTarget_guard_next : Ljava/lang/invoke/MethodHandle;
LDC "fd1a2fc6-03ef-4fd8-a2ae-ebbaa274fa97"
INVOKESTATIC java/lang/invoke/ObjectTransfer.peek (Ljava/lang/String;)Ljava/lang/Object;
CHECKCAST org/jruby/RubyClass
ALOAD 11
INVOKEVIRTUAL java/lang/invoke/MethodHandle.invokeExact (Lorg/jruby/RubyClass;Lorg/jruby/runtime/builtin/IRubyObject;)Z
GOTO L1
L1
IFEQ L2
ALOAD 9
ALOAD 8
ALOAD 7
ALOAD 6
ALOAD 5
ASTORE 15
ASTORE 16
ASTORE 17
ASTORE 18
ASTORE 19
ALOAD 19
ALOAD 16
ALOAD 18
ALOAD 15
ASTORE 20
ASTORE 21
ASTORE 22
ASTORE 23
ALOAD 23
ALOAD 22
CHECKCAST org/jruby/RubyString
ALOAD 21
ALOAD 20
ASTORE 24
ASTORE 25
ASTORE 26
ASTORE 27
ALOAD 27
ALOAD 26
ALOAD 25
ALOAD 24
ASTORE 28
ASTORE 29
ASTORE 30
ASTORE 31
我想知道是否有一些众所周知的优化来消除这些 xLoad/xStore 序列。
谢谢