changeset 6031:dcca80b5e7e7

8034867: Object references from expression stack are not visible as roots via jvmti FollowReferences and HeapDump Summary: The heap walking is inconsistent without following references from expression stack, so need to fix it Reviewed-by: coleenp, sspitsyn Contributed-by: axel.siebenborn@sap.com
author sspitsyn
date Sun, 23 Feb 2014 22:36:19 -0800
parents bb9356ec5967
children 61ab121722b8
files src/share/vm/prims/jvmtiTagMap.cpp src/share/vm/services/heapDumper.cpp
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/prims/jvmtiTagMap.cpp	Sun Feb 23 13:16:03 2014 -0500
+++ b/src/share/vm/prims/jvmtiTagMap.cpp	Sun Feb 23 22:36:19 2014 -0800
@@ -3081,6 +3081,23 @@
               }
             }
           }
+
+          StackValueCollection* exprs = jvf->expressions();
+          for (int index=0; index < exprs->size(); index++) {
+            if (exprs->at(index)->type() == T_OBJECT) {
+              oop o = exprs->obj_at(index)();
+              if (o == NULL) {
+                continue;
+              }
+
+              // stack reference
+              if (!CallbackInvoker::report_stack_ref_root(thread_tag, tid, depth, method,
+                                                   bci, locals->size() + index, o)) {
+                return false;
+              }
+            }
+          }
+
         } else {
           blk->set_context(thread_tag, tid, depth, method);
           if (is_top_frame) {
--- a/src/share/vm/services/heapDumper.cpp	Sun Feb 23 13:16:03 2014 -0500
+++ b/src/share/vm/services/heapDumper.cpp	Sun Feb 23 22:36:19 2014 -0800
@@ -1604,6 +1604,18 @@
               }
             }
           }
+          StackValueCollection *exprs = jvf->expressions();
+          for(int index = 0; index < exprs->size(); index++) {
+            if (exprs->at(index)->type() == T_OBJECT) {
+               oop o = exprs->obj_at(index)();
+               if (o != NULL) {
+                 writer()->write_u1(HPROF_GC_ROOT_JAVA_FRAME);
+                 writer()->write_objectID(o);
+                 writer()->write_u4(thread_serial_num);
+                 writer()->write_u4((u4) (stack_depth + extra_frames));
+               }
+             }
+          }
         } else {
           // native frame
           if (stack_depth == 0) {