# HG changeset patch # User Doug Simon # Date 1443773636 -7200 # Node ID 939d5da65929eaaa5f7c752875b82e8f7389254d # Parent 5cd42bb63fad02139f1b1983f607d4348afe019b reduced delta against jvmci-9 diff -r 5cd42bb63fad -r 939d5da65929 jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Fri Oct 02 10:12:01 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Fri Oct 02 10:13:56 2015 +0200 @@ -76,6 +76,9 @@ if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) { features.add(AMD64.CPUFeature.LZCNT); } + if ((config.x86CPUFeatures & config.cpuERMS) != 0) { + features.add(AMD64.CPUFeature.ERMS); + } if ((config.x86CPUFeatures & config.cpuAVX) != 0) { features.add(AMD64.CPUFeature.AVX); } @@ -85,8 +88,8 @@ if ((config.x86CPUFeatures & config.cpuAES) != 0) { features.add(AMD64.CPUFeature.AES); } - if ((config.x86CPUFeatures & config.cpuERMS) != 0) { - features.add(AMD64.CPUFeature.ERMS); + if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) { + features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); } if ((config.x86CPUFeatures & config.cpuBMI1) != 0) { features.add(AMD64.CPUFeature.BMI1); diff -r 5cd42bb63fad -r 939d5da65929 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Fri Oct 02 10:12:01 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Fri Oct 02 10:13:56 2015 +0200 @@ -49,7 +49,7 @@ /** * Initializes the native part of the JVMCI runtime. */ - private static native void init(); + private static native void registerNatives(); static { initialize(); @@ -57,8 +57,8 @@ @SuppressWarnings("try") private static void initialize() { - try (InitTimer t = timer("CompilerToVMImpl.init")) { - init(); + try (InitTimer t = timer("CompilerToVM.registerNatives")) { + registerNatives(); } } @@ -523,15 +523,18 @@ native boolean shouldDebugNonSafepoints(); /** - * Writes {@code length} bytes from {@code buf} starting at offset {@code offset} to the - * HotSpot's log stream. No range checking is performed. + * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the + * HotSpot's log stream. + * + * @exception NullPointerException if {@code bytes == null} + * @exception IndexOutOfBoundsException if copying would cause access of data outside array + * bounds */ native void writeDebugOutput(byte[] bytes, int offset, int length); /** * Flush HotSpot's log stream. */ - native void flushDebugOutput(); /** diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciCodeInstaller.cpp --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Fri Oct 02 10:13:56 2015 +0200 @@ -384,7 +384,7 @@ } // constructor used to create a method -JVMCIEnv::CodeInstallResult CodeInstaller::install(Handle target, Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log) { +JVMCIEnv::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, Handle target, Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log) { CodeBuffer buffer("JVMCI Compiler CodeBuffer"); jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); initialize_dependencies(JNIHandles::resolve(compiled_code_obj)); @@ -425,7 +425,7 @@ } result = JVMCIEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, - JVMCICompiler::instance(), _debug_recorder, _dependencies, env, id, + compiler, _debug_recorder, _dependencies, env, id, has_unsafe_access, _has_wide_vector, installed_code, compiled_code, speculation_log); cb = nm; } diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciCodeInstaller.hpp --- a/src/share/vm/jvmci/jvmciCodeInstaller.hpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.hpp Fri Oct 02 10:13:56 2015 +0200 @@ -24,6 +24,7 @@ #ifndef SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP #define SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP +#include "jvmci/jvmciCompiler.hpp" #include "jvmci/jvmciEnv.hpp" /* @@ -114,7 +115,7 @@ public: CodeInstaller() : _arena(mtCompiler) {} - JVMCIEnv::CodeInstallResult install(Handle target, Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log); + JVMCIEnv::CodeInstallResult install(JVMCICompiler* compiler, Handle target, Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log); static address runtime_call_target_address(oop runtime_call); static VMReg get_hotspot_reg(jint jvmciRegisterNumber); diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciCompiler.hpp --- a/src/share/vm/jvmci/jvmciCompiler.hpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCompiler.hpp Fri Oct 02 10:13:56 2015 +0200 @@ -50,7 +50,7 @@ JVMCICompiler(); - static JVMCICompiler* instance() { return _instance; } + static JVMCICompiler* instance(TRAPS) { return _instance; } virtual const char* name() { return "JVMCI"; } diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Oct 02 10:13:56 2015 +0200 @@ -22,13 +22,17 @@ */ #include "precompiled.hpp" +#include "code/codeCache.hpp" #include "code/scopeDesc.hpp" +#include "interpreter/linkResolver.hpp" #include "memory/oopFactory.hpp" #include "oops/generateOopMap.hpp" #include "oops/fieldStreams.hpp" +#include "oops/oop.inline.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/javaCalls.hpp" #include "jvmci/jvmciRuntime.hpp" +#include "compiler/abstractCompiler.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerOracle.hpp" #include "compiler/disassembler.hpp" @@ -586,9 +590,11 @@ Handle installed_code_handle = JNIHandles::resolve(installed_code); Handle speculation_log_handle = JNIHandles::resolve(speculation_log); + JVMCICompiler* compiler = JVMCICompiler::instance(CHECK_(JNI_ERR)); + TraceTime install_time("installCode", JVMCICompiler::codeInstallTimer()); CodeInstaller installer; - JVMCIEnv::CodeInstallResult result = installer.install(target_handle, compiled_code_handle, cb, installed_code_handle, speculation_log_handle); + JVMCIEnv::CodeInstallResult result = installer.install(compiler, target_handle, compiled_code_handle, cb, installed_code_handle, speculation_log_handle); if (PrintCodeCacheOnCompilation) { stringStream s; @@ -631,7 +637,8 @@ C2V_END C2V_VMENTRY(void, notifyCompilationStatistics, (JNIEnv *jniEnv, jobject, jint id, jobject hotspot_method, jboolean osr, jint processedBytecodes, jlong time, jlong timeUnitsPerSecond, jobject installed_code)) - CompilerStatistics* stats = JVMCICompiler::instance()->stats(); + JVMCICompiler* compiler = JVMCICompiler::instance(CHECK); + CompilerStatistics* stats = compiler->stats(); elapsedTimer timer = elapsedTimer(time, timeUnitsPerSecond); if (osr) { @@ -654,7 +661,8 @@ C2V_END C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject)) - CompilerStatistics* stats = JVMCICompiler::instance()->stats(); + JVMCICompiler* compiler = JVMCICompiler::instance(CHECK); + CompilerStatistics* stats = compiler->stats(); stats->_standard.reset(); stats->_osr.reset(); C2V_END @@ -936,10 +944,10 @@ initialSkip --; } else { GrowableArray* objects = cvf->scope()->objects(); - bool reallocated = false; + bool realloc_failures = false; if (objects != NULL) { - reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); - Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, reallocated, false); + realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); + Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, realloc_failures, false); GrowableArray* local_values = cvf->scope()->locals(); typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread); @@ -1104,8 +1112,8 @@ return; } - bool reallocated = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, THREAD); - Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, reallocated, false); + bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, THREAD); + Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false); for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) { compiledVFrame* cvf = virtualFrames->at(frame_index); @@ -1140,8 +1148,21 @@ C2V_END C2V_VMENTRY(void, writeDebugOutput, (JNIEnv*, jobject, jbyteArray bytes, jint offset, jint length)) + if (bytes == NULL) { + THROW(vmSymbols::java_lang_NullPointerException()); + } + typeArrayOop array = (typeArrayOop) JNIHandles::resolve(bytes); + + // Check if offset and length are non negative. + if (offset < 0 || length < 0) { + THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); + } + // Check if the range is valid. + if ((((unsigned int) length + (unsigned int) offset) > (unsigned int) array->length())) { + THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); + } while (length > 0) { - jbyte* start = ((typeArrayOop) JNIHandles::resolve(bytes))->byte_at_addr(offset); + jbyte* start = array->byte_at_addr(offset); tty->write((char*) start, MIN2(length, O_BUFLEN)); length -= O_BUFLEN; offset += O_BUFLEN; diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Fri Oct 02 10:13:56 2015 +0200 @@ -55,39 +55,7 @@ bool JVMCIRuntime::_shutdown_called = false; static const char* OPTION_PREFIX = "jvmci.option."; -static const int OPTION_PREFIX_LEN = (int)strlen(OPTION_PREFIX); - -void JVMCIRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { -#ifdef _LP64 -#ifndef TARGET_ARCH_sparc - uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); - uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; - guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"); -#endif // TARGET_ARCH_sparc -#else - fatal("check TLAB allocation code for address space conflicts"); -#endif - - ensure_jvmci_class_loader_is_initialized(); - - JavaThread* THREAD = JavaThread::current(); - { - ThreadToNativeFromVM trans(THREAD); - - ResourceMark rm; - HandleMark hm; - - jvmci_compute_offsets(); - - // Ensure _non_oop_bits is initialized - Universe::non_oop_word(); - - env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count()); - } - if (HAS_PENDING_EXCEPTION) { - abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives"); - } -} +static const size_t OPTION_PREFIX_LEN = strlen(OPTION_PREFIX); BasicType JVMCIRuntime::kindToBasicType(jchar ch) { switch(ch) { @@ -781,7 +749,7 @@ assert(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass() != NULL, "must be loaded"); assert(SystemDictionary::HotSpotConstantPool_klass() != NULL, "must be loaded"); assert(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass() != NULL, "must be loaded"); - + for (int i = 0; i < allContexts->length(); i++) { oop ref = allContexts->obj_at(i); if (ref != NULL) { @@ -821,9 +789,36 @@ } } -// private static void CompilerToVM.init() -JVM_ENTRY(void, JVM_InitializeJVMCINatives(JNIEnv *env, jclass c2vmClass)) - JVMCIRuntime::initialize_natives(env, c2vmClass); +// private static void CompilerToVM.registerNatives() +JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass)) +#ifdef _LP64 +#ifndef TARGET_ARCH_sparc + uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); + uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; + guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"); +#endif // TARGET_ARCH_sparc +#else + fatal("check TLAB allocation code for address space conflicts"); +#endif + + JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); + + { + ThreadToNativeFromVM trans(thread); + + ResourceMark rm; + HandleMark hm; + + jvmci_compute_offsets(); + + // Ensure _non_oop_bits is initialized + Universe::non_oop_word(); + + env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count()); + } + if (HAS_PENDING_EXCEPTION) { + JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives"); + } JVM_END void JVMCIRuntime::ensure_jvmci_class_loader_is_initialized() { diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/jvmci/jvmciRuntime.hpp --- a/src/share/vm/jvmci/jvmciRuntime.hpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.hpp Fri Oct 02 10:13:56 2015 +0200 @@ -100,8 +100,6 @@ */ static void ensure_jvmci_class_loader_is_initialized(); - static void initialize_natives(JNIEnv *env, jclass c2vmClass); - static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; } /** diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/prims/jni.cpp Fri Oct 02 10:13:56 2015 +0200 @@ -5212,7 +5212,9 @@ #ifdef COMPILERJVMCI // JVMCI is initialized on a CompilerThread if (BootstrapJVMCI) { - JVMCICompiler::instance()->bootstrap(); + JavaThread* THREAD = thread; + JVMCICompiler* compiler = JVMCICompiler::instance(CATCH); + compiler->bootstrap(); } #endif diff -r 5cd42bb63fad -r 939d5da65929 src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Fri Oct 02 10:12:01 2015 +0200 +++ b/src/share/vm/prims/nativeLookup.cpp Fri Oct 02 10:13:56 2015 +0200 @@ -128,7 +128,7 @@ void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass); #if INCLUDE_JVMCI void JNICALL JVM_InitJVMCIClassLoader(JNIEnv *env, jclass c, jobject loader); - void JNICALL JVM_InitializeJVMCINatives(JNIEnv *env, jclass compilerToVMClass); + void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass); jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); jobject JNICALL JVM_GetJVMCIServiceImpls(JNIEnv *env, jclass c, jclass serviceClass); #endif @@ -146,7 +146,7 @@ { CC"Java_jdk_internal_jvmci_service_JVMCIClassLoaderFactory_init", NULL, FN_PTR(JVM_InitJVMCIClassLoader) }, { CC"Java_jdk_internal_jvmci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, { CC"Java_jdk_internal_jvmci_service_Services_getServiceImpls", NULL, FN_PTR(JVM_GetJVMCIServiceImpls) }, - { CC"Java_jdk_internal_jvmci_hotspot_CompilerToVM_init", NULL, FN_PTR(JVM_InitializeJVMCINatives) }, + { CC"Java_jdk_internal_jvmci_hotspot_CompilerToVM_registerNatives", NULL, FN_PTR(JVM_RegisterJVMCINatives) }, #endif };