Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 8786 invoked from network); 18 Jul 2007 07:11:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2007 07:11:45 -0000 Received: (qmail 5779 invoked by uid 500); 18 Jul 2007 07:11:38 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 5758 invoked by uid 500); 18 Jul 2007 07:11:38 -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 5749 invoked by uid 99); 18 Jul 2007 07:11:38 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jul 2007 00:11:38 -0700 X-ASF-Spam-Status: No, hits=-99.5 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, 18 Jul 2007 00:11:35 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2E1841A981A; Wed, 18 Jul 2007 00:11:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r557179 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H3862/ vm/vmcore/src/verifier-3363/ Date: Wed, 18 Jul 2007 07:11:14 -0000 To: commits@harmony.apache.org From: mloenko@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070718071115.2E1841A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mloenko Date: Wed Jul 18 00:11:13 2007 New Revision: 557179 URL: http://svn.apache.org/viewvc?view=rev&rev=557179 Log: fix and regression test for jsr/ret processing, including HARMONY-3862 (A subroutine splits execution into several ret instructions) Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j (with props) harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml (with props) Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java Wed Jul 18 00:11:13 2007 @@ -0,0 +1,38 @@ +package org.apache.harmony.drlvm.tests.regression.h3862; + +import junit.framework.TestCase; + +public class SubrBounds extends TestCase { + + public void testPos() throws Exception { + pos.test(); + } + + public void testNeg() throws Exception { + try { + neg.test(); + fail("VerifyError expected"); + } catch( VerifyError e) { + } + } + + public void testPos2() throws Exception { + pos2.test(); + } + + public void testNeg2() throws Exception { + try { + neg2.test(); + fail("VerifyError expected"); + } catch( VerifyError e) { + } + } + + public void testNeg3() throws Exception { + try { + neg3.test(); + fail("VerifyError expected"); + } catch( VerifyError e) { + } + } +} \ No newline at end of file Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j Wed Jul 18 00:11:13 2007 @@ -0,0 +1,27 @@ +.class public org/apache/harmony/drlvm/tests/regression/h3862/neg +.super java/lang/Object +.method public ()V + aload_0 + invokespecial java/lang/Object/()V + return +.end method + +; +; Subroutine call order differs from ret order +; +.method public static test()V + .limit stack 1 + .limit locals 2 + + jsr L1 + ret 0 + +L1: + astore 1 + jsr L2 + return + +L2: + astore 0 + ret 1 +.end method Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j Wed Jul 18 00:11:13 2007 @@ -0,0 +1,27 @@ +.class public org/apache/harmony/drlvm/tests/regression/h3862/neg2 +.super java/lang/Object +.method public ()V + aload_0 + invokespecial java/lang/Object/()V + return +.end method + +; +; Return ret address remains on the stack after returning from subroutine +; +.method public static test()V + .limit stack 5 + .limit locals 5 + + jsr L1 + astore 1 + ret 1 + + return + +L1: + dup + astore 1 + ret 1 + +.end method Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j Wed Jul 18 00:11:13 2007 @@ -0,0 +1,25 @@ +.class public org/apache/harmony/drlvm/tests/regression/h3862/neg3 +.super java/lang/Object +.method public ()V + aload_0 + invokespecial java/lang/Object/()V + return +.end method + +; +; Return ret address remains on the stack after returning from subroutine +; +.method public static test()V + .limit stack 5 + .limit locals 5 + + jsr L1 + ret 1 + + return + +L1: + astore 1 + ret 1 + +.end method Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j Wed Jul 18 00:11:13 2007 @@ -0,0 +1,27 @@ +.class public org/apache/harmony/drlvm/tests/regression/h3862/pos +.super java/lang/Object +.method public ()V + aload_0 + invokespecial java/lang/Object/()V + return +.end method + +; +; Return from non-top subroutine +; +.method public static test()V + .limit stack 1 + .limit locals 2 + + jsr L1 + return + +L1: + astore 1 + jsr L2 + return + +L2: + astore 0 + ret 1 +.end method Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j Wed Jul 18 00:11:13 2007 @@ -0,0 +1,28 @@ +.class public org/apache/harmony/drlvm/tests/regression/h3862/pos2 +.super java/lang/Object +.method public ()V + aload_0 + invokespecial java/lang/Object/()V + return +.end method + +; +; Return store ret addr in sub-sub +; +.method public static test()V + .limit stack 5 + .limit locals 5 + + jsr L1 + return + +L1: + jsr L2 + ret 2 + +L2: + astore 1 + astore 2 + ret 1 + +.end method Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j ------------------------------------------------------------------------------ svn:executable = * Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml?view=auto&rev=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml (added) +++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml Wed Jul 18 00:11:13 2007 @@ -0,0 +1,8 @@ + + + + + + + Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml ------------------------------------------------------------------------------ svn:executable = * Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp?view=diff&rev=557179&r1=557178&r2=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp (original) +++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp Wed Jul 18 00:11:13 2007 @@ -473,12 +473,9 @@ } } - if(dead_code_parsing) { - return VF_OK; - } - - // control went out of method bounds - return error(VF_ErrorCodeEnd, "control went out of method bounds"); + //it might be a dead code -- code followed by JSR which never returns + //if it's a dead code - it's OK, if it's not - we will catch it on the second pass + return VF_OK; } } // namespace CPVerifier Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp?view=diff&rev=557179&r1=557178&r2=557179 ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp (original) +++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp Wed Jul 18 00:11:13 2007 @@ -1844,7 +1844,7 @@ vf_Result tcr; - while( true) { + while( instr < m_code_length ) { if( !workmap_is_a_copy_of_stackmap && props.isMultiway(instr) ) { //if instruction has a stackmap and workmap was not just obtained from that stackmap // add constraint: workmap is assignable to stackmap(instr) @@ -1906,16 +1906,6 @@ PropsHead *target_pro = props.getInstrProps(target); if( !props.isDataflowPassed(target) ) { - //for each local and stack (except just added retaddr) replace other retaddresses - //by SM_BOGUS to avoid ret from non-top subroutine on stack - assert(workmap->depth == target_pro->stackmap.depth); - for( unsigned i = 0; i < m_stack_start + workmap->depth - 1; i++ ) { - StackmapElement &el = target_pro->stackmap.elements[i]; - if( el.getAnyIncomingValue().isRetAddr() ) { - el.newIncomingType(&mem, SM_BOGUS); - } - } - for( unsigned i = 0; i < m_stack_start; i++ ) { StackmapElement &el = target_pro->stackmap.elements[i]; el.clearJsrModified(); @@ -2009,6 +1999,9 @@ } } + + // control went out of method bounds + return error(VF_ErrorCodeEnd, "control went out of method bounds"); } inline vf_Result vf_Context_t::dataflow_handlers(Address instr) { @@ -2311,6 +2304,47 @@ //if it is a first ret from the given subroutine (majority of the cases) if( subrdata->retCount == 1 ) { + //remove newly appeared ret addresses: it might happen + //if non-top subroutine made a ret + StackmapHead* original = inpro->getStackmap(); + unsigned i; + + for( i = 0; i < m_stack_start + workmap->depth; i++ ) { + if( i < m_stack_start && !workmap->elements[i].isJsrModified() ) { + //nothing new here + continue; + } + + SmConstant val = workmap->elements[i].getAnyPossibleValue(); + if( val.isRetAddr() ) { + //check if it's a newly appeared ret addfress + + // '-1' is twice below to exclude top of the stack. + // top of the stack contains ret address for the current subroutine + // it also cleaned up if it's still there + + if( i < m_stack_start + original->depth - 1 && + original->elements[i].getAnyIncomingValue() == val ) + { + //most likely: this ret address was there before + continue; + } + + //iterate thru original types and look for this ret address + int found_in_original = 0; + for( unsigned j = 0; j < m_stack_start + original->depth - 1; j++ ) { + if( original->elements[j].getAnyIncomingValue() == val ) { + found_in_original = 1; + break; + } + } + if( !found_in_original ) { + //original types did not have this ret address + workmap->elements[i] = _WorkmapElement(SM_BOGUS); + } + } + } + //TODO make sure incoming was created as JSR transformation tc_memcpy(outpro->getWorkmap(), workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + workmap->depth)); return VF_OK;