harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r595230 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H5094/ vm/jitrino/src/codegenerator/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/main/ vm/jitrino/src/optimizer/ vm/jitrino/src/vm/ vm/vmcore/include/ vm/vmcore/src/gc/ v...
Date Thu, 15 Nov 2007 07:34:09 GMT
Author: varlax
Date: Wed Nov 14 23:34:05 2007
New Revision: 595230

URL: http://svn.apache.org/viewvc?rev=595230&view=rev
Log:
Fixed HARMONY-5094  [drlvm] inlined stack inspection is broken

Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H5094/
    harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml   (with props)
Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/JITInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java?rev=595230&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java Wed Nov 14
23:34:05 2007
@@ -0,0 +1,114 @@
+/*
+ *  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.harmony.drlvm.tests.regression.h5094;
+
+import junit.framework.TestCase;
+
+public class InlinedStackTest extends TestCase {
+
+    private static void a() throws Exception{
+        smth();
+        b();
+    }
+    private static void b() throws Exception{
+        c();
+    }
+
+    static void c() throws Exception{
+        smth();
+        d();
+    }
+    static void d() throws Exception{
+        smth();
+        smth();
+        throw new RuntimeException();
+    }
+
+    static int i = 0;
+    static void smth() {
+        i++;
+    }
+
+    public static void assertStackFrame(String clsname, String methname, int ln, StackTraceElement
stf) {
+        assertEquals(clsname, stf.getClassName());
+        assertEquals(methname, stf.getMethodName());
+        assertEquals(ln, stf.getLineNumber());
+    }
+
+    public void test1() throws Exception {
+        try {
+            a();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            StackTraceElement[] st = t.getStackTrace();
+            assertTrue("trace is not deep enough: " + st.length, st.length >= 6);
+            assertStackFrame(this.getClass().getName(), "d", 39, st[0]);
+            assertStackFrame(this.getClass().getName(), "c", 34, st[1]);
+            assertStackFrame(this.getClass().getName(), "b", 29, st[2]);
+            assertStackFrame(this.getClass().getName(), "a", 26, st[3]);
+            assertStackFrame(this.getClass().getName(), "test1", 55, st[4]);
+        }
+    }
+
+    public void test2() throws Exception {
+        try {
+            Q.a();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            StackTraceElement[] st = t.getStackTrace();
+            assertTrue("trace is not deep enough: " + st.length, st.length >= 6);
+            assertStackFrame(this.getClass().getName(), "d", 39, st[0]);
+            assertStackFrame(Q.class.getName(), "c", 108, st[1]);
+            assertStackFrame(Q.class.getName(), "b", 104, st[2]);
+            assertStackFrame(Q.class.getName(), "a", 100, st[3]);
+            //assertStackFrame(this.getClass().getName(), "test2", 70, st[4]); //OPT to be
fixed yet
+        }
+    }
+
+    public void test3() throws Exception {
+        try {
+            Q.a2();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            StackTraceElement[] st = t.getStackTrace();
+            assertTrue("trace is not deep enough: " + st.length, st.length >= 5);
+            assertStackFrame(this.getClass().getName(), "d", 39, st[0]);
+            assertStackFrame(this.getClass().getName(), "c", 34, st[1]);
+            assertStackFrame(Q.class.getName(), "a2", 112, st[2]);
+            assertStackFrame(this.getClass().getName(), "test3", 85, st[3]);
+        }
+    }
+}
+
+class Q {
+    static void a() throws Exception{
+        b();
+    }
+    private static void b() throws Exception{
+        InlinedStackTest.smth();
+        c();
+    }
+
+    private static void c() throws Exception{
+        InlinedStackTest.d();
+    }
+
+    static void a2() throws Exception{
+        InlinedStackTest.c();
+    }
+}

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H5094/InlinedStackTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml?rev=595230&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml Wed Nov 14 23:34:05
2007
@@ -0,0 +1,37 @@
+<!-- 
+    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. -->
+
+<project name="RUN HARMONY-5094 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h5094.InlinedStackTest"
+             vmarg="-Xem:jet">
+        </run-junit-test>
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h5094.InlinedStackTest"
+             vmarg="-Xint">
+        </run-junit-test>
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h5094.InlinedStackTest"
+             vmarg="-Xem:opt">
+        </run-junit-test>
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h5094.InlinedStackTest"
+             vmarg="-Xem:server_static">
+        </run-junit-test>
+    </target>
+</project>
+

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H5094/run.test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Wed Nov 14 23:34:05
2007
@@ -619,7 +619,7 @@
         Method_Handle method;
 
         uint32 getInlineDepth() const { 
-            return (parentEntry == 0) ? 0 : 1 + parentEntry->getInlineDepth(); 
+            return (parentEntry == 0) ? 1 : 1 + parentEntry->getInlineDepth(); 
         }
     };
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp Wed
Nov 14 23:34:05 2007
@@ -341,7 +341,7 @@
     for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst())
{
         if (inst->getKind() == Inst::Kind_MethodEntryPseudoInst) {
             if (Log::isEnabled()) {
-                IRPrinter::printIndent(Log::out(), parentEntry ? parentEntry->getInlineDepth()
+ 1 : 0);
+                IRPrinter::printIndent(Log::out(), parentEntry ? parentEntry->getInlineDepth()
+ 1 : 1);
                 IRPrinter::printInst(Log::out(), inst);
                 Log::out()<<" bc offset="<<inst->getBCOffset()<<std::endl;
             }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
Wed Nov 14 23:34:05 2007
@@ -127,7 +127,9 @@
 
 uint32  RuntimeInterface::getInlineDepth(InlineInfoPtr ptr, uint32 offset) {
     const InlineInfoMap::Entry* e = InlineInfoMap::getEntryWithMaxDepth(ptr, offset);
-    return e == NULL ? 0 : e->getInlineDepth();
+    // real instructions are recorded at an extra nested level to enclosing method
+    // but we need to count method marker entries only
+    return e == NULL ? 0 : e->getInlineDepth() - 1;
 }
 
 Method_Handle   RuntimeInterface::getInlinedMethod(InlineInfoPtr ptr, uint32 offset, uint32
inline_depth) {
@@ -136,8 +138,26 @@
 }
 
 uint16 RuntimeInterface::getInlinedBc(InlineInfoPtr ptr, uint32 offset, uint32 inline_depth)
{
-    const InlineInfoMap::Entry* e = InlineInfoMap::getEntry(ptr, offset, inline_depth);
-    return e == NULL  ? 0 : e->bcOffset;
+    const InlineInfoMap::Entry* e = InlineInfoMap::getEntryWithMaxDepth(ptr, offset);
+    assert(inline_depth);
+
+    // Real instructions are recorded at a nested level to enclosing method
+    // and may happen on topmost entry only;
+    // otherwise we have a chain of inlined methods
+    // and each entry holds bcOffset of a call inst in parent method.
+    // In both cases needed bcOffset is stored in child entry
+    const InlineInfoMap::Entry* childCallee = e;
+    while (e) {
+        uint32 depth = e->getInlineDepth();
+        if (depth == inline_depth)
+        {
+            return childCallee->bcOffset;
+        }
+        childCallee = e;
+        e = e->parentEntry;
+    }
+
+    return 0;
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp Wed Nov 14 23:34:05 2007
@@ -286,21 +286,13 @@
 Method_Handle
 Jitrino::GetInlinedMethod(InlineInfoPtr ptr, uint32 offset, uint32 inline_depth)
 {
-    //+1 here because VM counts inlined methods range like: [0...max_depth)
-    //where 0 is the first inlined frame.
-    //but Jitrino.OPT algorithm counts methods like [0...max_depth]
-    //where 0 is an original method
-    return runtimeInterface->getInlinedMethod(ptr, offset, inline_depth+1);
+    return runtimeInterface->getInlinedMethod(ptr, offset, inline_depth);
 }
 
 uint16
 Jitrino::GetInlinedBc(InlineInfoPtr ptr, uint32 offset, uint32 inline_depth)
 {
-    //+1 here because VM counts inlined methods range like: [0...max_depth)
-    //where 0 is the first inlined frame.
-    //but Jitrino.OPT algorithm counts methods like [0...max_depth]
-    //where 0 is an original method
-    return runtimeInterface->getInlinedBc(ptr, offset, inline_depth + 1);
+    return runtimeInterface->getInlinedBc(ptr, offset, inline_depth);
 }
 
 bool

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Wed Nov 14 23:34:05
2007
@@ -146,6 +146,7 @@
         header++;
         if (nativeOffset == nativeOffs) {
             Entry* e = (Entry*)((char*)ptr + entryOffset);
+            assert(e->getInlineDepth() > 1);
             return e;
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Wed Nov 14 23:34:05
2007
@@ -525,18 +525,16 @@
         entry->getFirstInst()->unlink(); 
         entry->prependInst(_instFactory.makeLabel());
 
-        uint16 bcOffset = inlineNode->getCallInst()->getBCOffset();
-        assert(bcOffset!=ILLEGAL_BC_MAPPING_VALUE);
+        uint16 callerOffset = inlineNode->getCallInst()->getBCOffset();
+        assert(callerOffset!=ILLEGAL_BC_MAPPING_VALUE);
         Inst* entryMarker =  obj ? _instFactory.makeMethodMarker(MethodMarkerInst::Entry,
&methodDesc, obj)
             : _instFactory.makeMethodMarker(MethodMarkerInst::Entry, &methodDesc);
-        entryMarker->setBCOffset(bcOffset);
+        entryMarker->setBCOffset(callerOffset);
         entry->prependInst(entryMarker);
-
         Node* retNode = inlinedFlowGraph.getReturnNode();
         if (retNode) {
             Inst* exitMarker =  obj ? _instFactory.makeMethodMarker(MethodMarkerInst::Exit,
&methodDesc, obj)
                 : _instFactory.makeMethodMarker(MethodMarkerInst::Exit,  &methodDesc);
-            exitMarker->setBCOffset(entryMarker->getBCOffset());
             retNode->appendInst(exitMarker);
         }
 
@@ -544,7 +542,6 @@
         if (unwindNode) {
             Inst* exitMarker =  obj ? _instFactory.makeMethodMarker(MethodMarkerInst::Exit,
&methodDesc, obj)
                 : _instFactory.makeMethodMarker(MethodMarkerInst::Exit,  &methodDesc);
-            exitMarker->setBCOffset(entryMarker->getBCOffset());
             unwindNode->appendInst(exitMarker);
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/JITInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/JITInterface.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/JITInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/JITInterface.cpp Wed Nov 14 23:34:05 2007
@@ -419,6 +419,10 @@
     if (Log::cat_rt()->isEnabled()) {
         Log::cat_rt()->out() << "GET_INLINED_METHOD()" << ::std::endl;
     }
+    if (0 == inline_depth) {
+        assert(0 && "misused inline_depth, must be [1..max_depth]");
+        return 0;
+    }
     return Jitrino::GetInlinedMethod(ptr, offset, inline_depth);
 }
 
@@ -428,6 +432,10 @@
 {
     if (Log::cat_rt()->isEnabled()) {
         Log::cat_rt()->out() << "GET_INLINED_BC()" << ::std::endl;
+    }
+    if (0 == inline_depth) {
+        assert(0 && "misused inline_depth, must be [1..max_depth]");
+        return 0;
     }
     return Jitrino::GetInlinedBc(ptr, offset, inline_depth);
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h Wed Nov 14 23:34:05 2007
@@ -192,11 +192,50 @@
                                   GC_Enumeration_Handle  enum_handle,
                                   JitFrameContext* context
                                   );
-
+/**
+ * Returns number of methods which were inlined at the specified location (zero if none)
+ * @param jit - a JIT which produced the code
+ * @param prt - corresponding inline info
+ * @param offset - offset in native code relative to code block start
+ */
 JITEXPORT uint32 
 JIT_get_inline_depth(JIT_Handle jit, 
                      InlineInfoPtr   ptr, 
                      uint32          offset);
