Mercurial > hg > graal-compiler
changeset 3633:fc07cf6848fb
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 14 Nov 2011 22:34:14 +0100 |
parents | 136ea96eb7f8 (diff) 1ae6a886a45f (current diff) |
children | 076542d505cd |
files | |
diffstat | 7 files changed, 23 insertions(+), 146 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/classfile/vmSymbols.hpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/classfile/vmSymbols.hpp Mon Nov 14 22:34:14 2011 +0100 @@ -323,8 +323,6 @@ template(createRiTypePrimitive_signature, "(I)Lcom/sun/cri/ri/RiType;") \ template(createRiTypeUnresolved_name, "createRiTypeUnresolved") \ template(createRiTypeUnresolved_signature, "(Ljava/lang/String;)Lcom/sun/cri/ri/RiType;") \ - template(createRiConstantPool_name, "createRiConstantPool") \ - template(createRiConstantPool_signature, "(J)Lcom/sun/cri/ri/RiConstantPool;") \ template(createCiConstant_name, "createCiConstant") \ template(createCiConstant_signature, "(Lcom/sun/cri/ci/CiKind;J)Lcom/sun/cri/ci/CiConstant;") \ template(createCiConstantFloat_name, "createCiConstantFloat") \
--- a/src/share/vm/graal/graalCompiler.cpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalCompiler.cpp Mon Nov 14 22:34:14 2011 +0100 @@ -114,7 +114,6 @@ VMExits::compileMethod(hotspot_method, entry_bci); CompilerThread::current()->set_compiling(false); - VmIds::cleanupLocalObjects(); TRACE_graal_2("GraalCompiler::compile_method exit"); }
--- a/src/share/vm/graal/graalVMEntries.cpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalVMEntries.cpp Mon Nov 14 22:34:14 2011 +0100 @@ -76,7 +76,7 @@ } } -// public byte[] RiMethod_code(long vmId); +// public byte[] RiMethod_code(HotSpotResolvedMethod method); JNIEXPORT jbyteArray JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jobject hotspot_method) { TRACE_graal_3("VMEntries::RiMethod_code"); methodHandle method = getMethodFromHotSpotMethod(hotspot_method); @@ -86,7 +86,7 @@ return result; } -// public String RiMethod_signature(long vmId); +// public String RiMethod_signature(HotSpotResolvedMethod method); JNIEXPORT jstring JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1signature(JNIEnv *env, jobject, jobject hotspot_method) { TRACE_graal_3("VMEntries::RiMethod_signature"); VM_ENTRY_MARK @@ -428,16 +428,6 @@ return method->has_compiled_code(); } -// public native boolean RiMethod_compiledCodeSize(HotSpotMethodResolved method); -JNIEXPORT jint JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1compiledCodeSize(JNIEnv *, jobject, jobject hotspot_method) { - TRACE_graal_3("VMEntries::RiMethod_compiledCodeSize"); - nmethod* code = getMethodFromHotSpotMethod(hotspot_method)->code(); - if (code != NULL) { - return code->insts_end() - code->verified_entry_point(); - } - return -1; -} - // public RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass); JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass) { TRACE_graal_3("VMEntries::RiSignature_lookupType"); @@ -489,12 +479,12 @@ return JNIHandles::make_local(THREAD, result); } -// public Object RiConstantPool_lookupConstant(long vmId, int cpi); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jobject, jlong vmId, jint index) { +// public Object RiConstantPool_lookupConstant(HotSpotTypeResolved type, int cpi); +JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jobject, jobject type, jint index) { TRACE_graal_3("VMEntries::RiConstantPool_lookupConstant"); VM_ENTRY_MARK; - constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); + constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); oop result = NULL; constantTag tag = cp->tag_at(index); @@ -537,11 +527,11 @@ } // public RiMethod RiConstantPool_lookupMethod(long vmId, int cpi, byte byteCode); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) { +JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jobject type, jint index, jbyte byteCode) { TRACE_graal_3("VMEntries::RiConstantPool_lookupMethod"); VM_ENTRY_MARK; index = GraalCompiler::to_cp_index_u2(index); - constantPoolHandle cp = VmIds::get<constantPoolOop>(vmId); + constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF); ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder()); @@ -558,18 +548,12 @@ } } -// public RiSignature RiConstantPool_lookupSignature(long vmId, int cpi); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jobject, jlong vmId, jint index) { - fatal("currently unsupported"); - return NULL; -} - // public RiType RiConstantPool_lookupType(long vmId, int cpi); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jlong vmId, jint index) { +JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jobject type, jint index) { TRACE_graal_3("VMEntries::RiConstantPool_lookupType"); VM_ENTRY_MARK; - constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); + constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder()); bool is_accessible = false; @@ -578,11 +562,11 @@ } // public void RiConstantPool_loadReferencedType(long vmId, int cpi); -JNIEXPORT void JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1loadReferencedType(JNIEnv *env, jobject, jlong vmId, jint index, jbyte op) { +JNIEXPORT void JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1loadReferencedType(JNIEnv *env, jobject, jobject type, jint index, jbyte op) { TRACE_graal_3("VMEntries::RiConstantPool_lookupType"); VM_ENTRY_MARK; - - constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); + + constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); int byteCode = (op & 0xFF); if (byteCode != Bytecodes::_checkcast && byteCode != Bytecodes::_instanceof && byteCode != Bytecodes::_new && byteCode != Bytecodes::_anewarray && byteCode != Bytecodes::_multianewarray) { index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index_u2(index)); @@ -602,12 +586,12 @@ } // public RiField RiConstantPool_lookupField(long vmId, int cpi); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) { +JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jobject type, jint index, jbyte byteCode) { TRACE_graal_3("VMEntries::RiConstantPool_lookupField"); VM_ENTRY_MARK; index = GraalCompiler::to_cp_index_u2(index); - constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); + constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder()); ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); @@ -666,16 +650,6 @@ return JNIHandles::make_local(THREAD, field_handle()); } -// public RiConstantPool RiType_constantPool(HotSpotTypeResolved klass); -JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiType_1constantPool(JNIEnv *, jobject, jobject klass) { - TRACE_graal_3("VMEntries::RiType_constantPool"); - VM_ENTRY_MARK; - - assert(JNIHandles::resolve(klass) != NULL, ""); - constantPoolOop constantPool = ((instanceKlass*)java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass))->klass_part())->constants(); - return JNIHandles::make_local(VMExits::createRiConstantPool(VmIds::add<constantPoolOop>(constantPool), THREAD)); -} - // public RiMethod RiType_resolveMethodImpl(HotSpotTypeResolved klass, String name, String signature); JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiType_3resolveMethodImpl(JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature) { TRACE_graal_3("VMEntries::RiType_resolveMethodImpl"); @@ -1083,15 +1057,12 @@ {CC"RiMethod_invocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1invocationCount)}, {CC"RiMethod_exceptionProbability", CC"("RESOLVED_METHOD"I)I", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiMethod_2exceptionProbability)}, {CC"RiMethod_hasCompiledCode", CC"("RESOLVED_METHOD")Z", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1hasCompiledCode)}, - {CC"RiMethod_compiledCodeSize", CC"("RESOLVED_METHOD")I", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1compiledCodeSize)}, {CC"RiSignature_lookupType", CC"("STRING RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiSignature_1lookupType)}, - {CC"RiConstantPool_lookupConstant", CC"("PROXY"I)"OBJECT, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupConstant)}, - {CC"RiConstantPool_lookupMethod", CC"("PROXY"IB)"METHOD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupMethod)}, - {CC"RiConstantPool_lookupSignature", CC"("PROXY"I)"SIGNATURE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupSignature)}, - {CC"RiConstantPool_lookupType", CC"("PROXY"I)"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupType)}, - {CC"RiConstantPool_loadReferencedType", CC"("PROXY"IB)V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1loadReferencedType)}, - {CC"RiConstantPool_lookupField", CC"("PROXY"IB)"FIELD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupField)}, - {CC"RiType_constantPool", CC"("RESOLVED_TYPE")"CONSTANT_POOL, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_1constantPool)}, + {CC"RiConstantPool_lookupConstant", CC"("RESOLVED_TYPE"I)"OBJECT, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupConstant)}, + {CC"RiConstantPool_lookupMethod", CC"("RESOLVED_TYPE"IB)"METHOD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupMethod)}, + {CC"RiConstantPool_lookupType", CC"("RESOLVED_TYPE"I)"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupType)}, + {CC"RiConstantPool_loadReferencedType", CC"("RESOLVED_TYPE"IB)V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1loadReferencedType)}, + {CC"RiConstantPool_lookupField", CC"("RESOLVED_TYPE"IB)"FIELD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiConstantPool_1lookupField)}, {CC"RiType_resolveMethodImpl", CC"("RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_3resolveMethodImpl)}, {CC"RiType_isSubtypeOf", CC"("RESOLVED_TYPE TYPE")Z", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_2isSubtypeOf)}, {CC"RiType_componentType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_1componentType)},
--- a/src/share/vm/graal/graalVMExits.cpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalVMExits.cpp Mon Nov 14 22:34:14 2011 +0100 @@ -225,16 +225,6 @@ return (oop) result.get_jobject(); } -oop VMExits::createRiConstantPool(jlong vmId, TRAPS) { - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_oop(instance()); - args.push_long(vmId); - JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiConstantPool_name(), vmSymbols::createRiConstantPool_signature(), &args, THREAD); - check_pending_exception("Error while calling createRiConstantPool"); - return (oop) result.get_jobject(); -} - oop VMExits::createRiSignature(Handle name, TRAPS) { assert(!name.is_null(), "just checking"); JavaValue result(T_OBJECT);
--- a/src/share/vm/graal/graalVMExits.hpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalVMExits.hpp Mon Nov 14 22:34:14 2011 +0100 @@ -77,9 +77,6 @@ // public abstract RiType createRiTypeUnresolved(String name); static oop createRiTypeUnresolved(Handle name, TRAPS); - // public abstract RiConstantPool createRiConstantPool(long vmId); - static oop createRiConstantPool(jlong vmId, TRAPS); - // public abstract RiType createRiTypePrimitive(int basicType); static oop createRiTypePrimitive(int basicType, TRAPS);
--- a/src/share/vm/graal/graalVmIds.cpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalVmIds.cpp Mon Nov 14 22:34:14 2011 +0100 @@ -28,58 +28,24 @@ // VmIds implementation GrowableArray<address>* VmIds::_stubs = NULL; -GrowableArray<jobject>* VmIds::_localHandles = NULL; void VmIds::initializeObjects() { if (_stubs == NULL) { assert(_localHandles == NULL, "inconsistent state"); _stubs = new (ResourceObj::C_HEAP) GrowableArray<address> (64, true); - _localHandles = new (ResourceObj::C_HEAP) GrowableArray<jobject> (64, true); } assert(_localHandles->length() == 0, "invalid state"); } -void VmIds::cleanupLocalObjects() { - for (int i = 0; i < _localHandles->length(); i++) { - JNIHandles::destroy_global(_localHandles->at(i)); - } - _localHandles->clear(); -} - jlong VmIds::addStub(address stub) { assert(!_stubs->contains(stub), "duplicate stub"); return _stubs->append(stub) | STUB; } -jlong VmIds::add(Handle obj, jlong type) { - assert(!obj.is_null(), "cannot add NULL handle"); - int idx = -1; - for (int i = 0; i < _localHandles->length(); i++) - if (JNIHandles::resolve_non_null(_localHandles->at(i)) == obj()) { - idx = i; - break; - } - if (idx == -1) { - if (JavaThread::current()->thread_state() == _thread_in_vm) { - idx = _localHandles->append(JNIHandles::make_global(obj)); - } else { - VM_ENTRY_MARK; - idx = _localHandles->append(JNIHandles::make_global(obj)); - } - } - return idx | type; -} - address VmIds::getStub(jlong id) { assert((id & TYPE_MASK) == STUB, "wrong id type, STUB expected"); assert((id & ~TYPE_MASK) >= 0 && (id & ~TYPE_MASK) < _stubs->length(), "STUB index out of bounds"); return _stubs->at(id & ~TYPE_MASK); } -oop VmIds::getObject(jlong id) { - assert((id & TYPE_MASK) != STUB, "wrong id type"); - assert((id & ~TYPE_MASK) >= 0 && (id & ~TYPE_MASK) < _localHandles->length(), "index out of bounds"); - return JNIHandles::resolve_non_null(_localHandles->at(id & ~TYPE_MASK)); -} -
--- a/src/share/vm/graal/graalVmIds.hpp Mon Nov 14 18:14:13 2011 +0100 +++ b/src/share/vm/graal/graalVmIds.hpp Mon Nov 14 22:34:14 2011 +0100 @@ -33,7 +33,6 @@ private: static GrowableArray<address>* _stubs; - static GrowableArray<jobject>* _localHandles; static oop getObject(jlong id); @@ -49,28 +48,16 @@ // Initializes the VmIds for a compilation, by creating the arrays static void initializeObjects(); - // Cleans up after a compilation, by deallocating the arrays - static void cleanupLocalObjects(); // Adds a stub address, and returns the corresponding vmId (which is of type STUB) static jlong addStub(address stub); - // Adds an object, and returns the corresponding vmId (with the given type) - static jlong add(Handle obj, jlong type); - - // Adds an object, and returns the corresponding vmId (the type of which is determined by the template parameter) - template <typename T> static jlong add(T obj); - - // Returns the stub address with the given vmId static address getStub(jlong id); + // Returns the stub address with the given vmId taken from a java.lang.Long static address getStub(oop id); - // Returns the object with the given id, the return type is defined by the template parameter (which must correspond to the actual type of the vmId) - template <typename T> static T get(jlong id); - - // Helper function to convert a symbol to a java.lang.String object template <typename T> static T toString(Symbol* symbol, TRAPS); @@ -81,40 +68,6 @@ static jlong getBoxedLong(oop obj); }; - -template <> inline jlong VmIds::add<klassOop>(klassOop obj) { - assert(obj != NULL, "trying to add NULL<klassOop>"); - assert(obj->is_klass(), "trying to add mistyped object"); - return add(Handle(obj), CLASS); -} -template <> inline jlong VmIds::add<constantPoolOop>(constantPoolOop obj) { - assert(obj != NULL, "trying to add NULL<constantPoolOop>"); - assert(obj->is_constantPool(), "trying to add mistyped object"); - return add(Handle(obj), CONSTANT_POOL); -} -template <> inline jlong VmIds::add<oop>(oop obj) { - assert(obj != NULL, "trying to add NULL<oop>"); - assert(obj->is_oop(), "trying to add mistyped object"); - return add(Handle(obj), CONSTANT); -} - - -template <> inline klassOop VmIds::get<klassOop>(jlong id) { - assert((id & TYPE_MASK) == CLASS, "CLASS expected"); - assert(getObject(id)->is_klass(), "klassOop expected"); - return (klassOop)getObject(id); -} -template <> inline constantPoolOop VmIds::get<constantPoolOop>(jlong id) { - assert((id & TYPE_MASK) == CONSTANT_POOL, "CONSTANT_POOL expected"); - assert(getObject(id)->is_constantPool(), "constantPoolOop expected"); - return (constantPoolOop)getObject(id); -} -template <> inline oop VmIds::get<oop>(jlong id) { - assert((id & TYPE_MASK) == CONSTANT, "CONSTANT expected"); - assert(getObject(id)->is_oop(true), "oop expected"); - return (oop)getObject(id); -} - inline address VmIds::getStub(oop obj) { return getStub(getBoxedLong(obj)); } @@ -122,12 +75,15 @@ template <> inline Handle VmIds::toString<Handle>(Symbol* symbol, TRAPS) { return java_lang_String::create_from_symbol(symbol, THREAD); } + template <> inline oop VmIds::toString<oop>(Symbol* symbol, TRAPS) { return toString<Handle>(symbol, THREAD)(); } + template <> inline jstring VmIds::toString<jstring>(Symbol* symbol, TRAPS) { return (jstring)JNIHandles::make_local(toString<oop>(symbol, THREAD)); } + template <> inline jobject VmIds::toString<jobject>(Symbol* symbol, TRAPS) { return JNIHandles::make_local(toString<oop>(symbol, THREAD)); }