comparison src/share/vm/graal/graalCodeInstaller.cpp @ 9669:ed6202820ecf

renamed HotSpotCompilationResult to HotSpotCompiledCode and added subclasses HotSpotCompiledNmethod and HotSpotCompiledRuntimeStub
author Doug Simon <doug.simon@oracle.com>
date Mon, 13 May 2013 21:59:17 +0200
parents 18632807db02
children c4b1aa93b9af
comparison
equal deleted inserted replaced
9668:fe9a18fbb15e 9669:ed6202820ecf
301 } 301 }
302 302
303 return new MonitorValue(owner_value, lock_data_loc, eliminated); 303 return new MonitorValue(owner_value, lock_data_loc, eliminated);
304 } 304 }
305 305
306 void CodeInstaller::initialize_assumptions(oop target_method) { 306 void CodeInstaller::initialize_assumptions(oop compiled_code) {
307 _oop_recorder = new OopRecorder(&_arena); 307 _oop_recorder = new OopRecorder(&_arena);
308 _dependencies = new Dependencies(&_arena, _oop_recorder); 308 _dependencies = new Dependencies(&_arena, _oop_recorder);
309 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompilationResult::comp(target_method)); 309 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompiledCode::comp(compiled_code));
310 if (!assumptions_handle.is_null()) { 310 if (!assumptions_handle.is_null()) {
311 objArrayHandle assumptions(Thread::current(), (objArrayOop)Assumptions::list(assumptions_handle())); 311 objArrayHandle assumptions(Thread::current(), (objArrayOop)Assumptions::list(assumptions_handle()));
312 int length = assumptions->length(); 312 int length = assumptions->length();
313 for (int i = 0; i < length; ++i) { 313 for (int i = 0; i < length; ++i) {
314 Handle assumption = assumptions->obj_at(i); 314 Handle assumption = assumptions->obj_at(i);
330 } 330 }
331 } 331 }
332 } 332 }
333 } 333 }
334 334
335 GrowableArray<jlong>* get_leaf_graph_ids(Handle& comp_result) { 335 GrowableArray<jlong>* get_leaf_graph_ids(Handle& compiled_code) {
336 arrayOop leafGraphArray = (arrayOop) CompilationResult::leafGraphIds(HotSpotCompilationResult::comp(comp_result)); 336 arrayOop leafGraphArray = (arrayOop) CompilationResult::leafGraphIds(HotSpotCompiledCode::comp(compiled_code));
337 337
338 jint length; 338 jint length;
339 if (leafGraphArray == NULL) { 339 if (leafGraphArray == NULL) {
340 length = 0; 340 length = 0;
341 } else { 341 } else {
349 349
350 return result; 350 return result;
351 } 351 }
352 352
353 // constructor used to create a method 353 // constructor used to create a method
354 CodeInstaller::CodeInstaller(Handle& comp_result, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) { 354 CodeInstaller::CodeInstaller(Handle& compiled_code, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) {
355 GraalCompiler::initialize_buffer_blob(); 355 GraalCompiler::initialize_buffer_blob();
356 CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); 356 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
357 jobject comp_result_obj = JNIHandles::make_local(comp_result()); 357 jobject compiled_code_obj = JNIHandles::make_local(compiled_code());
358 jint entry_bci = HotSpotCompilationResult::entryBCI(comp_result); 358 initialize_assumptions(JNIHandles::resolve(compiled_code_obj));
359 initialize_assumptions(JNIHandles::resolve(comp_result_obj));
360 359
361 { 360 {
362 No_Safepoint_Verifier no_safepoint; 361 No_Safepoint_Verifier no_safepoint;
363 initialize_fields(JNIHandles::resolve(comp_result_obj)); 362 initialize_fields(JNIHandles::resolve(compiled_code_obj));
364 initialize_buffer(buffer); 363 initialize_buffer(buffer);
365 process_exception_handlers(); 364 process_exception_handlers();
366 } 365 }
367 366
368 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words 367 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words
369 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(comp_result); 368 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code);
370 369
371 if (_stubName != NULL) { 370 if (compiled_code->is_a(HotSpotCompiledRuntimeStub::klass())) {
372 char* name = strdup(java_lang_String::as_utf8_string(_stubName)); 371 oop stubName = HotSpotCompiledRuntimeStub::stubName(compiled_code);
372 char* name = strdup(java_lang_String::as_utf8_string(stubName));
373 cb = RuntimeStub::new_runtime_stub(name, 373 cb = RuntimeStub::new_runtime_stub(name,
374 &buffer, 374 &buffer,
375 CodeOffsets::frame_never_safe, 375 CodeOffsets::frame_never_safe,
376 stack_slots, 376 stack_slots,
377 _debug_recorder->_oopmaps, 377 _debug_recorder->_oopmaps,
378 false); 378 false);
379 result = GraalEnv::ok; 379 result = GraalEnv::ok;
380 } else { 380 } else {
381 nmethod* nm = NULL; 381 nmethod* nm = NULL;
382 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(comp_result)); 382 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompiledNmethod::method(compiled_code));
383 jint entry_bci = HotSpotCompiledNmethod::entryBCI(compiled_code);
383 result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, 384 result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
384 GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, leaf_graph_ids, installed_code, triggered_deoptimizations); 385 GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, leaf_graph_ids, installed_code, triggered_deoptimizations);
385 cb = nm; 386 cb = nm;
386 } 387 }
387 } 388 }
388 389
389 void CodeInstaller::initialize_fields(oop comp_result) { 390 void CodeInstaller::initialize_fields(oop compiled_code) {
390 _comp_result = HotSpotCompilationResult::comp(comp_result); 391 oop comp_result = HotSpotCompiledCode::comp(compiled_code);
391 oop hotspotJavaMethod = HotSpotCompilationResult::method(comp_result); 392 if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) {
392 if (hotspotJavaMethod != NULL) { 393 oop hotspotJavaMethod = HotSpotCompiledNmethod::method(compiled_code);
393 methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod); 394 methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod);
394 _parameter_count = method->size_of_parameters(); 395 _parameter_count = method->size_of_parameters();
395 TRACE_graal_1("installing code for %s", method->name_and_sig_as_C_string()); 396 TRACE_graal_1("installing code for %s", method->name_and_sig_as_C_string());
396 } else { 397 } else {
398 assert(compiled_code->is_a(HotSpotCompiledRuntimeStub::klass()), "CCE");
397 // TODO (ds) not sure if this is correct - only used in OopMap constructor for non-product builds 399 // TODO (ds) not sure if this is correct - only used in OopMap constructor for non-product builds
398 _parameter_count = 0; 400 _parameter_count = 0;
399 } 401 }
400 _stubName = HotSpotCompilationResult::stubName(comp_result); 402 _sites = (arrayOop) HotSpotCompiledCode::sites(compiled_code);
401 _sites = (arrayOop) HotSpotCompilationResult::sites(comp_result); 403 _exception_handlers = (arrayOop) HotSpotCompiledCode::exceptionHandlers(compiled_code);
402 _exception_handlers = (arrayOop) HotSpotCompilationResult::exceptionHandlers(comp_result); 404
403 405 _code = (arrayOop) CompilationResult::targetCode(comp_result);
404 _code = (arrayOop) CompilationResult::targetCode(_comp_result); 406 _code_size = CompilationResult::targetCodeSize(comp_result);
405 _code_size = CompilationResult::targetCodeSize(_comp_result);
406 // The frame size we get from the target method does not include the return address, so add one word for it here. 407 // The frame size we get from the target method does not include the return address, so add one word for it here.
407 _total_frame_size = CompilationResult::frameSize(_comp_result) + HeapWordSize; 408 _total_frame_size = CompilationResult::frameSize(comp_result) + HeapWordSize;
408 _custom_stack_area_offset = CompilationResult::customStackAreaOffset(_comp_result); 409 _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result);
409 410
410 // (very) conservative estimate: each site needs a constant section entry 411 // (very) conservative estimate: each site needs a constant section entry
411 _constants_size = _sites->length() * (BytesPerLong*2); 412 _constants_size = _sites->length() * (BytesPerLong*2);
412 413
413 _next_call_type = MARK_INVOKE_INVALID; 414 _next_call_type = MARK_INVOKE_INVALID;