Mercurial > hg > truffle
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 13493:03bb0ee05409
made CodeInstaller subclassable and virtualized the methods for creating ScopeValues
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 02 Jan 2014 18:02:01 +0100 |
parents | 0ffe9e4bb364 |
children | 4e679d50ba9a |
comparison
equal
deleted
inserted
replaced
13492:896c8712c7b4 | 13493:03bb0ee05409 |
---|---|
157 } | 157 } |
158 } | 158 } |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 static ScopeValue* get_hotspot_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) { | 162 ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) { |
163 second = NULL; | 163 second = NULL; |
164 if (value == Value::ILLEGAL()) { | 164 if (value == Value::ILLEGAL()) { |
165 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); | 165 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); |
166 } | 166 } |
167 | 167 |
263 | 263 |
264 arrayOop values = (arrayOop) VirtualObject::values(value); | 264 arrayOop values = (arrayOop) VirtualObject::values(value); |
265 for (jint i = 0; i < values->length(); i++) { | 265 for (jint i = 0; i < values->length(); i++) { |
266 ScopeValue* cur_second = NULL; | 266 ScopeValue* cur_second = NULL; |
267 oop object = ((objArrayOop) (values))->obj_at(i); | 267 oop object = ((objArrayOop) (values))->obj_at(i); |
268 ScopeValue* value = get_hotspot_value(object, total_frame_size, objects, cur_second, oop_recorder); | 268 ScopeValue* value = get_scope_value(object, total_frame_size, objects, cur_second, oop_recorder); |
269 | 269 |
270 if (isLongArray && cur_second == NULL) { | 270 if (isLongArray && cur_second == NULL) { |
271 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. | 271 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
272 // add an int 0 constant | 272 // add an int 0 constant |
273 #ifdef VM_LITTLE_ENDIAN | 273 #ifdef VM_LITTLE_ENDIAN |
290 } | 290 } |
291 ShouldNotReachHere(); | 291 ShouldNotReachHere(); |
292 return NULL; | 292 return NULL; |
293 } | 293 } |
294 | 294 |
295 static MonitorValue* get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, OopRecorder* oop_recorder) { | 295 MonitorValue* CodeInstaller::get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, OopRecorder* oop_recorder) { |
296 guarantee(value->is_a(HotSpotMonitorValue::klass()), "Monitors must be of type MonitorValue"); | 296 guarantee(value->is_a(HotSpotMonitorValue::klass()), "Monitors must be of type MonitorValue"); |
297 | 297 |
298 ScopeValue* second = NULL; | 298 ScopeValue* second = NULL; |
299 ScopeValue* owner_value = get_hotspot_value(HotSpotMonitorValue::owner(value), total_frame_size, objects, second, oop_recorder); | 299 ScopeValue* owner_value = get_scope_value(HotSpotMonitorValue::owner(value), total_frame_size, objects, second, oop_recorder); |
300 assert(second == NULL, "monitor cannot occupy two stack slots"); | 300 assert(second == NULL, "monitor cannot occupy two stack slots"); |
301 | 301 |
302 ScopeValue* lock_data_value = get_hotspot_value(HotSpotMonitorValue::slot(value), total_frame_size, objects, second, oop_recorder); | 302 ScopeValue* lock_data_value = get_scope_value(HotSpotMonitorValue::slot(value), total_frame_size, objects, second, oop_recorder); |
303 assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); | 303 assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); |
304 assert(lock_data_value->is_location(), "invalid monitor location"); | 304 assert(lock_data_value->is_location(), "invalid monitor location"); |
305 Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); | 305 Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); |
306 | 306 |
307 bool eliminated = false; | 307 bool eliminated = false; |
358 | 358 |
359 return result; | 359 return result; |
360 } | 360 } |
361 | 361 |
362 // constructor used to create a method | 362 // constructor used to create a method |
363 CodeInstaller::CodeInstaller(Handle& compiled_code, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) { | 363 GraalEnv::CodeInstallResult CodeInstaller::install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) { |
364 BufferBlob* buffer_blob = GraalCompiler::initialize_buffer_blob(); | 364 BufferBlob* buffer_blob = GraalCompiler::initialize_buffer_blob(); |
365 if (buffer_blob == NULL) { | 365 if (buffer_blob == NULL) { |
366 result = GraalEnv::cache_full; | 366 return GraalEnv::cache_full; |
367 return; | |
368 } | 367 } |
369 | 368 |
370 CodeBuffer buffer(buffer_blob); | 369 CodeBuffer buffer(buffer_blob); |
371 jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); | 370 jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); |
372 initialize_assumptions(JNIHandles::resolve(compiled_code_obj)); | 371 initialize_assumptions(JNIHandles::resolve(compiled_code_obj)); |
377 | 376 |
378 { | 377 { |
379 No_Safepoint_Verifier no_safepoint; | 378 No_Safepoint_Verifier no_safepoint; |
380 initialize_fields(JNIHandles::resolve(compiled_code_obj)); | 379 initialize_fields(JNIHandles::resolve(compiled_code_obj)); |
381 if (!initialize_buffer(buffer)) { | 380 if (!initialize_buffer(buffer)) { |
382 result = GraalEnv::code_too_large; | 381 return GraalEnv::code_too_large; |
383 return; | |
384 } | 382 } |
385 process_exception_handlers(); | 383 process_exception_handlers(); |
386 } | 384 } |
387 | 385 |
388 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words | 386 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words |
389 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code); | 387 GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code); |
390 | 388 |
389 GraalEnv::CodeInstallResult result; | |
391 if (compiled_code->is_a(HotSpotCompiledRuntimeStub::klass())) { | 390 if (compiled_code->is_a(HotSpotCompiledRuntimeStub::klass())) { |
392 oop stubName = HotSpotCompiledRuntimeStub::stubName(compiled_code); | 391 oop stubName = HotSpotCompiledRuntimeStub::stubName(compiled_code); |
393 char* name = strdup(java_lang_String::as_utf8_string(stubName)); | 392 char* name = strdup(java_lang_String::as_utf8_string(stubName)); |
394 cb = RuntimeStub::new_runtime_stub(name, | 393 cb = RuntimeStub::new_runtime_stub(name, |
395 &buffer, | 394 &buffer, |
409 | 408 |
410 if (cb != NULL) { | 409 if (cb != NULL) { |
411 // Make sure the pre-calculated constants section size was correct. | 410 // Make sure the pre-calculated constants section size was correct. |
412 guarantee((cb->code_begin() - cb->content_begin()) == _constants_size, err_msg("%d != %d", cb->code_begin() - cb->content_begin(), _constants_size)); | 411 guarantee((cb->code_begin() - cb->content_begin()) == _constants_size, err_msg("%d != %d", cb->code_begin() - cb->content_begin(), _constants_size)); |
413 } | 412 } |
413 return result; | |
414 } | 414 } |
415 | 415 |
416 void CodeInstaller::initialize_fields(oop compiled_code) { | 416 void CodeInstaller::initialize_fields(oop compiled_code) { |
417 oop comp_result = HotSpotCompiledCode::comp(compiled_code); | 417 oop comp_result = HotSpotCompiledCode::comp(compiled_code); |
418 if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) { | 418 if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) { |
664 | 664 |
665 for (jint i = 0; i < values->length(); i++) { | 665 for (jint i = 0; i < values->length(); i++) { |
666 ScopeValue* second = NULL; | 666 ScopeValue* second = NULL; |
667 oop value=((objArrayOop) (values))->obj_at(i); | 667 oop value=((objArrayOop) (values))->obj_at(i); |
668 if (i < local_count) { | 668 if (i < local_count) { |
669 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second, _oop_recorder); | 669 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); |
670 if (second != NULL) { | 670 if (second != NULL) { |
671 locals->append(second); | 671 locals->append(second); |
672 } | 672 } |
673 locals->append(first); | 673 locals->append(first); |
674 } else if (i < local_count + expression_count) { | 674 } else if (i < local_count + expression_count) { |
675 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second, _oop_recorder); | 675 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); |
676 if (second != NULL) { | 676 if (second != NULL) { |
677 expressions->append(second); | 677 expressions->append(second); |
678 } | 678 } |
679 expressions->append(first); | 679 expressions->append(first); |
680 } else { | 680 } else { |