commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1392842 - in /commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward: analysis/ arithmetic/ instructions/
Date Tue, 02 Oct 2012 11:19:34 GMT
Author: luc
Date: Tue Oct  2 11:19:33 2012
New Revision: 1392842

URL: http://svn.apache.org/viewvc?rev=1392842&view=rev
Log:
Allow instruction transformers to check conversion of any stack cell.

Modified:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DcmpTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/InvokeStaticTransformer.java

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
Tue Oct  2 11:19:33 2012
@@ -300,21 +300,31 @@ public class MethodDifferentiator {
 
     }
 
+    /** Check if a stack element has been converted to {@link DerivativeStructure}.
+     * @param insn current instruction
+     * @param index index of the stack element, 0 corresponding to top stack cell
+     * @return true if stack element has been converted to {@link DerivativeStructure}
+     */
+    public boolean stackElementIsConverted(final AbstractInsnNode insn, final int index)
{
+
+        // get the frame at the start of the instruction
+        final Frame<TrackingValue> frame = frames.get(insn);
+
+        // get stack size
+        final int size = frame.getStackSize();
+
+        return converted.contains(frame.getStack(size - (index + 1)));
+
+    }
+
     /** Get the replacement list for an instruction.
      * @param insn instruction to replace
      * @return replacement instructions list
      * @exception DifferentiationException if some instruction cannot be handled
-     * or if no temporary variable can be reserved
      */
     private InsnList getReplacement(final AbstractInsnNode insn)
         throws DifferentiationException {
 
-        // get the frame at the start of the instruction
-        final Frame<TrackingValue> frame = frames.get(insn);
-        final int size = frame.getStackSize();
-        final boolean stack1Converted = (size > 0) && converted.contains(frame.getStack(size
- 2));
-        final boolean stack0Converted = (size > 1) && converted.contains(frame.getStack(size
- 1));
-
         switch(insn.getOpcode()) {
             case Opcodes.DLOAD :
                 return new DLoadTransformer().getReplacement(insn, this);
@@ -333,17 +343,17 @@ public class MethodDifferentiator {
             case Opcodes.DUP2_X1 :
                 return new Dup2X1Transformer().getReplacement(insn, this);
             case Opcodes.DUP2_X2 :
-                return new Dup2X2Transformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new Dup2X2Transformer().getReplacement(insn, this);
             case Opcodes.DADD :
-                return new DAddTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DAddTransformer().getReplacement(insn, this);
             case Opcodes.DSUB :
-                return new DSubTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DSubTransformer().getReplacement(insn, this);
             case Opcodes.DMUL :
-                return new DMulTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DMulTransformer().getReplacement(insn, this);
             case Opcodes.DDIV :
-                return new DDivTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DDivTransformer().getReplacement(insn, this);
             case Opcodes.DREM :
-                return new DRemTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DRemTransformer().getReplacement(insn, this);
             case Opcodes.DNEG :
                 return new DNegTransformer().getReplacement(insn, this);
             case Opcodes.DCONST_0 :
@@ -359,7 +369,7 @@ public class MethodDifferentiator {
                 return new NarrowingTransformer().getReplacement(insn, this);
             case Opcodes.DCMPL :
             case Opcodes.DCMPG :
-                return new DcmpTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new DcmpTransformer().getReplacement(insn, this);
             case Opcodes.DRETURN :
                 // TODO: the constructor parameter forced to true seems strange...
                 return new DReturnTransformer(true).getReplacement(insn, this);
@@ -381,7 +391,7 @@ public class MethodDifferentiator {
                 // TODO: add support for INVOKESPECIAL differentiation
                 throw new RuntimeException("INVOKESPECIAL not handled yet");
             case Opcodes.INVOKESTATIC :
-                return new InvokeStaticTransformer(stack0Converted, stack1Converted).getReplacement(insn,
this);
+                return new InvokeStaticTransformer().getReplacement(insn, this);
             case Opcodes.INVOKEINTERFACE :
                 // TODO: add support for INVOKEINTERFACE differentiation
                 throw new RuntimeException("INVOKEINTERFACE not handled yet");

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer.java
Tue Oct  2 11:19:33 2012
@@ -34,21 +34,6 @@ public class DAddTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the addition. */
     private static final String ADD_METHOD = "add";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DAddTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -56,8 +41,8 @@ public class DAddTransformer implements 
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),
                                             ADD_METHOD,
                                             Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer.java
Tue Oct  2 11:19:33 2012
@@ -40,21 +40,6 @@ public class DDivTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the multiplication. */
     private static final String MULTIPLY_METHOD = "multiply";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DDivTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -62,8 +47,8 @@ public class DDivTransformer implements 
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),
                                             DIVIDE_METHOD,
                                             Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer.java
Tue Oct  2 11:19:33 2012
@@ -34,21 +34,6 @@ public class DMulTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the multiplication. */
     private static final String MULTIPLY_METHOD = "multiply";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DMulTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -56,8 +41,8 @@ public class DMulTransformer implements 
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),
                                             MULTIPLY_METHOD,
                                             Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer.java
Tue Oct  2 11:19:33 2012
@@ -46,21 +46,6 @@ public class DRemTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the negation. */
     private static final String NEGATE_METHOD = "negate";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DRemTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -68,8 +53,8 @@ public class DRemTransformer implements 
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),
                                             REMAINDER_METHOD,
                                             Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer.java
Tue Oct  2 11:19:33 2012
@@ -37,21 +37,6 @@ public class DSubTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the negation. */
     private static final String NEGATE_METHOD = "negate";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DSubTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -59,8 +44,8 @@ public class DSubTransformer implements 
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),
                                             SUBTRACT_METHOD,
                                             Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DcmpTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DcmpTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DcmpTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DcmpTransformer.java
