changeset 1413:1ecc8f0aad00

Draft implementation of HotSpot CRI / first method compiling without exception.
author Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
date Tue, 18 May 2010 17:43:37 +0200
parents 9195b99c841b
children e1a275dbc8cd
files src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_Compiler.hpp src/share/vm/c1x/c1x_VMEntries.cpp src/share/vm/c1x/c1x_VMEntries.hpp src/share/vm/c1x/c1x_VMExits.cpp src/share/vm/c1x/c1x_VMExits.hpp src/share/vm/ci/ciEnv.hpp src/share/vm/ci/ciSymbol.hpp src/share/vm/classfile/vmSymbols.hpp src/share/vm/compiler/compileBroker.cpp src/share/vm/includeDB_compiler1
diffstat 11 files changed, 652 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Tue May 18 17:43:37 2010 +0200
@@ -34,6 +34,12 @@
   JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment();
   jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntries");
   env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() );
+  
+  if (Thread::current()->has_pending_exception()) {
+
+    Thread::current()->pending_exception()->print();
+    fatal("Could not register natives");
+  }
 }
 
 // Compilation entry point for methods
@@ -48,7 +54,7 @@
 	HandleMark hm;
 
   CompilerThread::current()->set_compiling(true);
-  oop rimethod = get_rimethod(target);
+  oop rimethod = get_RiMethod(target);
   VMExits::compileMethod(rimethod, entry_bci);
 	CompilerThread::current()->set_compiling(false);
 }
@@ -58,8 +64,57 @@
 	TRACE_C1X_1("print_timers");
 }
 
-oop C1XCompiler::get_rimethod(ciMethod *method) {
+oop C1XCompiler::get_RiMethod(ciMethod *method) {
   methodOop m = (methodOop)method->get_oop();
+  return get_RiMethod(m);
+}
+
+oop C1XCompiler::get_RiField(ciField *field) {
+  oop field_holder = get_RiType(field->holder());
+  oop field_type = get_RiType(field->type());
+  symbolOop field_name = field->name()->get_symbolOop();
+  int offset = field->offset();
+
+  // TODO: implement caching
+  return VMExits::createRiField(field_holder, field_name, field_type, offset);
+}
+
+oop C1XCompiler::get_RiMethod(methodOop m) {
   // TODO: implement caching
   return VMExits::createRiMethod(m);
-}
\ No newline at end of file
+}
+
+oop C1XCompiler::get_RiType(ciType *type) {
+  if (type->is_loaded()) {
+    if (type->is_primitive_type()) {
+      return VMExits::createRiTypePrimitive((int)type->basic_type());
+    }
+    return get_RiType((klassOop)type->get_oop());
+  } else {
+    return get_unresolved_RiType(((ciKlass *)type)->name()->get_symbolOop(), NULL);
+  }
+}
+
+oop C1XCompiler::get_RiType(klassOop klass) {
+  // TODO: implement caching
+  return VMExits::createRiType(klass);
+}
+
+oop C1XCompiler::get_RiConstantPool(constantPoolOop cp) {
+  // TODO: implement caching
+  return VMExits::createRiConstantPool(cp);
+}
+
+oop C1XCompiler::get_RiType(symbolOop klass, klassOop accessingType) {
+  klassOop resolved_type = SystemDictionary::resolve_or_null(klass, accessingType->klass_part()->class_loader(), accessingType->klass_part()->protection_domain(), Thread::current());
+  if (resolved_type == NULL) {
+    return get_RiType(resolved_type);
+  } else {
+    return get_unresolved_RiType(klass, accessingType);
+  }
+}
+
+oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType)  {
+  // TODO: implement caching
+  return VMExits::createRiTypeUnresolved(klass, accessingType);
+}
--- a/src/share/vm/c1x/c1x_Compiler.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_Compiler.hpp	Tue May 18 17:43:37 2010 +0200
@@ -45,7 +45,14 @@
 	// Print compilation timers and statistics
 	virtual void print_timers();
 
-  static oop get_rimethod(ciMethod *ciMethod);
+  static oop get_RiMethod(ciMethod *ciMethod);
+  static oop get_RiField(ciField *ciField);
+  static oop get_RiType(ciType *klass);
+  static oop get_RiType(klassOop klass);
+  static oop get_RiMethod(methodOop method);
+  static oop get_RiType(symbolOop klass, klassOop accessingType);
+  static oop get_unresolved_RiType(symbolOop klass, klassOop accessingType);
+  static oop get_RiConstantPool(constantPoolOop cpOop);
 };
 
 
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Tue May 18 17:43:37 2010 +0200
@@ -25,16 +25,309 @@
 
 # include "incls/_precompiled.incl"
 # include "incls/_c1x_VMEntries.cpp.incl"
