Mercurial > hg > icedtea8-forest > hotspot
changeset 10851:96cdb50fe0bf
Merge
author | andrew |
---|---|
date | Mon, 16 Nov 2020 13:36:34 +0000 |
parents | b36870ac13f5 (current diff) 91bed84d3ef3 (diff) |
children | 312e9cb580c5 |
files | .hgtags test/runtime/containers/docker/Dockerfile-BasicTest test/runtime/containers/docker/Dockerfile-BasicTest-aarch64 test/runtime/containers/docker/Dockerfile-BasicTest-ppc64le test/runtime/containers/docker/Dockerfile-BasicTest-s390x |
diffstat | 57 files changed, 685 insertions(+), 220 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Thu Nov 05 05:11:10 2020 +0000 +++ b/.hgtags Mon Nov 16 13:36:34 2020 +0000 @@ -1327,11 +1327,13 @@ cbabffce5685f9a18bfd05bd1fb18c4c73be98cf jdk8u272-b04 1b2d99958c293b7ab324c5786664f82c8e9c4e50 jdk8u272-b05 4b0aa85a95653f44cc45f2ec0571153017ebbf03 jdk8u272-b06 +4b0aa85a95653f44cc45f2ec0571153017ebbf03 jdk8u282-b00 4689eaf1a5c9c5e284d466631420761f4bd4ecae jdk8u272-b07 a0eb08e2db5a40956a9c2d6b7dea76a894559033 jdk8u272-b08 176a7e5cc0609cface769e5e8a31b00700d223ba jdk8u272-b09 6b836efa38fef1b50ba798b6e344ab44ee995812 jdk8u272-b10 6b836efa38fef1b50ba798b6e344ab44ee995812 jdk8u272-ga +7f7c1e1fbc8a70f9730339872ddf56fee812304c jdk8u282-b01 6b836efa38fef1b50ba798b6e344ab44ee995812 jdk8u275-b00 b36c3f635d937798abe5e7c5a40a868705fed15e jdk8u275-b01 b36c3f635d937798abe5e7c5a40a868705fed15e jdk8u275-ga
--- a/THIRD_PARTY_README Thu Nov 05 05:11:10 2020 +0000 +++ b/THIRD_PARTY_README Mon Nov 16 13:36:34 2020 +0000 @@ -1672,13 +1672,13 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Little CMS 2.9, which may be +%% This notice is provided with respect to Little CMS 2.11, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- Little CMS -Copyright (c) 1998-2011 Marti Maria Saguer +Copyright (c) 1998-2020 Marti Maria Saguer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
--- a/make/bsd/makefiles/gcc.make Thu Nov 05 05:11:10 2020 +0000 +++ b/make/bsd/makefiles/gcc.make Mon Nov 16 13:36:34 2020 +0000 @@ -260,7 +260,7 @@ WARNINGS_ARE_ERRORS += -Wno-empty-body endif -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 ifeq ($(USE_CLANG),) # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit @@ -289,7 +289,7 @@ # The flags to use for an Optimized g++ build ifeq ($(OS_VENDOR), Darwin) # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy - # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers> + # <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata> OPT_CFLAGS_DEFAULT ?= SIZE else OPT_CFLAGS_DEFAULT ?= SPEED
--- a/make/linux/makefiles/gcc.make Thu Nov 05 05:11:10 2020 +0000 +++ b/make/linux/makefiles/gcc.make Mon Nov 16 13:36:34 2020 +0000 @@ -211,7 +211,7 @@ WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body endif -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type ifeq ($(USE_CLANG),) # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
--- a/make/solaris/makefiles/gcc.make Thu Nov 05 05:11:10 2020 +0000 +++ b/make/solaris/makefiles/gcc.make Mon Nov 16 13:36:34 2020 +0000 @@ -118,7 +118,7 @@ # Compiler warnings are treated as errors WARNINGS_ARE_ERRORS = -Werror # Enable these warnings. See 'info gcc' about details on these options -WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef +WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) # Special cases CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
--- a/src/cpu/x86/vm/x86_32.ad Thu Nov 05 05:11:10 2020 +0000 +++ b/src/cpu/x86/vm/x86_32.ad Mon Nov 16 13:36:34 2020 +0000 @@ -1250,6 +1250,7 @@ Unimplemented(); + return 0; // Mute compiler } #ifndef PRODUCT
--- a/src/cpu/zero/vm/cppInterpreter_zero.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -100,7 +100,9 @@ case T_DOUBLE: case T_VOID: return result; - default : ShouldNotReachHere(); + default: + ShouldNotReachHere(); + return result; // silence compiler warnings } }
--- a/src/os/bsd/vm/os_bsd.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os/bsd/vm/os_bsd.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1885,7 +1885,7 @@ jrelib_p = buf + len; snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT); if (0 != access(buf, F_OK)) { - snprintf(jrelib_p, buflen-len, ""); + snprintf(jrelib_p, buflen-len, "%s", ""); } // If the path exists within JAVA_HOME, add the JVM library name
--- a/src/os/linux/vm/os_linux.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os/linux/vm/os_linux.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1950,6 +1950,9 @@ #ifndef EM_486 #define EM_486 6 /* Intel 80486 */ #endif + #ifndef EM_AARCH64 + #define EM_AARCH64 183 /* ARM AARCH64 */ + #endif static const arch_t arch_array[]={ {EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"}, @@ -1971,7 +1974,8 @@ {EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"}, {EM_MIPS, EM_MIPS, ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"}, {EM_PARISC, EM_PARISC, ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"}, - {EM_68K, EM_68K, ELFCLASS32, ELFDATA2MSB, (char*)"M68k"} + {EM_68K, EM_68K, ELFCLASS32, ELFDATA2MSB, (char*)"M68k"}, + {EM_AARCH64, EM_AARCH64, ELFCLASS64, ELFDATA2LSB, (char*)"AARCH64"}, }; #if (defined IA32) @@ -2002,6 +2006,8 @@ static Elf32_Half running_arch_code=EM_MIPS; #elif (defined M68K) static Elf32_Half running_arch_code=EM_68K; + #elif (defined AARCH64) + static Elf32_Half running_arch_code=EM_AARCH64; #else #error Method os::dll_load requires that one of following is defined:\ IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K @@ -5796,7 +5802,6 @@ PRAGMA_FORMAT_NONLITERAL_IGNORED static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { static bool proc_task_unchecked = true; - static const char *proc_stat_path = "/proc/%d/stat"; pid_t tid = thread->osthread()->thread_id(); char *s; char stat[2048]; @@ -5809,6 +5814,8 @@ long ldummy; FILE *fp; + snprintf(proc_name, 64, "/proc/%d/stat", tid); + // The /proc/<tid>/stat aggregates per-process usage on // new Linux kernels 2.6+ where NPTL is supported. // The /proc/self/task/<tid>/stat still has the per-thread usage. @@ -5820,12 +5827,11 @@ proc_task_unchecked = false; fp = fopen("/proc/self/task", "r"); if (fp != NULL) { - proc_stat_path = "/proc/self/task/%d/stat"; + snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid); fclose(fp); } } - sprintf(proc_name, proc_stat_path, tid); fp = fopen(proc_name, "r"); if ( fp == NULL ) return -1; statlen = fread(stat, 1, 2047, fp);
--- a/src/os_cpu/bsd_zero/vm/orderAccess_bsd_zero.inline.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os_cpu/bsd_zero/vm/orderAccess_bsd_zero.inline.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -29,7 +29,7 @@ #include "runtime/orderAccess.hpp" #include "vm_version_zero.hpp" -#ifdef ARM +#if defined(ARM) // ---------------------------------------------------- /* * ARM Kernel helper for memory barrier. @@ -40,32 +40,36 @@ typedef void (__kernel_dmb_t) (void); #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) -#define FULL_MEM_BARRIER __kernel_dmb() -#define READ_MEM_BARRIER __kernel_dmb() +#define READ_MEM_BARRIER __kernel_dmb() #define WRITE_MEM_BARRIER __kernel_dmb() +#define FULL_MEM_BARRIER __kernel_dmb() -#else // ARM - -#define FULL_MEM_BARRIER __sync_synchronize() - -#ifdef PPC +#elif defined(PPC) // ---------------------------------------------------- #ifdef __NO_LWSYNC__ -#define READ_MEM_BARRIER __asm __volatile ("sync":::"memory") +#define READ_MEM_BARRIER __asm __volatile ("sync":::"memory") #define WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory") #else -#define READ_MEM_BARRIER __asm __volatile ("lwsync":::"memory") +#define READ_MEM_BARRIER __asm __volatile ("lwsync":::"memory") #define WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory") #endif +#define FULL_MEM_BARRIER __sync_synchronize() -#else // PPC +#elif defined(X86) // ---------------------------------------------------- -#define READ_MEM_BARRIER __asm __volatile ("":::"memory") +#define READ_MEM_BARRIER __asm __volatile ("":::"memory") #define WRITE_MEM_BARRIER __asm __volatile ("":::"memory") +#define FULL_MEM_BARRIER __sync_synchronize() -#endif // PPC +#else // ---------------------------------------------------- + +// Default to strongest barriers for correctness. -#endif // ARM +#define READ_MEM_BARRIER __sync_synchronize() +#define WRITE_MEM_BARRIER __sync_synchronize() +#define FULL_MEM_BARRIER __sync_synchronize() + +#endif // ---------------------------------------------------- inline void OrderAccess::loadload() { acquire(); }
--- a/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -457,6 +457,7 @@ long long unsigned int oldval, long long unsigned int newval) { ShouldNotCallThis(); + return 0; // silence compiler warnings } }; #endif // !_LP64
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -541,6 +541,7 @@ err.report_and_die(); ShouldNotReachHere(); + return true; // Mute compiler } void os::Linux::init_thread_fpu_state(void) {
--- a/src/os_cpu/linux_zero/vm/orderAccess_linux_zero.inline.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os_cpu/linux_zero/vm/orderAccess_linux_zero.inline.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -29,7 +29,7 @@ #include "runtime/orderAccess.hpp" #include "vm_version_zero.hpp" -#ifdef ARM +#if defined(ARM) // ---------------------------------------------------- /* * ARM Kernel helper for memory barrier. @@ -40,31 +40,35 @@ typedef void (__kernel_dmb_t) (void); #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) -#define FULL_MEM_BARRIER __kernel_dmb() -#define READ_MEM_BARRIER __kernel_dmb() +#define READ_MEM_BARRIER __kernel_dmb() #define WRITE_MEM_BARRIER __kernel_dmb() - -#else // ARM +#define FULL_MEM_BARRIER __kernel_dmb() -#define FULL_MEM_BARRIER __sync_synchronize() +#elif defined(PPC) // ---------------------------------------------------- -#ifdef PPC - -#define READ_MEM_BARRIER __asm __volatile ("isync":::"memory") +#define READ_MEM_BARRIER __asm __volatile ("isync":::"memory") #ifdef __NO_LWSYNC__ #define WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory") #else #define WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory") #endif +#define FULL_MEM_BARRIER __sync_synchronize() -#else // PPC +#elif defined(X86) // ---------------------------------------------------- -#define READ_MEM_BARRIER __asm __volatile ("":::"memory") +#define READ_MEM_BARRIER __asm __volatile ("":::"memory") #define WRITE_MEM_BARRIER __asm __volatile ("":::"memory") +#define FULL_MEM_BARRIER __sync_synchronize() -#endif // PPC +#else // ---------------------------------------------------- + +// Default to strongest barriers for correctness. -#endif // ARM +#define READ_MEM_BARRIER __sync_synchronize() +#define WRITE_MEM_BARRIER __sync_synchronize() +#define FULL_MEM_BARRIER __sync_synchronize() + +#endif // ---------------------------------------------------- inline void OrderAccess::loadload() { acquire(); }
--- a/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -488,6 +488,7 @@ long long unsigned int oldval, long long unsigned int newval) { ShouldNotCallThis(); + return 0; // silence compiler warnings } }; #endif // !_LP64
--- a/src/share/vm/classfile/classFileParser.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/classFileParser.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -3796,6 +3796,16 @@ info->has_nonstatic_fields = has_nonstatic_fields; } +static bool relax_format_check_for(ClassLoaderData* loader_data) { + bool trusted = (loader_data->is_the_null_class_loader_data() || + SystemDictionary::is_ext_class_loader(loader_data->class_loader())); + bool need_verify = + // verifyAll + (BytecodeVerificationLocal && BytecodeVerificationRemote) || + // verifyRemote + (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted); + return !need_verify; +} instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, ClassLoaderData* loader_data, @@ -3815,7 +3825,13 @@ Handle class_loader(THREAD, loader_data->class_loader()); bool has_default_methods = false; bool declares_default_methods = false; - ResourceMark rm(THREAD); + // JDK-8252904: + // The stream (resource) attached to the instance klass may + // be reallocated by this method. When JFR is included the + // stream may need to survive beyond the end of the call. So, + // the caller is expected to declare the ResourceMark that + // determines the lifetime of resources allocated under this + // call. ClassFileStream* cfs = stream(); // Timing @@ -3942,7 +3958,7 @@ // Check if verification needs to be relaxed for this class file // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376) - _relax_verify = Verifier::relax_verify_for(class_loader()); + _relax_verify = relax_format_check_for(_loader_data); // Constant pool constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle));
--- a/src/share/vm/classfile/classLoader.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/classLoader.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1179,6 +1179,11 @@ ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); Handle protection_domain; TempNewSymbol parsed_name = NULL; + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + // We do not declare another ResourceMark here, reusing the one declared + // at the start of the method instanceKlassHandle result = parser.parseClassFile(h_name, loader_data, protection_domain, @@ -1630,12 +1635,13 @@ } void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { - int len = (int)strlen(name); + size_t len = strlen(name); if (len > 6 && strcmp(".class", name + len - 6) == 0) { // We have a .class file char buffer[2048]; - strncpy(buffer, name, len - 6); - buffer[len-6] = 0; + if (len-6 >= sizeof(buffer)) return; + strncpy(buffer, name, sizeof(buffer)); + buffer[len-6] = 0; // Truncate ".class" suffix. // If the file has a period after removing .class, it's not really a // valid class file. The class loader will check everything else. if (strchr(buffer, '.') == NULL) {
--- a/src/share/vm/classfile/defaultMethods.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/defaultMethods.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -506,7 +506,7 @@ ss.write((const char*)name->bytes(), name->utf8_length()); ss.write((const char*)signature->bytes(), signature->utf8_length()); ss.print(" is abstract"); - return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL); + return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); } Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const { @@ -521,7 +521,7 @@ ss.print("."); ss.write((const char*)name->bytes(), name->utf8_length()); } - return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL); + return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); }
--- a/src/share/vm/classfile/symbolTable.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/symbolTable.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -249,7 +249,7 @@ MutexLocker ml(SymbolTable_lock, THREAD); // Otherwise, add to symbol to table - return the_table()->basic_add(index, (u1*)name, len, hashValue, true, CHECK_NULL); + return the_table()->basic_add(index, (u1*)name, len, hashValue, true, THREAD); } Symbol* SymbolTable::lookup(const Symbol* sym, int begin, int end, TRAPS) { @@ -288,7 +288,7 @@ // Grab SymbolTable_lock first. MutexLocker ml(SymbolTable_lock, THREAD); - return the_table()->basic_add(index, (u1*)buffer, len, hashValue, true, CHECK_NULL); + return the_table()->basic_add(index, (u1*)buffer, len, hashValue, true, THREAD); } Symbol* SymbolTable::lookup_only(const char* name, int len,
--- a/src/share/vm/classfile/systemDictionary.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/systemDictionary.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -236,15 +236,15 @@ class_name->as_C_string(), class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string())); if (FieldType::is_array(class_name)) { - return resolve_array_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL); + return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD); } else if (FieldType::is_obj(class_name)) { ResourceMark rm(THREAD); // Ignore wrapping L and ;. TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1, class_name->utf8_length() - 2, CHECK_NULL); - return resolve_instance_class_or_null(name, class_loader, protection_domain, CHECK_NULL); + return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD); } else { - return resolve_instance_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL); + return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD); } } @@ -1026,14 +1026,21 @@ // // Note: "name" is updated. - instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, - loader_data, - protection_domain, - host_klass, - cp_patches, - parsed_name, - true, - THREAD); + instanceKlassHandle k; + { + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + ResourceMark rm(THREAD); + k = ClassFileParser(st).parseClassFile(class_name, + loader_data, + protection_domain, + host_klass, + cp_patches, + parsed_name, + true, + THREAD); + } if (host_klass.not_null() && k.not_null()) { @@ -1120,6 +1127,10 @@ // // Note: "name" is updated. + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + ResourceMark rm(THREAD); ClassFileParser parser(st); instanceKlassHandle k = parser.parseClassFile(class_name, loader_data,
--- a/src/share/vm/classfile/verifier.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/verifier.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -98,7 +98,7 @@ BytecodeVerificationLocal : BytecodeVerificationRemote; } -bool Verifier::relax_verify_for(oop loader) { +bool Verifier::relax_access_for(oop loader) { bool trusted = java_lang_ClassLoader::is_trusted_loader(loader); bool need_verify = // verifyAll
--- a/src/share/vm/classfile/verifier.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/classfile/verifier.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -57,8 +57,8 @@ // -Xverify:all/none override this value static bool should_verify_for(oop class_loader, bool should_verify_class); - // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2. - static bool relax_verify_for(oop class_loader); + // Relax certain access checks to enable some broken 1.1 apps to run on 1.2. + static bool relax_access_for(oop class_loader); private: static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
--- a/src/share/vm/compiler/compileBroker.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/compiler/compileBroker.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -2042,6 +2042,15 @@ event.set_failureMessage(failure_reason); event.commit(); } + + if (AbortVMOnCompilationFailure) { + if (compilable == ciEnv::MethodCompilable_not_at_tier) { + fatal(err_msg("Not compilable at tier %d: %s", task_level, failure_reason)); + } + if (compilable == ciEnv::MethodCompilable_never) { + fatal(err_msg("Never compilable: %s", failure_reason)); + } + } } else { task->mark_success(); task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes());
--- a/src/share/vm/compiler/compilerOracle.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/compiler/compilerOracle.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -487,25 +487,8 @@ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" #define RANGE0 "[*" RANGEBASE "]" -#define RANGEDOT "[*" RANGEBASE ".]" #define RANGESLASH "[*" RANGEBASE "/]" - -// Accept several syntaxes for these patterns -// original syntax -// cmd java.lang.String foo -// PrintCompilation syntax -// cmd java.lang.String::foo -// VM syntax -// cmd java/lang/String[. ]foo -// - -static const char* patterns[] = { - "%*[ \t]%255" RANGEDOT " " "%255" RANGE0 "%n", - "%*[ \t]%255" RANGEDOT "::" "%255" RANGE0 "%n", - "%*[ \t]%255" RANGESLASH "%*[ .]" "%255" RANGE0 "%n", -}; - static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) { int match = MethodMatcher::Exact; while (name[0] == '*') { @@ -534,12 +517,10 @@ int* bytes_read, const char*& error_msg) { *bytes_read = 0; error_msg = NULL; - for (uint i = 0; i < ARRAY_SIZE(patterns); i++) { - if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) { - *c_mode = check_mode(class_name, error_msg); - *m_mode = check_mode(method_name, error_msg); - return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown; - } + if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) { + *c_mode = check_mode(class_name, error_msg); + *m_mode = check_mode(method_name, error_msg); + return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown; } return false; }
--- a/src/share/vm/gc_interface/collectedHeap.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/gc_interface/collectedHeap.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -320,9 +320,6 @@ inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS); inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS); - inline static void post_allocation_install_obj_klass(KlassHandle klass, - oop obj); - // Raw memory allocation facilities // The obj and array allocate methods are covers for these methods. // mem_allocate() should never be
--- a/src/share/vm/gc_interface/collectedHeap.inline.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/gc_interface/collectedHeap.inline.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -39,14 +39,22 @@ // Inline allocation implementations. void CollectedHeap::post_allocation_setup_common(KlassHandle klass, - HeapWord* obj) { - post_allocation_setup_no_klass_install(klass, obj); - post_allocation_install_obj_klass(klass, oop(obj)); + HeapWord* obj_ptr) { + post_allocation_setup_no_klass_install(klass, obj_ptr); + oop obj = (oop)obj_ptr; +#if ! INCLUDE_ALL_GCS + obj->set_klass(klass()); +#else + // Need a release store to ensure array/class length, mark word, and + // object zeroing are visible before setting the klass non-NULL, for + // concurrent collectors. + obj->release_set_klass(klass()); +#endif } void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, - HeapWord* objPtr) { - oop obj = (oop)objPtr; + HeapWord* obj_ptr) { + oop obj = (oop)obj_ptr; assert(obj != NULL, "NULL object pointer"); if (UseBiasedLocking && (klass() != NULL)) { @@ -57,18 +65,6 @@ } } -void CollectedHeap::post_allocation_install_obj_klass(KlassHandle klass, - oop obj) { - // These asserts are kind of complicated because of klassKlass - // and the beginning of the world. - assert(klass() != NULL || !Universe::is_fully_initialized(), "NULL klass"); - assert(klass() == NULL || klass()->is_klass(), "not a klass"); - assert(obj != NULL, "NULL object pointer"); - obj->set_klass(klass()); - assert(!Universe::is_fully_initialized() || obj->klass() != NULL, - "missing klass"); -} - // Support for jvmti and dtrace inline void post_allocation_notify(KlassHandle klass, oop obj, int size) { // support low memory notifications (no-op if not enabled) @@ -86,25 +82,26 @@ } void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, - HeapWord* obj, + HeapWord* obj_ptr, int size) { - post_allocation_setup_common(klass, obj); + post_allocation_setup_common(klass, obj_ptr); + oop obj = (oop)obj_ptr; assert(Universe::is_bootstrapping() || - !((oop)obj)->is_array(), "must not be an array"); + !obj->is_array(), "must not be an array"); // notify jvmti and dtrace - post_allocation_notify(klass, (oop)obj, size); + post_allocation_notify(klass, obj, size); } void CollectedHeap::post_allocation_setup_array(KlassHandle klass, - HeapWord* obj, + HeapWord* obj_ptr, int length) { - // Set array length before setting the _klass field - // in post_allocation_setup_common() because the klass field - // indicates that the object is parsable by concurrent GC. + // Set array length before setting the _klass field because a + // non-NULL klass field indicates that the object is parsable by + // concurrent GC. assert(length >= 0, "length should be non-negative"); - ((arrayOop)obj)->set_length(length); - post_allocation_setup_common(klass, obj); - oop new_obj = (oop)obj; + ((arrayOop)obj_ptr)->set_length(length); + post_allocation_setup_common(klass, obj_ptr); + oop new_obj = (oop)obj_ptr; assert(new_obj->is_array(), "must be an array"); // notify jvmti and dtrace (must be after length is set for dtrace) post_allocation_notify(klass, new_obj, new_obj->size());
--- a/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -285,13 +285,13 @@ void JfrThreadSampleClosure::commit_events(JfrSampleType type) { if (JAVA_SAMPLE == type) { - assert(_added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant"); + assert(_added_java > 0 && _added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant"); for (uint i = 0; i < _added_java; ++i) { _events[i].commit(); } } else { assert(NATIVE_SAMPLE == type, "invariant"); - assert(_added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant"); + assert(_added_native > 0 && _added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant"); for (uint i = 0; i < _added_native; ++i) { _events_native[i].commit(); } @@ -537,7 +537,7 @@ JfrThreadSampleClosure sample_task(samples, samples_native); const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES; - uint num_sample_attempts = 0; + uint num_samples = 0; JavaThread* start = NULL; { @@ -555,7 +555,7 @@ JavaThread* current = Threads::includes(*last_thread) ? *last_thread : NULL; JavaThread* start = NULL; - while (num_sample_attempts < sample_limit) { + while (num_samples < sample_limit) { current = next_thread(threads_list, index, start, current); if (current == NULL) { break; @@ -566,8 +566,9 @@ if (current->is_Compiler_thread()) { continue; } - sample_task.do_sample_thread(current, _frames, _max_frames, type); - num_sample_attempts++; + if (sample_task.do_sample_thread(current, _frames, _max_frames, type)) { + num_samples++; + } } *last_thread = current; // remember the thread we last attempted to sample FREE_C_HEAP_ARRAY(JavaThread *, threads_list, mtInternal); @@ -576,7 +577,7 @@ if (LogJFR && Verbose) tty->print_cr("JFR thread sampling done in %3.7f secs with %d java %d native samples", sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries()); } - if (num_sample_attempts > 0) { + if (num_samples > 0) { sample_task.commit_events(type); } }
--- a/src/share/vm/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -376,6 +376,7 @@ vfs.next(); } + _hash = 1; while (!vfs.at_end()) { if (count >= _max_frames) { _reached_root = false; @@ -391,7 +392,9 @@ bci = vfs.bci(); } // Can we determine if it's inlined? - _hash = (_hash << 2) + (unsigned int)(((size_t)mid >> 2) + (bci << 4) + type); + _hash = (_hash * 31) + mid; + _hash = (_hash * 31) + bci; + _hash = (_hash * 31) + type; _frames[count] = JfrStackFrame(mid, bci, type, method); vfs.next(); count++; @@ -406,6 +409,7 @@ u4 count = 0; _reached_root = true; + _hash = 1; while (!st.at_end()) { if (count >= _max_frames) { _reached_root = false; @@ -427,7 +431,9 @@ } const int lineno = method->line_number_from_bci(bci); // Can we determine if it's inlined? - _hash = (_hash << 2) + (unsigned int)(((size_t)mid >> 2) + (bci << 4) + type); + _hash = (_hash * 31) + mid; + _hash = (_hash * 31) + bci; + _hash = (_hash * 31) + type; _frames[count] = JfrStackFrame(mid, bci, type, lineno); st.samples_next(); count++;
--- a/src/share/vm/memory/allocation.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/memory/allocation.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -529,7 +529,7 @@ // change the size void Arena::set_size_in_bytes(size_t size) { if (_size_in_bytes != size) { - long delta = (long)(size - size_in_bytes()); + ssize_t delta = size - size_in_bytes(); _size_in_bytes = size; MemTracker::record_arena_size_change(delta, _flags); }
--- a/src/share/vm/memory/heapInspection.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/memory/heapInspection.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -367,7 +367,7 @@ _csv_format(csv_format), _print_help(print_help), _print_class_stats(print_class_stats), _columns(columns) {} void heap_inspection(outputStream* st) NOT_SERVICES_RETURN; - size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL) NOT_SERVICES_RETURN; + size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL) NOT_SERVICES_RETURN_(0); static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN; private: void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL);
--- a/src/share/vm/memory/metaspaceShared.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/memory/metaspaceShared.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -93,7 +93,7 @@ static void preload_and_dump(TRAPS) NOT_CDS_RETURN; static int preload_and_dump(const char * class_list_path, GrowableArray<Klass*>* class_promote_order, - TRAPS) NOT_CDS_RETURN; + TRAPS) NOT_CDS_RETURN_(0); static ReservedSpace* shared_rs() { CDS_ONLY(return _shared_rs);
--- a/src/share/vm/memory/padded.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/memory/padded.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -80,6 +80,12 @@ // super class that is specialized for the pad_size == 0 case. }; +// Similar to PaddedEnd, this macro defines a _pad_buf#id field +// that is (alignment - size) bytes in size. This macro is used +// to add padding in between non-class fields in a class or struct. +#define DEFINE_PAD_MINUS_SIZE(id, alignment, size) \ + char _pad_buf##id[(alignment) - (size)] + // Helper class to create an array of PaddedEnd<T> objects. All elements will // start at a multiple of alignment and the size will be aligned to alignment. template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
--- a/src/share/vm/memory/resourceArea.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/memory/resourceArea.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -31,8 +31,11 @@ void ResourceArea::bias_to(MEMFLAGS new_flags) { if (new_flags != _flags) { + size_t size = size_in_bytes(); + MemTracker::record_arena_size_change(-ssize_t(size), _flags); MemTracker::record_arena_free(_flags); MemTracker::record_new_arena(new_flags); + MemTracker::record_arena_size_change(ssize_t(size), new_flags); _flags = new_flags; } }
--- a/src/share/vm/oops/constantPool.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/oops/constantPool.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -350,7 +350,7 @@ Klass* klass_at(int which, TRAPS) { constantPoolHandle h_this(THREAD, this); - return klass_at_impl(h_this, which, CHECK_NULL); + return klass_at_impl(h_this, which, THREAD); } Symbol* klass_name_at(int which) const; // Returns the name, w/o resolving.
--- a/src/share/vm/oops/oop.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/oops/oop.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -87,6 +87,7 @@ narrowKlass* compressed_klass_addr(); void set_klass(Klass* k); + void release_set_klass(Klass* k); // For klass field compression int klass_gap() const;
--- a/src/share/vm/oops/oop.inline.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/oops/oop.inline.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -103,10 +103,14 @@ return &_metadata._compressed_klass; } +#define CHECK_SET_KLASS(k) \ + do { \ + assert(Universe::is_bootstrapping() || k != NULL, "NULL Klass"); \ + assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass"); \ + } while (0) + inline void oopDesc::set_klass(Klass* k) { - // since klasses are promoted no store check is needed - assert(Universe::is_bootstrapping() || k != NULL, "must be a real Klass*"); - assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass*"); + CHECK_SET_KLASS(k); if (UseCompressedClassPointers) { *compressed_klass_addr() = Klass::encode_klass_not_null(k); } else { @@ -114,6 +118,18 @@ } } +inline void oopDesc::release_set_klass(Klass* k) { + CHECK_SET_KLASS(k); + if (UseCompressedClassPointers) { + OrderAccess::release_store(compressed_klass_addr(), + Klass::encode_klass_not_null(k)); + } else { + OrderAccess::release_store_ptr(klass_addr(), k); + } +} + +#undef CHECK_SET_KLASS + inline int oopDesc::klass_gap() const { return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()); }
--- a/src/share/vm/prims/jvm.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/prims/jvm.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, 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 @@ -929,7 +929,7 @@ JVM_ENTRY(jboolean, JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname)) JVMWrapper("JVM_KnownToNotExist"); #if INCLUDE_CDS - return ClassLoaderExt::known_to_not_exist(env, loader, classname, CHECK_(false)); + return ClassLoaderExt::known_to_not_exist(env, loader, classname, THREAD); #else return false; #endif @@ -939,7 +939,7 @@ JVM_ENTRY(jobjectArray, JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader)) JVMWrapper("JVM_GetResourceLookupCacheURLs"); #if INCLUDE_CDS - return ClassLoaderExt::get_lookup_cache_urls(env, loader, CHECK_NULL); + return ClassLoaderExt::get_lookup_cache_urls(env, loader, THREAD); #else return NULL; #endif @@ -949,7 +949,7 @@ JVM_ENTRY(jintArray, JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name)) JVMWrapper("JVM_GetResourceLookupCache"); #if INCLUDE_CDS - return ClassLoaderExt::get_lookup_cache(env, loader, resource_name, CHECK_NULL); + return ClassLoaderExt::get_lookup_cache(env, loader, resource_name, THREAD); #else return NULL; #endif @@ -4368,7 +4368,7 @@ JVM_DTraceProvider* providers)) JVMWrapper("JVM_DTraceActivate"); return DTraceJSDT::activate( - version, module_name, providers_count, providers, CHECK_0); + version, module_name, providers_count, providers, THREAD); JVM_END JVM_ENTRY(jboolean,JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method))
--- a/src/share/vm/prims/whitebox.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/prims/whitebox.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -448,6 +448,21 @@ assert(hash_size > 0, "NMT hash_size should be > 0"); return (jint)hash_size; WB_END + +WB_ENTRY(jlong, WB_NMTNewArena(JNIEnv* env, jobject o, jlong init_size)) + Arena* arena = new (mtTest) Arena(mtTest, size_t(init_size)); + return (jlong)arena; +WB_END + +WB_ENTRY(void, WB_NMTFreeArena(JNIEnv* env, jobject o, jlong arena)) + Arena* a = (Arena*)arena; + delete a; +WB_END + +WB_ENTRY(void, WB_NMTArenaMalloc(JNIEnv* env, jobject o, jlong arena, jlong size)) + Arena* a = (Arena*)arena; + a->Amalloc(size_t(size)); +WB_END #endif // INCLUDE_NMT static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { @@ -1244,6 +1259,9 @@ {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, {CC"NMTChangeTrackingLevel", CC"()Z", (void*)&WB_NMTChangeTrackingLevel}, {CC"NMTGetHashSize", CC"()I", (void*)&WB_NMTGetHashSize }, + {CC"NMTNewArena", CC"(J)J", (void*)&WB_NMTNewArena }, + {CC"NMTFreeArena", CC"(J)V", (void*)&WB_NMTFreeArena }, + {CC"NMTArenaMalloc", CC"(JJ)V", (void*)&WB_NMTArenaMalloc }, #endif // INCLUDE_NMT {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I",
--- a/src/share/vm/runtime/globals.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/runtime/globals.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -3487,6 +3487,9 @@ notproduct(bool, CIObjectFactoryVerify, false, \ "enable potentially expensive verification in ciObjectFactory") \ \ + diagnostic(bool, AbortVMOnCompilationFailure, false, \ + "Abort VM when method had failed to compile.") \ + \ /* Priorities */ \ product_pd(bool, UseThreadPriorities, "Use native thread priorities") \ \
--- a/src/share/vm/runtime/perfData.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/runtime/perfData.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, 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 @@ -773,7 +773,7 @@ static PerfStringVariable* create_string_variable(CounterNS ns, const char* name, const char *s, TRAPS) { - return create_string_variable(ns, name, 0, s, CHECK_NULL); + return create_string_variable(ns, name, 0, s, THREAD); }; static PerfLongVariable* create_long_variable(CounterNS ns, @@ -784,7 +784,7 @@ static PerfLongVariable* create_long_variable(CounterNS ns, const char* name, PerfData::Units u, TRAPS) { - return create_long_variable(ns, name, u, (jlong)0, CHECK_NULL); + return create_long_variable(ns, name, u, (jlong)0, THREAD); }; static PerfLongVariable* create_long_variable(CounterNS, const char* name, @@ -805,7 +805,7 @@ static PerfLongCounter* create_long_counter(CounterNS ns, const char* name, PerfData::Units u, TRAPS) { - return create_long_counter(ns, name, u, (jlong)0, CHECK_NULL); + return create_long_counter(ns, name, u, (jlong)0, THREAD); }; static PerfLongCounter* create_long_counter(CounterNS ns, const char* name, @@ -823,49 +823,49 @@ static PerfConstant* create_constant(CounterNS ns, const char* name, PerfData::Units u, jlong val, TRAPS) { - return create_long_constant(ns, name, u, val, CHECK_NULL); + return create_long_constant(ns, name, u, val, THREAD); } static PerfVariable* create_variable(CounterNS ns, const char* name, PerfData::Units u, jlong ival, TRAPS) { - return create_long_variable(ns, name, u, ival, CHECK_NULL); + return create_long_variable(ns, name, u, ival, THREAD); } static PerfVariable* create_variable(CounterNS ns, const char* name, PerfData::Units u, TRAPS) { - return create_long_variable(ns, name, u, (jlong)0, CHECK_NULL); + return create_long_variable(ns, name, u, (jlong)0, THREAD); } static PerfVariable* create_variable(CounterNS ns, const char* name, PerfData::Units u, jlong* sp, TRAPS) { - return create_long_variable(ns, name, u, sp, CHECK_NULL); + return create_long_variable(ns, name, u, sp, THREAD); } static PerfVariable* create_variable(CounterNS ns, const char* name, PerfData::Units u, PerfSampleHelper* sh, TRAPS) { - return create_long_variable(ns, name, u, sh, CHECK_NULL); + return create_long_variable(ns, name, u, sh, THREAD); } static PerfCounter* create_counter(CounterNS ns, const char* name, PerfData::Units u, jlong ival, TRAPS) { - return create_long_counter(ns, name, u, ival, CHECK_NULL); + return create_long_counter(ns, name, u, ival, THREAD); } static PerfCounter* create_counter(CounterNS ns, const char* name, PerfData::Units u, TRAPS) { - return create_long_counter(ns, name, u, (jlong)0, CHECK_NULL); + return create_long_counter(ns, name, u, (jlong)0, THREAD); } static PerfCounter* create_counter(CounterNS ns, const char* name, PerfData::Units u, jlong* sp, TRAPS) { - return create_long_counter(ns, name, u, sp, CHECK_NULL); + return create_long_counter(ns, name, u, sp, THREAD); } static PerfCounter* create_counter(CounterNS ns, const char* name, PerfData::Units u, PerfSampleHelper* sh, TRAPS) { - return create_long_counter(ns, name, u, sh, CHECK_NULL); + return create_long_counter(ns, name, u, sh, THREAD); } static void destroy();
--- a/src/share/vm/runtime/reflection.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/runtime/reflection.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -506,7 +506,7 @@ (accessor_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION && accessee_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION)) { return classloader_only && - Verifier::relax_verify_for(accessor_ik->class_loader()) && + Verifier::relax_access_for(accessor_ik->class_loader()) && accessor_ik->protection_domain() == accessee_ik->protection_domain() && accessor_ik->class_loader() == accessee_ik->class_loader(); } else { @@ -1093,7 +1093,7 @@ } else { if (rtype == T_BOOLEAN || rtype == T_BYTE || rtype == T_CHAR || rtype == T_SHORT) narrow((jvalue*) result.get_value_addr(), rtype, CHECK_NULL); - return box((jvalue*) result.get_value_addr(), rtype, CHECK_NULL); + return box((jvalue*) result.get_value_addr(), rtype, THREAD); } }
--- a/src/share/vm/runtime/sharedRuntime.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/runtime/sharedRuntime.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1041,7 +1041,7 @@ // last java frame on stack (which includes native call frames) vframeStream vfst(thread, true); // Do not skip and javaCalls - return find_callee_info_helper(thread, vfst, bc, callinfo, CHECK_(Handle())); + return find_callee_info_helper(thread, vfst, bc, callinfo, THREAD); }
--- a/src/share/vm/services/jmm.h Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/services/jmm.h Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -219,7 +219,9 @@ typedef struct jmmInterface_1_ { void* reserved1; - void* reserved2; + jlong (JNICALL *GetOneThreadAllocatedMemory) + (JNIEnv *env, + jlong thread_id); jint (JNICALL *GetVersion) (JNIEnv *env); @@ -317,7 +319,11 @@ void (JNICALL *SetVMGlobal) (JNIEnv *env, jstring flag_name, jvalue new_value); - void* reserved6; + jobjectArray (JNICALL *DumpThreadsMaxDepth) (JNIEnv *env, + jlongArray ids, + jboolean lockedMonitors, + jboolean lockedSynchronizers, + jint maxDepth); jobjectArray (JNICALL *DumpThreads) (JNIEnv *env, jlongArray ids, jboolean lockedMonitors,
--- a/src/share/vm/services/mallocTracker.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/services/mallocTracker.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -69,8 +69,9 @@ } } - inline void resize(long sz) { + inline void resize(ssize_t sz) { if (sz != 0) { + assert(sz >= 0 || _size >= size_t(-sz), "Must be"); Atomic::add((MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); DEBUG_ONLY(_peak_size = MAX2(_size, _peak_size);) } @@ -112,7 +113,7 @@ _arena.deallocate(0); } - inline void record_arena_size_change(long sz) { + inline void record_arena_size_change(ssize_t sz) { _arena.resize(sz); } @@ -202,7 +203,7 @@ as_snapshot()->by_type(flag)->record_arena_free(); } - static inline void record_arena_size_change(long size, MEMFLAGS flag) { + static inline void record_arena_size_change(ssize_t size, MEMFLAGS flag) { as_snapshot()->by_type(flag)->record_arena_size_change(size); } @@ -356,7 +357,7 @@ MallocMemorySummary::record_arena_free(flags); } - static inline void record_arena_size_change(int size, MEMFLAGS flags) { + static inline void record_arena_size_change(ssize_t size, MEMFLAGS flags) { MallocMemorySummary::record_arena_size_change(size, flags); } private:
--- a/src/share/vm/services/management.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/services/management.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -1249,8 +1249,12 @@ // ids - array of thread IDs; NULL indicates all live threads // locked_monitors - if true, dump locked object monitors // locked_synchronizers - if true, dump locked JSR-166 synchronizers +// maxDepth - the maximum depth of stack traces to be dumped: +// maxDepth == -1 requests to dump entire stack trace. +// maxDepth == 0 requests no stack trace. // -JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors, jboolean locked_synchronizers)) +JVM_ENTRY(jobjectArray, jmm_DumpThreadsMaxDepth(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors, + jboolean locked_synchronizers, jint maxDepth)) ResourceMark rm(THREAD); if (JDK_Version::is_gte_jdk16x_version()) { @@ -1273,14 +1277,14 @@ do_thread_dump(&dump_result, ids_ah, num_threads, - -1, /* entire stack */ + maxDepth, /* stack depth */ (locked_monitors ? true : false), /* with locked monitors */ (locked_synchronizers ? true : false), /* with locked synchronizers */ CHECK_NULL); } else { // obtain thread dump of all threads VM_ThreadDump op(&dump_result, - -1, /* entire stack */ + maxDepth, /* stack depth */ (locked_monitors ? true : false), /* with locked monitors */ (locked_synchronizers ? true : false) /* with locked synchronizers */); VMThread::execute(&op); @@ -1386,6 +1390,25 @@ return (jobjectArray) JNIHandles::make_local(env, result_h()); JVM_END +// Dump thread info for the specified threads. +// It returns an array of ThreadInfo objects. Each element is the ThreadInfo +// for the thread ID specified in the corresponding entry in +// the given array of thread IDs; or NULL if the thread does not exist +// or has terminated. +// +// Input parameter: +// ids - array of thread IDs; NULL indicates all live threads +// locked_monitors - if true, dump locked object monitors +// locked_synchronizers - if true, dump locked JSR-166 synchronizers +// +// This method exists only for compatbility with compiled binaries that call it. +// The JDK library uses jmm_DumpThreadsMaxDepth. +// +JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors, + jboolean locked_synchronizers)) + return jmm_DumpThreadsMaxDepth(env, thread_ids, locked_monitors, locked_synchronizers, INT_MAX); +JVM_END + // Returns an array of Class objects. JVM_ENTRY(jobjectArray, jmm_GetLoadedClasses(JNIEnv *env)) ResourceMark rm(THREAD); @@ -2209,6 +2232,31 @@ } #endif // INCLUDE_MANAGEMENT +// Gets the amount of memory allocated on the Java heap for a single thread. +// Returns -1 if the thread does not exist or has terminated. +JVM_ENTRY(jlong, jmm_GetOneThreadAllocatedMemory(JNIEnv *env, jlong thread_id)) + if (thread_id < 0) { + THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), + "Invalid thread ID", -1); + } + + if (thread_id == 0) { + // current thread + if (THREAD->is_Java_thread()) { + return ((JavaThread*)THREAD)->cooked_allocated_bytes(); + } + return -1; + } + + MutexLockerEx ml(Threads_lock); + JavaThread* java_thread = Threads::find_java_thread_from_java_tid(thread_id); + + if (java_thread != NULL) { + return java_thread->cooked_allocated_bytes(); + } + return -1; +JVM_END + // Gets an array containing the amount of memory allocated on the Java // heap for a set of threads (in bytes). Each element of the array is // the amount of memory allocated for the thread ID specified in the @@ -2325,7 +2373,7 @@ #if INCLUDE_MANAGEMENT const struct jmmInterface_1_ jmm_interface = { NULL, - NULL, + jmm_GetOneThreadAllocatedMemory, jmm_GetVersion, jmm_GetOptionalSupport, jmm_GetInputArguments, @@ -2357,7 +2405,7 @@ jmm_DumpHeap0, jmm_FindDeadlockedThreads, jmm_SetVMGlobal, - NULL, + jmm_DumpThreadsMaxDepth, jmm_DumpThreads, jmm_SetGCNotificationEnabled, jmm_GetDiagnosticCommands,
--- a/src/share/vm/services/memTracker.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/services/memTracker.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -57,14 +57,14 @@ static inline void record_new_arena(MEMFLAGS flag) { } static inline void record_arena_free(MEMFLAGS flag) { } - static inline void record_arena_size_change(int diff, MEMFLAGS flag) { } + static inline void record_arena_size_change(ssize_t diff, MEMFLAGS flag) { } static inline void record_virtual_memory_reserve(void* addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone) { } static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone) { } static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { } static inline Tracker get_virtual_memory_uncommit_tracker() { return Tracker(); } - static inline Tracker get_virtual_memory_release_tracker() { } + static inline Tracker get_virtual_memory_release_tracker() { return Tracker(); } static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { } static inline void record_thread_stack(void* addr, size_t size) { } static inline void release_thread_stack(void* addr, size_t size) { } @@ -190,7 +190,7 @@ // Record arena size change. Arena size is the size of all arena // chuncks that backing up the arena. - static inline void record_arena_size_change(int diff, MEMFLAGS flag) { + static inline void record_arena_size_change(ssize_t diff, MEMFLAGS flag) { if (tracking_level() < NMT_summary) return; MallocTracker::record_arena_size_change(diff, flag); }
--- a/src/share/vm/services/threadService.cpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/services/threadService.cpp Mon Nov 16 13:36:34 2020 +0000 @@ -562,6 +562,10 @@ vframe* start_vf = _thread->last_java_vframe(®_map); int count = 0; for (vframe* f = start_vf; f; f = f->sender() ) { + if (maxDepth >= 0 && count == maxDepth) { + // Skip frames if more than maxDepth + break; + } if (f->is_java_frame()) { javaVFrame* jvf = javaVFrame::cast(f); add_stack_frame(jvf); @@ -569,10 +573,6 @@ } else { // Ignore non-Java frames } - if (maxDepth > 0 && count == maxDepth) { - // Skip frames if more than maxDepth - break; - } } }
--- a/src/share/vm/utilities/taskqueue.hpp Thu Nov 05 05:11:10 2020 +0000 +++ b/src/share/vm/utilities/taskqueue.hpp Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, 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 @@ -27,6 +27,7 @@ #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" +#include "memory/padded.hpp" #include "runtime/mutex.hpp" #include "runtime/orderAccess.inline.hpp" #include "utilities/globalDefinitions.hpp" @@ -112,9 +113,6 @@ // Internal type for indexing the queue; also used for the tag. typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t; - // The first free element after the last one pushed (mod N). - volatile uint _bottom; - enum { MOD_N_MASK = N - 1 }; class Age { @@ -154,6 +152,10 @@ }; }; + // The first free element after the last one pushed (mod N). + volatile uint _bottom; + // Add paddings to reduce false-sharing cache contention between _bottom and _age + DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(uint)); volatile Age _age; // These both operate mod N.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/ClassFile/BadHelloWorld.jcod Mon Nov 16 13:36:34 2020 +0000 @@ -0,0 +1,138 @@ +/* + * 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. + */ + +/* + * This file fuzzes the class name #15 to have a leading 'L' and ending ';'. + */ + +class BadHelloWorld { + 0xCAFEBABE; + 0; // minor version + 52; // version + [31] { // Constant Pool + ; // first element is empty + Utf8 "BadHelloWorld"; // #1 at 0x0A + class #1; // #2 at 0x1A + Utf8 "java/lang/Object"; // #3 at 0x1D + class #3; // #4 at 0x30 + Utf8 "<init>"; // #5 at 0x33 + Utf8 "()V"; // #6 at 0x3C + NameAndType #5 #6; // #7 at 0x42 + Method #4 #7; // #8 at 0x47 + Utf8 "toString"; // #9 at 0x4C + Utf8 "()Ljava/lang/String;"; // #10 at 0x57 + Utf8 "Hello, world!"; // #11 at 0x6E + String #11; // #12 at 0x7E + Utf8 "main"; // #13 at 0x81 + Utf8 "([Ljava/lang/String;)V"; // #14 at 0x88 + Utf8 "LBadHelloWorld;"; // #15 at 0xA1 + class #15; // #16 at 0xB3 + Method #16 #7; // #17 at 0xB6 + Utf8 "java/lang/System"; // #18 at 0xBB + class #18; // #19 at 0xCE + Utf8 "out"; // #20 at 0xD1 + Utf8 "Ljava/io/PrintStream;"; // #21 at 0xD7 + NameAndType #20 #21; // #22 at 0xEF + Field #19 #22; // #23 at 0xF4 + Utf8 "java/io/PrintStream"; // #24 at 0xF9 + class #24; // #25 at 0x010F + Utf8 "println"; // #26 at 0x0112 + Utf8 "(Ljava/lang/Object;)V"; // #27 at 0x011C + NameAndType #26 #27; // #28 at 0x0134 + Method #25 #28; // #29 at 0x0139 + Utf8 "Code"; // #30 at 0x013E + } // Constant Pool + + 0x0021; // access + #2;// this_cpx + #4;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // fields + } // fields + + [3] { // methods + { // Member at 0x0151 + 0x0001; // access + #5; // name_cpx + #6; // sig_cpx + [1] { // Attributes + Attr(#30, 17) { // Code at 0x0159 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70008B1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0170 + 0x0001; // access + #9; // name_cpx + #10; // sig_cpx + [1] { // Attributes + Attr(#30, 15) { // Code at 0x0178 + 1; // max_stack + 1; // max_locals + Bytes[3]{ + 0x120CB0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x018D + 0x0089; // access + #13; // name_cpx + #14; // sig_cpx + [1] { // Attributes + Attr(#30, 28) { // Code at 0x0195 + 2; // max_stack + 2; // max_locals + Bytes[16]{ + 0xBB001059B700114C; + 0xB200172BB6001DB1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [0] { // Attributes + } // Attributes +} // end class BadHelloWorld
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/ClassFile/FormatCheckingTest.java Mon Nov 16 13:36:34 2020 +0000 @@ -0,0 +1,43 @@ +/* + * 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 8148854 + * @summary Ensure class name loaded by app class loader is format checked by default + * @library /testlibrary + * @compile BadHelloWorld.jcod + * @run main FormatCheckingTest + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +public class FormatCheckingTest { + public static void main(String args[]) throws Throwable { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("BadHelloWorld"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("java.lang.ClassFormatError: Illegal class name"); + output.shouldHaveExitValue(1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/NMT/HugeArenaTracking.java Mon Nov 16 13:36:34 2020 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * + * 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 + * @key nmt jcmd + * @library /testlibrary /testlibrary/whitebox + * @build HugeArenaTracking + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail HugeArenaTracking + */ + +import java.util.Random; +import com.oracle.java.testlibrary.*; +import sun.hotspot.WhiteBox; + +public class HugeArenaTracking { + private static final long GB = 1024 * 1024 * 1024; + + public static void main(String args[]) throws Exception { + OutputAnalyzer output; + final WhiteBox wb = WhiteBox.getWhiteBox(); + + // Grab my own PID + String pid = Long.toString(ProcessTools.getProcessId()); + ProcessBuilder pb = new ProcessBuilder(); + + long arena1 = wb.NMTNewArena(1024); + long arena2 = wb.NMTNewArena(1024); + + // Run 'jcmd <pid> VM.native_memory summary' + pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Test (reserved=2KB, committed=2KB)"); + + Random rand = new Random(); + + // Allocate 2GB+ from arena + long total = 0; + while (total < 2 * GB) { + // Cap to 10M + long inc = rand.nextInt(10 * 1024 * 1024); + wb.NMTArenaMalloc(arena1, inc); + total += inc; + } + + ProcessBuilder pb2 = new ProcessBuilder(); + // Run 'jcmd <pid> VM.native_memory summary' + pb2.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB"}); + output = new OutputAnalyzer(pb2.start()); + output.shouldContain("Test (reserved=2GB, committed=2GB)"); + + wb.NMTFreeArena(arena1); + + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Test (reserved=1KB, committed=1KB)"); + wb.NMTFreeArena(arena2); + + output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Test (reserved"); + } +}
--- a/test/runtime/containers/docker/Dockerfile-BasicTest Thu Nov 05 05:11:10 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -FROM oraclelinux:7.6 -MAINTAINER mikhailo.seledtsov@oracle.com - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"]
--- a/test/runtime/containers/docker/Dockerfile-BasicTest-aarch64 Thu Nov 05 05:11:10 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# Use generic ubuntu Linux on AArch64 -FROM aarch64/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"]
--- a/test/runtime/containers/docker/Dockerfile-BasicTest-ppc64le Thu Nov 05 05:11:10 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -# test on x86_64 uses Oracle Linux but we do not have this for ppc64le -# so use some other Linux where OpenJDK works -# FROM oraclelinux:7.2 -FROM ppc64le/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"]
--- a/test/runtime/containers/docker/Dockerfile-BasicTest-s390x Thu Nov 05 05:11:10 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -FROM s390x/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"]
--- a/test/testlibrary/com/oracle/java/testlibrary/DockerTestUtils.java Thu Nov 05 05:11:10 2020 +0000 +++ b/test/testlibrary/com/oracle/java/testlibrary/DockerTestUtils.java Mon Nov 16 13:36:34 2020 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.FileVisitResult; import java.nio.file.Path; @@ -125,11 +126,6 @@ if (Files.exists(buildDir)) { throw new RuntimeException("The docker build directory already exists: " + buildDir); } - // check for the existance of a platform specific docker file as well - String platformSpecificDockerfile = dockerfile + "-" + Platform.getOsArch(); - if (Files.exists(Paths.get(Utils.TEST_SRC, platformSpecificDockerfile))) { - dockerfile = platformSpecificDockerfile; - } Path jdkSrcDir = Paths.get(Utils.TEST_JDK); Path jdkDstDir = buildDir.resolve("jdk"); @@ -156,8 +152,9 @@ */ public static void buildDockerImage(String imageName, Path dockerfile, Path buildDir) throws Exception { - // Copy docker file to the build dir - Files.copy(dockerfile, buildDir.resolve("Dockerfile")); + generateDockerFile(buildDir.resolve("Dockerfile"), + DockerfileConfig.getBaseImageName(), + DockerfileConfig.getBaseImageVersion()); // Build the docker execute("docker", "build", "--no-cache", "--tag", imageName, buildDir.toString()) @@ -247,6 +244,18 @@ } + private static void generateDockerFile(Path dockerfile, String baseImage, + String baseImageVersion) throws Exception { + String template = + "FROM %s:%s\n" + + "COPY /jdk /jdk\n" + + "ENV JAVA_HOME=/jdk\n" + + "CMD [\"/bin/bash\"]\n"; + String dockerFileStr = String.format(template, baseImage, baseImageVersion); + Files.write(dockerfile, dockerFileStr.getBytes(StandardCharsets.UTF_8)); + } + + private static class CopyFileVisitor extends SimpleFileVisitor<Path> { private final Path src; private final Path dst;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/testlibrary/com/oracle/java/testlibrary/DockerfileConfig.java Mon Nov 16 13:36:34 2020 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019, 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. + */ + +package com.oracle.java.testlibrary; + +// Use the following properties to specify docker base image at test execution time: +// Image name: jdk.test.docker.image.name +// Image version: jdk.test.docker.image.version +// Usage: +// jtreg -Djdk.test.docker.image.name=<BASE_IMAGE_NAME> -Djdk.test.docker.image.version=<BASE_IMAGE_VERSION> test/hotspot/jtreg/runtime/containers/docker/ +// E.g.: +// jtreg -Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest test/hotspot/jtreg/runtime/containers/docker/ +// Using make: +// make test TEST="test/hotspot/jtreg/runtime/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest" +// Note: base image version should not be an empty string. Use "latest" to get the latest version. + +public class DockerfileConfig { + static String getBaseImageName() { + String name = System.getProperty("jdk.test.docker.image.name"); + if (name != null) { + System.out.println("DockerfileConfig: using custom image name: " + name); + return name; + } + + switch (Platform.getOsArch()) { + case "aarch64": + return "aarch64/ubuntu"; + case "ppc64le": + return "ppc64le/ubuntu"; + case "s390x": + return "s390x/ubuntu"; + default: + return "oraclelinux"; + } + } + + static String getBaseImageVersion() { + String version = System.getProperty("jdk.test.docker.image.version"); + if (version != null) { + System.out.println("DockerfileConfig: using custom image version: " + version); + return version; + } + + switch (Platform.getOsArch()) { + case "aarch64": + case "ppc64le": + case "s390x": + return "latest"; + default: + return "7.6"; + } + } +}
--- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Thu Nov 05 05:11:10 2020 +0000 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Mon Nov 16 13:36:34 2020 +0000 @@ -122,6 +122,9 @@ public native boolean NMTIsDetailSupported(); public native boolean NMTChangeTrackingLevel(); public native int NMTGetHashSize(); + public native long NMTNewArena(long initSize); + public native void NMTFreeArena(long arena); + public native void NMTArenaMalloc(long arena, long size); // Compiler public native void deoptimizeAll();