From 38204f9c657313961504491c97533522e373889a Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Fri, 7 Jun 2019 10:26:21 -0700 Subject: [PATCH 01/45] 8209626: [JVMCI] Use implicit exception table for dispatch and printing Reviewed-by: kvn --- src/hotspot/share/aot/aotCompiledMethod.hpp | 5 +- src/hotspot/share/code/compiledMethod.cpp | 43 +++++++++ src/hotspot/share/code/compiledMethod.hpp | 5 +- .../share/code/exceptionHandlerTable.cpp | 14 ++- .../share/code/exceptionHandlerTable.hpp | 21 +++- src/hotspot/share/code/nmethod.cpp | 96 +++++++++++-------- src/hotspot/share/code/nmethod.hpp | 3 - .../share/jvmci/jvmciCodeInstaller.cpp | 7 +- .../share/jvmci/jvmciCodeInstaller.hpp | 8 ++ src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 8 ++ src/hotspot/share/jvmci/jvmciJavaClasses.hpp | 1 + src/hotspot/share/jvmci/jvmciRuntime.cpp | 4 +- src/hotspot/share/jvmci/jvmciRuntime.hpp | 1 + src/hotspot/share/runtime/sharedRuntime.cpp | 35 +------ src/hotspot/share/runtime/sharedRuntime.hpp | 3 - .../src/jdk/tools/jaotc/MetadataBuilder.java | 30 ++++-- .../jdk/vm/ci/hotspot/HotSpotMetaData.java | 5 + 17 files changed, 192 insertions(+), 97 deletions(-) diff --git a/src/hotspot/share/aot/aotCompiledMethod.hpp b/src/hotspot/share/aot/aotCompiledMethod.hpp index 93d985f9068..a42efe7e610 100644 --- a/src/hotspot/share/aot/aotCompiledMethod.hpp +++ b/src/hotspot/share/aot/aotCompiledMethod.hpp @@ -51,6 +51,7 @@ private: int _scopes_begin; int _reloc_begin; int _exception_table_begin; + int _nul_chk_table_begin; int _oopmap_begin; address at_offset(size_t offset) const { return ((address) this) + offset; } public: @@ -63,9 +64,9 @@ public: relocInfo* relocation_begin() const { return (relocInfo*) at_offset(_reloc_begin); } relocInfo* relocation_end() const { return (relocInfo*) at_offset(_exception_table_begin); } address handler_table_begin () const { return at_offset(_exception_table_begin); } - address handler_table_end() const { return at_offset(_oopmap_begin); } + address handler_table_end() const { return at_offset(_nul_chk_table_begin); } - address nul_chk_table_begin() const { return at_offset(_oopmap_begin); } + address nul_chk_table_begin() const { return at_offset(_nul_chk_table_begin); } address nul_chk_table_end() const { return at_offset(_oopmap_begin); } ImmutableOopMapSet* oopmap_set() const { return (ImmutableOopMapSet*) at_offset(_oopmap_begin); } diff --git a/src/hotspot/share/code/compiledMethod.cpp b/src/hotspot/share/code/compiledMethod.cpp index 47a7ff4bcd2..e2cf5e4b082 100644 --- a/src/hotspot/share/code/compiledMethod.cpp +++ b/src/hotspot/share/code/compiledMethod.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "code/compiledIC.hpp" #include "code/compiledMethod.inline.hpp" +#include "code/exceptionHandlerTable.hpp" #include "code/scopeDesc.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" @@ -37,8 +38,10 @@ #include "oops/methodData.hpp" #include "oops/method.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/deoptimization.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" +#include "runtime/sharedRuntime.hpp" CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, @@ -638,6 +641,46 @@ bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) { os::is_readable_pointer(method->signature()); } +address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { + // Exception happened outside inline-cache check code => we are inside + // an active nmethod => use cpc to determine a return address + int exception_offset = pc - code_begin(); + int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); +#ifdef ASSERT + if (cont_offset == 0) { + Thread* thread = Thread::current(); + ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY + HandleMark hm(thread); + ResourceMark rm(thread); + CodeBlob* cb = CodeCache::find_blob(pc); + assert(cb != NULL && cb == this, ""); + ttyLocker ttyl; + tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); + print(); + method()->print_codes(); + print_code(); + print_pcs(); + } +#endif + if (cont_offset == 0) { + // Let the normal error handling report the exception + return NULL; + } + if (cont_offset == exception_offset) { +#if INCLUDE_JVMCI + Deoptimization::DeoptReason deopt_reason = for_div0_check ? Deoptimization::Reason_div0_check : Deoptimization::Reason_null_check; + JavaThread *thread = JavaThread::current(); + thread->set_jvmci_implicit_exception_pc(pc); + thread->set_pending_deoptimization(Deoptimization::make_trap_request(deopt_reason, + Deoptimization::Action_reinterpret)); + return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); +#else + ShouldNotReachHere(); +#endif + } + return code_begin() + cont_offset; +} + class HasEvolDependency : public MetadataClosure { bool _has_evol_dependency; public: diff --git a/src/hotspot/share/code/compiledMethod.hpp b/src/hotspot/share/code/compiledMethod.hpp index 2ce03019457..b9110cee5e0 100644 --- a/src/hotspot/share/code/compiledMethod.hpp +++ b/src/hotspot/share/code/compiledMethod.hpp @@ -350,7 +350,8 @@ public: void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f); // implicit exceptions support - virtual address continuation_for_implicit_exception(address pc) { return NULL; } + address continuation_for_implicit_div0_exception(address pc) { return continuation_for_implicit_exception(pc, true); } + address continuation_for_implicit_null_exception(address pc) { return continuation_for_implicit_exception(pc, false); } static address get_deopt_original_pc(const frame* fr); @@ -358,6 +359,8 @@ public: private: bool cleanup_inline_caches_impl(bool unloading_occurred, bool clean_all); + address continuation_for_implicit_exception(address pc, bool for_div0_check); + public: // Serial version used by sweeper and whitebox test void cleanup_inline_caches(bool clean_all); diff --git a/src/hotspot/share/code/exceptionHandlerTable.cpp b/src/hotspot/share/code/exceptionHandlerTable.cpp index 254661a48f6..86161e9e371 100644 --- a/src/hotspot/share/code/exceptionHandlerTable.cpp +++ b/src/hotspot/share/code/exceptionHandlerTable.cpp @@ -176,7 +176,7 @@ void ImplicitExceptionTable::append( uint exec_off, uint cont_off ) { _len = l+1; }; -uint ImplicitExceptionTable::at( uint exec_off ) const { +uint ImplicitExceptionTable::continuation_offset( uint exec_off ) const { uint l = len(); for( uint i=0; inul_chk_table_size() == 0) { _len = 0; _data = NULL; @@ -221,9 +221,13 @@ ImplicitExceptionTable::ImplicitExceptionTable(const nmethod* nm) { } void ImplicitExceptionTable::copy_to( nmethod* nm ) { - assert(size_in_bytes() <= nm->nul_chk_table_size(), "size of space allocated in nmethod incorrect"); + copy_bytes_to(nm->nul_chk_table_begin(), nm->nul_chk_table_size()); +} + +void ImplicitExceptionTable::copy_bytes_to(address addr, int size) { + assert(size_in_bytes() <= size, "size of space allocated in nmethod incorrect"); if (len() != 0) { - implicit_null_entry* nmdata = (implicit_null_entry*)nm->nul_chk_table_begin(); + implicit_null_entry* nmdata = (implicit_null_entry*)addr; // store the length in the first uint nmdata[0] = _len; nmdata++; @@ -232,7 +236,7 @@ void ImplicitExceptionTable::copy_to( nmethod* nm ) { } else { // zero length table takes zero bytes assert(size_in_bytes() == 0, "bad size"); - assert(nm->nul_chk_table_size() == 0, "bad size"); + assert(size == 0, "bad size"); } } diff --git a/src/hotspot/share/code/exceptionHandlerTable.hpp b/src/hotspot/share/code/exceptionHandlerTable.hpp index e5a407ec0d2..d9f88e4a539 100644 --- a/src/hotspot/share/code/exceptionHandlerTable.hpp +++ b/src/hotspot/share/code/exceptionHandlerTable.hpp @@ -146,19 +146,36 @@ class ImplicitExceptionTable { implicit_null_entry *_data; implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; } ReallocMark _nesting; // assertion check for reallocations + public: ImplicitExceptionTable( ) : _size(0), _len(0), _data(0) { } // (run-time) construction from nmethod - ImplicitExceptionTable( const nmethod *nm ); + ImplicitExceptionTable( const CompiledMethod *nm ); void set_size( uint size ); void append( uint exec_off, uint cont_off ); - uint at( uint exec_off ) const; + +#if INCLUDE_JVMCI + void add_deoptimize(uint exec_off) { + // Use the same offset as a marker value for deoptimization + append(exec_off, exec_off); + } +#endif + + // Returns the offset to continue execution at. If the returned + // value equals exec_off then the dispatch is expected to be a + // deoptimization instead. + uint continuation_offset( uint exec_off ) const; uint len() const { return _len; } + + uint get_exec_offset(uint i) { assert(i < _len, "oob"); return *adr(i); } + uint get_cont_offset(uint i) { assert(i < _len, "oob"); return *(adr(i) + 1); } + int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * sizeof(implicit_null_entry)); } void copy_to(nmethod* nm); + void copy_bytes_to(address addr, int size); void print(address base) const; void verify(nmethod *nm) const; }; diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 9f7b2c9b591..27c79844911 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -923,6 +923,7 @@ void nmethod::print_nmethod(bool printmethod) { ttyLocker ttyl; // keep the following output all in one block if (xtty != NULL) { xtty->begin_head("print_nmethod"); + log_identity(xtty); xtty->stamp(); xtty->end_head(); } @@ -2093,34 +2094,6 @@ bool nmethod::is_patchable_at(address instr_addr) { } -address nmethod::continuation_for_implicit_exception(address pc) { - // Exception happened outside inline-cache check code => we are inside - // an active nmethod => use cpc to determine a return address - int exception_offset = pc - code_begin(); - int cont_offset = ImplicitExceptionTable(this).at( exception_offset ); -#ifdef ASSERT - if (cont_offset == 0) { - Thread* thread = Thread::current(); - ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY - HandleMark hm(thread); - ResourceMark rm(thread); - CodeBlob* cb = CodeCache::find_blob(pc); - assert(cb != NULL && cb == this, ""); - ttyLocker ttyl; - tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); - // Print all available nmethod info. - print_nmethod(true); - method()->print_codes(); - } -#endif - if (cont_offset == 0) { - // Let the normal error handling report the exception - return NULL; - } - return code_begin() + cont_offset; -} - - void nmethod_init() { // make sure you didn't forget to adjust the filler fields assert(sizeof(nmethod) % oopSize == 0, "nmethod size must be multiple of a word"); @@ -2213,6 +2186,30 @@ void nmethod::verify() { } } +#ifdef ASSERT +#if INCLUDE_JVMCI + { + // Verify that implicit exceptions that deoptimize have a PcDesc and OopMap + ImmutableOopMapSet* oms = oop_maps(); + ImplicitExceptionTable implicit_table(this); + for (uint i = 0; i < implicit_table.len(); i++) { + int exec_offset = (int) implicit_table.get_exec_offset(i); + if (implicit_table.get_exec_offset(i) == implicit_table.get_cont_offset(i)) { + assert(pc_desc_at(code_begin() + exec_offset) != NULL, "missing PcDesc"); + bool found = false; + for (int i = 0, imax = oms->count(); i < imax; i++) { + if (oms->pair_at(i)->pc_offset() == exec_offset) { + found = true; + break; + } + } + assert(found, "missing oopmap"); + } + } + } +#endif +#endif + VerifyOopsClosure voc(this); oops_do(&voc); assert(voc.ok(), "embedded oops must be OK"); @@ -3012,16 +3009,32 @@ bool nmethod::has_code_comment(address begin, address end) { if (str != NULL) return true; // implicit exceptions? - int cont_offset = ImplicitExceptionTable(this).at(begin - code_begin()); + int cont_offset = ImplicitExceptionTable(this).continuation_offset(begin - code_begin()); if (cont_offset != 0) return true; return false; } void nmethod::print_code_comment_on(outputStream* st, int column, address begin, address end) { - // First, find an oopmap in (begin, end]. - // We use the odd half-closed interval so that oop maps and scope descs - // which are tied to the byte after a call are printed with the call itself. + ImplicitExceptionTable implicit_table(this); + int pc_offset = begin - code_begin(); + int cont_offset = implicit_table.continuation_offset(pc_offset); + bool oop_map_required = false; + if (cont_offset != 0) { + st->move_to(column, 6, 0); + if (pc_offset == cont_offset) { + st->print("; implicit exception: deoptimizes"); + oop_map_required = true; + } else { + st->print("; implicit exception: dispatches to " INTPTR_FORMAT, p2i(code_begin() + cont_offset)); + } + } + + // Find an oopmap in (begin, end]. We use the odd half-closed + // interval so that oop maps and scope descs which are tied to the + // byte after a call are printed with the call itself. OopMaps + // associated with implicit exceptions are printed with the implicit + // instruction. address base = code_begin(); ImmutableOopMapSet* oms = oop_maps(); if (oms != NULL) { @@ -3029,16 +3042,25 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, const ImmutableOopMapPair* pair = oms->pair_at(i); const ImmutableOopMap* om = pair->get_from(oms); address pc = base + pair->pc_offset(); - if (pc > begin) { - if (pc <= end) { + if (pc >= begin) { +#if INCLUDE_JVMCI + bool is_implicit_deopt = implicit_table.continuation_offset(pair->pc_offset()) == (uint) pair->pc_offset(); +#else + bool is_implicit_deopt = false; +#endif + if (is_implicit_deopt ? pc == begin : pc > begin && pc <= end) { st->move_to(column, 6, 0); st->print("; "); om->print_on(st); + oop_map_required = false; } + } + if (pc > end) { break; } } } + assert(!oop_map_required, "missed oopmap"); // Print any debug info present at this pc. ScopeDesc* sd = scope_desc_in(begin, end); @@ -3128,12 +3150,6 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, st->move_to(column, 6, 0); st->print("; {%s}", str); } - int cont_offset = ImplicitExceptionTable(this).at(begin - code_begin()); - if (cont_offset != 0) { - st->move_to(column, 6, 0); - st->print("; implicit exception: dispatches to " INTPTR_FORMAT, p2i(code_begin() + cont_offset)); - } - } #endif diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index b2999ade4c9..d59220449d0 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -424,9 +424,6 @@ public: long stack_traversal_mark() { return _stack_traversal_mark; } void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } - // implicit exceptions support - address continuation_for_implicit_exception(address pc); - // On-stack replacement support int osr_entry_bci() const { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; } address osr_entry() const { assert(is_osr_method(), "wrong kind of nmethod"); return _osr_entry_point; } diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index 7951065ab88..57bfd5b969d 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -562,6 +562,7 @@ JVMCI::CodeInstallResult CodeInstaller::gather_metadata(JVMCIObject target, JVMC metadata.set_pc_desc(_debug_recorder->pcs(), _debug_recorder->pcs_length()); metadata.set_scopes(_debug_recorder->stream()->buffer(), _debug_recorder->data_size()); metadata.set_exception_table(&_exception_handler_table); + metadata.set_implicit_exception_table(&_implicit_exception_table); RelocBuffer* reloc_buffer = metadata.get_reloc_buffer(); @@ -637,7 +638,7 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, JVMCIObject mirror = installed_code; nmethod* nm = NULL; result = runtime()->register_method(jvmci_env(), method, nm, entry_bci, &_offsets, _orig_pc_offset, &buffer, - stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, + stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, &_implicit_exception_table, compiler, _debug_recorder, _dependencies, id, has_unsafe_access, _has_wide_vector, compiled_code, mirror, failed_speculations, speculations, speculations_len); @@ -870,6 +871,10 @@ JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bo if (_orig_pc_offset < 0) { JVMCI_ERROR_OK("method contains safepoint, but has no deopt rescue slot"); } + if (JVMCIENV->equals(reason, jvmci_env()->get_site_InfopointReason_IMPLICIT_EXCEPTION())) { + TRACE_jvmci_4("implicit exception at %i", pc_offset); + _implicit_exception_table.add_deoptimize(pc_offset); + } } else { TRACE_jvmci_4("infopoint at %i", pc_offset); site_Infopoint(buffer, pc_offset, site, JVMCI_CHECK_OK); diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp index c0d0a0a2c6f..21f6e76b174 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp @@ -85,6 +85,8 @@ public: ExceptionHandlerTable* get_exception_table() { return _exception_table; } + ImplicitExceptionTable* get_implicit_exception_table() { return _implicit_exception_table; } + void set_pc_desc(PcDesc* desc, int count) { _pc_desc = desc; _nr_pc_desc = count; @@ -105,6 +107,10 @@ public: _exception_table = table; } + void set_implicit_exception_table(ImplicitExceptionTable* table) { + _implicit_exception_table = table; + } + private: CodeBlob* _cb; PcDesc* _pc_desc; @@ -118,6 +124,7 @@ private: AOTOopRecorder* _oop_recorder; #endif ExceptionHandlerTable* _exception_table; + ImplicitExceptionTable* _implicit_exception_table; }; /* @@ -185,6 +192,7 @@ private: DebugInformationRecorder* _debug_recorder; Dependencies* _dependencies; ExceptionHandlerTable _exception_handler_table; + ImplicitExceptionTable _implicit_exception_table; bool _immutable_pic_compilation; // Installer is called for Immutable PIC compilation. diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 52cfa231341..0b862d8d581 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -921,6 +921,14 @@ C2V_VMENTRY_0(jint, getMetadata, (JNIEnv *env, jobject, jobject target, jobject } HotSpotJVMCI::HotSpotMetaData::set_exceptionBytes(JVMCIENV, metadata_handle, exceptionArray); + ImplicitExceptionTable* implicit = code_metadata.get_implicit_exception_table(); + int implicit_table_size = implicit->size_in_bytes(); + JVMCIPrimitiveArray implicitExceptionArray = JVMCIENV->new_byteArray(implicit_table_size, JVMCI_CHECK_(JVMCI::cache_full)); + if (implicit_table_size > 0) { + implicit->copy_bytes_to((address) HotSpotJVMCI::resolve(implicitExceptionArray)->byte_at_addr(0), implicit_table_size); + } + HotSpotJVMCI::HotSpotMetaData::set_implicitExceptionBytes(JVMCIENV, metadata_handle, implicitExceptionArray); + return result; #else JVMCI_THROW_MSG_0(InternalError, "unimplemented"); diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp index 52146707b60..aacac51dffd 100644 --- a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp +++ b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp @@ -334,6 +334,7 @@ primarray_field(HotSpotMetaData, scopesDescBytes, "[B") \ primarray_field(HotSpotMetaData, relocBytes, "[B") \ primarray_field(HotSpotMetaData, exceptionBytes, "[B") \ + primarray_field(HotSpotMetaData, implicitExceptionBytes, "[B") \ primarray_field(HotSpotMetaData, oopMaps, "[B") \ object_field(HotSpotMetaData, metadata, "[Ljava/lang/Object;") \ end_class \ diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 571dc916a48..bcc403412d5 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -1425,6 +1425,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, int frame_words, OopMapSet* oop_map_set, ExceptionHandlerTable* handler_table, + ImplicitExceptionTable* implicit_exception_table, AbstractCompiler* compiler, DebugInformationRecorder* debug_info, Dependencies* dependencies, @@ -1494,7 +1495,6 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, // as in C2, then it must be freed. //code_buffer->free_blob(); } else { - ImplicitExceptionTable implicit_tbl; nm = nmethod::new_nmethod(method, compile_id, entry_bci, @@ -1502,7 +1502,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, orig_pc_offset, debug_info, dependencies, code_buffer, frame_words, oop_map_set, - handler_table, &implicit_tbl, + handler_table, implicit_exception_table, compiler, comp_level, speculations, speculations_len, nmethod_mirror_index, nmethod_mirror_name, failed_speculations); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp index c2c39a4936b..0afbf3b656a 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp @@ -222,6 +222,7 @@ class JVMCIRuntime: public CHeapObj { int frame_words, OopMapSet* oop_map_set, ExceptionHandlerTable* handler_table, + ImplicitExceptionTable* implicit_exception_table, AbstractCompiler* compiler, DebugInformationRecorder* debug_info, Dependencies* dependencies, diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 0c128ea69fc..1660e60cb0a 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -764,18 +764,9 @@ void SharedRuntime::throw_StackOverflowError_common(JavaThread* thread, bool del throw_and_post_jvmti_exception(thread, exception); } -#if INCLUDE_JVMCI -address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason) { - assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason"); - thread->set_jvmci_implicit_exception_pc(pc); - thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret)); - return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); -} -#endif // INCLUDE_JVMCI - address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, address pc, - SharedRuntime::ImplicitExceptionKind exception_kind) + ImplicitExceptionKind exception_kind) { address target_pc = NULL; @@ -876,19 +867,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, #ifndef PRODUCT _implicit_null_throws++; #endif -#if INCLUDE_JVMCI - if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) { - // If there's no PcDesc then we'll die way down inside of - // deopt instead of just getting normal error reporting, - // so only go there if it will succeed. - return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_null_check); - } else { -#endif // INCLUDE_JVMCI - assert (cm->is_nmethod(), "Expect nmethod"); - target_pc = ((nmethod*)cm)->continuation_for_implicit_exception(pc); -#if INCLUDE_JVMCI - } -#endif // INCLUDE_JVMCI + target_pc = cm->continuation_for_implicit_null_exception(pc); // If there's an unexpected fault, target_pc might be NULL, // in which case we want to fall through into the normal // error handling code. @@ -904,15 +883,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, #ifndef PRODUCT _implicit_div0_throws++; #endif -#if INCLUDE_JVMCI - if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) { - return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_div0_check); - } else { -#endif // INCLUDE_JVMCI - target_pc = cm->continuation_for_implicit_exception(pc); -#if INCLUDE_JVMCI - } -#endif // INCLUDE_JVMCI + target_pc = cm->continuation_for_implicit_div0_exception(pc); // If there's an unexpected fault, target_pc might be NULL, // in which case we want to fall through into the normal // error handling code. diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index 9dc1379da23..5979c68911f 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -204,9 +204,6 @@ class SharedRuntime: AllStatic { static address continuation_for_implicit_exception(JavaThread* thread, address faulting_pc, ImplicitExceptionKind exception_kind); -#if INCLUDE_JVMCI - static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason); -#endif // Post-slow-path-allocation, pre-initializing-stores step for // implementing e.g. ReduceInitialCardMarks diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java index 1af7c5699d6..29bda177370 100644 --- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java +++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java @@ -25,16 +25,20 @@ package jdk.tools.jaotc; +import static jdk.tools.jaotc.AOTCompiledClass.getType; +import static jdk.tools.jaotc.AOTCompiledClass.metadataName; + +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import org.graalvm.compiler.code.CompilationResult; +import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; + import jdk.tools.jaotc.binformat.BinaryContainer; import jdk.tools.jaotc.binformat.ByteContainer; import jdk.tools.jaotc.binformat.GotSymbol; import jdk.tools.jaotc.utils.NativeOrderOutputStream; -import org.graalvm.compiler.code.CompilationResult; -import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; - import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.DataPatch; import jdk.vm.ci.code.site.Infopoint; @@ -42,9 +46,6 @@ import jdk.vm.ci.code.site.Mark; import jdk.vm.ci.hotspot.HotSpotCompiledCode; import jdk.vm.ci.hotspot.HotSpotMetaData; -import static jdk.tools.jaotc.AOTCompiledClass.getType; -import static jdk.tools.jaotc.AOTCompiledClass.metadataName; - final class MetadataBuilder { private final DataBuilder dataBuilder; @@ -81,6 +82,12 @@ final class MetadataBuilder { HotSpotGraalRuntimeProvider runtime = dataBuilder.getBackend().getRuntime(); ByteContainer methodMetadataContainer = binaryContainer.getMethodMetadataContainer(); + Method implicitExceptionsMethod = null; + try { + implicitExceptionsMethod = HotSpotMetaData.class.getDeclaredMethod("implicitExceptionBytes"); + } catch (NoSuchMethodException e) { + } + // For each of the compiled java methods, create records holding information about them. for (CompiledMethodInfo methodInfo : compiledClass.getCompiledMethods()) { // Get the current offset in the methodmetadata container. @@ -141,6 +148,11 @@ final class MetadataBuilder { NativeOrderOutputStream.PatchableInt scopeOffset = metadataStream.patchableInt(); NativeOrderOutputStream.PatchableInt relocationOffset = metadataStream.patchableInt(); NativeOrderOutputStream.PatchableInt exceptionOffset = metadataStream.patchableInt(); + NativeOrderOutputStream.PatchableInt implictTableOFfset = null; + + if (implicitExceptionsMethod != null) { + implictTableOFfset = metadataStream.patchableInt(); + } NativeOrderOutputStream.PatchableInt oopMapOffset = metadataStream.patchableInt(); metadataStream.align(8); @@ -156,6 +168,12 @@ final class MetadataBuilder { exceptionOffset.set(metadataStream.position()); metadataStream.put(metaData.exceptionBytes()).align(8); + if (implicitExceptionsMethod != null) { + implictTableOFfset.set(metadataStream.position()); + byte[] data = (byte[]) implicitExceptionsMethod.invoke(metaData); + metadataStream.put(data).align(8); + } + // oopmaps should be last oopMapOffset.set(metadataStream.position()); metadataStream.put(oopMapInfo).align(8); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java index 259cf070840..fc54c41312e 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java @@ -31,6 +31,7 @@ public class HotSpotMetaData { private byte[] scopesDescBytes; private byte[] relocBytes; private byte[] exceptionBytes; + private byte[] implicitExceptionBytes; private byte[] oopMaps; private Object[] metadata; @@ -62,6 +63,10 @@ public class HotSpotMetaData { return exceptionBytes; } + public byte[] implicitExceptionBytes() { + return implicitExceptionBytes; + } + public byte[] oopMaps() { return oopMaps; } From 8c40b77cd826b7d4db0acc4b64729422d7089502 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 7 Jun 2019 12:26:50 -0700 Subject: [PATCH 02/45] 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash Reviewed-by: thartmann, sspitsyn --- src/hotspot/share/code/codeCache.cpp | 4 +- src/hotspot/share/code/codeCache.hpp | 2 +- src/hotspot/share/code/codeHeapState.cpp | 5 ++- src/hotspot/share/code/codeHeapState.hpp | 2 +- src/hotspot/share/compiler/compileBroker.cpp | 2 +- src/hotspot/share/compiler/compileBroker.hpp | 2 +- src/hotspot/share/runtime/java.cpp | 4 +- .../share/services/diagnosticCommand.cpp | 11 ++++- .../share/services/diagnosticCommand.hpp | 2 +- .../compiler/CodeHeapAnalyticsParams.java | 44 +++++++++++++++++++ 10 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index cc8ff62a15b..13dbbaa3319 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -1284,7 +1284,7 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) { if (heap->full_count() == 0) { if (PrintCodeHeapAnalytics) { - CompileBroker::print_heapinfo(tty, "all", "4096"); // details, may be a lot! + CompileBroker::print_heapinfo(tty, "all", 4096); // details, may be a lot! } } } @@ -1571,7 +1571,7 @@ void CodeCache::log_state(outputStream* st) { //---< BEGIN >--- CodeHeap State Analytics. -void CodeCache::aggregate(outputStream *out, const char* granularity) { +void CodeCache::aggregate(outputStream *out, size_t granularity) { FOR_ALL_ALLOCABLE_HEAPS(heap) { CodeHeapState::aggregate(out, (*heap), granularity); } diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp index 1013163c5ba..8baa3651a81 100644 --- a/src/hotspot/share/code/codeCache.hpp +++ b/src/hotspot/share/code/codeCache.hpp @@ -294,7 +294,7 @@ class CodeCache : AllStatic { // CodeHeap State Analytics. // interface methods for CodeHeap printing, called by CompileBroker - static void aggregate(outputStream *out, const char* granularity); + static void aggregate(outputStream *out, size_t granularity); static void discard(outputStream *out); static void print_usedSpace(outputStream *out); static void print_freeSpace(outputStream *out); diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index eebb7ca017f..ca5c439fcde 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -530,7 +530,7 @@ void CodeHeapState::discard(outputStream* out, CodeHeap* heap) { } } -void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* granularity_request) { +void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granularity) { unsigned int nBlocks_free = 0; unsigned int nBlocks_used = 0; unsigned int nBlocks_zomb = 0; @@ -612,7 +612,8 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* gra // Finally, we adjust the granularity such that each granule covers at most 64k-1 segments. // This is necessary to prevent an unsigned short overflow while accumulating space information. // - size_t granularity = strtol(granularity_request, NULL, 0); + assert(granularity > 0, "granularity should be positive."); + if (granularity > size) { granularity = size; } diff --git a/src/hotspot/share/code/codeHeapState.hpp b/src/hotspot/share/code/codeHeapState.hpp index 076d43d34ed..3b314ca587c 100644 --- a/src/hotspot/share/code/codeHeapState.hpp +++ b/src/hotspot/share/code/codeHeapState.hpp @@ -99,7 +99,7 @@ class CodeHeapState : public CHeapObj { public: static void discard(outputStream* out, CodeHeap* heap); - static void aggregate(outputStream* out, CodeHeap* heap, const char* granularity); + static void aggregate(outputStream* out, CodeHeap* heap, size_t granularity); static void print_usedSpace(outputStream* out, CodeHeap* heap); static void print_freeSpace(outputStream* out, CodeHeap* heap); static void print_count(outputStream* out, CodeHeap* heap); diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 799cae6f554..ae8f83acd22 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -2640,7 +2640,7 @@ void CompileBroker::print_info(outputStream *out) { // That's a tradeoff which keeps together important blocks of output. // At the same time, continuous tty_lock hold time is kept in check, // preventing concurrently printing threads from stalling a long time. -void CompileBroker::print_heapinfo(outputStream* out, const char* function, const char* granularity) { +void CompileBroker::print_heapinfo(outputStream* out, const char* function, size_t granularity) { TimeStamp ts_total; TimeStamp ts_global; TimeStamp ts; diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index c3d433ebc66..77e0ceab1e5 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -417,7 +417,7 @@ public: // CodeHeap State Analytics. static void print_info(outputStream *out); - static void print_heapinfo(outputStream *out, const char* function, const char* granularity ); + static void print_heapinfo(outputStream *out, const char* function, size_t granularity); }; #endif // SHARE_COMPILER_COMPILEBROKER_HPP diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index 0f1079eaef3..c24fff99e66 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -310,7 +310,7 @@ void print_statistics() { // CodeHeap State Analytics. // Does also call NMethodSweeper::print(tty) if (PrintCodeHeapAnalytics) { - CompileBroker::print_heapinfo(NULL, "all", "4096"); // details + CompileBroker::print_heapinfo(NULL, "all", 4096); // details } else if (PrintMethodFlushingStatistics) { NMethodSweeper::print(tty); } @@ -378,7 +378,7 @@ void print_statistics() { // CodeHeap State Analytics. // Does also call NMethodSweeper::print(tty) if (PrintCodeHeapAnalytics) { - CompileBroker::print_heapinfo(NULL, "all", "4096"); // details + CompileBroker::print_heapinfo(NULL, "all", 4096); // details } else if (PrintMethodFlushingStatistics) { NMethodSweeper::print(tty); } diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index d460e61bcc9..5f67f59ac84 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -946,13 +946,20 @@ void CodeCacheDCmd::execute(DCmdSource source, TRAPS) { CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"), - _granularity("granularity", "Detail level - smaller value -> more detail", "STRING", false, "4096") { + _granularity("granularity", "Detail level - smaller value -> more detail", "INT", false, "4096") { _dcmdparser.add_dcmd_argument(&_function); _dcmdparser.add_dcmd_argument(&_granularity); } void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) { - CompileBroker::print_heapinfo(output(), _function.value(), _granularity.value()); + jlong granularity = _granularity.value(); + if (granularity < 1) { + Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(), + "Invalid granularity value " JLONG_FORMAT ". Should be positive.\n", granularity); + return; + } + + CompileBroker::print_heapinfo(output(), _function.value(), granularity); } int CodeHeapAnalyticsDCmd::num_arguments() { diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index 2e0356066f4..5ac399268ad 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -645,7 +645,7 @@ public: class CodeHeapAnalyticsDCmd : public DCmdWithParser { protected: DCmdArgument _function; - DCmdArgument _granularity; + DCmdArgument _granularity; public: CodeHeapAnalyticsDCmd(outputStream* output, bool heap); static const char* name() { diff --git a/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java b/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java new file mode 100644 index 00000000000..a4f3c466d25 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java @@ -0,0 +1,44 @@ +/* + * 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. + */ + +import jdk.test.lib.dcmd.PidJcmdExecutor; + +/* + * @test CodeHeapAnalyticsParams + * @key jcmd + * @summary Test the Compiler.CodeHeap_Analytics command + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run driver CodeHeapAnalyticsParams + */ + +public class CodeHeapAnalyticsParams { + + public static void main(String args[]) throws Exception { + PidJcmdExecutor executor = new PidJcmdExecutor(); + executor.execute("Compiler.CodeHeap_Analytics all 1").shouldHaveExitValue(0); + executor.execute("Compiler.CodeHeap_Analytics all 0").shouldHaveExitValue(1); + executor.execute("Compiler.CodeHeap_Analytics all k").shouldHaveExitValue(1); + } +} From 12bb59fb639b7ce43dca265b0a6c6b08be6e5c36 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Fri, 7 Jun 2019 13:57:08 -0700 Subject: [PATCH 03/45] 8225350: compiler/jvmci/compilerToVM/IsCompilableTest.java timed out Reviewed-by: iignatyev --- .../compiler/jvmci/TestJVMCIPrintProperties.java | 4 ++-- .../jvmci/compilerToVM/IsCompilableTest.java | 2 +- .../compilerToVM/MaterializeVirtualObjectTest.java | 12 ++++++------ .../JvmciNotifyBootstrapFinishedEventTest.java | 2 +- .../jvmci/events/JvmciNotifyInstallEventTest.java | 6 +++--- .../runtime/appcds/GraalWithLimitedMetaspace.java | 6 ++++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java index 0751d05cbbf..7709a7f076f 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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,7 +25,7 @@ * @test TestBasicLogOutput * @bug 8203370 * @summary Ensure -XX:-JVMCIPrintProperties can be enabled and successfully prints expected output to stdout. - * @requires vm.jvmci + * @requires vm.jvmci & !vm.graal.enabled & vm.compMode == "Xmixed" * @library /test/lib */ diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java index bff54f2fd83..a6a5ee501c6 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8136421 - * @requires vm.jvmci + * @requires vm.jvmci & vm.compMode == "Xmixed" * @library /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index 6a2b08124c7..1703c186c73 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -25,11 +25,11 @@ * @test * @bug 8136421 * - * @requires vm.jvmci + * @requires vm.jvmci & vm.compMode == "Xmixed" * @requires vm.opt.final.EliminateAllocations == true * * @comment no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved - * @requires vm.compMode != "Xcomp" | vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true + * @requires vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true * * @library / /test/lib * @library ../common/patches @@ -44,7 +44,7 @@ * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. + * @run main/othervm -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check @@ -56,7 +56,7 @@ * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. + * @run main/othervm -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check @@ -68,7 +68,7 @@ * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. + * @run main/othervm -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check @@ -80,7 +80,7 @@ * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. + * @run main/othervm -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java index f3396103384..3dbcf868fc7 100644 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8156034 - * @requires vm.jvmci & !vm.graal.enabled + * @requires vm.jvmci & !vm.graal.enabled & vm.compMode == "Xmixed" * @library / /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyInstallEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyInstallEventTest.java index a94a74927d2..bc5e52eef1d 100644 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyInstallEventTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyInstallEventTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires vm.jvmci & !vm.graal.enabled + * @requires vm.jvmci & !vm.graal.enabled & vm.compMode == "Xmixed" * @library / /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc @@ -47,11 +47,11 @@ * compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult * compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed + * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI * compiler.jvmci.events.JvmciNotifyInstallEventTest * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed + * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI -XX:JVMCINMethodSizeLimit=0 * compiler.jvmci.events.JvmciNotifyInstallEventTest */ diff --git a/test/hotspot/jtreg/runtime/appcds/GraalWithLimitedMetaspace.java b/test/hotspot/jtreg/runtime/appcds/GraalWithLimitedMetaspace.java index 5e956e299d0..ed86a578df7 100644 --- a/test/hotspot/jtreg/runtime/appcds/GraalWithLimitedMetaspace.java +++ b/test/hotspot/jtreg/runtime/appcds/GraalWithLimitedMetaspace.java @@ -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 @@ -26,7 +26,7 @@ * @test * @summary Test dumping with limited metaspace with loading of JVMCI related classes. * VM should not crash but CDS dump will abort upon failure in allocating metaspace. - * @requires vm.cds & vm.graal.enabled + * @requires vm.cds & vm.graal.enabled & vm.compMode == "Xmixed" * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -90,6 +90,8 @@ public class GraalWithLimitedMetaspace { "-XX:DumpLoadedClassList=" + CLASSLIST_FILE, // trigger JVMCI runtime init so that JVMCI classes will be // included in the classlist + "-XX:+UnlockExperimentalVMOptions", + "-XX:+EnableJVMCI", "-XX:+EagerJVMCI", "-cp", TESTJAR, From d0725682a8946531b45fdd0ebb6e7dd1f1c1f958 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 7 Jun 2019 14:03:17 -0700 Subject: [PATCH 04/45] 8224497: Remove FIXME in metaspaceClosure.cpp Also cleaned up some comment and code related to the od (optional data) region. Reviewed-by: iklam, jiangli --- src/hotspot/share/memory/filemap.cpp | 4 +-- src/hotspot/share/memory/metaspaceClosure.cpp | 2 +- src/hotspot/share/memory/metaspaceShared.cpp | 26 +++++++------------ src/hotspot/share/memory/metaspaceShared.hpp | 1 - 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index cc867fe6397..0f923b25e0b 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -1080,7 +1080,7 @@ ReservedSpace FileMapInfo::reserve_shared_memory() { } // Memory map a region in the address space. -static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData", +static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "String1", "String2", "OpenArchive1", "OpenArchive2" }; char* FileMapInfo::map_regions(int regions[], char* saved_base[], size_t len) { @@ -1094,7 +1094,7 @@ char* FileMapInfo::map_regions(int regions[], char* saved_base[], size_t len) { return NULL; } if (i > 0) { - // We require that mc->rw->ro->md->od to be laid out consecutively, with no + // We require that mc->rw->ro->md to be laid out consecutively, with no // gaps between them. That way, we can ensure that the OS won't be able to // allocate any new memory spaces inside _shared_metaspace_{base,top}, which // would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace(). diff --git a/src/hotspot/share/memory/metaspaceClosure.cpp b/src/hotspot/share/memory/metaspaceClosure.cpp index 379871f0b7d..9a72eb4655c 100644 --- a/src/hotspot/share/memory/metaspaceClosure.cpp +++ b/src/hotspot/share/memory/metaspaceClosure.cpp @@ -45,7 +45,7 @@ void MetaspaceClosure::push_impl(MetaspaceClosure::Ref* ref) { } void MetaspaceClosure::do_push(MetaspaceClosure::Ref* ref) { - if (ref->not_null()) { // FIXME: make this configurable, so DynamicArchiveBuilder mark all pointers + if (ref->not_null()) { bool read_only; Writability w = ref->writability(); switch (w) { diff --git a/src/hotspot/share/memory/metaspaceShared.cpp b/src/hotspot/share/memory/metaspaceShared.cpp index 9841c904294..f028781ba01 100644 --- a/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/hotspot/share/memory/metaspaceShared.cpp @@ -90,18 +90,17 @@ void* MetaspaceShared::_shared_metaspace_static_top = NULL; // rw - read-write metadata // ro - read-only metadata and read-only tables // md - misc data (the c++ vtables) -// od - optional data (original class files) // // ca0 - closed archive heap space #0 // ca1 - closed archive heap space #1 (may be empty) // oa0 - open archive heap space #0 // oa1 - open archive heap space #1 (may be empty) // -// The mc, rw, ro, md and od regions are linearly allocated, starting from -// SharedBaseAddress, in the order of mc->rw->ro->md->od. The size of these 5 regions +// The mc, rw, ro, and md regions are linearly allocated, starting from +// SharedBaseAddress, in the order of mc->rw->ro->md. The size of these 4 regions // are page-aligned, and there's no gap between any consecutive regions. // -// These 5 regions are populated in the following steps: +// These 4 regions are populated in the following steps: // [1] All classes are loaded in MetaspaceShared::preload_classes(). All metadata are // temporarily allocated outside of the shared regions. Only the method entry // trampolines are written into the mc region. @@ -110,10 +109,9 @@ void* MetaspaceShared::_shared_metaspace_static_top = NULL; // [4] SymbolTable, StringTable, SystemDictionary, and a few other read-only data // are copied into the ro region as read-only tables. // [5] C++ vtables are copied into the md region. -// [6] Original class files are copied into the od region. // // The s0/s1 and oa0/oa1 regions are populated inside HeapShared::archive_java_heap_objects. -// Their layout is independent of the other 5 regions. +// Their layout is independent of the other 4 regions. char* DumpRegion::expand_top_to(char* newtop) { assert(is_allocatable(), "must be initialized and not packed"); @@ -174,7 +172,7 @@ void DumpRegion::pack(DumpRegion* next) { } } -DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md"), _od_region("od"); +DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md"); size_t _total_closed_archive_region_size = 0, _total_open_archive_region_size = 0; void MetaspaceShared::init_shared_dump_space(DumpRegion* first_space, address first_space_bottom) { @@ -198,10 +196,6 @@ DumpRegion* MetaspaceShared::read_only_dump_space() { return &_ro_region; } -DumpRegion* MetaspaceShared::optional_data_dump_space() { - return &_od_region; -} - void MetaspaceShared::pack_dump_space(DumpRegion* current, DumpRegion* next, ReservedSpace* rs) { current->pack(next); @@ -290,10 +284,10 @@ void MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() { // // +-- SharedBaseAddress (default = 0x800000000) // v - // +-..---------+---------+ ... +----+----+----+----+----+---------------+ - // | Heap | Archive | | MC | RW | RO | MD | OD | class space | - // +-..---------+---------+ ... +----+----+----+----+----+---------------+ - // |<-- MaxHeapSize -->| |<-- UnscaledClassSpaceMax = 4GB ------->| + // +-..---------+---------+ ... +----+----+----+----+---------------+ + // | Heap | Archive | | MC | RW | RO | MD | class space | + // +-..---------+---------+ ... +----+----+----+----+---------------+ + // |<-- MaxHeapSize -->| |<-- UnscaledClassSpaceMax = 4GB -->| // const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1); const size_t cds_total = align_down(UnscaledClassSpaceMax, reserve_alignment); @@ -1074,7 +1068,7 @@ void DumpAllocStats::print_stats(int ro_all, int rw_all, int mc_all, int md_all) LogMessage(cds) msg; - msg.info("Detailed metadata info (excluding od/st regions; rw stats include md/mc regions):"); + msg.info("Detailed metadata info (excluding st regions; rw stats include md/mc regions):"); msg.info("%s", hdr); msg.info("%s", sep); for (int type = 0; type < int(_number_of_types); type ++) { diff --git a/src/hotspot/share/memory/metaspaceShared.hpp b/src/hotspot/share/memory/metaspaceShared.hpp index 733e2dd5715..9f01b169822 100644 --- a/src/hotspot/share/memory/metaspaceShared.hpp +++ b/src/hotspot/share/memory/metaspaceShared.hpp @@ -304,7 +304,6 @@ class MetaspaceShared : AllStatic { static DumpRegion* misc_code_dump_space(); static DumpRegion* read_write_dump_space(); static DumpRegion* read_only_dump_space(); - static DumpRegion* optional_data_dump_space(); static void pack_dump_space(DumpRegion* current, DumpRegion* next, ReservedSpace* rs); From e27ad50eb080d8e370fc04a2a0e668b30c97bd34 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 7 Jun 2019 14:32:48 -0700 Subject: [PATCH 05/45] 8224257: fix issues in files generated by pandoc Reviewed-by: mchung --- .../classes/build/tools/fixuppandoc/Main.java | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/make/jdk/src/classes/build/tools/fixuppandoc/Main.java b/make/jdk/src/classes/build/tools/fixuppandoc/Main.java index df41bbfed46..59d75eeb9e6 100644 --- a/make/jdk/src/classes/build/tools/fixuppandoc/Main.java +++ b/make/jdk/src/classes/build/tools/fixuppandoc/Main.java @@ -44,6 +44,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -63,11 +64,18 @@ import java.util.regex.Pattern; * *

Tables: row headings

* - * {@code scope="row"} is added to the {@code } elements in the first - * column whose cell contents are all different and therefore which can be - * used to identify the row. In case of ambiguity, a column containing - * a {@code } whose contents begin name is preferred. + * For simple tables, as typically generated by _pandoc_, determine the column + * whose contents are unique, and convert the cells in that column to be header + * cells with {@code scope="row"}. In case of ambiguity, a column containing a + * {@code } whose contents begin with name is preferred. + * When converting the cell, the {@code style} attribute will be updated to + * specify {@code font-weight: normal}, and if there is not already an explicit + * setting for {@code text-align}, then the style will be updated to include + * {@code text-align:left;}. * + * These rules do not apply if the table contains any cells that include + * a setting for the {@code scope} attribute, or if the table contains + * spanning cells or nested tables. * *

{@code }

* @@ -533,12 +541,39 @@ public class Main { } index++; } + boolean updateEndTd = false; + Pattern styleAttr = Pattern.compile("(?.*style=\")(?