# HG changeset patch # User Thomas Wuerthinger # Date 1274212385 -7200 # Node ID e1a275dbc8cd868f7d0de67f2ad2f7045015f7bc # Parent 1ecc8f0aad001159eaa2c6a56b355bbe103733d3 Executing a+b with C1X on HotSpot ;-) ! diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/cpu/x86/vm/c1_Runtime1_x86.cpp --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue May 18 17:43:37 2010 +0200 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue May 18 21:53:05 2010 +0200 @@ -1717,7 +1717,7 @@ __ bind(runtime); NOT_LP64(__ push(rcx);) - __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread); + //__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread); NOT_LP64(__ pop(rcx);) __ bind(done); diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/asm/codeBuffer.cpp --- a/src/share/vm/asm/codeBuffer.cpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/asm/codeBuffer.cpp Tue May 18 21:53:05 2010 +0200 @@ -436,8 +436,9 @@ { // not sure why this is here, but why not... - int alignSize = MAX2((intx) sizeof(jdouble), CodeEntryAlignment); - assert( (dest->_total_start - _insts.start()) % alignSize == 0, "copy must preserve alignment"); + // (tw) disabled assert + // int alignSize = MAX2((intx) sizeof(jdouble), CodeEntryAlignment); + // assert( (dest->_total_start - _insts.start()) % alignSize == 0, "copy must preserve alignment"); } const CodeSection* prev_cs = NULL; diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_Compiler.cpp --- a/src/share/vm/c1x/c1x_Compiler.cpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_Compiler.cpp Tue May 18 21:53:05 2010 +0200 @@ -29,6 +29,8 @@ // Initialization void C1XCompiler::initialize() { + if (_initialized) return; + _initialized = true; TRACE_C1X_1("initialize"); JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment(); @@ -51,7 +53,7 @@ ResourceMark rm; - HandleMark hm; + //HandleMark hm; CompilerThread::current()->set_compiling(true); oop rimethod = get_RiMethod(target); @@ -106,8 +108,23 @@ } oop C1XCompiler::get_RiType(symbolOop klass, klassOop accessingType) { + if (klass == vmSymbols::byte_signature()) { + return VMExits::createRiTypePrimitive((int)T_BYTE); + } else if (klass == vmSymbols::char_signature()) { + return VMExits::createRiTypePrimitive((int)T_CHAR); + } else if (klass == vmSymbols::double_signature()) { + return VMExits::createRiTypePrimitive((int)T_DOUBLE); + } else if (klass == vmSymbols::float_signature()) { + return VMExits::createRiTypePrimitive((int)T_FLOAT); + } else if (klass == vmSymbols::int_signature()) { + return VMExits::createRiTypePrimitive((int)T_INT); + } else if (klass == vmSymbols::long_signature()) { + return VMExits::createRiTypePrimitive((int)T_LONG); + } else if (klass == vmSymbols::bool_signature()) { + return VMExits::createRiTypePrimitive((int)T_BOOLEAN); + } klassOop resolved_type = SystemDictionary::resolve_or_null(klass, accessingType->klass_part()->class_loader(), accessingType->klass_part()->protection_domain(), Thread::current()); - if (resolved_type == NULL) { + if (resolved_type != NULL) { return get_RiType(resolved_type); } else { return get_unresolved_RiType(klass, accessingType); diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_Compiler.hpp --- a/src/share/vm/c1x/c1x_Compiler.hpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_Compiler.hpp Tue May 18 21:53:05 2010 +0200 @@ -24,8 +24,14 @@ class C1XCompiler : public AbstractCompiler { +private: + + boolean _initialized; + public: + C1XCompiler() { _initialized = false; } + virtual const char* name() { return "C1X"; } // Native / OSR not supported diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_VMEntries.cpp --- a/src/share/vm/c1x/c1x_VMEntries.cpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_VMEntries.cpp Tue May 18 21:53:05 2010 +0200 @@ -25,11 +25,11 @@ # include "incls/_precompiled.incl" # include "incls/_c1x_VMEntries.cpp.incl" - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_code -* Signature: (Ljava/lang/Object;)[B + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_code +* Signature: (Ljava/lang/Object;)[B */ JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jclass, jobject method) { methodOop m = (methodOop)JNIHandles::resolve(method); @@ -38,31 +38,31 @@ env->SetByteArrayRegion(result, 0, code_size, (const jbyte *)m->code_base()); return result; } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_maxStackSize -* Signature: (Ljava/lang/Object;)I + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_maxStackSize +* Signature: (Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jclass, jobject method) { methodOop m = (methodOop)JNIHandles::resolve(method); return m->max_stack(); } -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_maxLocals -* Signature: (Ljava/lang/Object;)I +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_maxLocals +* Signature: (Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals(JNIEnv *, jclass, jobject method) { methodOop m = (methodOop)JNIHandles::resolve(method); return m->max_locals(); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_holder -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_holder +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; */ JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jclass, jobject method) { VM_ENTRY_MARK @@ -70,31 +70,31 @@ klassOop k = m->method_holder(); return JNIHandles::make_local(Thread::current(), C1XCompiler::get_RiType(k)); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_signature -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiSignature; + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_signature +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiSignature; */ JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature(JNIEnv *env, jclass, jobject method) { methodOop m = (methodOop)JNIHandles::resolve(method); return env->NewStringUTF(m->signature()->as_utf8()); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiMethod_name -* Signature: (Ljava/lang/Object;)Ljava/lang/String; + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiMethod_name +* Signature: (Ljava/lang/Object;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name(JNIEnv *env, jclass, jobject method) { methodOop m = (methodOop)JNIHandles::resolve(method); return env->NewStringUTF(m->name()->as_utf8()); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiSignature_lookupType -* Signature: (Ljava/lang/String;Lcom/sun/cri/ri/RiType;)Lcom/sun/cri/ri/RiType; + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiSignature_lookupType +* Signature: (Ljava/lang/String;Lcom/sun/cri/ri/RiType;)Lcom/sun/cri/ri/RiType; */ JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *, jclass, jstring name, jobject accessor) { VM_ENTRY_MARK @@ -108,48 +108,48 @@ oop result = C1XCompiler::get_RiType(symbol, k); return JNIHandles::make_local(THREAD, result); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiSignature_symbolToString -* Signature: (Ljava/lang/Object;)Ljava/lang/String; + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiSignature_symbolToString +* Signature: (Ljava/lang/Object;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString(JNIEnv *env, jclass, jobject symbol) { symbolOop s = (symbolOop)JNIHandles::resolve(symbol); return env->NewStringUTF(s->as_utf8()); } - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_javaClass -* Signature: (Ljava/lang/Object;)Ljava/lang/Class; -*/ -JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass(JNIEnv *, jclass, jobject klass) { - klassOop k = (klassOop)JNIHandles::resolve(klass); - oop result = k->klass_part()->java_mirror(); - return (jclass) JNIHandles::make_local(Thread::current(), result); -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_name -* Signature: (Ljava/lang/Object;)Ljava/lang/String; -*/ + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_javaClass +* Signature: (Ljava/lang/Object;)Ljava/lang/Class; +*/ +JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass(JNIEnv *, jclass, jobject klass) { + klassOop k = (klassOop)JNIHandles::resolve(klass); + oop result = k->klass_part()->java_mirror(); + return (jclass) JNIHandles::make_local(Thread::current(), result); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_name +* Signature: (Ljava/lang/Object;)Ljava/lang/String; +*/ JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1name(JNIEnv *env, jclass, jobject klass) { klassOop k = (klassOop)JNIHandles::resolve(klass); - return env->NewStringUTF(k->klass_part()->name()->as_utf8()); -} - - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupConstant -* Signature: (Ljava/lang/Object;I)Ljava/lang/Object; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jclass, jobject cpHandle, jint index) { - - VM_ENTRY_MARK; - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); + return env->NewStringUTF(k->klass_part()->name()->as_utf8()); +} + + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupConstant +* Signature: (Ljava/lang/Object;I)Ljava/lang/Object; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jclass, jobject cpHandle, jint index) { + + VM_ENTRY_MARK; + constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); oop result = NULL; constantTag tag = cp->tag_at(index); @@ -196,117 +196,168 @@ result = VMExits::createCiConstantObject(obj); } else { ShouldNotReachHere(); - } - - return JNIHandles::make_local(THREAD, result); -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupMethod -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jclass, jobject cpHandle, jint index, jbyte byteCode) { - VM_ENTRY_MARK; + } + + return JNIHandles::make_local(THREAD, result); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupMethod +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jclass, jobject cpHandle, jint index, jbyte byteCode) { + VM_ENTRY_MARK; constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); - Bytecodes::Code bc = (Bytecodes::Code)byteCode; + Bytecodes::Code bc = (Bytecodes::Code)(((int)byteCode) & 0xFF); ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); ciMethod *method = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass); - return JNIHandles::make_local(THREAD, C1XCompiler::get_RiMethod(method)); -} - + return JNIHandles::make_local(THREAD, C1XCompiler::get_RiMethod(method)); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupSignature +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jclass, jobject cpHandle, jint index) { + fatal("currently unsupported"); + return NULL; +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupType +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jclass, jobject cpHandle, jint index) { + VM_ENTRY_MARK; + constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); + ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); + bool is_accessible = false; + ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass); + return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass)); + +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupField +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jclass, jobject cpHandle, jint index) { + VM_ENTRY_MARK; + constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); + ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); + ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); + return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field)); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: findRiType +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType(JNIEnv *, jclass, jobject klass) { + VM_ENTRY_MARK; + klassOop o = (klassOop)JNIHandles::resolve(klass); + return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(o)); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiRuntime_getConstantPool +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool(JNIEnv *, jclass, jobject klass) { + VM_ENTRY_MARK; + klassOop o = (klassOop)JNIHandles::resolve(klass); + return JNIHandles::make_local(THREAD, C1XCompiler::get_RiConstantPool(((instanceKlass*)o->klass_part())->constants())); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isArrayClass +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass(JNIEnv *, jclass, jobject klass) { + klassOop o = (klassOop)JNIHandles::resolve(klass); + o->print(); + bool result = o->klass_part()->oop_is_array(); + tty->print_cr("result=%d", (int)result); + return result; +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isInstanceClass +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass(JNIEnv *, jclass, jobject klass) { + klassOop o = (klassOop)JNIHandles::resolve(klass); + return o->klass_part()->oop_is_instanceKlass(); +} + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isInterface +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jclass, jobject klass) { + klassOop o = (klassOop)JNIHandles::resolve(klass); + return o->klass_part()->is_interface(); +} + /* * Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupSignature -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; +* Method: RiMethod_accessFlags +* Signature: (Ljava/lang/Object;)I */ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jclass, jobject cpHandle, jint index) { - fatal("currently unsupported"); - return NULL; -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupType -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jclass, jobject cpHandle, jint index) { - VM_ENTRY_MARK; - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); - ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); - bool is_accessible = false; - ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass); - return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass)); - +JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jclass, jobject method) { + methodOop m = (methodOop)JNIHandles::resolve(method); + return m->access_flags().as_int(); } /* * Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupField -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; +* Method: installCode +* Signature: (Ljava/lang/Object;[BI)V */ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jclass, jobject cpHandle, jint index) { +JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode(JNIEnv *jniEnv, jclass, jobject method, jbyteArray code, jint frameSize) { + + methodOop m = (methodOop)JNIHandles::resolve(method); + jboolean isCopy = false; + jbyte *codeBytes = jniEnv->GetByteArrayElements(code, &isCopy); + // TODO: Check if we need to disallocate? + int codeSize = jniEnv->GetArrayLength(code); VM_ENTRY_MARK; - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); - ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); - ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); - return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field)); + ciEnv *env = CURRENT_ENV; + + env->set_oop_recorder(new OopRecorder(env->arena())); + env->set_debug_info(new DebugInformationRecorder(env->oop_recorder())); + env->set_dependencies(new Dependencies(env)); + ciMethod *ciMethodObject = (ciMethod *)env->get_object(m); + CodeOffsets offsets; + + // TODO: This is a hack.. Produce correct entries. + offsets.set_value(CodeOffsets::Exceptions, 0); + offsets.set_value(CodeOffsets::Deopt, 0); + + CodeBuffer buffer((address)codeBytes, codeSize); + buffer.print(); + CodeSection *inst_section = buffer.insts(); + inst_section->set_end(inst_section->start() + codeSize); + buffer.initialize_oop_recorder(env->oop_recorder()); + OopMapSet oop_map_set; + ExceptionHandlerTable handler_table; + ImplicitExceptionTable inc_table; + { + ThreadToNativeFromVM t((JavaThread*)THREAD); + env->register_method(ciMethodObject, -1, &offsets, 0, &buffer, frameSize, &oop_map_set, &handler_table, &inc_table, NULL, env->comp_level(), false, false); + + } } -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: findRiType -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType(JNIEnv *, jclass, jobject klass) { - VM_ENTRY_MARK; - klassOop o = (klassOop)JNIHandles::resolve(klass); - return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(o)); -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiRuntime_getConstantPool -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool(JNIEnv *, jclass, jobject klass) { - VM_ENTRY_MARK; - klassOop o = (klassOop)JNIHandles::resolve(klass); - return JNIHandles::make_local(THREAD, C1XCompiler::get_RiConstantPool(((instanceKlass*)o->klass_part())->constants())); -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isArrayClass -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass(JNIEnv *, jclass, jobject klass) { - klassOop o = (klassOop)JNIHandles::resolve(klass); - o->print(); - bool result = o->klass_part()->oop_is_array(); - tty->print_cr("result=%d", (int)result); - return result; -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isInstanceClass -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass(JNIEnv *, jclass, jobject klass) { - klassOop o = (klassOop)JNIHandles::resolve(klass); - return o->klass_part()->oop_is_instanceKlass(); -} - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isInterface -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jclass, jobject klass) { - klassOop o = (klassOop)JNIHandles::resolve(klass); - return o->klass_part()->is_interface(); -} JNINativeMethod VMEntries_methods[] = { @@ -327,7 +378,9 @@ {CC"RiRuntime_getConstantPool", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool)}, {CC"RiType_isArrayClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, {CC"RiType_isInstanceClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, - {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)} + {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)}, + {CC"RiMethod_accessFlags", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags)}, + {CC"installCode", CC"(Ljava/lang/Object;[BI)V", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)} }; int VMEntries_methods_count() { diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_VMEntries.hpp --- a/src/share/vm/c1x/c1x_VMEntries.hpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_VMEntries.hpp Tue May 18 21:53:05 2010 +0200 @@ -85,110 +85,128 @@ JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType (JNIEnv *, jclass, jstring, jobject); -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiSignature_symbolToString -* Signature: (Ljava/lang/Object;)Ljava/lang/String; -*/ -JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString -(JNIEnv *, jclass, jobject); +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiSignature_symbolToString +* Signature: (Ljava/lang/Object;)Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_javaClass +* Signature: (Ljava/lang/Object;)Ljava/lang/Class; +*/ +JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_name +* Signature: (Ljava/lang/Object;)Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1name +(JNIEnv *, jclass, jobject); + + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupConstant +* Signature: (Ljava/lang/Object;I)Ljava/lang/Object; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant +(JNIEnv *, jclass, jobject, jint); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupMethod +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod +(JNIEnv *, jclass, jobject, jint, jbyte); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupSignature +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature +(JNIEnv *, jclass, jobject, jint); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupType +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType +(JNIEnv *, jclass, jobject, jint); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiConstantPool_lookupField +* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField +(JNIEnv *, jclass, jobject, jint); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: findRiType +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiRuntime_getConstantPool +* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; +*/ +JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isArrayClass +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isInstanceClass +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass +(JNIEnv *, jclass, jobject); + +/* +* Class: com_sun_hotspot_c1x_VMEntries +* Method: RiType_isInterface +* Signature: (Ljava/lang/Object;)Z +*/ +JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface +(JNIEnv *, jclass, jobject); /* * Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_javaClass -* Signature: (Ljava/lang/Object;)Ljava/lang/Class; +* Method: RiMethod_accessFlags +* Signature: (Ljava/lang/Object;)I */ -JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass +JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags (JNIEnv *, jclass, jobject); /* * Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_name -* Signature: (Ljava/lang/Object;)Ljava/lang/String; -*/ -JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1name -(JNIEnv *, jclass, jobject); - - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupConstant -* Signature: (Ljava/lang/Object;I)Ljava/lang/Object; +* Method: installCode +* Signature: (Ljava/lang/Object;[BI)V */ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant -(JNIEnv *, jclass, jobject, jint); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupMethod -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod -(JNIEnv *, jclass, jobject, jint, jbyte); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupSignature -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature -(JNIEnv *, jclass, jobject, jint); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupType -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType -(JNIEnv *, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode +(JNIEnv *, jclass, jobject, jbyteArray, jint); -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiConstantPool_lookupField -* Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField -(JNIEnv *, jclass, jobject, jint); -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: findRiType -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType -(JNIEnv *, jclass, jobject); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiRuntime_getConstantPool -* Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; -*/ -JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool -(JNIEnv *, jclass, jobject); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isArrayClass -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass -(JNIEnv *, jclass, jobject); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isInstanceClass -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass -(JNIEnv *, jclass, jobject); - -/* -* Class: com_sun_hotspot_c1x_VMEntries -* Method: RiType_isInterface -* Signature: (Ljava/lang/Object;)Z -*/ -JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface -(JNIEnv *, jclass, jobject); extern JNINativeMethod VMEntries_methods[]; int VMEntries_methods_count(); diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_VMExits.cpp --- a/src/share/vm/c1x/c1x_VMExits.cpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.cpp Tue May 18 21:53:05 2010 +0200 @@ -29,17 +29,18 @@ KlassHandle &VMExits::vmExitsKlass() { - if (_vmExitsKlass.is_null()) { + //if (_vmExitsKlass.is_null()) { Handle nullh; _vmExitsKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_VMExits(), SystemDictionary::java_system_loader(), nullh, Thread::current()); if (_vmExitsKlass.is_null()) { fatal("Could not find class com.sun.hotspot.c1x.VMExits"); } - } + //} return _vmExitsKlass; } void VMExits::compileMethod(oop method, int entry_bci) { + assert(method != NULL, "just checking"); JavaValue result(T_VOID); JavaCallArguments args; args.push_oop(method); @@ -48,6 +49,7 @@ } oop VMExits::createRiMethod(methodOop m) { + assert(m != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(m); @@ -59,6 +61,7 @@ } oop VMExits::createRiField(oop field_holder, symbolOop field_name, oop field_type, int index) { + assert(field_holder != NULL && field_name != NULL && field_type != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(field_holder); @@ -70,6 +73,7 @@ } oop VMExits::createRiType(klassOop k) { + assert(k != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(k); @@ -86,6 +90,7 @@ } oop VMExits::createRiTypeUnresolved(symbolOop name, klassOop accessor) { + assert(name != NULL && accessor != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(name); @@ -95,6 +100,7 @@ } oop VMExits::createRiConstantPool(constantPoolOop cp) { + assert(cp != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(cp); @@ -103,6 +109,7 @@ } oop VMExits::createRiSignature(symbolOop symbol) { + assert(symbol != NULL, "just checking"); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(symbol); @@ -150,5 +157,5 @@ JavaCallArguments args; args.push_oop(value); JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantObject_signature(), &args, Thread::current()); - return (oop)result.get_jobject(); -} + return (oop)result.get_jobject(); +} diff -r 1ecc8f0aad00 -r e1a275dbc8cd src/share/vm/c1x/c1x_VMExits.hpp --- a/src/share/vm/c1x/c1x_VMExits.hpp Tue May 18 17:43:37 2010 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.hpp Tue May 18 21:53:05 2010 +0200 @@ -1,47 +1,47 @@ -/* - * Copyright 2000-2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -class VMExits : public AllStatic { - -private: - - static KlassHandle _vmExitsKlass; - -public: - - static KlassHandle& vmExitsKlass(); - static void compileMethod(oop method, int entry_bci); - static oop createRiMethod(methodOop m); - static oop createRiField(oop field_holder, symbolOop field_name, oop field_type, int index); - static oop createRiType(klassOop k); - static oop createRiConstantPool(constantPoolOop cp); - static oop createRiTypeUnresolved(symbolOop name, klassOop accessor); - static oop createRiSignature(symbolOop name); +/* + * Copyright 2000-2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +class VMExits : public AllStatic { + +private: + + static KlassHandle _vmExitsKlass; + +public: + + static KlassHandle& vmExitsKlass(); + static void compileMethod(oop method, int entry_bci); + static oop createRiMethod(methodOop m); + static oop createRiField(oop field_holder, symbolOop field_name, oop field_type, int index); + static oop createRiType(klassOop k); + static oop createRiConstantPool(constantPoolOop cp); + static oop createRiTypeUnresolved(symbolOop name, klassOop accessor); + static oop createRiSignature(symbolOop name); static oop createCiConstantInt(jint value); static oop createCiConstantLong(jlong value); static oop createCiConstantFloat(jfloat value); static oop createCiConstantDouble(jdouble value); - static oop createCiConstantObject(oop value); - static oop createRiTypePrimitive(int basic_type); + static oop createCiConstantObject(oop value); + static oop createRiTypePrimitive(int basic_type); }; \ No newline at end of file