Mercurial > hg > truffle
diff src/share/vm/c1x/c1x_Compiler.cpp @ 1422:3483ec571caf
* using reflected objects instead of oops
* removed scratch from allocatable registers
* instanceof xir snippet
* arraylength xir snippet
* exceptionobject xir snippet
* VMEntries and VMExits as interfaces
* calls to VMEntries and VMExits are routet through logging proxies
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 02 Aug 2010 15:44:38 -0700 |
parents | 6223633ce7dd |
children | 760213a60e8b |
line wrap: on
line diff
--- a/src/share/vm/c1x/c1x_Compiler.cpp Fri Jul 23 15:53:02 2010 -0700 +++ b/src/share/vm/c1x/c1x_Compiler.cpp Mon Aug 02 15:44:38 2010 -0700 @@ -43,19 +43,16 @@ // Compilation entry point for methods void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { - initialize(); - VM_ENTRY_MARK; - - - ResourceMark rm; - HandleMark hm; + VM_ENTRY_MARK; + + ResourceMark rm; + HandleMark hm; CompilerThread::current()->set_compiling(true); - oop rimethod = get_RiMethod(target); - VMExits::compileMethod(rimethod, entry_bci); - CompilerThread::current()->set_compiling(false); + VMExits::compileMethod((methodOop)target->get_oop(), entry_bci); + CompilerThread::current()->set_compiling(false); } // Print compilation timers and statistics @@ -63,72 +60,129 @@ TRACE_C1X_1("print_timers"); } -oop C1XCompiler::get_RiMethod(ciMethod *method) { - methodOop m = (methodOop)method->get_oop(); - return get_RiMethod(m); +oop C1XCompiler::get_RiType(oop name, klassOop accessingType, TRAPS) { + symbolOop klass = java_lang_String::as_symbol_or_null(name); + + if (klass == vmSymbols::byte_signature()) { + return VMExits::createRiTypePrimitive((int)T_BYTE, THREAD); + } else if (klass == vmSymbols::char_signature()) { + return VMExits::createRiTypePrimitive((int)T_CHAR, THREAD); + } else if (klass == vmSymbols::double_signature()) { + return VMExits::createRiTypePrimitive((int)T_DOUBLE, THREAD); + } else if (klass == vmSymbols::float_signature()) { + return VMExits::createRiTypePrimitive((int)T_FLOAT, THREAD); + } else if (klass == vmSymbols::int_signature()) { + return VMExits::createRiTypePrimitive((int)T_INT, THREAD); + } else if (klass == vmSymbols::long_signature()) { + return VMExits::createRiTypePrimitive((int)T_LONG, THREAD); + } else if (klass == vmSymbols::bool_signature()) { + return VMExits::createRiTypePrimitive((int)T_BOOLEAN, THREAD); + } + Handle classloader; + if (accessingType != NULL) { + classloader = accessingType->klass_part()->class_loader(); + } + klassOop resolved_type = SystemDictionary::resolve_or_null(klass, classloader, accessingType->klass_part()->protection_domain(), Thread::current()); + if (resolved_type != NULL) { + return VMExits::createRiType(resolved_type, THREAD); + } else { + return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD); + } } -oop C1XCompiler::get_RiField(ciField *field) { - oop field_holder = get_RiType(field->holder()); - oop field_type = get_RiType(field->type()); +oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) { + if (type->is_loaded()) { + if (type->is_primitive_type()) { + return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD); + } + return VMExits::createRiType((klassOop)type->get_oop(), THREAD); + } else { + return VMExits::createRiTypeUnresolved(((ciKlass *)type)->name()->get_symbolOop(), accessor, THREAD); + } +} + +oop C1XCompiler::get_RiField(ciField *field, TRAPS) { + oop field_holder = get_RiType(field->holder(), NULL, CHECK_0); + oop field_type = get_RiType(field->type(), NULL, CHECK_0); symbolOop field_name = field->name()->get_symbolOop(); int offset = field->offset(); // TODO: implement caching - return VMExits::createRiField(field_holder, field_name, field_type, offset); + return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); } -oop C1XCompiler::get_RiMethod(methodOop m) { +/* +oop C1XCompiler::get_RiMethod(ciMethod *method, TRAPS) { + methodOop m = (methodOop)method->get_oop(); + return get_RiMethod(m, THREAD); +} + +oop C1XCompiler::get_RiMethod(methodOop m, TRAPS) { // TODO: implement caching - return VMExits::createRiMethod(m); + return VMExits::createRiMethod(m, THREAD); } -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()); + +oop C1XCompiler::get_RiType(klassOop klass, TRAPS) { + // TODO: implement caching + return VMExits::createRiType(klass, THREAD); +} + +oop C1XCompiler::get_RiConstantPool(constantPoolOop cp, TRAPS) { + // TODO: implement caching + return VMExits::createRiConstantPool(cp, THREAD); +} + +oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType, TRAPS) { + // TODO: implement caching + return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD); +} +*/ + +// conversion internal objects -> reflected objects + +oop C1XObjects::getReflectedMethod(methodOop method, TRAPS) { + if (method->is_initializer()) { + return Reflection::new_constructor(method, CHECK_0); } else { - return get_unresolved_RiType(((ciKlass *)type)->name()->get_symbolOop(), NULL); + return Reflection::new_method(method, UseNewReflection, false, CHECK_0); } } -oop C1XCompiler::get_RiType(klassOop klass) { - // TODO: implement caching - return VMExits::createRiType(klass); +oop C1XObjects::getReflectedClass(klassOop klass) { + return klass->klass_part()->java_mirror(); } -oop C1XCompiler::get_RiConstantPool(constantPoolOop cp) { - // TODO: implement caching - return VMExits::createRiConstantPool(cp); +oop C1XObjects::getReflectedSymbol(symbolOop symbol, TRAPS) { + return java_lang_String::create_from_symbol(symbol, THREAD)(); } -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); +// conversion reflected objects -> internal objects + +methodOop C1XObjects::getInternalMethod(oop method) { + // copied from JNIEnv::FromReflectedMethod + oop mirror = NULL; + int slot = 0; + + if (method->klass() == SystemDictionary::reflect_Constructor_klass()) { + mirror = java_lang_reflect_Constructor::clazz(method); + slot = java_lang_reflect_Constructor::slot(method); + } else { + assert(method->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); + mirror = java_lang_reflect_Method::clazz(method); + slot = java_lang_reflect_Method::slot(method); } - 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); - } + klassOop k = java_lang_Class::as_klassOop(mirror); + return instanceKlass::cast(k)->method_with_idnum(slot); } -oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType) { - // TODO: implement caching - return VMExits::createRiTypeUnresolved(klass, accessingType); +klassOop C1XObjects::getInternalClass(oop klass) { + return java_lang_Class::as_klassOop(klass); } + +symbolOop C1XObjects::getInternalSymbol(oop string) { + return java_lang_String::as_symbol_or_null(string); +} + + +