+
+/*
+* 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);
+  int code_size = m->code_size();
+  jbyteArray result = env->NewByteArray(code_size);
+  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
+*/
+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();
+}
 
-JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code
-(JNIEnv *, jclass, jobject) {
-  tty->print_cr("hello world");
-  return NULL;
+/*
+* 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;
+*/
+JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jclass, jobject method) {
+  VM_ENTRY_MARK
+  methodOop m = (methodOop)JNIHandles::resolve(method);
+  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;
+*/
+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;
+*/
+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;
+*/
+JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *, jclass, jstring name, jobject accessor) {
+  VM_ENTRY_MARK
+  klassOop k = (klassOop)JNIHandles::resolve(accessor);
+  oop n = JNIHandles::resolve_external_guard(name);
+  if (n == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "Name must not be null.", NULL);
+  }
+  char* utf8 = java_lang_String::as_utf8_string(n);
+  symbolOop symbol = oopFactory::new_symbol(utf8, java_lang_String::length(n), THREAD);
+  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;
+*/
+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;
+*/
+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);
+
+  oop result = NULL;
+  constantTag tag = cp->tag_at(index);
+  if (tag.is_int()) {
+    result = VMExits::createCiConstantInt(cp->int_at(index));
+  } else if (tag.is_long()) {
+    result = VMExits::createCiConstantLong(cp->long_at(index));
+  } else if (tag.is_float()) {
+    result = VMExits::createCiConstantFloat(cp->float_at(index));
+  } else if (tag.is_double()) {
+    result = VMExits::createCiConstantDouble(cp->double_at(index));
+  } else if (tag.is_string() || tag.is_unresolved_string()) {
+    oop string = NULL;
+    if (cp->is_pseudo_string_at(index)) {
+      string = cp->pseudo_string_at(index);
+    } else {
+      string = cp->string_at(index, THREAD);
+      if (HAS_PENDING_EXCEPTION) {
+        CLEAR_PENDING_EXCEPTION;
+        // TODO: Gracefully exit compilation.
+        fatal("out of memory during compilation!");
+        return NULL;
+      }
+    }
+    result = VMExits::createCiConstantObject(string);
+  } else if (tag.is_klass() || tag.is_unresolved_klass()) {
+    
+    // TODO: Return RiType object
+    ShouldNotReachHere();
+    // 4881222: allow ldc to take a class type
+    //bool ignore;
+    //ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore, accessor);
+    //if (HAS_PENDING_EXCEPTION) {
+    //  CLEAR_PENDING_EXCEPTION;
+    //  record_out_of_memory_failure();
+    //  return ciConstant();
+    //}
+    //assert (klass->is_instance_klass() || klass->is_array_klass(),
+    //  "must be an instance or array klass ");
+    //return ciConstant(T_OBJECT, klass);
+  } else if (tag.is_object()) {
+    oop obj = cp->object_at(index);
+    assert(obj->is_instance(), "must be an instance");
+    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;
+  constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle);
+  Bytecodes::Code bc = (Bytecodes::Code)byteCode;
+  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));
+}
+
+/*
+* 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();
+}
 
 
 JNINativeMethod VMEntries_methods[] = {
-  {CC"RiMethod_code",            CC"(Ljava/lang/Object;)[B",                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code)}
+  {CC"RiMethod_code",                   CC"(Ljava/lang/Object;)[B",                                                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code)},
+  {CC"RiMethod_maxStackSize",           CC"(Ljava/lang/Object;)I",                                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize)},
+  {CC"RiMethod_maxLocals",              CC"(Ljava/lang/Object;)I",                                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals)},
+  {CC"RiMethod_holder",                 CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;",                            FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder)},
+  {CC"RiMethod_signature",              CC"(Ljava/lang/Object;)Ljava/lang/String;",                                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature)},
+  {CC"RiMethod_name",                   CC"(Ljava/lang/Object;)Ljava/lang/String;",                                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name)},
+  {CC"RiSignature_lookupType",          CC"(Ljava/lang/String;Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;",          FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType)},
+  {CC"RiType_javaClass",                CC"(Ljava/lang/Object;)Ljava/lang/Class;",                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass)},
+  {CC"RiType_name",                     CC"(Ljava/lang/Object;)Ljava/lang/String;",                                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1name)},
+  {CC"RiConstantPool_lookupConstant",   CC"(Ljava/lang/Object;I)Ljava/lang/Object;",                                FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant)},
+  {CC"RiConstantPool_lookupMethod",     CC"(Ljava/lang/Object;IB)Lcom/sun/cri/ri/RiMethod;",                        FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod)},
+  {CC"RiConstantPool_lookupSignature",  CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature;",                      FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature)},
+  {CC"RiConstantPool_lookupType",       CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType;",                           FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType)},
+  {CC"RiConstantPool_lookupField",      CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField;",                          FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField)},
+  {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)}
 };
 
 int VMEntries_methods_count() {
--- a/src/share/vm/c1x/c1x_VMEntries.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_VMEntries.hpp	Tue May 18 17:43:37 2010 +0200
@@ -24,27 +24,173 @@
 
 #ifndef _Included_com_sun_hotspot_c1x_VMEntries
 #define _Included_com_sun_hotspot_c1x_VMEntries
-#ifdef __cplusplus
-extern "C" {
 
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 
+/*
+* 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 *, jclass, jobject);
 
-#endif
-  /*
-  * 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 *, jclass, jobject);
+/*
+* 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);
+
+/*
+* 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);
+
+
+/*
+* 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);
+
+/*
+* 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 *, jclass, jobject);
+
+/*
+* 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 *, jclass, jobject);
+
+/*
+* 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, 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);
 
 extern JNINativeMethod VMEntries_methods[];
 int VMEntries_methods_count();
 
-#ifdef __cplusplus
-}
-#endif
 #endif
\ No newline at end of file
--- a/src/share/vm/c1x/c1x_VMExits.cpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_VMExits.cpp	Tue May 18 17:43:37 2010 +0200
@@ -31,7 +31,7 @@
 
   if (_vmExitsKlass.is_null()) {
     Handle nullh;
-    _vmExitsKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_VMExits(), nullh, nullh, Thread::current());
+    _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");
     }
@@ -58,10 +58,12 @@
   return (oop)result.get_jobject();
 }
 
-oop VMExits::createRiField(klassOop k, int index) {
+oop VMExits::createRiField(oop field_holder, symbolOop field_name, oop field_type, int index) {
   JavaValue result(T_OBJECT);
   JavaCallArguments args;
-  args.push_oop(k);
+  args.push_oop(field_holder);
+  args.push_oop(field_name);
+  args.push_oop(field_type);
   args.push_int(index);
   JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createRiField_name(), vmSymbols::createRiField_signature(), &args, Thread::current());
   return (oop)result.get_jobject();
@@ -75,10 +77,78 @@
   return (oop)result.get_jobject();
 }
 
+oop VMExits::createRiTypePrimitive(int basic_type) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_int(basic_type);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createRiTypePrimitive_name(), vmSymbols::createRiTypePrimitive_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+}
+
+oop VMExits::createRiTypeUnresolved(symbolOop name, klassOop accessor) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_oop(name);
+  args.push_oop(accessor);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createRiTypeUnresolved_name(), vmSymbols::createRiTypeUnresolved_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+}
+
 oop VMExits::createRiConstantPool(constantPoolOop cp) {
   JavaValue result(T_OBJECT);
   JavaCallArguments args;
   args.push_oop(cp);
   JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createRiConstantPool_name(), vmSymbols::createRiConstantPool_signature(), &args, Thread::current());
   return (oop)result.get_jobject();
-}
\ No newline at end of file
+}
+
+oop VMExits::createRiSignature(symbolOop symbol) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_oop(symbol);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createRiSignature_name(), vmSymbols::createRiSignature_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+}
+
+oop VMExits::createCiConstantInt(jint value) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_int(value);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createCiConstantInt_name(), vmSymbols::createCiConstantInt_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+
+}
+
+oop VMExits::createCiConstantLong(jlong value) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_long(value);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createCiConstantLong_name(), vmSymbols::createCiConstantLong_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+
+}
+
+oop VMExits::createCiConstantFloat(jfloat value) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_float(value);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createCiConstantFloat_name(), vmSymbols::createCiConstantFloat_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+
+}
+
+oop VMExits::createCiConstantDouble(jdouble value) {
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_double(value);
+  JavaCalls::call_static(&result, vmExitsKlass(), vmSymbols::createCiConstantDouble_name(), vmSymbols::createCiConstantDouble_signature(), &args, Thread::current());
+  return (oop)result.get_jobject();
+}
+
+oop VMExits::createCiConstantObject(oop value) {
+  JavaValue result(T_OBJECT);
+  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();
+}
--- a/src/share/vm/c1x/c1x_VMExits.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/c1x/c1x_VMExits.hpp	Tue May 18 17:43:37 2010 +0200
@@ -33,7 +33,15 @@
   static KlassHandle& vmExitsKlass();
   static void compileMethod(oop method, int entry_bci);
   static oop createRiMethod(methodOop m);
-  static oop createRiField(klassOop k, int index);
+  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);
 };
\ No newline at end of file
--- a/src/share/vm/ci/ciEnv.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/ci/ciEnv.hpp	Tue May 18 17:43:37 2010 +0200
@@ -94,6 +94,8 @@
   ciInstance* _the_null_string;      // The Java string "null"
   ciInstance* _the_min_jint_string; // The Java string "-2147483648"
 
+public:
+
   // Look up a klass by name from a particular class loader (the accessor's).
   // If require_local, result must be defined in that class loader, or NULL.
   // If !require_local, a result from remote class loader may be reported,
@@ -128,6 +130,8 @@
                                  int method_index, Bytecodes::Code bc,
                                  ciInstanceKlass* loading_klass);
 
+private:
+
   // Implementation methods for loading and constant pool access.
   ciKlass* get_klass_by_name_impl(ciKlass* accessing_klass,
                                   ciSymbol* klass_name,
@@ -160,6 +164,7 @@
                            symbolOop       sig,
                            Bytecodes::Code bc);
 
+  public:
   // Get a ciObject from the object factory.  Ensures uniqueness
   // of ciObjects.
   ciObject* get_object(oop o) {
@@ -169,6 +174,7 @@
       return _factory->get(o);
     }
   }
+  private:
 
   ciMethod* get_method_from_handle(jobject method);
 
--- a/src/share/vm/ci/ciSymbol.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/ci/ciSymbol.hpp	Tue May 18 17:43:37 2010 +0200
@@ -39,8 +39,10 @@
   ciSymbol(symbolOop s) : ciObject(s) {}
   ciSymbol(symbolHandle s);   // for use with vmSymbolHandles
 
+public:
   symbolOop get_symbolOop() const { return (symbolOop)get_oop(); }
 
+private:
   const char* type_string() { return "ciSymbol"; }
 
   void print_impl(outputStream* st);
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Tue May 18 17:43:37 2010 +0200
@@ -243,24 +243,40 @@
   template(findBootstrapMethod_signature, "(Ljava/lang/Class;Ljava/lang/Class;)Ljava/dyn/MethodHandle;") \
   NOT_LP64(  do_alias(machine_word_signature,         int_signature)  )                           \
   LP64_ONLY( do_alias(machine_word_signature,         long_signature) )                           \
-                                                                                                  \
-  /* support for C1X */                                                                                        \
-  template(com_sun_hotspot_c1x_VMExits,               "com/sun/hotspot/c1x/VMExits")                           \
-  template(com_sun_cri_ri_RiMethod,                   "com/sun/cri/ri/RiMethod")                               \
-  template(com_sun_cri_ri_RiField,                    "com/sun/cri/ri/RiField")                                \
-  template(com_sun_cri_ri_RiType,                     "com/sun/cri/ri/RiType")                                 \
-  template(com_sun_cri_ri_RiConstantPool,             "com/sun/cri/ri/RiConstantPool")                         \
-  template(compileMethod_name,                        "compileMethod")                                         \
-  template(compileMethod_signature,                   "(Lcom/sun/cri/ri/RiMethod;I)V")                         \
-  template(createRiMethod_name,                       "createRiMethod")                                        \
-  template(createRiMethod_signature,                  "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiMethod;")         \
-  template(createRiField_name,                        "createRiField")                                         \
-  template(createRiField_signature,                   "(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField;")         \
-  template(createRiType_name,                         "createRiType")                                          \
-  template(createRiType_signature,                    "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;")           \
-  template(createRiConstantPool_name,                 "createRiConstantPool")                                  \
-  template(createRiConstantPool_signature,            "(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiConstantPool;")  \
-                                                                                                  \
+                                                                                                                        \
+  /* support for C1X */                                                                                                 \
+  template(com_sun_hotspot_c1x_VMExits,               "com/sun/hotspot/c1x/VMExits")                                    \
+  template(com_sun_cri_ri_RiMethod,                   "com/sun/cri/ri/RiMethod")                                        \
+  template(com_sun_cri_ri_RiField,                    "com/sun/cri/ri/RiField")                                         \
+  template(com_sun_cri_ri_RiType,                     "com/sun/cri/ri/RiType")                                          \
+  template(com_sun_cri_ri_RiConstantPool,             "com/sun/cri/ri/RiConstantPool")                                  \
+  template(compileMethod_name,                        "compileMethod")                                                  \
+  template(compileMethod_signature,                   "(Lcom/sun/cri/ri/RiMethod;I)V")                                  \
+  template(createRiMethod_name,                       "createRiMethod")                                                 \
+  template(createRiMethod_signature,                  "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiMethod;")                  \
+  template(createRiSignature_name,                    "createRiSignature")                                              \
+  template(createRiSignature_signature,               "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiSignature;")               \
+  template(createRiField_name,                        "createRiField")                                                  \
+  template(createRiField_signature,                   "(Lcom/sun/cri/ri/RiType;Ljava/lang/Object;Lcom/sun/cri/ri/RiType;I)Lcom/sun/cri/ri/RiField;")                  \
+  template(createRiType_name,                         "createRiType")                                                   \
+  template(createRiType_signature,                    "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;")                    \
+  template(createRiTypePrimitive_name,                "createRiTypePrimitive")                                          \
+  template(createRiTypePrimitive_signature,           "(I)Lcom/sun/cri/ri/RiType;")                                     \
+  template(createRiTypeUnresolved_name,               "createRiTypeUnresolved")                                         \
+  template(createRiTypeUnresolved_signature,          "(Ljava/lang/Object;Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;")  \
+  template(createRiConstantPool_name,                 "createRiConstantPool")                                           \
+  template(createRiConstantPool_signature,            "(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;")            \
+  template(createCiConstantInt_name,                  "createCiConstantInt")                                            \
+  template(createCiConstantInt_signature,             "(I)Lcom/sun/cri/ci/CiConstant;")                                 \
+  template(createCiConstantLong_name,                 "createCiConstantLong")                                           \
+  template(createCiConstantLong_signature,            "(J)Lcom/sun/cri/ci/CiConstant;")                                 \
+  template(createCiConstantFloat_name,                "createCiConstantFloat")                                          \
+  template(createCiConstantFloat_signature,           "(F)Lcom/sun/cri/ci/CiConstant;")                                 \
+  template(createCiConstantDouble_name,               "createCiConstantDouble")                                         \
+  template(createCiConstantDouble_signature,          "(D)Lcom/sun/cri/ci/CiConstant;")                                 \
+  template(createCiConstantObject_name,               "createCiConstantObject")                                         \
+  template(createCiConstantObject_signature,          "(Ljava/lang/Object;)Lcom/sun/cri/ci/CiConstant;")                \
+                                                                                                                        \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \
   template(class_initializer_name,                    "<clinit>")                                 \
--- a/src/share/vm/compiler/compileBroker.cpp	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/compiler/compileBroker.cpp	Tue May 18 17:43:37 2010 +0200
@@ -865,7 +865,9 @@
     MutexLocker locker(_method_queue->lock(), THREAD);
 
 	if (Thread::current()->is_Compiler_thread() && CompilerThread::current()->is_compiling()) {
-		TRACE_C1X_1("Recursive compile!");
+    
+		TRACE_C1X_1("Recursive compile %s!", method->name_and_sig_as_C_string());
+    method->set_not_compilable();
 		return;
 	}
 
--- a/src/share/vm/includeDB_compiler1	Mon May 17 16:37:23 2010 +0200
+++ b/src/share/vm/includeDB_compiler1	Tue May 18 17:43:37 2010 +0200
@@ -453,6 +453,7 @@
 c1x_Compiler.cpp                        c1x_VMEntries.hpp
 
 c1x_VMEntries.cpp                       c1x_VMEntries.hpp
+c1x_VMEntries.cpp                       c1x_Compiler.hpp
 c1x_VMEntries.cpp                       c1x_VMExits.hpp
 
 c1x_VMExits.hpp                	        systemDictionary.hpp