+
+/**
+* Returns specified inlined method (null if not found).
+* The inlined methods are indexed as [max_depth..1], 
+* so the topmost method on the stack has maximum inline depth and
+* enclosing methods have descending indicies. 
+* Zero depth would mean nearest non-inlined method and should not be used here.
+* @param jit - a JIT which produced the code
+* @param prt - corresponding inline info
+* @param offset - offset in native code relative to code block start
+* @param inline_depth - index of the inlined method
+*/
+JITEXPORT Method_Handle
+JIT_get_inlined_method(JIT_Handle jit, 
+                       InlineInfoPtr ptr, 
+                       uint32 offset,
+                       uint32 inline_depth);
+
+/**
+* Returns bytecode offset at specified inlined method for the native code (zero if unknown).
+* The inlined methods are indexed as [max_depth..1], 
+* so the topmost method on the stack has maximum inline depth and
+* enclosing methods have descending indicies. 
+* Zero depth would mean nearest non-inlined method and should not be used here.
+* @param jit - a JIT which produced the code
+* @param prt - corresponding inline info
+* @param offset - offset in native code relative to code block start
+* @param inline_depth - index of the inlined method
+*/
+JITEXPORT uint16
+JIT_get_inlined_bc(JIT_Handle jit, 
+                   InlineInfoPtr ptr, 
+                   uint32 offset, 
+                   uint32 inline_depth);
 
 JITEXPORT Boolean
 JIT_can_enumerate(JIT_Handle        jit, 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h Wed Nov 14 23:34:05 2007
@@ -87,11 +87,10 @@
 VMEXPORT unsigned st_get_depth(VM_thread *p_vmthread);
 
 /**
- * Fills the stack trace frame at the given depth for the current thread.
+ * Fills the stack trace frame at the given relative depth for the current thread.
  *
- * @param[in]  depth - the zero-based depth of the frame or inlined method,
- *                     information about which will be stored at the given stack trace
- *                     frame, <i>stf</i>
+ * @param[in]  depth - relative depth of a frame or inlined method on the stack,
+ *                     topmost frame has zero depth.
  * @param[out] stf   - the pointer to the <code>StackTraceFrame</code> structure
that needs
  *                     to be filled with the data on the frame or inlined method
  *                     corresponding to the given depth
@@ -135,7 +134,7 @@
  *
  * @param[in]  method - the handle of the method information to identify the source file
  * @param[in]  ip     - the instruction pointer to identify the JIT and using the JIT line
number
- * @param[in]  depth  - the inlined depth for inlined methods, starting from 0;
+ * @param[in]  depth  - the inlined depth for inlined methods;
  *                      (-1) for native methods and methods which were not inlined
  * @param[out] file   - the pointer to the file reference to be filled by this function
  * @param[out] line   - the pointer to the line number to be filled by this function

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp Wed Nov 14 23:34:05
2007
@@ -320,14 +320,16 @@
                 JIT *jit = cci->get_jit();
                 NativeCodePtr ip = si_get_ip(si);
                 uint32 inlined_depth = si_get_inline_depth(si);
-                uint32 offset = (uint32)((POINTER_SIZE_INT)ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
-                for (uint32 i = 0; i < inlined_depth; i++) {
-                    Method* m = jit->get_inlined_method(cci->get_inline_info(), offset,
i);
-                    assert (m);
-                    cl = m->get_class()->get_class_loader();
-                    assert (cl);
-                    // force cl classloader to be enumerated as strong reference
-                    cl->Mark();
+                if (inlined_depth) {
+                    uint32 offset = (uint32)((POINTER_SIZE_INT)ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
+                    for (uint32 i = inlined_depth; i > 0; i--) {
+                        Method* m = jit->get_inlined_method(cci->get_inline_info(),
offset, i);
+                        assert (m);
+                        cl = m->get_class()->get_class_loader();
+                        assert (cl);
+                        // force cl classloader to be enumerated as strong reference
+                        cl->Mark();
+                    }
                 }
             }
             TRACE2("enumeration", "enumerated eip=" << (void *) si_get_ip(si)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Wed Nov 14 23:34:05 2007
@@ -153,18 +153,20 @@
         CodeChunkInfo *cci = si_get_code_chunk_info(si);
         JIT *jit = cci->get_jit();
 
+        uint16 bc;
         // inlined method frame
         if (0 != inlined_depth) {
             uint32 offset = (uint32) ((char*) ip -
                 (char*) cci->get_code_block_addr());
             method = jit->get_inlined_method(
-                cci->get_inline_info(), offset, inlined_num - inlined_depth);
+                cci->get_inline_info(), offset, inlined_depth);
+            bc = jit->get_inlined_bc(
+                cci->get_inline_info(), offset, inlined_depth);
+        } else {
+            OpenExeJpdaError UNREF result = jit->get_bc_location_for_native(
+                    method, ip, &bc);
+            assert(result == EXE_ERROR_NONE);
         }
-
-        uint16 bc;
-        OpenExeJpdaError UNREF result = jit->get_bc_location_for_native(
-                method, ip, &bc);
-        assert(result == EXE_ERROR_NONE);
 
         *p_method = (jmethodID) method;
         *p_location = (jlocation) bc;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp?rev=595230&r1=595229&r2=595230&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp Wed Nov 14 23:34:05 2007
@@ -19,6 +19,10 @@
  * @version $Revision: 1.1.2.1.4.3 $
  */  
 
+#define LOG_DOMAIN "vm.stack"
+#include "cxxlog.h"
+#include "vm_log.h"
+
 #include "m2n.h"
 #include "stack_iterator.h"
 #include "stack_trace.h"
@@ -47,8 +51,6 @@
         return;
     }
 
