7090259: Fix hotspot sources to build with old compilers
authorkvn
Tue, 13 Sep 2011 20:28:00 -0700
changeset 10537 23539f11e110
parent 10536 28111f5acd64
child 10553 e95834531c7d
7090259: Fix hotspot sources to build with old compilers Summary: Fixed warnings which prevent building VM with old compilers. Reviewed-by: never
hotspot/make/solaris/makefiles/sparcWorks.make
hotspot/src/share/vm/classfile/javaClasses.cpp
hotspot/src/share/vm/oops/instanceRefKlass.cpp
hotspot/src/share/vm/oops/methodOop.cpp
hotspot/src/share/vm/opto/block.cpp
--- a/hotspot/make/solaris/makefiles/sparcWorks.make	Tue Sep 13 16:58:35 2011 -0700
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make	Tue Sep 13 20:28:00 2011 -0700
@@ -148,6 +148,9 @@
 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 
+# Compiler warnings are treated as errors
+CFLAGS_WARN = -xwe
+
 ################################################
 # Begin current (>=5.9) Forte compiler options #
 #################################################
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Sep 13 16:58:35 2011 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Sep 13 20:28:00 2011 -0700
@@ -2701,7 +2701,7 @@
     instanceKlass* ik = instanceKlass::cast(k);
     methodOop m_normal   = ik->lookup_method(vmSymbols::setTargetNormal_name(),   vmSymbols::setTarget_signature());
     methodOop m_volatile = ik->lookup_method(vmSymbols::setTargetVolatile_name(), vmSymbols::setTarget_signature());
-    guarantee(m_normal && m_volatile, "must exist");
+    guarantee(m_normal != NULL && m_volatile != NULL, "must exist");
     m_normal->set_not_compilable_quietly();
     m_volatile->set_not_compilable_quietly();
   }
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Tue Sep 13 16:58:35 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Tue Sep 13 20:28:00 2011 -0700
@@ -45,7 +45,7 @@
 #endif
 
 template <class T>
-static void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
+void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
   T heap_oop = oopDesc::load_heap_oop(referent_addr);
   debug_only(
@@ -99,7 +99,7 @@
     oop discovered = java_lang_ref_Reference::discovered(obj);
     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
-                   obj));
+                   (oopDesc*)obj));
 #endif
   }
   // treat next as normal oop.  next is a link in the reference queue.
@@ -179,7 +179,7 @@
     oop discovered = java_lang_ref_Reference::discovered(obj);
     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
-                   obj));
+                   (oopDesc*)obj));
 #endif
   }
   PSParallelCompact::mark_and_push(cm, next_addr);
@@ -285,7 +285,7 @@
       T disc_oop = oopDesc::load_heap_oop(disc_addr);                           \
       assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),          \
            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \
-                   "discovered field", obj));                                   \
+                   "discovered field", (oopDesc*)obj));                                   \
     )                                                                           \
   }                                                                             \
   /* treat next as normal oop */                                                \
@@ -403,7 +403,7 @@
     oop discovered = java_lang_ref_Reference::discovered(obj);
     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
-                   obj));
+                   (oopDesc*)obj));
 #endif
   }
 
--- a/hotspot/src/share/vm/oops/methodOop.cpp	Tue Sep 13 16:58:35 2011 -0700
+++ b/hotspot/src/share/vm/oops/methodOop.cpp	Tue Sep 13 20:28:00 2011 -0700
@@ -1268,12 +1268,19 @@
 
 // Comparer for sorting an object array containing
 // methodOops.
-template <class T>
-static int method_comparator(T a, T b) {
+// Used non-template method_comparator methods since
+// Visual Studio 2003 compiler generates incorrect
+// optimized code for it.
+static int method_comparator_narrowOop(narrowOop a, narrowOop b) {
   methodOop m = (methodOop)oopDesc::decode_heap_oop_not_null(a);
   methodOop n = (methodOop)oopDesc::decode_heap_oop_not_null(b);
   return m->name()->fast_compare(n->name());
 }
+static int method_comparator_oop(oop a, oop b) {
+  methodOop m = (methodOop)a;
+  methodOop n = (methodOop)b;
+  return m->name()->fast_compare(n->name());
+}
 
 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
 void methodOopDesc::sort_methods(objArrayOop methods,
@@ -1299,9 +1306,9 @@
     {
       No_Safepoint_Verifier nsv;
       if (UseCompressedOops) {
-        QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator<narrowOop>, idempotent);
+        QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator_narrowOop, idempotent);
       } else {
-        QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator<oop>, idempotent);
+        QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator_oop, idempotent);
       }
       if (UseConcMarkSweepGC) {
         // For CMS we need to dirty the cards for the array
--- a/hotspot/src/share/vm/opto/block.cpp	Tue Sep 13 16:58:35 2011 -0700
+++ b/hotspot/src/share/vm/opto/block.cpp	Tue Sep 13 20:28:00 2011 -0700
@@ -1107,7 +1107,7 @@
 
 //------------------------------trace_frequency_order--------------------------
 // Comparison function for edges
-static int trace_frequency_order(const void *p0, const void *p1) {
+extern "C" int trace_frequency_order(const void *p0, const void *p1) {
   Trace *tr0 = *(Trace **) p0;
   Trace *tr1 = *(Trace **) p1;
   Block *b0 = tr0->first_block();