changeset 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 896c8712c7b4
children ab4c3a33a8b1 0b17dd482532
files src/share/vm/graal/graalCodeInstaller.cpp src/share/vm/graal/graalCodeInstaller.hpp src/share/vm/graal/graalCompilerToVM.cpp
diffstat 3 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Mon Dec 30 20:36:04 2013 +0000
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Thu Jan 02 18:02:01 2014 +0100
@@ -159,7 +159,7 @@
   }
 }
 
-static ScopeValue* get_hotspot_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) {
+ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) {
   second = NULL;
   if (value == Value::ILLEGAL()) {
     return new LocationValue(Location::new_stk_loc(Location::invalid, 0));
@@ -265,7 +265,7 @@
     for (jint i = 0; i < values->length(); i++) {
       ScopeValue* cur_second = NULL;
       oop object = ((objArrayOop) (values))->obj_at(i);
-      ScopeValue* value = get_hotspot_value(object, total_frame_size, objects, cur_second, oop_recorder);
+      ScopeValue* value = get_scope_value(object, total_frame_size, objects, cur_second, oop_recorder);
 
       if (isLongArray && cur_second == NULL) {
         // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations.
@@ -292,14 +292,14 @@
   return NULL;
 }
 
-static MonitorValue* get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, OopRecorder* oop_recorder) {
+MonitorValue* CodeInstaller::get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, OopRecorder* oop_recorder) {
   guarantee(value->is_a(HotSpotMonitorValue::klass()), "Monitors must be of type MonitorValue");
 
   ScopeValue* second = NULL;
-  ScopeValue* owner_value = get_hotspot_value(HotSpotMonitorValue::owner(value), total_frame_size, objects, second, oop_recorder);
+  ScopeValue* owner_value = get_scope_value(HotSpotMonitorValue::owner(value), total_frame_size, objects, second, oop_recorder);
   assert(second == NULL, "monitor cannot occupy two stack slots");
 
-  ScopeValue* lock_data_value = get_hotspot_value(HotSpotMonitorValue::slot(value), total_frame_size, objects, second, oop_recorder);
+  ScopeValue* lock_data_value = get_scope_value(HotSpotMonitorValue::slot(value), total_frame_size, objects, second, oop_recorder);
   assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots");
   assert(lock_data_value->is_location(), "invalid monitor location");
   Location lock_data_loc = ((LocationValue*)lock_data_value)->location();
@@ -360,11 +360,10 @@
 }
 
 // constructor used to create a method
-CodeInstaller::CodeInstaller(Handle& compiled_code, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) {
+GraalEnv::CodeInstallResult CodeInstaller::install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) {
   BufferBlob* buffer_blob = GraalCompiler::initialize_buffer_blob();
   if (buffer_blob == NULL) {
-    result = GraalEnv::cache_full;
-    return;
+    return GraalEnv::cache_full;
   }
 
   CodeBuffer buffer(buffer_blob);
@@ -379,8 +378,7 @@
     No_Safepoint_Verifier no_safepoint;
     initialize_fields(JNIHandles::resolve(compiled_code_obj));
     if (!initialize_buffer(buffer)) {
-      result = GraalEnv::code_too_large;
-      return;
+      return GraalEnv::code_too_large;
     }
     process_exception_handlers();
   }
@@ -388,6 +386,7 @@
   int stack_slots = _total_frame_size / HeapWordSize; // conversion to words
   GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(compiled_code);
 
+  GraalEnv::CodeInstallResult result;
   if (compiled_code->is_a(HotSpotCompiledRuntimeStub::klass())) {
     oop stubName = HotSpotCompiledRuntimeStub::stubName(compiled_code);
     char* name = strdup(java_lang_String::as_utf8_string(stubName));
@@ -411,6 +410,7 @@
     // Make sure the pre-calculated constants section size was correct.
     guarantee((cb->code_begin() - cb->content_begin()) == _constants_size, err_msg("%d != %d", cb->code_begin() - cb->content_begin(), _constants_size));
   }
+  return result;
 }
 
 void CodeInstaller::initialize_fields(oop compiled_code) {
@@ -666,13 +666,13 @@
     ScopeValue* second = NULL;
     oop value=((objArrayOop) (values))->obj_at(i);
     if (i < local_count) {
-      ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second, _oop_recorder);
+      ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder);
       if (second != NULL) {
         locals->append(second);
       }
       locals->append(first);
     } else if (i < local_count + expression_count) {
-      ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second, _oop_recorder);
+      ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder);
       if (second != NULL) {
         expressions->append(second);
       }
--- a/src/share/vm/graal/graalCodeInstaller.hpp	Mon Dec 30 20:36:04 2013 +0000
+++ b/src/share/vm/graal/graalCodeInstaller.hpp	Thu Jan 02 18:02:01 2014 +0100
@@ -84,10 +84,16 @@
 
 public:
 
-  CodeInstaller(Handle& comp_result, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations);
+  CodeInstaller() {};
+  GraalEnv::CodeInstallResult install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations);
 
   static address runtime_call_target_address(oop runtime_call);
 
+protected:
+
+  virtual ScopeValue* get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder);
+  virtual MonitorValue* get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, OopRecorder* oop_recorder);
+
 private:
   // extract the fields of the CompilationResult
   void initialize_fields(oop target_method);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Dec 30 20:36:04 2013 +0000
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Thu Jan 02 18:02:01 2014 +0100
@@ -569,9 +569,9 @@
   CodeBlob* cb = NULL;
   Handle installed_code_handle = JNIHandles::resolve(installed_code);
   Handle triggered_deoptimizations_handle = JNIHandles::resolve(triggered_deoptimizations);
-  GraalEnv::CodeInstallResult result;
 
-  CodeInstaller installer(compiled_code_handle, result, cb, installed_code_handle, triggered_deoptimizations_handle);
+  CodeInstaller installer;
+  GraalEnv::CodeInstallResult result = installer.install(compiled_code_handle, cb, installed_code_handle, triggered_deoptimizations_handle);
 
   if (PrintCodeCacheOnCompilation) {
     stringStream s;