Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompiler.cpp @ 3637:ff6a991c6e3c
Use GraalEnv to look up types.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Nov 2011 01:48:25 +0100 |
parents | 076542d505cd |
children | 5a8c44b5fb80 |
comparison
equal
deleted
inserted
replaced
3636:c7d4198a9bce | 3637:ff6a991c6e3c |
---|---|
25 #include "graal/graalCompiler.hpp" | 25 #include "graal/graalCompiler.hpp" |
26 #include "graal/graalJavaAccess.hpp" | 26 #include "graal/graalJavaAccess.hpp" |
27 #include "graal/graalVMExits.hpp" | 27 #include "graal/graalVMExits.hpp" |
28 #include "graal/graalVMEntries.hpp" | 28 #include "graal/graalVMEntries.hpp" |
29 #include "graal/graalVmIds.hpp" | 29 #include "graal/graalVmIds.hpp" |
30 #include "graal/graalEnv.hpp" | |
30 #include "c1/c1_Runtime1.hpp" | 31 #include "c1/c1_Runtime1.hpp" |
31 #include "runtime/arguments.hpp" | 32 #include "runtime/arguments.hpp" |
32 | 33 |
33 GraalCompiler* GraalCompiler::_instance = NULL; | 34 GraalCompiler* GraalCompiler::_instance = NULL; |
34 | 35 |
122 // Print compilation timers and statistics | 123 // Print compilation timers and statistics |
123 void GraalCompiler::print_timers() { | 124 void GraalCompiler::print_timers() { |
124 TRACE_graal_1("GraalCompiler::print_timers"); | 125 TRACE_graal_1("GraalCompiler::print_timers"); |
125 } | 126 } |
126 | 127 |
127 oop GraalCompiler::get_RiType(KlassHandle klass, KlassHandle accessor, TRAPS) { | 128 oop GraalCompiler::get_RiType(Symbol* klass_name, TRAPS) { |
128 if (klass->oop_is_instance_slow()) { | 129 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(klass_name, THREAD), THREAD); |
129 assert(instanceKlass::cast(klass())->is_initialized(), "unexpected unresolved klass"); | 130 } |
130 } else if (klass->oop_is_javaArray_slow()){ | 131 |
131 } else { | 132 oop GraalCompiler::get_RiTypeFromSignature(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { |
132 klass()->print(); | 133 |
133 assert(false, "unexpected klass"); | 134 Symbol* signature = cp->symbol_at(index); |
134 } | 135 BasicType field_type = FieldType::basic_type(signature); |
136 // If the field is a pointer type, get the klass of the | |
137 // field. | |
138 if (field_type == T_OBJECT || field_type == T_ARRAY) { | |
139 KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false); | |
140 if (handle.is_null()) { | |
141 return get_RiType(signature, CHECK_NULL); | |
142 } else { | |
143 return get_RiType(handle, CHECK_NULL); | |
144 } | |
145 } else { | |
146 return VMExits::createRiTypePrimitive(field_type, CHECK_NULL); | |
147 } | |
148 } | |
149 | |
150 oop GraalCompiler::get_RiType(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { | |
151 bool is_accessible = false; | |
152 | |
153 KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); | |
154 oop catch_class = NULL; | |
155 if (klass.is_null()) { | |
156 // We have to lock the cpool to keep the oop from being resolved | |
157 // while we are accessing it. | |
158 ObjectLocker ol(cp, THREAD); | |
159 | |
160 Symbol* klass_name = NULL; | |
161 constantTag tag = cp->tag_at(index); | |
162 if (tag.is_klass()) { | |
163 // The klass has been inserted into the constant pool | |
164 // very recently. | |
165 return GraalCompiler::get_RiType(cp->resolved_klass_at(index), CHECK_NULL); | |
166 } else if (tag.is_symbol()) { | |
167 klass_name = cp->symbol_at(index); | |
168 } else { | |
169 assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); | |
170 klass_name = cp->unresolved_klass_at(index); | |
171 } | |
172 return GraalCompiler::get_RiType(klass_name, CHECK_NULL); | |
173 } else { | |
174 return GraalCompiler::get_RiType(klass, CHECK_NULL); | |
175 } | |
176 } | |
177 | |
178 oop GraalCompiler::get_RiType(KlassHandle klass, TRAPS) { | |
135 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); | 179 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); |
136 return createHotSpotTypeResolved(klass, name, CHECK_NULL); | 180 return createHotSpotTypeResolved(klass, name, CHECK_NULL); |
137 } | 181 } |
138 | 182 |
139 oop GraalCompiler::get_RiType(ciType *type, KlassHandle accessor, TRAPS) { | 183 oop GraalCompiler::get_RiField(ciField *field, ciInstanceKlass* accessor_klass, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS) { |
140 if (type->is_loaded()) { | |
141 if (type->is_primitive_type()) { | |
142 return VMExits::createRiTypePrimitive((int) type->basic_type(), THREAD); | |
143 } | |
144 KlassHandle klass = (klassOop) type->get_oop(); | |
145 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); | |
146 return createHotSpotTypeResolved(klass, name, CHECK_NULL); | |
147 } else { | |
148 Symbol* name = ((ciKlass *) type)->name()->get_symbol(); | |
149 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), THREAD); | |
150 } | |
151 } | |
152 | |
153 oop GraalCompiler::get_RiField(ciField *field, ciInstanceKlass* accessor_klass, KlassHandle accessor, Bytecodes::Code byteCode, TRAPS) { | |
154 int offset; | 184 int offset; |
155 if (byteCode != Bytecodes::_illegal) { | 185 if (byteCode != Bytecodes::_illegal) { |
156 bool will_link = field->will_link_from_vm(accessor_klass, byteCode); | 186 bool will_link = field->will_link_from_vm(accessor_klass, byteCode); |
157 offset = (field->holder()->is_loaded() && will_link) ? field->offset() : -1; | 187 offset = (field->holder()->is_loaded() && will_link) ? field->offset() : -1; |
158 } else { | 188 } else { |
159 offset = field->offset(); | 189 offset = field->offset(); |
160 } | 190 } |
161 Handle field_name = VmIds::toString<Handle>(field->name()->get_symbol(), CHECK_0); | 191 Handle field_name = VmIds::toString<Handle>(field->name()->get_symbol(), CHECK_0); |
162 Handle field_holder = get_RiType(field->holder(), accessor, CHECK_0); | |
163 Handle field_type = get_RiType(field->type(), accessor, CHECK_0); | |
164 int flags = field->flags().as_int(); | 192 int flags = field->flags().as_int(); |
165 return VMExits::createRiField(field_holder, field_name, field_type, offset, flags, THREAD); | 193 return VMExits::createRiField(field_holder, field_name, field_type, offset, flags, THREAD); |
166 } | 194 } |
167 | 195 |
168 oop GraalCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { | 196 oop GraalCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { |