changeset 10326:0bdb1a9d1fd1

8150180: String.value contents should be trusted Reviewed-by: vlivanov, redestad, jrose, twisti
author shade
date Tue, 23 Feb 2016 17:55:20 +0300
parents 94f78e8d4d83
children dfa7d9934ab4
files src/share/vm/opto/library_call.cpp
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/library_call.cpp	Mon Feb 22 23:37:29 2016 -0800
+++ b/src/share/vm/opto/library_call.cpp	Tue Feb 23 17:55:20 2016 +0300
@@ -1584,6 +1584,13 @@
   assert (type2aelembytes(T_CHAR) == type2aelembytes(T_BYTE)*2,
           "sanity: byte[] and char[] scales agree");
 
+  // Bail when getChar over constants is requested: constant folding would
+  // reject folding mismatched char access over byte[]. A normal inlining for getChar
+  // Java method would constant fold nicely instead.
+  if (!is_store && value->is_Con() && index->is_Con()) {
+    return false;
+  }
+
   Node* adr = array_element_address(value, index, T_CHAR);
   if (is_store) {
     (void) store_to_memory(control(), adr, ch, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,