comparison hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp @ 39423:0f8dc3693499

8159167: [JVMCI] fix HotSpotVMConfig startup performance Reviewed-by: iveresov
author rschatz
date Thu, 16 Jun 2016 16:41:50 +0000
parents a9652c919db8
children 7464b1552bf7
comparison
equal deleted inserted replaced
40:c3f8df62b57d 41:1482912b25e2
86 return (oop)result.get_jobject(); 86 return (oop)result.get_jobject();
87 } 87 }
88 return NULL; 88 return NULL;
89 } 89 }
90 90
91 extern "C" {
92 extern VMStructEntry* jvmciHotSpotVMStructs;
93 extern uint64_t jvmciHotSpotVMStructEntryTypeNameOffset;
94 extern uint64_t jvmciHotSpotVMStructEntryFieldNameOffset;
95 extern uint64_t jvmciHotSpotVMStructEntryTypeStringOffset;
96 extern uint64_t jvmciHotSpotVMStructEntryIsStaticOffset;
97 extern uint64_t jvmciHotSpotVMStructEntryOffsetOffset;
98 extern uint64_t jvmciHotSpotVMStructEntryAddressOffset;
99 extern uint64_t jvmciHotSpotVMStructEntryArrayStride;
100
101 extern VMTypeEntry* jvmciHotSpotVMTypes;
102 extern uint64_t jvmciHotSpotVMTypeEntryTypeNameOffset;
103 extern uint64_t jvmciHotSpotVMTypeEntrySuperclassNameOffset;
104 extern uint64_t jvmciHotSpotVMTypeEntryIsOopTypeOffset;
105 extern uint64_t jvmciHotSpotVMTypeEntryIsIntegerTypeOffset;
106 extern uint64_t jvmciHotSpotVMTypeEntryIsUnsignedOffset;
107 extern uint64_t jvmciHotSpotVMTypeEntrySizeOffset;
108 extern uint64_t jvmciHotSpotVMTypeEntryArrayStride;
109
110 extern VMIntConstantEntry* jvmciHotSpotVMIntConstants;
111 extern uint64_t jvmciHotSpotVMIntConstantEntryNameOffset;
112 extern uint64_t jvmciHotSpotVMIntConstantEntryValueOffset;
113 extern uint64_t jvmciHotSpotVMIntConstantEntryArrayStride;
114
115 extern VMLongConstantEntry* jvmciHotSpotVMLongConstants;
116 extern uint64_t jvmciHotSpotVMLongConstantEntryNameOffset;
117 extern uint64_t jvmciHotSpotVMLongConstantEntryValueOffset;
118 extern uint64_t jvmciHotSpotVMLongConstantEntryArrayStride;
119
120 extern VMAddressEntry* jvmciHotSpotVMAddresses;
121 extern uint64_t jvmciHotSpotVMAddressEntryNameOffset;
122 extern uint64_t jvmciHotSpotVMAddressEntryValueOffset;
123 extern uint64_t jvmciHotSpotVMAddressEntryArrayStride;
124 }
125
126 int CompilerToVM::Data::Klass_vtable_start_offset; 91 int CompilerToVM::Data::Klass_vtable_start_offset;
127 int CompilerToVM::Data::Klass_vtable_length_offset; 92 int CompilerToVM::Data::Klass_vtable_length_offset;
128 93
129 int CompilerToVM::Data::Method_extra_stack_entries; 94 int CompilerToVM::Data::Method_extra_stack_entries;
130 95
230 SET_TRIGFUNC(dpow); 195 SET_TRIGFUNC(dpow);
231 196
232 #undef SET_TRIGFUNC 197 #undef SET_TRIGFUNC
233 } 198 }
234 199
235 /** 200 C2V_VMENTRY(jobjectArray, readConfiguration, (JNIEnv *env))
236 * We put all jvmciHotSpotVM values in an array so we can read them easily from Java. 201 #define BOXED_LONG(name, value) oop name; do { jvalue p; p.j = (jlong) (value); name = java_lang_boxing_object::create(T_LONG, &p, CHECK_NULL);} while(0)
237 */ 202 #define BOXED_DOUBLE(name, value) oop name; do { jvalue p; p.d = (jdouble) (value); name = java_lang_boxing_object::create(T_DOUBLE, &p, CHECK_NULL);} while(0)
238 static uintptr_t ciHotSpotVMData[28]; 203 ResourceMark rm;
239 204 HandleMark hm;
240 C2V_VMENTRY(jlong, initializeConfiguration, (JNIEnv *env, jobject))
241 ciHotSpotVMData[0] = (uintptr_t) jvmciHotSpotVMStructs;
242 ciHotSpotVMData[1] = jvmciHotSpotVMStructEntryTypeNameOffset;
243 ciHotSpotVMData[2] = jvmciHotSpotVMStructEntryFieldNameOffset;
244 ciHotSpotVMData[3] = jvmciHotSpotVMStructEntryTypeStringOffset;
245 ciHotSpotVMData[4] = jvmciHotSpotVMStructEntryIsStaticOffset;
246 ciHotSpotVMData[5] = jvmciHotSpotVMStructEntryOffsetOffset;
247 ciHotSpotVMData[6] = jvmciHotSpotVMStructEntryAddressOffset;
248 ciHotSpotVMData[7] = jvmciHotSpotVMStructEntryArrayStride;
249
250 ciHotSpotVMData[8] = (uintptr_t) jvmciHotSpotVMTypes;
251 ciHotSpotVMData[9] = jvmciHotSpotVMTypeEntryTypeNameOffset;
252 ciHotSpotVMData[10] = jvmciHotSpotVMTypeEntrySuperclassNameOffset;
253 ciHotSpotVMData[11] = jvmciHotSpotVMTypeEntryIsOopTypeOffset;
254 ciHotSpotVMData[12] = jvmciHotSpotVMTypeEntryIsIntegerTypeOffset;
255 ciHotSpotVMData[13] = jvmciHotSpotVMTypeEntryIsUnsignedOffset;
256 ciHotSpotVMData[14] = jvmciHotSpotVMTypeEntrySizeOffset;
257 ciHotSpotVMData[15] = jvmciHotSpotVMTypeEntryArrayStride;
258
259 ciHotSpotVMData[16] = (uintptr_t) jvmciHotSpotVMIntConstants;
260 ciHotSpotVMData[17] = jvmciHotSpotVMIntConstantEntryNameOffset;
261 ciHotSpotVMData[18] = jvmciHotSpotVMIntConstantEntryValueOffset;
262 ciHotSpotVMData[19] = jvmciHotSpotVMIntConstantEntryArrayStride;
263
264 ciHotSpotVMData[20] = (uintptr_t) jvmciHotSpotVMLongConstants;
265 ciHotSpotVMData[21] = jvmciHotSpotVMLongConstantEntryNameOffset;
266 ciHotSpotVMData[22] = jvmciHotSpotVMLongConstantEntryValueOffset;
267 ciHotSpotVMData[23] = jvmciHotSpotVMLongConstantEntryArrayStride;
268
269 ciHotSpotVMData[24] = (uintptr_t) jvmciHotSpotVMAddresses;
270 ciHotSpotVMData[25] = jvmciHotSpotVMAddressEntryNameOffset;
271 ciHotSpotVMData[26] = jvmciHotSpotVMAddressEntryValueOffset;
272 ciHotSpotVMData[27] = jvmciHotSpotVMAddressEntryArrayStride;
273 205
274 CompilerToVM::Data::initialize(); 206 CompilerToVM::Data::initialize();
275 207
276 return (jlong) (address) &ciHotSpotVMData; 208 VMField::klass()->initialize(thread);
209 VMFlag::klass()->initialize(thread);
210
211 int len = JVMCIVMStructs::localHotSpotVMStructs_count();
212 objArrayHandle vmFields = oopFactory::new_objArray(VMField::klass(), len, CHECK_NULL);
213 for (int i = 0; i < len ; i++) {
214 VMStructEntry vmField = JVMCIVMStructs::localHotSpotVMStructs[i];
215 instanceHandle vmFieldObj = InstanceKlass::cast(VMField::klass())->allocate_instance_handle(CHECK_NULL);
216 size_t name_buf_len = strlen(vmField.typeName) + strlen(vmField.fieldName) + 2 /* "::" */;
217 char* name_buf = NEW_RESOURCE_ARRAY(char, name_buf_len + 1);
218 sprintf(name_buf, "%s::%s", vmField.typeName, vmField.fieldName);
219 Handle name = java_lang_String::create_from_str(name_buf, CHECK_NULL);
220 Handle type = java_lang_String::create_from_str(vmField.typeString, CHECK_NULL);
221 VMField::set_name(vmFieldObj, name());
222 VMField::set_type(vmFieldObj, type());
223 VMField::set_offset(vmFieldObj, vmField.offset);
224 VMField::set_address(vmFieldObj, (jlong) vmField.address);
225 if (vmField.isStatic) {
226 if (strcmp(vmField.typeString, "bool") == 0) {
227 BOXED_LONG(value, *(jbyte*) vmField.address);
228 VMField::set_value(vmFieldObj, value);
229 } else if (strcmp(vmField.typeString, "int") == 0 ||
230 strcmp(vmField.typeString, "jint") == 0) {
231 BOXED_LONG(value, *(jint*) vmField.address);
232 VMField::set_value(vmFieldObj, value);
233 } else if (strcmp(vmField.typeString, "uint64_t") == 0) {
234 BOXED_LONG(value, *(uint64_t*) vmField.address);
235 VMField::set_value(vmFieldObj, value);
236 } else if (strcmp(vmField.typeString, "address") == 0 ||
237 strcmp(vmField.typeString, "intptr_t") == 0 ||
238 strcmp(vmField.typeString, "uintptr_t") == 0 ||
239 strcmp(vmField.typeString, "size_t") == 0 ||
240 // All foo* types are addresses.
241 vmField.typeString[strlen(vmField.typeString) - 1] == '*') {
242 BOXED_LONG(value, *((address*) vmField.address));
243 VMField::set_value(vmFieldObj, value);
244 } else {
245 JVMCI_ERROR_NULL("VM field %s has unsupported type %s", name_buf, vmField.typeString);
246 }
247 }
248 vmFields->obj_at_put(i, vmFieldObj());
249 }
250
251 len = JVMCIVMStructs::localHotSpotVMTypes_count();
252 objArrayHandle vmTypes = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL);
253 for (int i = 0; i < len ; i++) {
254 VMTypeEntry vmType = JVMCIVMStructs::localHotSpotVMTypes[i];
255 Handle name = java_lang_String::create_from_str(vmType.typeName, CHECK_NULL);
256 BOXED_LONG(size, vmType.size);
257 vmTypes->obj_at_put(i * 2, name());
258 vmTypes->obj_at_put(i * 2 + 1, size);
259 }
260
261 int ints_len = JVMCIVMStructs::localHotSpotVMIntConstants_count();
262 int longs_len = JVMCIVMStructs::localHotSpotVMLongConstants_count();
263 len = ints_len + longs_len;
264 objArrayHandle vmConstants = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL);
265 int insert = 0;
266 for (int i = 0; i < ints_len ; i++) {
267 VMIntConstantEntry c = JVMCIVMStructs::localHotSpotVMIntConstants[i];
268 Handle name = java_lang_String::create_from_str(c.name, CHECK_NULL);
269 BOXED_LONG(value, c.value);
270 vmConstants->obj_at_put(insert++, name());
271 vmConstants->obj_at_put(insert++, value);
272 }
273 for (int i = 0; i < longs_len ; i++) {
274 VMLongConstantEntry c = JVMCIVMStructs::localHotSpotVMLongConstants[i];
275 Handle name = java_lang_String::create_from_str(c.name, CHECK_NULL);
276 BOXED_LONG(value, c.value);
277 vmConstants->obj_at_put(insert++, name());
278 vmConstants->obj_at_put(insert++, value);
279 }
280 assert(insert == len * 2, "must be");
281
282 len = JVMCIVMStructs::localHotSpotVMAddresses_count();
283 objArrayHandle vmAddresses = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL);
284 for (int i = 0; i < len ; i++) {
285 VMAddressEntry a = JVMCIVMStructs::localHotSpotVMAddresses[i];
286 Handle name = java_lang_String::create_from_str(a.name, CHECK_NULL);
287 BOXED_LONG(value, a.value);
288 vmAddresses->obj_at_put(i * 2, name());
289 vmAddresses->obj_at_put(i * 2 + 1, value);
290 }
291
292 // The last entry is the null entry.
293 len = (int) Flag::numFlags - 1;
294 objArrayHandle vmFlags = oopFactory::new_objArray(VMFlag::klass(), len, CHECK_NULL);
295 for (int i = 0; i < len; i++) {
296 Flag* flag = &Flag::flags[i];
297 instanceHandle vmFlagObj = InstanceKlass::cast(VMFlag::klass())->allocate_instance_handle(CHECK_NULL);
298 Handle name = java_lang_String::create_from_str(flag->_name, CHECK_NULL);
299 Handle type = java_lang_String::create_from_str(flag->_type, CHECK_NULL);
300 VMFlag::set_name(vmFlagObj, name());
301 VMFlag::set_type(vmFlagObj, type());
302 if (flag->is_bool()) {
303 BOXED_LONG(value, flag->get_bool());
304 VMFlag::set_value(vmFlagObj, value);
305 } else if (flag->is_ccstr()) {
306 Handle value = java_lang_String::create_from_str(flag->get_ccstr(), CHECK_NULL);
307 VMFlag::set_value(vmFlagObj, value());
308 } else if (flag->is_int()) {
309 BOXED_LONG(value, flag->get_int());
310 VMFlag::set_value(vmFlagObj, value);
311 } else if (flag->is_intx()) {
312 BOXED_LONG(value, flag->get_intx());
313 VMFlag::set_value(vmFlagObj, value);
314 } else if (flag->is_uint()) {
315 BOXED_LONG(value, flag->get_uint());
316 VMFlag::set_value(vmFlagObj, value);
317 } else if (flag->is_uint64_t()) {
318 BOXED_LONG(value, flag->get_uint64_t());
319 VMFlag::set_value(vmFlagObj, value);
320 } else if (flag->is_uintx()) {
321 BOXED_LONG(value, flag->get_uintx());
322 VMFlag::set_value(vmFlagObj, value);
323 } else if (flag->is_double()) {
324 BOXED_DOUBLE(value, flag->get_double());
325 VMFlag::set_value(vmFlagObj, value);
326 } else if (flag->is_size_t()) {
327 BOXED_LONG(value, flag->get_size_t());
328 VMFlag::set_value(vmFlagObj, value);
329 } else {
330 JVMCI_ERROR_NULL("VM flag %s has unsupported type %s", flag->_name, flag->_type);
331 }
332 vmFlags->obj_at_put(i, vmFlagObj());
333 }
334
335 objArrayOop data = oopFactory::new_objArray(SystemDictionary::Object_klass(), 5, CHECK_NULL);
336 data->obj_at_put(0, vmFields());
337 data->obj_at_put(1, vmTypes());
338 data->obj_at_put(2, vmConstants());
339 data->obj_at_put(3, vmAddresses());
340 data->obj_at_put(4, vmFlags());
341
342 return (jobjectArray) JNIHandles::make_local(THREAD, data);
343 #undef BOXED_LONG
344 #undef BOXED_DOUBLE
277 C2V_END 345 C2V_END
278 346
279 C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jobject jvmci_method)) 347 C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jobject jvmci_method))
280 methodHandle method = CompilerToVM::asMethod(jvmci_method); 348 methodHandle method = CompilerToVM::asMethod(jvmci_method);
281 ResourceMark rm; 349 ResourceMark rm;
1448 {CC "getMaxCallTargetOffset", CC "(J)J", FN_PTR(getMaxCallTargetOffset)}, 1516 {CC "getMaxCallTargetOffset", CC "(J)J", FN_PTR(getMaxCallTargetOffset)},
1449 {CC "getResolvedJavaMethodAtSlot", CC "(" CLASS "I)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethodAtSlot)}, 1517 {CC "getResolvedJavaMethodAtSlot", CC "(" CLASS "I)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethodAtSlot)},
1450 {CC "getResolvedJavaMethod", CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethod)}, 1518 {CC "getResolvedJavaMethod", CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethod)},
1451 {CC "getConstantPool", CC "(Ljava/lang/Object;J)" HS_CONSTANT_POOL, FN_PTR(getConstantPool)}, 1519 {CC "getConstantPool", CC "(Ljava/lang/Object;J)" HS_CONSTANT_POOL, FN_PTR(getConstantPool)},
1452 {CC "getResolvedJavaType", CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS, FN_PTR(getResolvedJavaType)}, 1520 {CC "getResolvedJavaType", CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS, FN_PTR(getResolvedJavaType)},
1453 {CC "initializeConfiguration", CC "(" HS_CONFIG ")J", FN_PTR(initializeConfiguration)}, 1521 {CC "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)},
1454 {CC "installCode", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG ")I", FN_PTR(installCode)}, 1522 {CC "installCode", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG ")I", FN_PTR(installCode)},
1455 {CC "getMetadata", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA ")I", FN_PTR(getMetadata)}, 1523 {CC "getMetadata", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA ")I", FN_PTR(getMetadata)},
1456 {CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)}, 1524 {CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)},
1457 {CC "disassembleCodeBlob", CC "(" INSTALLED_CODE ")" STRING, FN_PTR(disassembleCodeBlob)}, 1525 {CC "disassembleCodeBlob", CC "(" INSTALLED_CODE ")" STRING, FN_PTR(disassembleCodeBlob)},
1458 {CC "executeInstalledCode", CC "([" OBJECT INSTALLED_CODE ")" OBJECT, FN_PTR(executeInstalledCode)}, 1526 {CC "executeInstalledCode", CC "([" OBJECT INSTALLED_CODE ")" OBJECT, FN_PTR(executeInstalledCode)},