Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 28511 invoked from network); 20 Dec 2006 11:34:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Dec 2006 11:34:03 -0000 Received: (qmail 78939 invoked by uid 500); 20 Dec 2006 11:34:10 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 78922 invoked by uid 500); 20 Dec 2006 11:34:10 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 78913 invoked by uid 99); 20 Dec 2006 11:34:10 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Dec 2006 03:34:10 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Dec 2006 03:34:02 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 676381A981A; Wed, 20 Dec 2006 03:33:13 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r489057 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H2261/ src/test/regression/H2261/RCETest.java src/test/regression/H2261/run.test.xml vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp Date: Wed, 20 Dec 2006 11:33:13 -0000 To: commits@harmony.apache.org From: varlax@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061220113313.676381A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: varlax Date: Wed Dec 20 03:33:12 2006 New Revision: 489057 URL: http://svn.apache.org/viewvc?view=rev&rev=489057 Log: Applied HARMONY-2261 [drlvm][jit][opt] java.awt.ScrollbarTest fails on Jitrino.OPT while passes on Jitrino.JET Tested on SUSE9 Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2261/ harmony/enhanced/drlvm/trunk/src/test/regression/H2261/RCETest.java harmony/enhanced/drlvm/trunk/src/test/regression/H2261/run.test.xml Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2261/RCETest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H2261/RCETest.java?view=auto&rev=489057 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H2261/RCETest.java (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H2261/RCETest.java Wed Dec 20 03:33:12 2006 @@ -0,0 +1,31 @@ +package org.apache.harmony.drlvm.tests.regression.h2261; + +import junit.framework.TestCase; + +public class RCETest extends TestCase +{ + private int maximum, minimum, visibleAmount; + + public RCETest() + { + visibleAmount = 10; + minimum = -100; + } + + public static void main(String[] args) + { + (new RCETest()).test(); + } + + public void test() { + minimum = -2147483648; + maximum = 100; + System.out.println("."); + if (maximum - minimum < 0) { + maximum = minimum + Integer.MAX_VALUE; + } + visibleAmount = Math.min(maximum - minimum, visibleAmount); + assertTrue(visibleAmount == 10); + } + +} Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2261/run.test.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H2261/run.test.xml?view=auto&rev=489057 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H2261/run.test.xml (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H2261/run.test.xml Wed Dec 20 03:33:12 2006 @@ -0,0 +1,9 @@ + + + + + + + Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp?view=diff&rev=489057&r1=489056&r2=489057 ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp (original) +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RCE.cpp Wed Dec 20 03:33:12 2006 @@ -67,8 +67,10 @@ void runImpl(); protected: - // check is flags using by conditional instruction affected by instruction - bool isUsingFlagsAffected(Inst * inst, Inst * condInst); + // check if flags used by the conditional instruction (=condInst) + // are affected by the instruction (=inst) in the same way as + // a hypothetical CMP follower (with appropriate arguments) does + bool instAffectsFlagsAsCmpInst(Inst * inst, Inst * condInst); // check instruction inst for possibility of removing bool isSuitableToRemove(Inst * inst, Inst * condInst, Inst * cmpInst, Opnd * cmpOp); @@ -78,14 +80,14 @@ static ActionFactory _rce("rce"); /** - * The algorithm finds conditional instruction first, then corresponded - * CMP instruction and arithmetic instruction which affects flags in the same - * way as CMP. Combination is considered as available to be reduced if there - * are no instructions between CMP and arithmetic instruction which influence - * to flags or CMP operands. + * The algorithm finds conditional instruction (=condInst) first, then + * corresponding CMP instruction (=cmpInst) and arithmetic instruction (=inst) + * which affects flags in the same way as CMP. Combination is considered as + * available to be reduced if there are no instructions between CMP and + * arithmetic instruction which influence to flags or CMP operands. * - * Also it tries to change improper conditional instruction to more optimizable - * kind. + * Also it transforms some conditional instruction to make them more suitable + * for optimizations */ void RCE::runImpl() @@ -103,7 +105,7 @@ cmpInst = NULL; Inst* prevInst = NULL; for(inst = (Inst*)node->getLastInst(); inst != NULL; inst = prevInst) { - prevInst = inst->getPrevInst(); + prevInst = inst->getPrevInst(); //find conditional instruction Mnemonic baseMnem = getBaseConditionMnemonic(inst->getMnemonic()); if (baseMnem != Mnemonic_NULL) { @@ -151,16 +153,17 @@ inst->setOpnd(defCount+1, irManager->newImmOpnd(inst->getOpnd(defCount+1)->getType(),0)); } //find flags affected instruction precedes cmpInst - } else if (isUsingFlagsAffected(inst, condInst)) { + } else if (instAffectsFlagsAsCmpInst(inst, condInst)) { if (cmpInst) { if (isSuitableToRemove(inst, condInst, cmpInst, cmpOp)) { - cmpInst->unlink();//replace cmp + cmpInst->unlink(); } } - condInst = NULL; + condInst = NULL; // do not optimize cmpInst any more in this block } else { if (inst->getOpndCount(Inst::OpndRole_Implicit|Inst::OpndRole_Def) || inst->getMnemonic() == Mnemonic_CALL) { + // instruction affects flags, skip optimizing cmpInst condInst = NULL; } else { //check for moving cmpInst operands @@ -176,15 +179,18 @@ } bool -RCE::isUsingFlagsAffected(Inst * inst, Inst * condInst) +RCE::instAffectsFlagsAsCmpInst(Inst * inst, Inst * condInst) { if (!inst->getOpndCount(Inst::OpndRole_Implicit|Inst::OpndRole_Def)) //instruction doesn't change flags return false; + + ConditionMnemonic mn = ConditionMnemonic(condInst->getMnemonic()-getBaseConditionMnemonic(condInst->getMnemonic())); switch (inst->getMnemonic()) { case Mnemonic_SUB: - //instruction changes all flags - return true; + // instruction changes all flags, but an overflow may affect the OF flag, + // in that case jumping by JL, JLE, etc. is incorrect + return (mn != ConditionMnemonic_L && mn != ConditionMnemonic_LE && mn != ConditionMnemonic_GE && mn != ConditionMnemonic_G); case Mnemonic_IDIV: case Mnemonic_CALL: case Mnemonic_IMUL: @@ -193,7 +199,6 @@ return false; default: //instruction changes particular flags - ConditionMnemonic mn = ConditionMnemonic(condInst->getMnemonic()-getBaseConditionMnemonic(condInst->getMnemonic())); return ( mn == ConditionMnemonic_Z || mn == ConditionMnemonic_NZ) ? true : false; } } @@ -201,7 +206,7 @@ bool RCE::isSuitableToRemove(Inst * inst, Inst * condInst, Inst * cmpInst, Opnd * cmpOp) { /* cmpInst can be removed if inst defines the same operand which will be - * compared with zero by cmpInst or inst is SUB with the same use-operands as cmpInst + * compared with zero by cmpInst * Required: Native form of insts */ uint32 cmpOpCount = cmpInst->getOpndCount(Inst::OpndRole_InstLevel|Inst::OpndRole_UseDef);