You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/04/15 15:20:54 UTC
svn commit: r648239 [4/4] - in
/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic:
./ analysis/ arithmetic/ functions/ instructions/ trimming/
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+
+/** Differentiation transformer for DCMPx instructions.
+ * <p>Each DCMPx instruction is replaced by a sequence that
+ * first remove the differential parts from the top stack cells
+ * followed by the comparison instruction.
+ */
+public class DcmpTransformer12 implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new DcmpTransformer12();
+ }
+
+ /** Hidden constructor.
+ */
+ private DcmpTransformer12() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+ final InsnList list = new InsnList();
+ // operand stack initial state: a0, a1, b0, b1
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, a1, b0
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, b0, a1, b0
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, b0, a1
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, b0
+ list.add(methodDifferentiator.clone(insn));
+ return list;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer12.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+
+/** Differentiation transformer for DCMPx instructions.
+ * <p>Each DCMPx instruction is replaced by a sequence that
+ * first remove the differential parts from the top stack cells
+ * followed by the comparison instruction.
+ */
+public class DcmpTransformer2 implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new DcmpTransformer2();
+ }
+
+ /** Hidden constructor.
+ */
+ private DcmpTransformer2() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+ final InsnList list = new InsnList();
+ // operand stack initial state: a, b0, b1
+ list.add(new InsnNode(Opcodes.POP2)); // => a, b0
+ list.add(methodDifferentiator.clone(insn));
+ return list;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DcmpTransformer2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2Transformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2Transformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2Transformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2Transformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DUP2 instructions.
+ * <p>DUP2 instructions are replaced by instructions
+ * that duplicate the two parts of a differential pair on stack.</p>
+ */
+public class Dup2Transformer implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new Dup2Transformer();
+ }
+
+ /** Hidden constructor.
+ */
+ private Dup2Transformer() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+
+ final int tmp1 = methodDifferentiator.getTmp(1);
+
+ final InsnList list = new InsnList();
+ // operand stack initial state: a0, a1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0
+ list.add(new InsnNode(Opcodes.DUP2)); // => a0, a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, a0, a1
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, a1, a0, a1
+ return list;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2Transformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X1Transformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X1Transformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X1Transformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X1Transformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DUP2_X1 instructions.
+ * <p>DUP2_X1 instructions are replaced by instructions
+ * that duplicate the two parts of a differential pair on stack.</p>
+ */
+public class Dup2X1Transformer implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new Dup2X1Transformer();
+ }
+
+ /** Hidden constructor.
+ */
+ private Dup2X1Transformer() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+
+ final int tmp1 = methodDifferentiator.getTmp(1);
+ final int tmp2 = methodDifferentiator.getTmp(2);
+
+ final InsnList list = new InsnList();
+ // operand stack initial state: v, a0, a1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => v, a0
+ list.add(new InsnNode(Opcodes.DUP2)); // => v, a0, a0
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => v, a0
+ list.add(new InsnNode(Opcodes.DUP2_X1)); // => a0, v, a0
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, v
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, v, a1
+ list.add(new InsnNode(Opcodes.DUP2_X1)); // => a0, a1, v, a1
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, a1, v
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => a0, a1, v, a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, a1, v, a0, a1
+ return list;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X1Transformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DUP2_X2 instructions.
+ * <p>DUP2_X2 instructions are replaced by instructions
+ * that duplicate the two parts of a differential pair on stack.</p>
+ */
+public class Dup2X2Transformer1 implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new Dup2X2Transformer1();
+ }
+
+ /** Hidden constructor.
+ */
+ private Dup2X2Transformer1() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+
+ final int tmp1 = methodDifferentiator.getTmp(1);
+
+ final InsnList list = new InsnList();
+ // operand stack initial state: a0, a1, w
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, w, a1, w
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, w, a1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, w
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => w, a0, w
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => w, a0, w, a1
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => w, a0, a1, w, a1
+ list.add(new InsnNode(Opcodes.POP2)); // => w, a0, a1, w
+ return list;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DUP2_X2 instructions.
+ * <p>DUP2_X2 instructions are replaced by instructions
+ * that duplicate the two parts of a differential pair on stack.</p>
+ */
+public class Dup2X2Transformer12 implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new Dup2X2Transformer12();
+ }
+
+ /** Hidden constructor.
+ */
+ private Dup2X2Transformer12() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+
+ final int tmp1 = methodDifferentiator.getTmp(1);
+ final int tmp2 = methodDifferentiator.getTmp(2);
+ final int tmp3 = methodDifferentiator.getTmp(3);
+
+ final InsnList list = new InsnList();
+ // operand stack initial state: a0, a1, b0, b1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => a0, b0
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => b0, a0, b0
+ list.add(new InsnNode(Opcodes.POP2)); // => b0, a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => b0, a0, b1
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => b0, b1, a0, b1
+ list.add(new InsnNode(Opcodes.POP2)); // => b0, b1, a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); // => b0, b1, a0, a1
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => b0, b1, a0, a1, b0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => b0, b1, a0, a1, b0, b1
+ return list;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer12.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DUP2_X2 instructions.
+ * <p>DUP2_X2 instructions are replaced by instructions
+ * that duplicate the two parts of a differential pair on stack.</p>
+ */
+public class Dup2X2Transformer2 implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new Dup2X2Transformer2();
+ }
+
+ /** Hidden constructor.
+ */
+ private Dup2X2Transformer2() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+
+ final int tmp1 = methodDifferentiator.getTmp(1);
+ final int tmp2 = methodDifferentiator.getTmp(2);
+
+ final InsnList list = new InsnList();
+ // operand stack initial state: w, a0, a1
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => w, a0
+ list.add(new InsnNode(Opcodes.DUP2)); // => w, a0, a0
+ list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => w, a0
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, w, a0
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, w
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, w, a1
+ list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, a1, w, a1
+ list.add(new InsnNode(Opcodes.POP2)); // => a0, a1, w
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => a0, a1, w, a0
+ list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, a1, w, a0, a1
+ return list;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/Dup2X2Transformer2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/NarrowingTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/NarrowingTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/NarrowingTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/NarrowingTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+
+/** Differentiation transformer for narrowing a differential part on the stack
+ * to a double.
+ * <p>Some instructions (D2I, D2L, D2F, POP2) may handle differential pair
+ * on the stack by simply popping the differential part out before being
+ * applied.</p>
+ */
+public class NarrowingTransformer implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new NarrowingTransformer();
+ }
+
+ /** Hidden constructor.
+ */
+ private NarrowingTransformer() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+ final InsnList list = new InsnList();
+ list.add(new InsnNode(Opcodes.POP2));
+ list.add(methodDifferentiator.clone(insn));
+ return list;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/NarrowingTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/WideningTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/WideningTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/WideningTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/WideningTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.instructions;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+
+/** Differentiation transformer for promoting a double on the stack
+ * to a differential pair.
+ * <p>Some instructions pushing a double on the stack simply need to
+ * be completed by pushing a 0 afterwards to form a differential pair
+ * representing a constant value. These instructions are replaced by
+ * a copy of themselves followed by a DCONST_0 instruction.</p>
+ */
+public class WideningTransformer implements InstructionsTransformer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final InstructionsTransformer INSTANCE = new WideningTransformer();
+ }
+
+ /** Hidden constructor.
+ */
+ private WideningTransformer() {
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static InstructionsTransformer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ public InsnList getReplacement(final AbstractInsnNode insn,
+ final MethodDifferentiator methodDifferentiator)
+ throws DifferentiationException {
+ final InsnList list = new InsnList();
+ list.add(methodDifferentiator.clone(insn));
+ list.add(new InsnNode(Opcodes.DCONST_0));
+ return list;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/WideningTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/BytecodeTrimmer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/BytecodeTrimmer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/BytecodeTrimmer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/BytecodeTrimmer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.trimming;
+
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+
+/** Base class for code trimmers.
+ */
+public abstract class BytecodeTrimmer {
+
+ /** Current instructions window. */
+ private AbstractInsnNode[] currentWindow;
+
+ /** Simple constructor.
+ * @param lookahead number of lookahead instructions
+ */
+ protected BytecodeTrimmer(final int lookahead) {
+ currentWindow = new AbstractInsnNode[lookahead];
+ }
+
+ /** Trim a list of instructions.
+ * @param instructions list of instructions to optimize
+ */
+ public void trim(final InsnList instructions) {
+
+ // set up lookahead instructions
+ currentWindow[0] = instructions.get(0);
+ for (int i = 1; (i < currentWindow.length) && (currentWindow[i - 1] != null); ++i) {
+ currentWindow[i] = currentWindow[i - 1].getNext();
+ }
+
+ // trim the whole instructions set using a sliding window
+ while (currentWindow[currentWindow.length - 1] != null) {
+
+ // trim current window
+ final boolean updated = trimWindow(instructions, currentWindow);
+
+ if (!updated) {
+ // slide the window ourselves one instruction forward
+ for (int i = 1; i < currentWindow.length; ++i) {
+ currentWindow[i - 1] = currentWindow[i];
+ }
+ if (currentWindow[currentWindow.length - 1] != null) {
+ currentWindow[currentWindow.length - 1] = currentWindow[currentWindow.length - 1].getNext();
+ }
+ }
+
+ }
+
+ }
+
+ /** Trim the current window of lookahead instructions.
+ * @param instructions complete instructions list of instructions to trim
+ * @param window current instructions window (belongs to the list)
+ * @return true if instructions and window have been updated and are ready
+ * for next iteration
+ */
+ protected abstract boolean trimWindow(InsnList instructions,
+ AbstractInsnNode[] window);
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/BytecodeTrimmer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/DLoadPop2Trimmer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/DLoadPop2Trimmer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/DLoadPop2Trimmer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/DLoadPop2Trimmer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.trimming;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+
+/** Trimmer removing (DLOAD i, POP2).
+ */
+public class DLoadPop2Trimmer extends BytecodeTrimmer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final BytecodeTrimmer INSTANCE = new DLoadPop2Trimmer();
+ }
+
+ /** Hidden constructor.
+ */
+ private DLoadPop2Trimmer() {
+ super(2);
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static BytecodeTrimmer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean trimWindow(final InsnList instructions,
+ final AbstractInsnNode[] window) {
+
+ if ((window[0].getOpcode() == Opcodes.DUP2) &&
+ (window[1].getOpcode() == Opcodes.POP2)) {
+
+ // remove the no-op instructions pair
+ instructions.remove(window[0]);
+ instructions.remove(window[1]);
+
+ return true;
+
+ }
+
+ // nothing have been done
+ return false;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/DLoadPop2Trimmer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDloadTrimmer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDloadTrimmer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDloadTrimmer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDloadTrimmer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.trimming;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Trimmer replacing (DLOAD i, DLOAD j, DUP2_X2, POP2) with (DLOAD j, DLOAD i).
+ */
+public class SwappedDloadTrimmer extends BytecodeTrimmer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final BytecodeTrimmer INSTANCE = new SwappedDloadTrimmer();
+ }
+
+ /** Hidden constructor.
+ */
+ private SwappedDloadTrimmer() {
+ super(4);
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static BytecodeTrimmer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean trimWindow(final InsnList instructions,
+ final AbstractInsnNode[] window) {
+
+ if ((window[0].getOpcode() == Opcodes.DLOAD) &&
+ (window[1].getOpcode() == Opcodes.DLOAD) &&
+ (window[2].getOpcode() == Opcodes.DUP2_X2) &&
+ (window[3].getOpcode() == Opcodes.POP2)) {
+
+ // reverse the DLOAD orders
+ final int tmp = ((VarInsnNode) window[0]).var;
+ ((VarInsnNode) window[0]).var = ((VarInsnNode) window[1]).var;
+ ((VarInsnNode) window[1]).var = tmp;
+
+ // remove the operand stack swap instructions
+ instructions.remove(window[2]);
+ instructions.remove(window[3]);
+
+ // slide window two instructions forward
+ window[2] = window[1].getNext();
+ window[3] = (window[2] == null) ? null : window[2].getNext();
+ return true;
+
+ }
+
+ // nothing have been done
+ return false;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDloadTrimmer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDstoreTrimmer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDstoreTrimmer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDstoreTrimmer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDstoreTrimmer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.trimming;
+
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Trimmer replacing (DUP2_X2, POP2, DSTORE i, DSTORE j) with (DSTORE j, DSTORE i).
+ */
+public class SwappedDstoreTrimmer extends BytecodeTrimmer {
+
+ /** Holder for the singleton instance.*/
+ private static class LazyHolder {
+ /** The singleton instance. */
+ private static final BytecodeTrimmer INSTANCE = new SwappedDstoreTrimmer();
+ }
+
+ /** Hidden constructor.
+ */
+ private SwappedDstoreTrimmer() {
+ super(4);
+ }
+
+ /** Get the singleton instance.
+ * <p>We use here the Initialization on Demand Holder idiom.</p>
+ * @return the singleton instance
+ */
+ public static BytecodeTrimmer getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean trimWindow(final InsnList instructions,
+ final AbstractInsnNode[] window) {
+
+ if ((window[0].getOpcode() == Opcodes.DUP2_X2) &&
+ (window[1].getOpcode() == Opcodes.POP2) &&
+ (window[2].getOpcode() == Opcodes.DSTORE) &&
+ (window[3].getOpcode() == Opcodes.DSTORE)) {
+
+ // reverse the DSTORE orders
+ final int tmp = ((VarInsnNode) window[2]).var;
+ ((VarInsnNode) window[2]).var = ((VarInsnNode) window[3]).var;
+ ((VarInsnNode) window[3]).var = tmp;
+
+ // remove the operand stack swap instructions
+ instructions.remove(window[0]);
+ instructions.remove(window[1]);
+
+ // update lookahead instructions
+ window[0] = window[2];
+ window[1] = window[3];
+ window[2] = window[1].getNext();
+ window[3] = (window[2] == null) ? null : window[2].getNext();
+ return true;
+
+ }
+
+ // nothing have been done
+ return false;
+
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/trimming/SwappedDstoreTrimmer.java
------------------------------------------------------------------------------
svn:eol-style = native