Tue Oct  2 11:19:33 2012
@@ -34,29 +34,14 @@ public class DcmpTransformer implements 
     /** Name of the {@link org.apache.commons.math3.analysis.differentiation.DerivativeStructure}
method corresponding to the value getter. */
     private static final String VALUE_GETTER_METHOD = "getValue";
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public DcmpTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
         throws DifferentiationException {
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 // operand stack initial state: ds_a, ds_b
                 list.add(new InsnNode(Opcodes.SWAP));                                   
          // => ds_b, ds_a
                 list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DS_TYPE.getInternalName(),

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer.java
Tue Oct  2 11:19:33 2012
@@ -29,21 +29,6 @@ import org.objectweb.asm.tree.InsnNode;
  */
 public class Dup2X2Transformer implements InstructionsTransformer {
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public Dup2X2Transformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -51,8 +36,8 @@ public class Dup2X2Transformer implement
 
         final InsnList list = new InsnList();
 
-        if (stack1Converted) {
-            if (stack0Converted) {
+        if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+            if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                 list.add(new InsnNode(Opcodes.DUP_X1));
             } else {
                 list.add(new InsnNode(Opcodes.DUP2_X1));

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/InvokeStaticTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/InvokeStaticTransformer.java?rev=1392842&r1=1392841&r2=1392842&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/InvokeStaticTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/InvokeStaticTransformer.java
Tue Oct  2 11:19:33 2012
@@ -33,21 +33,6 @@ import org.objectweb.asm.tree.MethodInsn
  */
 public class InvokeStaticTransformer implements InstructionsTransformer {
 
-    /** Indicator for top stack element conversion. */
-    private final boolean stack0Converted;
-
-    /** Indicator for next to top stack element conversion. */
-    private final boolean stack1Converted;
-
-    /** Simple constructor.
-     * @param stack0Converted if true, the top level stack element has already been converted
-     * @param stack1Converted if true, the next to top level stack element has already been
converted
-     */
-    public InvokeStaticTransformer(final boolean stack0Converted, final boolean stack1Converted)
{
-        this.stack0Converted = stack0Converted;
-        this.stack1Converted = stack1Converted;
-    }
-
     /** {@inheritDoc} */
     public InsnList getReplacement(final AbstractInsnNode insn,
                                    final MethodDifferentiator methodDifferentiator)
@@ -84,15 +69,15 @@ public class InvokeStaticTransformer imp
                 // special case for pow: in DerivativeStructure, it is an instance method,
                 // not a static method as the other two parameters functions like atan2 or
hypot
 
-                if (stack1Converted) {
-                    if (!stack0Converted) {
+                if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+                    if (methodDifferentiator.stackElementIsConverted(insn, 0)) {
                         list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
                                                     DS_TYPE.getInternalName(), methodInsn.name,
-                                                    Type.getMethodDescriptor(DS_TYPE, Type.DOUBLE_TYPE)));
+                                                    Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));
                     } else {
                         list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
                                                     DS_TYPE.getInternalName(), methodInsn.name,
-                                                    Type.getMethodDescriptor(DS_TYPE, DS_TYPE)));
+                                                    Type.getMethodDescriptor(DS_TYPE, Type.DOUBLE_TYPE)));
                     }
                 } else {
 
@@ -110,8 +95,8 @@ public class InvokeStaticTransformer imp
 
             } else {
 
-                if (stack1Converted) {
-                    if (!stack0Converted) {
+                if (methodDifferentiator.stackElementIsConverted(insn, 1)) {
+                    if (!methodDifferentiator.stackElementIsConverted(insn, 0)) {
                         // the top level element is not a DerivativeStructure, convert it
                         list.add(methodDifferentiator.doubleToDerivativeStructureConversion());
                     }



Mime
View raw message