我在內聯多個方法調用後生成一個字節碼序列。在內聯開始時,如果內聯方法出現任何異常,我首先將現有變量索引重新設置爲新的局部變量數字。此操作會導致最終字節碼中出現多個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序列。
謝謝
數據流分析? – immibis