changeset 23733:b4838d622f3f

Fix exception when printing BytecodeFrame in test
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 02 Aug 2016 17:25:40 -0700
parents 5dae5deb92fb
children 2e17c65dddd7
files jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java	Tue Aug 02 17:12:16 2016 -0700
+++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java	Tue Aug 02 17:25:40 2016 -0700
@@ -194,7 +194,13 @@
      */
     public static String tabulateValues(BytecodeFrame frame) {
         int cols = Math.max(frame.numLocals, Math.max(frame.numStack, frame.numLocks));
-        assert cols > 0;
+        if (frame.values == null || frame.values.length == 0) {
+            assert cols == 0;
+            return null;
+        }
+        if (cols == 0) {
+            return null;
+        }
         ArrayList<Object> cells = new ArrayList<>();
         cells.add("");
         for (int i = 0; i < cols; i++) {
@@ -302,9 +308,9 @@
         assert sb.charAt(sb.length() - 1) == ']';
         sb.deleteCharAt(sb.length() - 1);
         sb.append(", duringCall: ").append(frame.duringCall).append(", rethrow: ").append(frame.rethrowException).append(']');
-        if (frame.values != null && frame.values.length > 0) {
+        String table = tabulateValues(frame);
+        if (table != null) {
             sb.append(NEW_LINE);
-            String table = tabulateValues(frame);
             String[] rows = table.split(NEW_LINE);
             for (int i = 0; i < rows.length; i++) {
                 String row = rows[i];