comparison src/share/vm/c1x/c1x_Compiler.cpp @ 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
comparison
equal deleted inserted replaced
1412:9195b99c841b 1413:1ecc8f0aad00
32 TRACE_C1X_1("initialize"); 32 TRACE_C1X_1("initialize");
33 33
34 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment(); 34 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment();
35 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntries"); 35 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntries");
36 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() ); 36 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() );
37
38 if (Thread::current()->has_pending_exception()) {
39
40 Thread::current()->pending_exception()->print();
41 fatal("Could not register natives");
42 }
37 } 43 }
38 44
39 // Compilation entry point for methods 45 // Compilation entry point for methods
40 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { 46 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
41 47
46 52
47 ResourceMark rm; 53 ResourceMark rm;
48 HandleMark hm; 54 HandleMark hm;
49 55
50 CompilerThread::current()->set_compiling(true); 56 CompilerThread::current()->set_compiling(true);
51 oop rimethod = get_rimethod(target); 57 oop rimethod = get_RiMethod(target);
52 VMExits::compileMethod(rimethod, entry_bci); 58 VMExits::compileMethod(rimethod, entry_bci);
53 CompilerThread::current()->set_compiling(false); 59 CompilerThread::current()->set_compiling(false);
54 } 60 }
55 61
56 // Print compilation timers and statistics 62 // Print compilation timers and statistics
57 void C1XCompiler::print_timers() { 63 void C1XCompiler::print_timers() {
58 TRACE_C1X_1("print_timers"); 64 TRACE_C1X_1("print_timers");
59 } 65 }
60 66
61 oop C1XCompiler::get_rimethod(ciMethod *method) { 67 oop C1XCompiler::get_RiMethod(ciMethod *method) {
62 methodOop m = (methodOop)method->get_oop(); 68 methodOop m = (methodOop)method->get_oop();
69 return get_RiMethod(m);
70 }
71
72 oop C1XCompiler::get_RiField(ciField *field) {
73 oop field_holder = get_RiType(field->holder());
74 oop field_type = get_RiType(field->type());
75 symbolOop field_name = field->name()->get_symbolOop();
76 int offset = field->offset();
77
78 // TODO: implement caching
79 return VMExits::createRiField(field_holder, field_name, field_type, offset);
80 }
81
82 oop C1XCompiler::get_RiMethod(methodOop m) {
63 // TODO: implement caching 83 // TODO: implement caching
64 return VMExits::createRiMethod(m); 84 return VMExits::createRiMethod(m);
65 } 85 }
86
87 oop C1XCompiler::get_RiType(ciType *type) {
88 if (type->is_loaded()) {
89 if (type->is_primitive_type()) {
90 return VMExits::createRiTypePrimitive((int)type->basic_type());
91 }
92 return get_RiType((klassOop)type->get_oop());
93 } else {
94 return get_unresolved_RiType(((ciKlass *)type)->name()->get_symbolOop(), NULL);
95 }
96 }
97
98 oop C1XCompiler::get_RiType(klassOop klass) {
99 // TODO: implement caching
100 return VMExits::createRiType(klass);
101 }
102
103 oop C1XCompiler::get_RiConstantPool(constantPoolOop cp) {
104 // TODO: implement caching
105 return VMExits::createRiConstantPool(cp);
106 }
107
108 oop C1XCompiler::get_RiType(symbolOop klass, klassOop accessingType) {
109 klassOop resolved_type = SystemDictionary::resolve_or_null(klass, accessingType->klass_part()->class_loader(), accessingType->klass_part()->protection_domain(), Thread::current());
110 if (resolved_type == NULL) {
111 return get_RiType(resolved_type);
112 } else {
113 return get_unresolved_RiType(klass, accessingType);
114 }
115 }
116
117 oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType) {
118 // TODO: implement caching
119 return VMExits::createRiTypeUnresolved(klass, accessingType);
120 }