changeset 1931:48bbaead8b6c

Adjustments after merge with OpenJDK repository.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 30 Nov 2010 16:39:35 +0100
parents 2d26b0046e0d
children e6500c6c5e24
files src/share/vm/c1/c1_Runtime1.cpp src/share/vm/c1x/c1x_CodeInstaller.cpp src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_Compiler.hpp src/share/vm/c1x/c1x_VMEntries.cpp src/share/vm/code/nmethod.cpp src/share/vm/compiler/compileBroker.cpp
diffstat 7 files changed, 55 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Runtime1.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -148,8 +148,6 @@
     case counter_overflow_id: // Not generated outside the tiered world
 #endif
 #ifdef SPARC
-    case counter_overflow_id:
-#if defined(SPARC) || defined(PPC)
     case handle_exception_nofpu_id:  // Unused on sparc
 #endif
       break;
--- a/src/share/vm/c1x/c1x_CodeInstaller.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -172,7 +172,8 @@
   }
 
   // (very) conservative estimate: each site needs a relocation
-  CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit);
+  //CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit);
+  CodeBuffer buffer(CompilerThread::current()->get_buffer_blob());
   initialize_buffer(buffer);
   process_exception_handlers();
 
@@ -192,13 +193,13 @@
   assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method");
 
   // (very) conservative estimate: each site needs a relocation
-  CodeBuffer buffer("temp c1x stub", _total_size, _sites->length() * relocInfo::length_limit);
+  CodeBuffer buffer(CompilerThread::current()->get_buffer_blob());
   initialize_buffer(buffer);
 
   const char* cname = java_lang_String::as_utf8_string(_name);
   BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created
   IF_TRACE_C1X_3 Disassembler::decode((CodeBlob*) blob);
-  id = VmIds::addStub(blob->instructions_begin());
+  id = VmIds::addStub(blob->code_begin());
 }
 
 void CodeInstaller::initialize_fields(oop target_method) {
@@ -221,6 +222,12 @@
 
 // perform data and call relocation on the CodeBuffer
 void CodeInstaller::initialize_buffer(CodeBuffer& buffer) {
+  int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo));
+  char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
+  buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo));
+  buffer.initialize_stubs_size(256);
+  buffer.initialize_consts_size(_constants_size);
+
   _oop_recorder = new OopRecorder(_env->arena());
   _env->set_oop_recorder(_oop_recorder);
   _debug_recorder = new DebugInformationRecorder(_env->oop_recorder());
@@ -232,7 +239,6 @@
   _env->set_dependencies(_dependencies);
   buffer.initialize_oop_recorder(_oop_recorder);
 
-  buffer.initialize_consts_size(_constants_size);
   _instructions = buffer.insts();
   _constants = buffer.consts();
 
@@ -498,7 +504,7 @@
       }
       case MARK_INVOKE_INVALID:
       default:
-        fatal("invalid _next_call_type value")
+        fatal("invalid _next_call_type value");
         break;
     }
   }
@@ -563,7 +569,7 @@
       break;
     }
     default:
-      fatal("unexpected CiKind in DataPatch")
+      fatal("unexpected CiKind in DataPatch");
       break;
   }
 }
@@ -645,7 +651,7 @@
         break;
       }
       default:
-        ShouldNotReachHere()
+        ShouldNotReachHere();
         break;
     }
   }
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -36,10 +36,13 @@
 // Initialization
 void C1XCompiler::initialize() {
   if (_initialized) return;
-  Thread* THREAD = Thread::current();
+  CompilerThread* THREAD = CompilerThread::current();
   _initialized = true;
   TRACE_C1X_1("C1XCompiler::initialize");
 
+  initialize_buffer_blob();
+  Runtime1::initialize(THREAD->get_buffer_blob());
+
   JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment();
   jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative");
   if (klass == NULL) {
@@ -66,6 +69,21 @@
   }
 }
 
+void C1XCompiler::initialize_buffer_blob() {
+
+  CompilerThread* THREAD = CompilerThread::current();
+  if (THREAD->get_buffer_blob() == NULL) {
+    // setup CodeBuffer.  Preallocate a BufferBlob of size
+    // NMethodSizeLimit plus some extra space for constants.
+    int code_buffer_size = Compilation::desired_max_code_buffer_size() +
+      Compilation::desired_max_constant_size();
+    BufferBlob* blob = BufferBlob::create("C1X temporary CodeBuffer",
+                                          code_buffer_size);
+    guarantee(blob != NULL, "must create code buffer");
+    THREAD->set_buffer_blob(blob);
+  }
+}
+
 // Compilation entry point for methods
 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
   initialize();