-    // inlined method will not have line numbers for now
-    // they are marked with zero ip address.
     if (ip == NULL) {
         return;
     }
@@ -65,6 +67,7 @@
     POINTER_SIZE_INT eff_ip = (POINTER_SIZE_INT)ip -
                                 (is_ip_past ? callLength : 0);
 
+    uint32 offset = 0;
     if (depth < 0) // Not inlined method
     {
         if (cci->get_jit()->get_bc_location_for_native(
@@ -77,13 +80,15 @@
 
         if (inl_info)
         {
-            uint32 offset = (uint32) ((POINTER_SIZE_INT)ip -
+            offset = (uint32) ((POINTER_SIZE_INT)ip -
                 (POINTER_SIZE_INT)cci->get_code_block_addr());
             bcOffset = cci->get_jit()->get_inlined_bc(inl_info, offset, depth);
         }
     }
 
     *line = method->get_line_number(bcOffset);
+    TRACE("Location of " << method << " at idepth=" << depth << "
noff=" << offset
+        << " bc=" << bcOffset << " line=" << *line);
 #endif        
 }
 
@@ -108,6 +113,7 @@
         return interpreter.interpreter_st_get_frame(target_depth, stf);
     }
 
+    TRACE("looking for frame: "<<target_depth);
     StackIterator* si = si_create_from_native();
     unsigned depth = 0;
     while (!si_is_past_end(si)) {
@@ -119,14 +125,19 @@
                  (target_depth <= depth + inlined_depth) ) {
                 stf->ip = si_get_ip(si);
 
-                if (target_depth < depth + inlined_depth) {
+                if (target_depth != depth + inlined_depth) {
+                    assert(inlined_depth);
                     CodeChunkInfo* cci = si_get_code_chunk_info(si);
                     // FIXME64: no support for large methods
                     // with compiled code size greater than 4GB
                     uint32 offset = (uint32)((POINTER_SIZE_INT)stf->ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
+                    stf->depth = inlined_depth - (target_depth - depth);
                     stf->method = cci->get_jit()->get_inlined_method(
-                            cci->get_inline_info(), offset, target_depth - depth);
-                    stf->depth = target_depth - depth;
+                            cci->get_inline_info(), offset, stf->depth);
+                    TRACE("found inlined frame: "<<stf->method << " at depth="<<stf->depth
<< " of "<< inlined_depth);
+                }
+                else {
+                    TRACE("found frame: "<<stf->method);
                 }
 
                 si_free(si);
@@ -181,22 +192,28 @@
                 stf->outdated_this = 0;
             } else {
                 JIT *jit = cci->get_jit();
-                uint32 inlined_depth = si_get_inline_depth(si);
-                // FIXME64: no support for large methods
-                // with compiled code greater than 4GB
-                uint32 offset = (uint32)((POINTER_SIZE_INT)ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
-
-                for (uint32 i = 0; i < inlined_depth; i++) {
-                    stf->method = jit->get_inlined_method(cci->get_inline_info(),
offset, i);
-                    stf->ip = ip;
-                    stf->depth = i;
-                    stf->outdated_this = get_this(jit, method, si);
-                    stf++;
-                    depth++;
+                if (cci->has_inline_info()) {
+                    // FIXME64: no support for large methods
+                    // with compiled code greater than 4GB
+                    uint32 offset = (uint32)((POINTER_SIZE_INT)ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
+                    uint32 inlined_depth = jit->get_inline_depth(
+                        cci->get_inline_info(), offset);
+                    if (inlined_depth) {
+                        for (uint32 i = inlined_depth; i > 0; i--) {
+                            stf->method = jit->get_inlined_method(cci->get_inline_info(),
offset, i);
+                            stf->ip = ip;
+                            stf->depth = i;
+                            TRACE("tracing inlined frame: "<<stf->method <<
" at depth="<<stf->depth);
+                            stf->outdated_this = get_this(jit, method, si);
+                            stf++;
+                            depth++;
+                        }
+                    }
                 }
                 stf->outdated_this = get_this(jit, method, si);
             }
             stf->method = method;
+            TRACE("tracing frame: "<<stf->method);
             stf->ip = ip;
             stf->depth = -1;
             stf++;
@@ -282,17 +299,19 @@
         if (m) {
             fprintf(f, "  [%p] %p(%c): ", vm_thread, si_get_ip(si), (si_is_native(si) ? 'n'
: 'm'));
             CodeChunkInfo* cci = si_get_code_chunk_info(si);
-            if ( cci != NULL ) {
-                uint32 inlined_depth = si_get_inline_depth(si);
+            if (cci != NULL && cci->has_inline_info()) {
                 // FIXME64: no support for large methods
                 // with compiled code size greater than 4GB
                 uint32 offset = (uint32)((POINTER_SIZE_INT)si_get_ip(si) - (POINTER_SIZE_INT)cci->get_code_block_addr());
-                
-                for (uint32 i = 0; i < inlined_depth; i++) {
-                    Method *real_method = cci->get_jit()->get_inlined_method(cci->get_inline_info(),
offset, i);
-                    fprintf(f, "%s.%s%s\n", class_get_name(method_get_class(real_method)),

-                            method_get_name(real_method), method_get_descriptor(real_method));
-                    depth++;
+                uint32 inlined_depth = cci->get_jit()->get_inline_depth(
+                    cci->get_inline_info(), offset);
+                if (inlined_depth) {
+                    for (uint32 i = inlined_depth; i > 0; i--) {
+                        Method *real_method = cci->get_jit()->get_inlined_method(cci->get_inline_info(),
offset, i);
+                        fprintf(f, "%s.%s%s\n", class_get_name(method_get_class(real_method)),

+                                method_get_name(real_method), method_get_descriptor(real_method));
+                        depth++;
+                    }
                 }
             }
             fprintf(f, "%s.%s%s\n", class_get_name(method_get_class(m)), method_get_name(m),
method_get_descriptor(m));



Mime
View raw message