Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
1421:6223633ce7dd | 1422:3483ec571caf |
---|---|
41 check_pending_exception("Could not register natives"); | 41 check_pending_exception("Could not register natives"); |
42 } | 42 } |
43 | 43 |
44 // Compilation entry point for methods | 44 // Compilation entry point for methods |
45 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { | 45 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
46 | |
47 initialize(); | 46 initialize(); |
48 | 47 |
49 VM_ENTRY_MARK; | 48 VM_ENTRY_MARK; |
50 | 49 |
51 | 50 ResourceMark rm; |
52 ResourceMark rm; | 51 HandleMark hm; |
53 HandleMark hm; | |
54 | 52 |
55 CompilerThread::current()->set_compiling(true); | 53 CompilerThread::current()->set_compiling(true); |
56 oop rimethod = get_RiMethod(target); | 54 VMExits::compileMethod((methodOop)target->get_oop(), entry_bci); |
57 VMExits::compileMethod(rimethod, entry_bci); | 55 CompilerThread::current()->set_compiling(false); |
58 CompilerThread::current()->set_compiling(false); | |
59 } | 56 } |
60 | 57 |
61 // Print compilation timers and statistics | 58 // Print compilation timers and statistics |
62 void C1XCompiler::print_timers() { | 59 void C1XCompiler::print_timers() { |
63 TRACE_C1X_1("print_timers"); | 60 TRACE_C1X_1("print_timers"); |
64 } | 61 } |
65 | 62 |
66 oop C1XCompiler::get_RiMethod(ciMethod *method) { | 63 oop C1XCompiler::get_RiType(oop name, klassOop accessingType, TRAPS) { |
67 methodOop m = (methodOop)method->get_oop(); | 64 symbolOop klass = java_lang_String::as_symbol_or_null(name); |
68 return get_RiMethod(m); | 65 |
66 if (klass == vmSymbols::byte_signature()) { | |
67 return VMExits::createRiTypePrimitive((int)T_BYTE, THREAD); | |
68 } else if (klass == vmSymbols::char_signature()) { | |
69 return VMExits::createRiTypePrimitive((int)T_CHAR, THREAD); | |
70 } else if (klass == vmSymbols::double_signature()) { | |
71 return VMExits::createRiTypePrimitive((int)T_DOUBLE, THREAD); | |
72 } else if (klass == vmSymbols::float_signature()) { | |
73 return VMExits::createRiTypePrimitive((int)T_FLOAT, THREAD); | |
74 } else if (klass == vmSymbols::int_signature()) { | |
75 return VMExits::createRiTypePrimitive((int)T_INT, THREAD); | |
76 } else if (klass == vmSymbols::long_signature()) { | |
77 return VMExits::createRiTypePrimitive((int)T_LONG, THREAD); | |
78 } else if (klass == vmSymbols::bool_signature()) { | |
79 return VMExits::createRiTypePrimitive((int)T_BOOLEAN, THREAD); | |
80 } | |
81 Handle classloader; | |
82 if (accessingType != NULL) { | |
83 classloader = accessingType->klass_part()->class_loader(); | |
84 } | |
85 klassOop resolved_type = SystemDictionary::resolve_or_null(klass, classloader, accessingType->klass_part()->protection_domain(), Thread::current()); | |
86 if (resolved_type != NULL) { | |
87 return VMExits::createRiType(resolved_type, THREAD); | |
88 } else { | |
89 return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD); | |
90 } | |
69 } | 91 } |
70 | 92 |
71 oop C1XCompiler::get_RiField(ciField *field) { | 93 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) { |
72 oop field_holder = get_RiType(field->holder()); | 94 if (type->is_loaded()) { |
73 oop field_type = get_RiType(field->type()); | 95 if (type->is_primitive_type()) { |
96 return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD); | |
97 } | |
98 return VMExits::createRiType((klassOop)type->get_oop(), THREAD); | |
99 } else { | |
100 return VMExits::createRiTypeUnresolved(((ciKlass *)type)->name()->get_symbolOop(), accessor, THREAD); | |
101 } | |
102 } | |
103 | |
104 oop C1XCompiler::get_RiField(ciField *field, TRAPS) { | |
105 oop field_holder = get_RiType(field->holder(), NULL, CHECK_0); | |
106 oop field_type = get_RiType(field->type(), NULL, CHECK_0); | |
74 symbolOop field_name = field->name()->get_symbolOop(); | 107 symbolOop field_name = field->name()->get_symbolOop(); |
75 int offset = field->offset(); | 108 int offset = field->offset(); |
76 | 109 |
77 // TODO: implement caching | 110 // TODO: implement caching |
78 return VMExits::createRiField(field_holder, field_name, field_type, offset); | 111 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); |
79 } | 112 } |
80 | 113 |
81 oop C1XCompiler::get_RiMethod(methodOop m) { | 114 /* |
82 // TODO: implement caching | 115 oop C1XCompiler::get_RiMethod(ciMethod *method, TRAPS) { |
83 return VMExits::createRiMethod(m); | 116 methodOop m = (methodOop)method->get_oop(); |
117 return get_RiMethod(m, THREAD); | |
84 } | 118 } |
85 | 119 |
86 oop C1XCompiler::get_RiType(ciType *type) { | 120 oop C1XCompiler::get_RiMethod(methodOop m, TRAPS) { |
87 if (type->is_loaded()) { | 121 // TODO: implement caching |
88 if (type->is_primitive_type()) { | 122 return VMExits::createRiMethod(m, THREAD); |
89 return VMExits::createRiTypePrimitive((int)type->basic_type()); | 123 } |
90 } | 124 |
91 return get_RiType((klassOop)type->get_oop()); | 125 |
126 oop C1XCompiler::get_RiType(klassOop klass, TRAPS) { | |
127 // TODO: implement caching | |
128 return VMExits::createRiType(klass, THREAD); | |
129 } | |
130 | |
131 oop C1XCompiler::get_RiConstantPool(constantPoolOop cp, TRAPS) { | |
132 // TODO: implement caching | |
133 return VMExits::createRiConstantPool(cp, THREAD); | |
134 } | |
135 | |
136 oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType, TRAPS) { | |
137 // TODO: implement caching | |
138 return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD); | |
139 } | |
140 */ | |
141 | |
142 // conversion internal objects -> reflected objects | |
143 | |
144 oop C1XObjects::getReflectedMethod(methodOop method, TRAPS) { | |
145 if (method->is_initializer()) { | |
146 return Reflection::new_constructor(method, CHECK_0); | |
92 } else { | 147 } else { |
93 return get_unresolved_RiType(((ciKlass *)type)->name()->get_symbolOop(), NULL); | 148 return Reflection::new_method(method, UseNewReflection, false, CHECK_0); |
94 } | 149 } |
95 } | 150 } |
96 | 151 |
97 oop C1XCompiler::get_RiType(klassOop klass) { | 152 oop C1XObjects::getReflectedClass(klassOop klass) { |
98 // TODO: implement caching | 153 return klass->klass_part()->java_mirror(); |
99 return VMExits::createRiType(klass); | |
100 } | 154 } |
101 | 155 |
102 oop C1XCompiler::get_RiConstantPool(constantPoolOop cp) { | 156 oop C1XObjects::getReflectedSymbol(symbolOop symbol, TRAPS) { |
103 // TODO: implement caching | 157 return java_lang_String::create_from_symbol(symbol, THREAD)(); |
104 return VMExits::createRiConstantPool(cp); | |
105 } | 158 } |
106 | 159 |
107 oop C1XCompiler::get_RiType(symbolOop klass, klassOop accessingType) { | 160 // conversion reflected objects -> internal objects |
108 if (klass == vmSymbols::byte_signature()) { | 161 |
109 return VMExits::createRiTypePrimitive((int)T_BYTE); | 162 methodOop C1XObjects::getInternalMethod(oop method) { |
110 } else if (klass == vmSymbols::char_signature()) { | 163 // copied from JNIEnv::FromReflectedMethod |
111 return VMExits::createRiTypePrimitive((int)T_CHAR); | 164 oop mirror = NULL; |
112 } else if (klass == vmSymbols::double_signature()) { | 165 int slot = 0; |
113 return VMExits::createRiTypePrimitive((int)T_DOUBLE); | 166 |
114 } else if (klass == vmSymbols::float_signature()) { | 167 if (method->klass() == SystemDictionary::reflect_Constructor_klass()) { |
115 return VMExits::createRiTypePrimitive((int)T_FLOAT); | 168 mirror = java_lang_reflect_Constructor::clazz(method); |
116 } else if (klass == vmSymbols::int_signature()) { | 169 slot = java_lang_reflect_Constructor::slot(method); |
117 return VMExits::createRiTypePrimitive((int)T_INT); | 170 } else { |
118 } else if (klass == vmSymbols::long_signature()) { | 171 assert(method->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); |
119 return VMExits::createRiTypePrimitive((int)T_LONG); | 172 mirror = java_lang_reflect_Method::clazz(method); |
120 } else if (klass == vmSymbols::bool_signature()) { | 173 slot = java_lang_reflect_Method::slot(method); |
121 return VMExits::createRiTypePrimitive((int)T_BOOLEAN); | |
122 } | 174 } |
123 klassOop resolved_type = SystemDictionary::resolve_or_null(klass, accessingType->klass_part()->class_loader(), accessingType->klass_part()->protection_domain(), Thread::current()); | 175 klassOop k = java_lang_Class::as_klassOop(mirror); |
124 if (resolved_type != NULL) { | 176 return instanceKlass::cast(k)->method_with_idnum(slot); |
125 return get_RiType(resolved_type); | |
126 } else { | |
127 return get_unresolved_RiType(klass, accessingType); | |
128 } | |
129 } | 177 } |
130 | 178 |
131 oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType) { | 179 klassOop C1XObjects::getInternalClass(oop klass) { |
132 // TODO: implement caching | 180 return java_lang_Class::as_klassOop(klass); |
133 return VMExits::createRiTypeUnresolved(klass, accessingType); | |
134 } | 181 } |
182 | |
183 symbolOop C1XObjects::getInternalSymbol(oop string) { | |
184 return java_lang_String::as_symbol_or_null(string); | |
185 } | |
186 | |
187 | |
188 |