Mercurial > hg > graal-jvmci-8
changeset 23958:28ce1b5f0c2e
Merge
author | asaha |
---|---|
date | Tue, 05 Jul 2016 14:40:55 -0700 |
parents | 9c9896bbdd50 (diff) c8988d2e4212 (current diff) |
children | 65029655928a 72a298cbc071 |
files | .hgtags |
diffstat | 7 files changed, 181 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Mon Jul 04 15:07:13 2016 -0700 +++ b/.hgtags Tue Jul 05 14:40:55 2016 -0700 @@ -895,3 +895,7 @@ f6daf04c0f48dab5420ad63d21da82a7fa4e3ad7 jdk8u102-b13 ac29c9c1193aef5d480b200ed94c5d579243c17b jdk8u102-b14 96e1c72fc617d3c6c125bcfc9182f77fc6aa38e6 jdk8u102-b31 +ceecf88e5c2c09bfabf5926581e6d0b0f65f5148 jdk8u111-b00 +e73d79ce00e4a0451e464c7a73d9c911d01e169a jdk8u111-b01 +d584a614818562e1187e1a15c202aec01491caeb jdk8u111-b02 +a3ede966ecfe6009fe4a58fbd6903c470a059ad3 jdk8u111-b03
--- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Mon Jul 04 15:07:13 2016 -0700 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Jul 05 14:40:55 2016 -0700 @@ -2168,6 +2168,27 @@ __ delayed()->nop(); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(dst, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) { + __ load_klass(src, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + } + if (flags & LIR_OpArrayCopy::src_pos_positive_check) { // test src_pos register __ cmp_zero_and_br(Assembler::less, src_pos, *stub->entry());
--- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Mon Jul 04 15:07:13 2016 -0700 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Jul 05 14:40:55 2016 -0700 @@ -3275,6 +3275,23 @@ __ jcc(Assembler::zero, *stub->entry()); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(tmp, dst); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + + if (!(flags & LIR_OpArrayCopy::src_objarray)) { + __ load_klass(tmp, src); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + } + // check if negative if (flags & LIR_OpArrayCopy::src_pos_positive_check) { __ testl(src_pos, src_pos);
--- a/src/share/vm/runtime/arguments.cpp Mon Jul 04 15:07:13 2016 -0700 +++ b/src/share/vm/runtime/arguments.cpp Tue Jul 05 14:40:55 2016 -0700 @@ -560,8 +560,9 @@ (os::file_name_strcmp(ext, ".jar") == 0 || os::file_name_strcmp(ext, ".zip") == 0); if (isJarOrZip) { - char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal); - sprintf(jarpath, "%s%s%s", directory, dir_sep, name); + size_t length = directory_len + 2 + strlen(name); + char* jarpath = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(jarpath, length, "%s%s%s", directory, dir_sep, name); path = add_to_path(path, jarpath, false); FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); } @@ -704,9 +705,10 @@ } else if (new_len == 0) { value = old_value; } else { - char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal); + size_t length = old_len + 1 + new_len + 1; + char* buf = NEW_C_HEAP_ARRAY(char, length, mtInternal); // each new setting adds another LINE to the switch: - sprintf(buf, "%s\n%s", old_value, new_value); + jio_snprintf(buf, length, "%s\n%s", old_value, new_value); value = buf; free_this_too = buf; } @@ -813,15 +815,17 @@ if (args == NULL || count == 0) { return NULL; } - size_t length = strlen(args[0]) + 1; // add 1 for the null terminator - for (int i = 1; i < count; i++) { - length += strlen(args[i]) + 1; // add 1 for a space + size_t length = 0; + for (int i = 0; i < count; i++) { + length += strlen(args[i]) + 1; // add 1 for a space or NULL terminating character } char* s = NEW_RESOURCE_ARRAY(char, length); - strcpy(s, args[0]); - for (int j = 1; j < count; j++) { - strcat(s, " "); - strcat(s, args[j]); + char* dst = s; + for (int j = 0; j < count; j++) { + size_t offset = strlen(args[j]) + 1; // add 1 for a space or NULL terminating character + jio_snprintf(dst, length, "%s ", args[j]); // jio_snprintf will replace the last space character with NULL character + dst += offset; + length -= offset; } return (const char*) s; } @@ -1889,7 +1893,7 @@ // Feed the cache size setting into the JDK char buffer[1024]; - sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); + jio_snprintf(buffer, 1024, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); add_property(buffer); } if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) { @@ -2764,7 +2768,9 @@ char *options = NULL; if(pos != NULL) { - options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); + size_t length = strlen(pos + 1) + 1; + options = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(options, length, "%s", pos + 1); } #if !INCLUDE_JVMTI if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) { @@ -2783,7 +2789,9 @@ return JNI_ERR; #else if(tail != NULL) { - char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail); + size_t length = strlen(tail) + 1; + char *options = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(options, length, "%s", tail); add_init_agent("instrument", options, false); } #endif // !INCLUDE_JVMTI @@ -3621,8 +3629,7 @@ } } else { char buffer[256]; - strcpy(buffer, "java.awt.headless="); - strcat(buffer, envbuffer); + jio_snprintf(buffer, 256, "java.awt.headless=%s", envbuffer); if (!add_property(buffer)) { return JNI_ENOMEM; } @@ -3721,6 +3728,14 @@ void Arguments::set_shared_spaces_flags() { if (DumpSharedSpaces) { + if (FailOverToOldVerifier) { + // Don't fall back to the old verifier on verification failure. If a + // class fails verification with the split verifier, it might fail the + // CDS runtime verifier constraint check. In that case, we don't want + // to share the class. We only archive classes that pass the split verifier. + FLAG_SET_DEFAULT(FailOverToOldVerifier, false); + } + if (RequireSharedSpaces) { warning("cannot dump shared archive while using shared archive"); }
--- a/src/share/vm/runtime/sharedRuntime.cpp Mon Jul 04 15:07:13 2016 -0700 +++ b/src/share/vm/runtime/sharedRuntime.cpp Tue Jul 05 14:40:55 2016 -0700 @@ -2830,8 +2830,6 @@ char *s = sig->as_C_string(); int len = (int)strlen(s); s++; len--; // Skip opening paren - char *t = s+len; - while( *(--t) != ')' ) ; // Find close paren BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 ); VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 ); @@ -2840,7 +2838,7 @@ sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature } - while( s < t ) { + while( *s != ')' ) { // Find closing right paren switch( *s++ ) { // Switch on signature character case 'B': sig_bt[cnt++] = T_BYTE; break; case 'C': sig_bt[cnt++] = T_CHAR; break;
--- a/src/share/vm/runtime/signature.cpp Mon Jul 04 15:07:13 2016 -0700 +++ b/src/share/vm/runtime/signature.cpp Tue Jul 05 14:40:55 2016 -0700 @@ -225,7 +225,49 @@ _index = 0; expect('('); Symbol* sig = _signature; - while (sig->byte_at(_index) != ')') _index++; + // Need to skip over each type in the signature's argument list until a + // closing ')' is found., then get the return type. We cannot just scan + // for the first ')' because ')' is a legal character in a type name. + while (sig->byte_at(_index) != ')') { + switch(sig->byte_at(_index)) { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + case 'V': + { + _index++; + } + break; + case 'L': + { + while (sig->byte_at(_index++) != ';') ; + } + break; + case '[': + { + int begin = ++_index; + skip_optional_size(); + while (sig->byte_at(_index) == '[') { + _index++; + skip_optional_size(); + } + if (sig->byte_at(_index) == 'L') { + while (sig->byte_at(_index++) != ';') ; + } else { + _index++; + } + } + break; + default: + ShouldNotReachHere(); + break; + } + } expect(')'); // Parse return type _parameter_index = -1;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/c1/TestArrayCopyToFromObject.java Tue Jul 05 14:40:55 2016 -0700 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8160591 + * @summary C1-generated code for System.arraycopy() does not throw an ArrayStoreException if 'dst' is no a "proper" array (i.e., it is java.lang.Object) + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:-UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject.test TestArrayCopyToFromObject + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:+UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject.test TestArrayCopyToFromObject + */ +public class TestArrayCopyToFromObject { + + public void test(Object aArray[]) { + Object a = new Object(); + + try { + System.arraycopy(aArray, 0, a, 0, 1); + throw new RuntimeException ("FAILED: Expected ArrayStoreException " + + "(due to destination not being an array) " + + "was not thrown"); + } catch (ArrayStoreException e) { + System.out.println("PASSED: Expected ArrayStoreException was thrown"); + } + + try { + System.arraycopy(a, 0, aArray, 0, 1); + throw new RuntimeException ("FAILED: Expected ArrayStoreException " + + "(due to source not being an array) " + + "was not thrown"); + } catch (ArrayStoreException e) { + System.out.println("PASSED: Expected ArrayStoreException was thrown"); + } + + } + + public static void main(String args[]) { + System.out.println("TestArrayCopyToFromObject"); + Object aArray[] = new Object[10]; + for (int i = 0; i < 10; i++) { + aArray[i] = new Object(); + } + new TestArrayCopyToFromObject().test(aArray); + } +}