diff src/share/vm/interpreter/bytecodeInterpreter.cpp @ 23614:32b682649973 jdk8u75-b04

8132051: Better byte behavior Reviewed-by: coleenp, roland
author kevinw
date Fri, 15 Jan 2016 22:33:15 +0000
parents 6d13c17668d1
children b5f3a471e646 8f58998958ca
line wrap: on
line diff
--- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Mon Jan 11 13:41:45 2016 -0800
+++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Fri Jan 15 22:33:15 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -1780,8 +1780,19 @@
           ((objArrayOop) arrObj)->obj_at_put(index, rhsObject);
           UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
       }
-      CASE(_bastore):
-          ARRAY_STOREFROM32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
+      CASE(_bastore): {
+          ARRAY_INTRO(-3);
+          int item = STACK_INT(-1);
+          // if it is a T_BOOLEAN array, mask the stored value to 0/1
+          if (arrObj->klass() == Universe::boolArrayKlassObj()) {
+            item &= 1;
+          } else {
+            assert(arrObj->klass() == Universe::byteArrayKlassObj(),
+                   "should be byte array otherwise");
+          }
+          ((typeArrayOop)arrObj)->byte_at_put(index, item);
+          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
+      }
       CASE(_castore):
           ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
       CASE(_sastore):
@@ -2012,7 +2023,7 @@
             } else if (tos_type == ltos) {
               SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
               MORE_STACK(1);
-            } else if (tos_type == btos) {
+            } else if (tos_type == btos || tos_type == ztos) {
               SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
             } else if (tos_type == ctos) {
               SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
@@ -2033,7 +2044,7 @@
             } else if (tos_type == ltos) {
               SET_STACK_LONG(obj->long_field(field_offset), 0);
               MORE_STACK(1);
-            } else if (tos_type == btos) {
+            } else if (tos_type == btos || tos_type == ztos) {
               SET_STACK_INT(obj->byte_field(field_offset), -1);
             } else if (tos_type == ctos) {
               SET_STACK_INT(obj->char_field(field_offset), -1);
@@ -2122,6 +2133,9 @@
               obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
             } else if (tos_type == btos) {
               obj->release_byte_field_put(field_offset, STACK_INT(-1));
+            } else if (tos_type == ztos) {
+              int bool_field = STACK_INT(-1);  // only store LSB
+              obj->release_byte_field_put(field_offset, (bool_field & 1));
             } else if (tos_type == ltos) {
               obj->release_long_field_put(field_offset, STACK_LONG(-1));
             } else if (tos_type == ctos) {
@@ -2142,6 +2156,9 @@
               obj->obj_field_put(field_offset, STACK_OBJECT(-1));
             } else if (tos_type == btos) {
               obj->byte_field_put(field_offset, STACK_INT(-1));
+            } else if (tos_type == ztos) {
+              int bool_field = STACK_INT(-1);  // only store LSB
+              obj->byte_field_put(field_offset, (bool_field & 1));
             } else if (tos_type == ltos) {
               obj->long_field_put(field_offset, STACK_LONG(-1));
             } else if (tos_type == ctos) {