changeset 14042:10e2de50a300

Array load/store bytecodes mangling
author dsimms
date Thu, 21 Apr 2016 10:47:50 +0200
parents f0f28425e3e8
children 64db0365ed01
files src/java.base/share/classes/valhalla/model3/Model3Converter.java
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/valhalla/model3/Model3Converter.java	Mon Apr 18 17:33:38 2016 +0100
+++ b/src/java.base/share/classes/valhalla/model3/Model3Converter.java	Thu Apr 21 10:47:50 2016 +0200
@@ -432,9 +432,12 @@
                     case ALOAD:
                     case ASTORE:
                     case ARETURN:
+                        bytes[pc] += typeOffset(type);
+                        break;
+
                     case AALOAD:
                     case AASTORE:
-                        bytes[pc] += typeOffset(type);
+                        bytes[pc] += arrayTypeOffset(type);
                         break;
 
                     case ALOAD_0:
@@ -489,7 +492,7 @@
                     case ANEWARRAY:
                         bytes[pc + 0] = (byte)Opcode.NOP.opcode;
                         bytes[pc + 1] = (byte)Opcode.NEWARRAY.opcode;
-                        bytes[pc + 2] = (byte)arrayTypeCode(type);
+                        bytes[pc + 2] = (byte)arrayTypeNewCode(type);
                         break;
                 }
             }
@@ -597,7 +600,21 @@
         }
     }
 
-    private static int arrayTypeCode(String type) {
+    private static int arrayTypeOffset(String type) {
+        switch (type) {
+            case "I": return -4;
+            case "J": return -3;
+            case "F": return -2;
+            case "D": return -1;
+            case "B":
+            case "Z": return 1;
+            case "C": return 2;
+            case "S": return 3;
+            default: return 0;
+        }
+    }
+
+    private static int arrayTypeNewCode(String type) {
         switch (type) {
             case "Z": return 4;
             case "C": return 5;