comparison src/share/vm/graal/graalCodeInstaller.cpp @ 7094:eec7173947a1

removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
author Doug Simon <doug.simon@oracle.com>
date Thu, 29 Nov 2012 17:13:13 +0100
parents dff79b1f82f1
children 0778b04fc682
comparison
equal deleted inserted replaced
7093:dff79b1f82f1 7094:eec7173947a1
262 262
263 return new MonitorValue(owner_value, lock_data_loc, eliminated); 263 return new MonitorValue(owner_value, lock_data_loc, eliminated);
264 } 264 }
265 265
266 void CodeInstaller::initialize_assumptions(oop target_method) { 266 void CodeInstaller::initialize_assumptions(oop target_method) {
267 _oop_recorder = new OopRecorder(_env->arena()); 267 _oop_recorder = new OopRecorder(&_arena);
268 _env->set_oop_recorder(_oop_recorder); 268 _dependencies = new Dependencies(&_arena, _oop_recorder);
269 _dependencies = new Dependencies(_env);
270 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompilationResult::comp(target_method)); 269 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompilationResult::comp(target_method));
271 if (!assumptions_handle.is_null()) { 270 if (!assumptions_handle.is_null()) {
272 objArrayHandle assumptions(Thread::current(), (objArrayOop)Assumptions::list(assumptions_handle())); 271 objArrayHandle assumptions(Thread::current(), (objArrayOop)Assumptions::list(assumptions_handle()));
273 int length = assumptions->length(); 272 int length = assumptions->length();
274 for (int i = 0; i < length; ++i) { 273 for (int i = 0; i < length; ++i) {
289 } 288 }
290 } 289 }
291 290
292 // constructor used to create a method 291 // constructor used to create a method
293 CodeInstaller::CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code) { 292 CodeInstaller::CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code) {
294 _env = CURRENT_ENV;
295 GraalCompiler::initialize_buffer_blob(); 293 GraalCompiler::initialize_buffer_blob();
296 CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); 294 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
297 jobject comp_result_obj = JNIHandles::make_local(comp_result()); 295 jobject comp_result_obj = JNIHandles::make_local(comp_result());
298 jint entry_bci = HotSpotCompilationResult::entryBCI(comp_result); 296 jint entry_bci = HotSpotCompilationResult::entryBCI(comp_result);
299 initialize_assumptions(JNIHandles::resolve(comp_result_obj)); 297 initialize_assumptions(JNIHandles::resolve(comp_result_obj));
314 } 312 }
315 313
316 // constructor used to create a stub 314 // constructor used to create a stub
317 CodeInstaller::CodeInstaller(Handle& target_method, BufferBlob*& blob, jlong& id) { 315 CodeInstaller::CodeInstaller(Handle& target_method, BufferBlob*& blob, jlong& id) {
318 No_Safepoint_Verifier no_safepoint; 316 No_Safepoint_Verifier no_safepoint;
319 _env = CURRENT_ENV;
320 317
321 _oop_recorder = new OopRecorder(_env->arena()); 318 _oop_recorder = new OopRecorder(&_arena);
322 _env->set_oop_recorder(_oop_recorder);
323 initialize_fields(target_method(), NULL); 319 initialize_fields(target_method(), NULL);
324 assert(_name != NULL, "installMethod needs NON-NULL name"); 320 assert(_name != NULL, "installMethod needs NON-NULL name");
325 321
326 // (very) conservative estimate: each site needs a relocation 322 // (very) conservative estimate: each site needs a relocation
327 GraalCompiler::initialize_buffer_blob(); 323 GraalCompiler::initialize_buffer_blob();
363 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); 359 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
364 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); 360 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo));
365 buffer.initialize_stubs_size(256); 361 buffer.initialize_stubs_size(256);
366 buffer.initialize_consts_size(_constants_size); 362 buffer.initialize_consts_size(_constants_size);
367 363
368 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder()); 364 _debug_recorder = new DebugInformationRecorder(_oop_recorder);
369 _debug_recorder->set_oopmaps(new OopMapSet()); 365 _debug_recorder->set_oopmaps(new OopMapSet());
370 366
371 _env->set_debug_info(_debug_recorder);
372 buffer.initialize_oop_recorder(_oop_recorder); 367 buffer.initialize_oop_recorder(_oop_recorder);
373 368
374 _instructions = buffer.insts(); 369 _instructions = buffer.insts();
375 _constants = buffer.consts(); 370 _constants = buffer.consts();
376 371
402 } 397 }
403 398
404 void CodeInstaller::assumption_MethodContents(Handle assumption) { 399 void CodeInstaller::assumption_MethodContents(Handle assumption) {
405 Handle method_handle = Assumptions_MethodContents::method(assumption()); 400 Handle method_handle = Assumptions_MethodContents::method(assumption());
406 methodHandle method = getMethodFromHotSpotMethod(method_handle()); 401 methodHandle method = getMethodFromHotSpotMethod(method_handle());
407 ciMethod* m = (ciMethod*) CURRENT_ENV->get_method(method()); 402 DepValue method_dv(_oop_recorder, method());
408 403 _dependencies->assert_evol_method(method_dv);
409 _dependencies->assert_evol_method(m);
410 } 404 }
411 405
412 void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) { 406 void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) {
413 Handle context_handle = Assumptions_ConcreteSubtype::context(assumption()); 407 Handle context_handle = Assumptions_ConcreteSubtype::context(assumption());
414 ciKlass* context = (ciKlass*) CURRENT_ENV->get_klass(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(context_handle))); 408 Handle subtype_handle = Assumptions_ConcreteSubtype::subtype(assumption());
415 409 Klass* context = asKlass(HotSpotResolvedObjectType::metaspaceKlass(context_handle));
416 Handle type_handle = Assumptions_ConcreteSubtype::subtype(assumption()); 410 Klass* subtype = asKlass(HotSpotResolvedObjectType::metaspaceKlass(subtype_handle));
417 ciKlass* type = (ciKlass*) CURRENT_ENV->get_klass(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type_handle))); 411
418 412 DepValue subtype_dv(_oop_recorder, subtype);
419 _dependencies->assert_leaf_type(type); 413 _dependencies->assert_leaf_type(subtype_dv);
420 if (context != type) { 414 if (context != subtype) {
421 assert(context->is_abstract(), ""); 415 assert(context->is_abstract(), "");
422 _dependencies->assert_abstract_with_unique_concrete_subtype(context, type); 416 DepValue context_dv(_oop_recorder, context);
417 _dependencies->assert_abstract_with_unique_concrete_subtype(context_dv, subtype_dv);
423 } 418 }
424 } 419 }
425 420
426 void CodeInstaller::assumption_ConcreteMethod(Handle assumption) { 421 void CodeInstaller::assumption_ConcreteMethod(Handle assumption) {
427 Handle impl_handle = Assumptions_ConcreteMethod::impl(assumption()); 422 Handle impl_handle = Assumptions_ConcreteMethod::impl(assumption());
423 Handle context_handle = Assumptions_ConcreteMethod::context(assumption());
424
428 methodHandle impl = getMethodFromHotSpotMethod(impl_handle()); 425 methodHandle impl = getMethodFromHotSpotMethod(impl_handle());
429 ciMethod* m = (ciMethod*) CURRENT_ENV->get_method(impl()); 426 Klass* context = asKlass(HotSpotResolvedObjectType::metaspaceKlass(context_handle));
430 427
431 Handle context_handle = Assumptions_ConcreteMethod::context(assumption()); 428 DepValue context_dv(_oop_recorder, context);
432 ciKlass* context = (ciKlass*) CURRENT_ENV->get_klass(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(context_handle))); 429 DepValue impl_dv(_oop_recorder, impl());
433 _dependencies->assert_unique_concrete_method(context, m); 430 _dependencies->assert_unique_concrete_method(context_dv, impl_dv);
434 } 431 }
435 432
436 void CodeInstaller::process_exception_handlers() { 433 void CodeInstaller::process_exception_handlers() {
437 // allocate some arrays for use by the collection code. 434 // allocate some arrays for use by the collection code.
438 const int num_handlers = 5; 435 const int num_handlers = 5;