8187401: Java Stack cannot be shown on HSDB
authorysuenaga
Sat, 07 Oct 2017 22:42:35 +0900
changeset 47601 f9ace8da5e9c
parent 47568 f03b72b451a6
child 47602 d4380ee1cbe9
8187401: Java Stack cannot be shown on HSDB Reviewed-by: sspitsyn, jgeorge
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java	Sat Sep 30 00:14:39 2017 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java	Sat Oct 07 22:42:35 2017 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,20 +28,23 @@
     VM. */
 
 public class BasicType {
-  public static final int tBoolean  = 4;
-  public static final int tChar     = 5;
-  public static final int tFloat    = 6;
-  public static final int tDouble   = 7;
-  public static final int tByte     = 8;
-  public static final int tShort    = 9;
-  public static final int tInt      = 10;
-  public static final int tLong     = 11;
-  public static final int tObject   = 12;
-  public static final int tArray    = 13;
-  public static final int tVoid     = 14;
-  public static final int tAddress  = 15;
-  public static final int tConflict = 16;
-  public static final int tIllegal  = 99;
+  public static final int tBoolean     = 4;
+  public static final int tChar        = 5;
+  public static final int tFloat       = 6;
+  public static final int tDouble      = 7;
+  public static final int tByte        = 8;
+  public static final int tShort       = 9;
+  public static final int tInt         = 10;
+  public static final int tLong        = 11;
+  public static final int tObject      = 12;
+  public static final int tArray       = 13;
+  public static final int tVoid        = 14;
+  public static final int tAddress     = 15;
+  public static final int tNarrowOop   = 16;
+  public static final int tMetadata    = 17;
+  public static final int tNarrowKlass = 18;
+  public static final int tConflict    = 19;
+  public static final int tIllegal     = 99;
 
   public static final BasicType T_BOOLEAN = new BasicType(tBoolean);
   public static final BasicType T_CHAR = new BasicType(tChar);
@@ -55,6 +58,9 @@
   public static final BasicType T_ARRAY = new BasicType(tArray);
   public static final BasicType T_VOID = new BasicType(tVoid);
   public static final BasicType T_ADDRESS = new BasicType(tAddress);
+  public static final BasicType T_NARROWOOP = new BasicType(tNarrowOop);
+  public static final BasicType T_METADATA = new BasicType(tMetadata);
+  public static final BasicType T_NARROWKLASS = new BasicType(tNarrowKlass);
   public static final BasicType T_CONFLICT = new BasicType(tConflict);
   public static final BasicType T_ILLEGAL = new BasicType(tIllegal);
 
@@ -106,6 +112,18 @@
     return tAddress;
   }
 
+  public static int getTNarrowOop() {
+    return tNarrowOop;
+  }
+
+  public static int getTMetadata() {
+    return tMetadata;
+  }
+
+  public static int getTNarrowKlass() {
+    return tNarrowKlass;
+  }
+
   /** For stack value type with conflicting contents */
   public static int getTConflict() {
     return tConflict;
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java	Sat Sep 30 00:14:39 2017 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java	Sat Oct 07 22:42:35 2017 +0900
@@ -27,6 +27,7 @@
 import java.util.*;
 
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.types.*;
 
 public class StackValueCollection {
   private List list;
@@ -48,7 +49,15 @@
   public int       intAt(int slot)       { return (int) get(slot).getInteger(); }
   public long      longAt(int slot)      { return VM.getVM().buildLongFromIntsPD((int) get(slot).getInteger(),
                                                                                  (int) get(slot+1).getInteger()); }
-  public OopHandle oopHandleAt(int slot) { return get(slot).getObject(); }
+
+  public OopHandle oopHandleAt(int slot) {
+    StackValue sv = get(slot);
+    if (sv.getType() == BasicType.getTConflict()) {
+      throw new WrongTypeException("Conflict type");
+    }
+    return sv.getObject();
+  }
+
   public float     floatAt(int slot)     { return Float.intBitsToFloat(intAt(slot)); }
   public double    doubleAt(int slot)    { return Double.longBitsToDouble(longAt(slot)); }
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Sat Sep 30 00:14:39 2017 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Sat Oct 07 22:42:35 2017 +0900
@@ -34,6 +34,7 @@
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.tools.jcore.*;
+import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
 public class HTMLGenerator implements /* imports */ ClassConstants {
@@ -1928,11 +1929,16 @@
          }
 
          if (!method.isStatic() && !method.isNative()) {
-            OopHandle oopHandle = vf.getLocals().oopHandleAt(0);
+            try {
+               OopHandle oopHandle = vf.getLocals().oopHandleAt(0);
 
-            if (oopHandle != null) {
-               buf.append(", oop = ");
-               buf.append(oopHandle.toString());
+               if (oopHandle != null) {
+                  buf.append(", oop = ");
+                  buf.append(oopHandle.toString());
+               }
+            } catch (WrongTypeException e) {
+              // Do nothing.
+              // It might be caused by JIT'ed inline frame.
             }
          }