@@ -73,6 +91,7 @@
   ResourceMark rm;
   HandleMark hm;
 
+  initialize_buffer_blob();
   VmIds::initializeObjects();
 
   CompilerThread::current()->set_compiling(true);
@@ -156,7 +175,7 @@
     case 'r': return T_ADDRESS;
     case '-': return T_ILLEGAL;
     default:
-      fatal1("unexpected CiKind: %c", ch);
+      fatal(err_msg("unexpected CiKind: %c", ch));
       break;
   }
 }
--- a/src/share/vm/c1x/c1x_Compiler.hpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.hpp	Tue Nov 30 16:39:35 2010 +0100
@@ -62,6 +62,18 @@
   static oop createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS);
 
   static BasicType kindToBasicType(jchar ch);
+
+  static int to_cp_index_u2(int index) {
+    // Swap.
+    index = ((index & 0xFF) << 8) | (index >> 8);
+    // Tag.
+    index = index + constantPoolOopDesc::CPCACHE_INDEX_TAG;
+    return index;
+  }
+
+private:
+
+  void initialize_buffer_blob();
 };
 
 // Tracing macros
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -213,6 +213,7 @@
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
   VM_ENTRY_MARK;
 
+  index = C1XCompiler::to_cp_index_u2(index);
   constantPoolHandle cp = VmIds::get<constantPoolOop>(vmId);
 
   Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF);
@@ -252,6 +253,7 @@
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
   VM_ENTRY_MARK;
 
+  index = C1XCompiler::to_cp_index_u2(index);
   constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
 
   ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
--- a/src/share/vm/code/nmethod.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/code/nmethod.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -795,10 +795,10 @@
     // Exception handler and deopt handler are in the stub section
     if (UseC1X) {
       // c1x produces no stub section
-      _exception_offset        = instructions_offset() + offsets->value(CodeOffsets::Exceptions);
-      _deoptimize_offset       = instructions_offset() + offsets->value(CodeOffsets::Deopt);
+      _exception_offset        = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
+      _deoptimize_offset       = _stub_offset          + offsets->value(CodeOffsets::Deopt);
       if (has_method_handle_invokes()) {
-        _deoptimize_mh_offset    = instructions_offset() + offsets->value(CodeOffsets::DeoptMH);
+        _deoptimize_mh_offset  = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
       } else {
         _deoptimize_mh_offset  = -1;
       }
--- a/src/share/vm/compiler/compileBroker.cpp	Tue Nov 30 14:53:30 2010 +0100
+++ b/src/share/vm/compiler/compileBroker.cpp	Tue Nov 30 16:39:35 2010 +0100
@@ -531,7 +531,7 @@
 
   instanceKlass* klass = (instanceKlass*)SystemDictionary::Object_klass()->klass_part();
   methodOop method = klass->find_method(vmSymbols::object_initializer_name(), vmSymbols::void_method_signature());
-  CompileBroker::compile_method(method, -1, method, 0, "initial compile of object initializer", THREAD);
+  CompileBroker::compile_method(method, -1, 0, method, 0, "initial compile of object initializer", THREAD);
   if (HAS_PENDING_EXCEPTION) {
     CLEAR_PENDING_EXCEPTION;
     fatal("error inserting object initializer into compile queue");
@@ -542,8 +542,8 @@
     {
       HandleMark hm;
       ResourceMark rm;
-      MutexLocker locker(_method_queue->lock(), Thread::current());
-      if (_method_queue->is_empty()) {
+      MutexLocker locker(_c1_method_queue->lock(), Thread::current());
+      if (_c1_method_queue->is_empty()) {
         MutexLocker mu(Threads_lock); // grab Threads_lock
         JavaThread* current = Threads::first();
         bool compiling = false;
@@ -565,7 +565,7 @@
         }
       }
       if (TraceC1X >= 4) {
-        _method_queue->print();
+        _c1_method_queue->print();
       }
     }