# HG changeset patch # User Tom Rodriguez # Date 1441350388 25200 # Node ID 0915f5bfdfaaa9d3b040fb4a1ba9e5db8276c34d # Parent de39d937276519da1783ca94dfc2ec2b62257adf Adopt some jvmci-9 source changes diff -r de39d9372765 -r 0915f5bfdfaa jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java Fri Sep 04 00:06:13 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java Fri Sep 04 00:06:28 2015 -0700 @@ -206,6 +206,10 @@ sectionSize = position; } + public boolean isFinalized() { + return finalLayout; + } + /** * Get the size of the data section. Can only be called after {@link #finalizeLayout}. */ diff -r de39d9372765 -r 0915f5bfdfaa jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java Fri Sep 04 00:06:13 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java Fri Sep 04 00:06:28 2015 -0700 @@ -188,4 +188,29 @@ } return registers; } + + /** + * Subtract sets of registers (x - y). + * + * @param x a set of register to subtract from. + * @param y a set of registers to subtract. + * @return resulting set of registers (x - y). + */ + public static Value[] subtractRegisters(Value[] x, Value[] y) { + ArrayList result = new ArrayList<>(x.length); + for (Value i : x) { + boolean append = true; + for (Value j : y) { + if (ValueUtil.sameRegister(i, j)) { + append = false; + break; + } + } + if (append) { + result.add(i); + } + } + Value[] resultArray = new Value[result.size()]; + return result.toArray(resultArray); + } } diff -r de39d9372765 -r 0915f5bfdfaa jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java Fri Sep 04 00:06:13 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java Fri Sep 04 00:06:28 2015 -0700 @@ -427,22 +427,11 @@ * @param index constant pool index * @return klass reference index */ - private int getUncachedKlassRefIndexAt(int index, JVM_CONSTANT tag) { - int resultIndex; - if (tag == JVM_CONSTANT.MethodRef || tag == JVM_CONSTANT.Fieldref || tag == JVM_CONSTANT.InterfaceMethodref) { - assertTagIsFieldOrMethod(index); - final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - // klass ref index is in the low 16-bits. - resultIndex = refIndex & 0xFFFF; - } else { - resultIndex = index; - } - - // Read the tag only once because it could change between multiple reads. - final JVM_CONSTANT klassTag = getTagAt(resultIndex); - assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; - - return resultIndex; + private int getUncachedKlassRefIndexAt(int index) { + assertTagIsFieldOrMethod(index); + final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + // klass ref index is in the low 16-bits. + return refIndex & 0xFFFF; } /** @@ -627,6 +616,7 @@ } @Override + @SuppressWarnings("fallthrough") public void loadReferencedType(int cpi, int opcode) { int index; switch (opcode) { @@ -672,10 +662,14 @@ case MethodRef: case Fieldref: case InterfaceMethodref: + index = getUncachedKlassRefIndexAt(index); + // Read the tag only once because it could change between multiple reads. + final JVM_CONSTANT klassTag = getTagAt(index); + assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; + // fall through case Class: case UnresolvedClass: case UnresolvedClassInError: - index = getUncachedKlassRefIndexAt(index, tag); final HotSpotResolvedObjectTypeImpl type = runtime().getCompilerToVM().resolveTypeInPool(this, index); Class klass = type.mirror(); if (!klass.isPrimitive() && !klass.isArray()) { diff -r de39d9372765 -r 0915f5bfdfaa jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstant.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstant.java Fri Sep 04 00:06:13 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstant.java Fri Sep 04 00:06:28 2015 -0700 @@ -33,5 +33,7 @@ HotSpotResolvedObjectType asResolvedJavaType(); + HotSpotResolvedJavaMethod asResolvedJavaMethod(); + long rawValue(); } diff -r de39d9372765 -r 0915f5bfdfaa jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstantImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstantImpl.java Fri Sep 04 00:06:13 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaspaceConstantImpl.java Fri Sep 04 00:06:28 2015 -0700 @@ -86,6 +86,13 @@ return null; } + public HotSpotResolvedJavaMethod asResolvedJavaMethod() { + if (metaspaceObject instanceof HotSpotResolvedJavaMethod) { + return (HotSpotResolvedJavaMethod) metaspaceObject; + } + return null; + } + public long rawValue() { return asLong(); } diff -r de39d9372765 -r 0915f5bfdfaa src/share/vm/jvmci/jvmciEnv.cpp --- a/src/share/vm/jvmci/jvmciEnv.cpp Fri Sep 04 00:06:13 2015 -0700 +++ b/src/share/vm/jvmci/jvmciEnv.cpp Fri Sep 04 00:06:28 2015 -0700 @@ -27,6 +27,7 @@ #include "classfile/javaAssertions.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" +#include "code/codeCache.hpp" #include "code/scopeDesc.hpp" #include "runtime/sweeper.hpp" #include "compiler/compileBroker.hpp" @@ -38,6 +39,7 @@ #include "memory/universe.inline.hpp" #include "oops/methodData.hpp" #include "oops/objArrayKlass.hpp" +#include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/init.hpp" #include "runtime/reflection.hpp" @@ -180,25 +182,7 @@ KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); Symbol* klass_name = NULL; if (klass.is_null()) { - // The klass has not been inserted into the constant pool. - // Try to look it up by name. - { - // We have to lock the cpool to keep the oop from being resolved - // while we are accessing it. - MonitorLockerEx ml(cpool->lock()); - - constantTag tag = cpool->tag_at(index); - if (tag.is_klass()) { - // The klass has been inserted into the constant pool - // very recently. - klass = KlassHandle(THREAD, cpool->resolved_klass_at(index)); - } else if (tag.is_symbol()) { - klass_name = cpool->symbol_at(index); - } else { - assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag"); - klass_name = cpool->unresolved_klass_at(index); - } - } + klass_name = cpool->klass_name_at(index); } if (klass.is_null()) { @@ -538,7 +522,6 @@ // Free codeBlobs //code_buffer->free_blob(); - if (nm == NULL) { // The CodeCache is full. Print out warning and disable compilation. { diff -r de39d9372765 -r 0915f5bfdfaa src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Fri Sep 04 00:06:13 2015 -0700 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Fri Sep 04 00:06:28 2015 -0700 @@ -23,6 +23,7 @@ #include "precompiled.hpp" #include "asm/codeBuffer.hpp" +#include "code/codeCache.hpp" #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" #include "jvmci/jvmciRuntime.hpp" @@ -31,10 +32,12 @@ #include "jvmci/jvmciJavaAccess.hpp" #include "jvmci/jvmciEnv.hpp" #include "memory/oopFactory.hpp" +#include "oops/oop.inline.hpp" #include "prims/jvm.h" #include "runtime/biasedLocking.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/reflection.hpp" +#include "runtime/sharedRuntime.hpp" #include "utilities/debug.hpp" #include "utilities/defaultStream.hpp" @@ -49,10 +52,13 @@ bool JVMCIRuntime::_shutdown_called = false; void JVMCIRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { +#ifdef _LP64 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; - AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); - NOT_LP64(error("check TLAB allocation code for address space conflicts")); + guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"); +#else + fatal("check TLAB allocation code for address space conflicts"); +#endif ensure_jvmci_class_loader_is_initialized(); @@ -252,7 +258,7 @@ Handle exception(thread, ex); nm = CodeCache::find_nmethod(pc); - assert(nm != NULL, "this is not an nmethod"); + assert(nm != NULL, "this is not a compiled method"); // Adjust the pc as needed/ if (nm->is_deopt_pc(pc)) { RegisterMap map(thread, false); @@ -378,7 +384,7 @@ } // Back in JAVA, use no oops DON'T safepoint - // Now check to see if the nmethod we were called from is now deoptimized. + // Now check to see if the compiled method we were called from is now deoptimized. // If so we must return to the deopt blob and deoptimize the nmethod if (nm != NULL && caller_is_deopted()) { continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); @@ -531,12 +537,15 @@ return exception; JRT_END +PRAGMA_DIAG_PUSH +PRAGMA_FORMAT_NONLITERAL_IGNORED JRT_LEAF(void, JVMCIRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) ResourceMark rm; assert(format != NULL && java_lang_String::is_instance(format), "must be"); char *buf = java_lang_String::as_utf8_string(format); - tty->print(buf, v1, v2, v3); + tty->print((const char*)buf, v1, v2, v3); JRT_END +PRAGMA_DIAG_POP static void decipher(jlong v, bool ignoreZero) { if (v != 0 || !ignoreZero) { @@ -560,9 +569,11 @@ } } +PRAGMA_DIAG_PUSH +PRAGMA_FORMAT_NONLITERAL_IGNORED JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) ResourceMark rm; - char *buf = (char*) (address) format; + const char *buf = (const char*) (address) format; if (vmError) { if (buf != NULL) { fatal(err_msg(buf, v1, v2, v3)); @@ -577,6 +588,7 @@ decipher(v1, false); } JRT_END +PRAGMA_DIAG_POP JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) union {