Merge
authorctornqvi
Fri, 01 Apr 2016 03:33:39 +0000
changeset 37223 85fec26392d7
parent 37222 1981bca3f428 (current diff)
parent 37221 f56daef767c3 (diff)
child 37224 fd3320bf6413
Merge
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -226,11 +226,12 @@
   return NULL;
 }
 
-ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() {
+ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append) : ClassPathEntry() {
   _zip = zip;
   char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass);
   strcpy(copy, zip_name);
   _zip_name = copy;
+  _is_boot_append = is_boot_append;
 }
 
 ClassPathZipEntry::~ClassPathZipEntry() {
@@ -274,11 +275,79 @@
   return buffer;
 }
 
+#if INCLUDE_CDS
+u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TRAPS) {
+  u1* buffer = NULL;
+  if (!_is_boot_append) {
+    assert(DumpSharedSpaces, "Should be called only for non-boot entries during dump time");
+    // We presume default is multi-release enabled
+    const char* multi_ver = Arguments::get_property("jdk.util.jar.enableMultiRelease");
+    const char* verstr = Arguments::get_property("jdk.util.jar.version");
+    bool is_multi_ver = (multi_ver == NULL ||
+                         strcmp(multi_ver, "true") == 0 ||
+                         strcmp(multi_ver, "force")  == 0) &&
+                         is_multiple_versioned(THREAD);
+    // command line version setting
+    int version = 0;
+    const int base_version = 8; // JDK8
+    int cur_ver = JDK_Version::current().major_version();
+    if (verstr != NULL) {
+      version = atoi(verstr);
+      if (version < base_version || version > cur_ver) {
+        is_multi_ver = false;
+        // print out warning, do not use assertion here since it will continue to look
+        // for proper version.
+        warning("JDK%d is not supported in multiple version jars", version);
+      }
+    }
+
+    if (is_multi_ver) {
+      int n;
+      char entry_name[JVM_MAXPATHLEN];
+      if (version > 0) {
+        n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", version, name);
+        entry_name[n] = '\0';
+        buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL);
+        if (buffer == NULL) {
+          warning("Could not find %s in %s, try to find highest version instead", entry_name, _zip_name);
+        }
+      }
+      if (buffer == NULL) {
+        for (int i = cur_ver; i >= base_version; i--) {
+          n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", i, name);
+          entry_name[n] = '\0';
+          buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL);
+          if (buffer != NULL) {
+            break;
+          }
+        }
+      }
+    }
+  }
+  return buffer;
+}
+
+bool ClassPathZipEntry::is_multiple_versioned(TRAPS) {
+  assert(DumpSharedSpaces, "called only at dump time");
+  jint size;
+  char* buffer = (char*)open_entry("META-INF/MANIFEST.MF", &size, false, CHECK_false);
+  if (buffer != NULL) {
+    if (strstr(buffer, "Multi-Release: true") != NULL) {
+      return true;
+    }
+  }
+  return false;
+}
+#endif // INCLUDE_CDS
+
 ClassFileStream* ClassPathZipEntry::open_stream(const char* name, TRAPS) {
   jint filesize;
-  const u1* buffer = open_entry(name, &filesize, false, CHECK_NULL);
+  u1* buffer = open_versioned_entry(name, &filesize, CHECK_NULL);
   if (buffer == NULL) {
-    return NULL;
+    buffer = open_entry(name, &filesize, false, CHECK_NULL);
+    if (buffer == NULL) {
+      return NULL;
+    }
   }
   if (UsePerfData) {
     ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize);
@@ -558,7 +627,7 @@
     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
     strncpy(path, &class_path[start], end - start);
     path[end - start] = '\0';
-    update_class_path_entry_list(path, false, mark_append_entry, false);
+    update_class_path_entry_list(path, false, mark_append_entry, false, bootstrap_search);
 
     // Check on the state of the boot loader's append path
     if (mark_append_entry && (_first_append_entry == NULL)) {
@@ -582,7 +651,8 @@
 }
 
 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st,
-                                                     bool throw_exception, TRAPS) {
+                                                     bool throw_exception,
+                                                     bool is_boot_append, TRAPS) {
   JavaThread* thread = JavaThread::current();
   ClassPathEntry* new_entry = NULL;
   if ((st->st_mode & S_IFREG) == S_IFREG) {
@@ -611,7 +681,7 @@
         zip = (*ZipOpen)(canonical_path, &error_msg);
       }
       if (zip != NULL && error_msg == NULL) {
-        new_entry = new ClassPathZipEntry(zip, path);
+        new_entry = new ClassPathZipEntry(zip, path, is_boot_append);
       } else {
         ResourceMark rm(thread);
         char *msg;
@@ -644,7 +714,7 @@
 
 // Create a class path zip entry for a given path (return NULL if not found
 // or zip/JAR file cannot be opened)
-ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
+ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bool is_boot_append) {
   // check for a regular file
   struct stat st;
   if (os::stat(path, &st) == 0) {
@@ -662,7 +732,7 @@
         }
         if (zip != NULL && error_msg == NULL) {
           // create using canonical path
-          return new ClassPathZipEntry(zip, canonical_path);
+          return new ClassPathZipEntry(zip, canonical_path, is_boot_append);
         }
       }
     }
@@ -720,11 +790,11 @@
 }
 
 void ClassLoader::add_to_list(const char *apath) {
-  update_class_path_entry_list((char*)apath, false, false, false);
+  update_class_path_entry_list((char*)apath, false, false, false, false);
 }
 
 void ClassLoader::prepend_to_list(const char *apath) {
-  update_class_path_entry_list((char*)apath, false, false, true);
+  update_class_path_entry_list((char*)apath, false, false, true, false);
 }
 
 // Returns true IFF the file/dir exists and the entry was successfully created.
@@ -732,13 +802,14 @@
                                                bool check_for_duplicates,
                                                bool mark_append_entry,
                                                bool prepend_entry,
+                                               bool is_boot_append,
                                                bool throw_exception) {
   struct stat st;
   if (os::stat(path, &st) == 0) {
     // File or directory found
     ClassPathEntry* new_entry = NULL;
     Thread* THREAD = Thread::current();
-    new_entry = create_class_path_entry(path, &st, throw_exception, CHECK_(false));
+    new_entry = create_class_path_entry(path, &st, throw_exception, is_boot_append, CHECK_(false));
     if (new_entry == NULL) {
       return false;
     }
--- a/hotspot/src/share/vm/classfile/classLoader.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -104,16 +104,19 @@
  private:
   jzfile* _zip;              // The zip archive
   const char*   _zip_name;   // Name of zip archive
+  bool _is_boot_append;      // entry coming from -Xbootclasspath/a
  public:
   bool is_jrt()            { return false; }
   bool is_jar_file() const { return true;  }
   const char* name() const { return _zip_name; }
   JImageFile* jimage() const { return NULL; }
-  ClassPathZipEntry(jzfile* zip, const char* zip_name);
+  ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append);
   ~ClassPathZipEntry();
   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
+  u1* open_versioned_entry(const char* name, jint* filesize, TRAPS) NOT_CDS_RETURN_(NULL);
   ClassFileStream* open_stream(const char* name, TRAPS);
   void contents_do(void f(const char* name, void* context), void* context);
+  bool is_multiple_versioned(TRAPS) NOT_CDS_RETURN_(false);
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
 };
@@ -223,7 +226,8 @@
   static void load_zip_library();
   static void load_jimage_library();
   static ClassPathEntry* create_class_path_entry(const char *path, const struct stat* st,
-                                                 bool throw_exception, TRAPS);
+                                                 bool throw_exception,
+                                                 bool is_boot_append, TRAPS);
 
  public:
 
@@ -249,6 +253,7 @@
                                            bool check_for_duplicates,
                                            bool mark_append_entry,
                                            bool prepend_entry,
+                                           bool is_boot_append,
                                            bool throw_exception=true);
   static void print_bootclasspath();
 
@@ -394,7 +399,7 @@
   static void prepend_to_list(ClassPathEntry* new_entry);
 
   // creates a class path zip entry (returns NULL if JAR file cannot be opened)
-  static ClassPathZipEntry* create_class_path_zip_entry(const char *apath);
+  static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
 
   // add a path to class path list
   static void add_to_list(const char* apath);
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -626,6 +626,7 @@
 
   NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;)
   _gc_counters = new CollectorCounters("CMS", 1);
+  _cgc_counters = new CollectorCounters("CMS stop-the-world phases", 2);
   _completed_initialization = true;
   _inter_sweep_timer.start();  // start of time
 }
@@ -5546,18 +5547,18 @@
 
 void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) {
   GCTraceCPUTime tcpu;
-  TraceCollectorStats tcs(counters());
+  TraceCollectorStats tcs(cgc_counters());
 
   switch (op) {
     case CMS_op_checkpointRootsInitial: {
       GCTraceTime(Info, gc) t("Pause Initial Mark", NULL, GCCause::_no_gc, true);
-      SvcGCMarker sgcm(SvcGCMarker::OTHER);
+      SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
       checkpointRootsInitial();
       break;
     }
     case CMS_op_checkpointRootsFinal: {
       GCTraceTime(Info, gc) t("Pause Remark", NULL, GCCause::_no_gc, true);
-      SvcGCMarker sgcm(SvcGCMarker::OTHER);
+      SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
       checkpointRootsFinal();
       break;
     }
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -555,6 +555,7 @@
 
   // Performance Counters
   CollectorCounters* _gc_counters;
+  CollectorCounters* _cgc_counters;
 
   // Initialization Errors
   bool _completed_initialization;
@@ -929,7 +930,8 @@
   NOT_PRODUCT(bool is_cms_reachable(HeapWord* addr);)
 
   // Performance Counter Support
-  CollectorCounters* counters()    { return _gc_counters; }
+  CollectorCounters* counters()     { return _gc_counters; }
+  CollectorCounters* cgc_counters() { return _cgc_counters; }
 
   // Timer stuff
   void    startTimer() { assert(!_timer.is_active(), "Error"); _timer.start();   }
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -3228,7 +3228,7 @@
                                                                   Threads::number_of_non_daemon_threads());
     workers()->set_active_workers(active_workers);
 
-    g1_policy()->note_gc_start(active_workers);
+    g1_policy()->note_gc_start();
 
     TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
     TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -186,8 +186,8 @@
   _collection_set->start_incremental_building();
 }
 
-void G1CollectorPolicy::note_gc_start(uint num_active_workers) {
-  phase_times()->note_gc_start(num_active_workers);
+void G1CollectorPolicy::note_gc_start() {
+  phase_times()->note_gc_start();
 }
 
 // Create the jstat counters for the policy.
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -317,7 +317,7 @@
 
   void init();
 
-  virtual void note_gc_start(uint num_active_workers);
+  virtual void note_gc_start();
 
   // Create jstat counters for the policy.
   virtual void initialize_gc_policy_counters();
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1072,8 +1072,6 @@
     return;
   }
 
-  SvcGCMarker sgcm(SvcGCMarker::OTHER);
-
   if (VerifyDuringGC) {
     HandleMark hm;  // handle scope
     g1h->prepare_for_verify();
--- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -33,7 +33,7 @@
 #include "runtime/timer.hpp"
 #include "runtime/os.hpp"
 
-static const char* Indents[5] = {"", "  ", "    ", "     ", "       "};
+static const char* Indents[5] = {"", "  ", "    ", "      ", "        "};
 
 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
   _max_gc_threads(max_gc_threads)
@@ -94,11 +94,8 @@
   _gc_par_phases[PreserveCMReferents] = new WorkerDataArray<double>(max_gc_threads, "Parallel Preserve CM Refs (ms):");
 }
 
-void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
-  assert(active_gc_threads > 0, "The number of threads must be > 0");
-  assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max number of threads");
+void G1GCPhaseTimes::note_gc_start() {
   _gc_start_counter = os::elapsed_counter();
-  _active_gc_threads = active_gc_threads;
   _cur_expand_heap_time_ms = 0.0;
   _external_accounted_time_ms = 0.0;
 
@@ -109,31 +106,55 @@
   }
 }
 
+#define ASSERT_PHASE_UNINITIALIZED(phase) \
+    assert(_gc_par_phases[phase]->get(i) == uninitialized, "Phase " #phase " reported for thread that was not started");
+
+double G1GCPhaseTimes::worker_time(GCParPhases phase, uint worker) {
+  double value = _gc_par_phases[phase]->get(worker);
+  if (value != WorkerDataArray<double>::uninitialized()) {
+    return value;
+  }
+  return 0.0;
+}
+
 void G1GCPhaseTimes::note_gc_end() {
   _gc_pause_time_ms = TimeHelper::counter_to_millis(os::elapsed_counter() - _gc_start_counter);
-  for (uint i = 0; i < _active_gc_threads; i++) {
-    double worker_time = _gc_par_phases[GCWorkerEnd]->get(i) - _gc_par_phases[GCWorkerStart]->get(i);
-    record_time_secs(GCWorkerTotal, i , worker_time);
+
+  double uninitialized = WorkerDataArray<double>::uninitialized();
+
+  for (uint i = 0; i < _max_gc_threads; i++) {
+    double worker_start = _gc_par_phases[GCWorkerStart]->get(i);
+    if (worker_start != uninitialized) {
+      assert(_gc_par_phases[GCWorkerEnd]->get(i) != uninitialized, "Worker started but not ended.");
+      double total_worker_time = _gc_par_phases[GCWorkerEnd]->get(i) - _gc_par_phases[GCWorkerStart]->get(i);
+      record_time_secs(GCWorkerTotal, i , total_worker_time);
 
-    double worker_known_time =
-        _gc_par_phases[ExtRootScan]->get(i) +
-        _gc_par_phases[SATBFiltering]->get(i) +
-        _gc_par_phases[UpdateRS]->get(i) +
-        _gc_par_phases[ScanRS]->get(i) +
-        _gc_par_phases[CodeRoots]->get(i) +
-        _gc_par_phases[ObjCopy]->get(i) +
-        _gc_par_phases[Termination]->get(i);
+      double worker_known_time =
+          worker_time(ExtRootScan, i)
+          + worker_time(SATBFiltering, i)
+          + worker_time(UpdateRS, i)
+          + worker_time(ScanRS, i)
+          + worker_time(CodeRoots, i)
+          + worker_time(ObjCopy, i)
+          + worker_time(Termination, i);
 
-    record_time_secs(Other, i, worker_time - worker_known_time);
-  }
-
-  for (int i = 0; i < GCParPhasesSentinel; i++) {
-    if (_gc_par_phases[i] != NULL) {
-      _gc_par_phases[i]->verify(_active_gc_threads);
+      record_time_secs(Other, i, total_worker_time - worker_known_time);
+    } else {
+      // Make sure all slots are uninitialized since this thread did not seem to have been started
+      ASSERT_PHASE_UNINITIALIZED(GCWorkerEnd);
+      ASSERT_PHASE_UNINITIALIZED(ExtRootScan);
+      ASSERT_PHASE_UNINITIALIZED(SATBFiltering);
+      ASSERT_PHASE_UNINITIALIZED(UpdateRS);
+      ASSERT_PHASE_UNINITIALIZED(ScanRS);
+      ASSERT_PHASE_UNINITIALIZED(CodeRoots);
+      ASSERT_PHASE_UNINITIALIZED(ObjCopy);
+      ASSERT_PHASE_UNINITIALIZED(Termination);
     }
   }
 }
 
+#undef ASSERT_PHASE_UNINITIALIZED
+
 // record the time a phase took in seconds
 void G1GCPhaseTimes::record_time_secs(GCParPhases phase, uint worker_i, double secs) {
   _gc_par_phases[phase]->set(worker_i, secs);
@@ -150,12 +171,12 @@
 
 // return the average time for a phase in milliseconds
 double G1GCPhaseTimes::average_time_ms(GCParPhases phase) {
-  return _gc_par_phases[phase]->average(_active_gc_threads) * 1000.0;
+  return _gc_par_phases[phase]->average() * 1000.0;
 }
 
 size_t G1GCPhaseTimes::sum_thread_work_items(GCParPhases phase) {
   assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
-  return _gc_par_phases[phase]->thread_work_items()->sum(_active_gc_threads);
+  return _gc_par_phases[phase]->thread_work_items()->sum();
 }
 
 template <class T>
@@ -164,19 +185,19 @@
   if (log.is_level(LogLevel::Trace)) {
     outputStream* trace_out = log.trace_stream();
     trace_out->print("%s", indent);
-    phase->print_details_on(trace_out, _active_gc_threads);
+    phase->print_details_on(trace_out);
   }
 }
 
 void G1GCPhaseTimes::log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) {
   out->print("%s", Indents[indent]);
-  phase->print_summary_on(out, _active_gc_threads, print_sum);
+  phase->print_summary_on(out, print_sum);
   details(phase, Indents[indent]);
 
   WorkerDataArray<size_t>* work_items = phase->thread_work_items();
   if (work_items != NULL) {
     out->print("%s", Indents[indent + 1]);
-    work_items->print_summary_on(out, _active_gc_threads, true);
+    work_items->print_summary_on(out, true);
     details(work_items, Indents[indent + 1]);
   }
 }
--- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -32,7 +32,6 @@
 template <class T> class WorkerDataArray;
 
 class G1GCPhaseTimes : public CHeapObj<mtGC> {
-  uint _active_gc_threads;
   uint _max_gc_threads;
   jlong _gc_start_counter;
   double _gc_pause_time_ms;
@@ -123,6 +122,7 @@
   double _cur_verify_before_time_ms;
   double _cur_verify_after_time_ms;
 
+  double worker_time(GCParPhases phase, uint worker);
   void note_gc_end();
 
   template <class T>
@@ -133,7 +133,7 @@
 
  public:
   G1GCPhaseTimes(uint max_gc_threads);
-  void note_gc_start(uint active_gc_threads);
+  void note_gc_start();
   void print();
 
   // record the time a phase took in seconds
--- a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -76,6 +76,7 @@
   _g1h(g1h),
   _incremental_collection_counters(NULL),
   _full_collection_counters(NULL),
+  _conc_collection_counters(NULL),
   _old_collection_counters(NULL),
   _old_space_counters(NULL),
   _young_collection_counters(NULL),
@@ -104,6 +105,9 @@
   // old generation collection.
   _full_collection_counters =
     new CollectorCounters("G1 stop-the-world full collections", 1);
+  // name "collector.2". STW phases as part of a concurrent collection.
+  _conc_collection_counters =
+    new CollectorCounters("G1 stop-the-world phases", 2);
 
   // timer sampling for all counters supporting sampling only update the
   // used value.  See the take_sample() method.  G1 requires both used and
--- a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -122,6 +122,8 @@
   CollectorCounters*   _incremental_collection_counters;
   //  full stop-the-world collections
   CollectorCounters*   _full_collection_counters;
+  //  stop-the-world phases in G1
+  CollectorCounters*   _conc_collection_counters;
   //  young collection set counters.  The _eden_counters,
   // _from_counters, and _to_counters are associated with
   // this "generational" counter.
@@ -210,6 +212,9 @@
   CollectorCounters* full_collection_counters() {
     return _full_collection_counters;
   }
+  CollectorCounters* conc_collection_counters() {
+    return _conc_collection_counters;
+  }
   GenerationCounters* young_collection_counters() {
     return _young_collection_counters;
   }
--- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -217,6 +217,8 @@
   GCTraceCPUTime tcpu;
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   GCTraceTime(Info, gc) t(_printGCMessage, g1h->concurrent_mark()->gc_timer_cm(), GCCause::_no_gc, true);
+  TraceCollectorStats tcs(g1h->g1mm()->conc_collection_counters());
+  SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
   IsGCActiveMark x;
   _cl->do_void();
 }
--- a/hotspot/src/share/vm/gc/g1/workerDataArray.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/workerDataArray.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,67 +27,178 @@
 #include "utilities/ostream.hpp"
 
 template <>
-void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, const char* title, double min, double avg, double max, double diff, double sum, bool print_sum) {
-  out->print("%-25s Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", title, min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
+size_t WorkerDataArray<size_t>::uninitialized() {
+  return (size_t)-1;
+}
+
+template <>
+double WorkerDataArray<double>::uninitialized() {
+  return -1.0;
+}
+
+template <>
+void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum) {
+  out->print(" Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
   if (print_sum) {
-    out->print_cr(", Sum: %4.1lf", sum * MILLIUNITS);
-  } else {
-    out->cr();
+    out->print(", Sum: %4.1lf", sum * MILLIUNITS);
   }
 }
 
 template <>
-void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, const char* title, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) {
-  out->print("%-25s Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, title, min, avg, max, diff);
+void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) {
+  out->print(" Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, min, avg, max, diff);
   if (print_sum) {
-    out->print_cr(", Sum: " SIZE_FORMAT, sum);
-  } else {
-    out->cr();
+    out->print(", Sum: " SIZE_FORMAT, sum);
   }
 }
 
 template <>
-void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>* phase, outputStream* out, uint active_threads) {
+void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>* phase, outputStream* out) {
   out->print("%-25s", "");
-  for (uint i = 0; i < active_threads; ++i) {
-    out->print(" %4.1lf", phase->get(i) * 1000.0);
+  for (uint i = 0; i < phase->_length; ++i) {
+    double value = phase->get(i);
+    if (value != phase->uninitialized()) {
+      out->print(" %4.1lf", phase->get(i) * 1000.0);
+    } else {
+      out->print(" -");
+    }
   }
   out->cr();
 }
 
 template <>
-void WorkerDataArray<size_t>::WDAPrinter::details(const WorkerDataArray<size_t>* phase, outputStream* out, uint active_threads) {
+void WorkerDataArray<size_t>::WDAPrinter::details(const WorkerDataArray<size_t>* phase, outputStream* out) {
   out->print("%-25s", "");
-  for (uint i = 0; i < active_threads; ++i) {
-    out->print("  " SIZE_FORMAT, phase->get(i));
+  for (uint i = 0; i < phase->_length; ++i) {
+    size_t value = phase->get(i);
+    if (value != phase->uninitialized()) {
+      out->print("  " SIZE_FORMAT, phase->get(i));
+    } else {
+      out->print(" -");
+    }
   }
   out->cr();
 }
 
 #ifndef PRODUCT
-void WorkerDataArray_test() {
-  const uint length = 3;
-  const char* title = "Test array";
+
+#include "memory/resourceArea.hpp"
+
+void WorkerDataArray_test_verify_string(const char* expected_string, const char* actual_string) {
+  const size_t expected_len = strlen(expected_string);
+
+  assert(expected_len == strlen(actual_string),
+      "Wrong string length, expected " SIZE_FORMAT " but got " SIZE_FORMAT "(Expected '%s' but got: '%s')",
+      expected_len, strlen(actual_string), expected_string, actual_string);
 
-  WorkerDataArray<size_t> array(length, title);
-  assert(strncmp(array.title(), title, strlen(title)) == 0 , "Expected titles to match");
+  // Can't use strncmp here because floating point values use different decimal points for different locales.
+  // Allow strings to differ in "." vs. "," only. This should still catch most errors.
+  for (size_t i = 0; i < expected_len; i++) {
+    char e = expected_string[i];
+    char a = actual_string[i];
+    if (e != a) {
+      if ((e == '.' || e == ',') && (a == '.' || a == ',')) {
+        // Most likely just a difference in locale
+      } else {
+        assert(false, "Expected '%s' but got: '%s'", expected_string, actual_string);
+      }
+    }
+  }
+}
+
+void WorkerDataArray_test_verify_array(WorkerDataArray<size_t>& array, size_t expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
+  const double epsilon = 0.0001;
+  assert(array.sum() == expected_sum, "Wrong sum, expected: " SIZE_FORMAT " but got: " SIZE_FORMAT, expected_sum, array.sum());
+  assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
 
-  const size_t expected[length] = {5, 3, 7};
-  for (uint i = 0; i < length; i++) {
-    array.set(i, expected[i]);
-  }
-  for (uint i = 0; i < length; i++) {
-    assert(array.get(i) == expected[i], "Expected elements to match");
+  ResourceMark rm;
+  stringStream out;
+  array.print_summary_on(&out);
+  WorkerDataArray_test_verify_string(expected_summary, out.as_string());
+  out.reset();
+  array.print_details_on(&out);
+  WorkerDataArray_test_verify_string(exected_details, out.as_string());
+}
+
+void WorkerDataArray_test_verify_array(WorkerDataArray<double>& array, double expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
+  const double epsilon = 0.0001;
+  assert(fabs(array.sum() - expected_sum) < epsilon, "Wrong sum, expected: %f but got: %f", expected_sum, array.sum());
+  assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
+
+  ResourceMark rm;
+  stringStream out;
+  array.print_summary_on(&out);
+  WorkerDataArray_test_verify_string(expected_summary, out.as_string());
+  out.reset();
+  array.print_details_on(&out);
+  WorkerDataArray_test_verify_string(exected_details, out.as_string());
+}
+
+void WorkerDataArray_test_basic() {
+  WorkerDataArray<size_t> array(3, "Test array");
+  array.set(0, 5);
+  array.set(1, 3);
+  array.set(2, 7);
+
+  WorkerDataArray_test_verify_array(array, 15, 5.0,
+      "Test array                Min: 3, Avg:  5.0, Max: 7, Diff: 4, Sum: 15, Workers: 3\n",
+      "                           5  3  7\n" );
+}
+
+void WorkerDataArray_test_add() {
+  WorkerDataArray<size_t> array(3, "Test array");
+  array.set(0, 5);
+  array.set(1, 3);
+  array.set(2, 7);
+
+  for (uint i = 0; i < 3; i++) {
+    array.add(i, 1);
   }
 
-  assert(array.sum(length) == (5 + 3 + 7), "Expected sums to match");
-  assert(array.average(length) == 5.0, "Expected averages to match");
+  WorkerDataArray_test_verify_array(array, 18, 6.0,
+      "Test array                Min: 4, Avg:  6.0, Max: 8, Diff: 4, Sum: 18, Workers: 3\n",
+      "                           6  4  8\n" );
+}
+
+void WorkerDataArray_test_with_uninitialized() {
+  WorkerDataArray<size_t> array(3, "Test array");
+  array.set(0, 5);
+  array.set(1, WorkerDataArray<size_t>::uninitialized());
+  array.set(2, 7);
+
+  WorkerDataArray_test_verify_array(array, 12, 6,
+      "Test array                Min: 5, Avg:  6.0, Max: 7, Diff: 2, Sum: 12, Workers: 2\n",
+      "                           5 -  7\n" );
+}
+
+void WorkerDataArray_test_uninitialized() {
+  WorkerDataArray<size_t> array(3, "Test array");
+  array.set(0, WorkerDataArray<size_t>::uninitialized());
+  array.set(1, WorkerDataArray<size_t>::uninitialized());
+  array.set(2, WorkerDataArray<size_t>::uninitialized());
 
-  for (uint i = 0; i < length; i++) {
-    array.add(i, 1);
-  }
-  for (uint i = 0; i < length; i++) {
-    assert(array.get(i) == expected[i] + 1, "Expected add to increment values");
-  }
+  WorkerDataArray_test_verify_array(array, 0, 0.0,
+      "Test array                skipped\n",
+      "                          - - -\n" );
 }
+
+void WorkerDataArray_test_double_with_uninitialized() {
+  WorkerDataArray<double> array(3, "Test array");
+  array.set(0, 5.1 / MILLIUNITS);
+  array.set(1, WorkerDataArray<double>::uninitialized());
+  array.set(2, 7.2 / MILLIUNITS);
+
+  WorkerDataArray_test_verify_array(array, 12.3 / MILLIUNITS, 6.15 / MILLIUNITS,
+      "Test array                Min:  5.1, Avg:  6.1, Max:  7.2, Diff:  2.1, Sum: 12.3, Workers: 2\n",
+      "                           5.1 -  7.2\n" );
+}
+
+void WorkerDataArray_test() {
+  WorkerDataArray_test_basic();
+  WorkerDataArray_test_add();
+  WorkerDataArray_test_with_uninitialized();
+  WorkerDataArray_test_uninitialized();
+  WorkerDataArray_test_double_with_uninitialized();
+}
+
 #endif
--- a/hotspot/src/share/vm/gc/g1/workerDataArray.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/workerDataArray.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,16 +32,13 @@
 
 template <class T>
 class WorkerDataArray  : public CHeapObj<mtGC> {
+  friend class WDAPrinter;
   T*          _data;
   uint        _length;
   const char* _title;
 
   WorkerDataArray<size_t>* _thread_work_items;
 
-  NOT_PRODUCT(inline T uninitialized() const;)
-
-  void set_all(T value);
-
  public:
   WorkerDataArray(uint length, const char* title);
   ~WorkerDataArray();
@@ -52,37 +49,38 @@
     return _thread_work_items;
   }
 
+  static T uninitialized();
+
   void set(uint worker_i, T value);
   T get(uint worker_i) const;
 
   void add(uint worker_i, T value);
 
-  double average(uint active_threads) const;
-  T sum(uint active_threads) const;
+  // The sum() and average() methods below consider uninitialized slots to be 0.
+  double average() const;
+  T sum() const;
 
   const char* title() const {
     return _title;
   }
 
-  void clear();
-
-  void reset() PRODUCT_RETURN;
-  void verify(uint active_threads) const PRODUCT_RETURN;
+  void reset();
+  void set_all(T value);
 
 
  private:
   class WDAPrinter {
   public:
-    static void summary(outputStream* out, const char* title, double min, double avg, double max, double diff, double sum, bool print_sum);
-    static void summary(outputStream* out, const char* title, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum);
+    static void summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum);
+    static void summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum);
 
-    static void details(const WorkerDataArray<double>* phase, outputStream* out, uint active_threads);
-    static void details(const WorkerDataArray<size_t>* phase, outputStream* out, uint active_threads);
+    static void details(const WorkerDataArray<double>* phase, outputStream* out);
+    static void details(const WorkerDataArray<size_t>* phase, outputStream* out);
   };
 
  public:
-  void print_summary_on(outputStream* out, uint active_threads, bool print_sum = true) const;
-  void print_details_on(outputStream* out, uint active_threads) const;
+  void print_summary_on(outputStream* out, bool print_sum = true) const;
+  void print_details_on(outputStream* out) const;
 };
 
 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_HPP
--- a/hotspot/src/share/vm/gc/g1/workerDataArray.inline.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/workerDataArray.inline.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,6 @@
 template <typename T>
 T WorkerDataArray<T>::get(uint worker_i) const {
   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
-  assert(_data[worker_i] != uninitialized(), "No data added for worker %d", worker_i);
   return _data[worker_i];
 }
 
@@ -78,25 +77,31 @@
 }
 
 template <typename T>
-double WorkerDataArray<T>::average(uint active_threads) const {
-  return sum(active_threads) / (double) active_threads;
+double WorkerDataArray<T>::average() const {
+  uint contributing_threads = 0;
+  for (uint i = 0; i < _length; ++i) {
+    if (get(i) != uninitialized()) {
+      contributing_threads++;
+    }
+  }
+  if (contributing_threads == 0) {
+    return 0.0;
+  }
+  return sum() / (double) contributing_threads;
 }
 
 template <typename T>
-T WorkerDataArray<T>::sum(uint active_threads) const {
-  T s = get(0);
-  for (uint i = 1; i < active_threads; ++i) {
-    s += get(i);
+T WorkerDataArray<T>::sum() const {
+  T s = 0;
+  for (uint i = 0; i < _length; ++i) {
+    if (get(i) != uninitialized()) {
+      s += get(i);
+    }
   }
   return s;
 }
 
 template <typename T>
-void WorkerDataArray<T>::clear() {
-  set_all(0);
-}
-
-template <typename T>
 void WorkerDataArray<T>::set_all(T value) {
   for (uint i = 0; i < _length; i++) {
     _data[i] = value;
@@ -104,27 +109,42 @@
 }
 
 template <class T>
-void WorkerDataArray<T>::print_summary_on(outputStream* out, uint active_threads, bool print_sum) const {
-  T max = get(0);
-  T min = max;
-  T sum = 0;
-  for (uint i = 1; i < active_threads; ++i) {
-    T value = get(i);
-    max = MAX2(max, value);
-    min = MIN2(min, value);
-    sum += value;
+void WorkerDataArray<T>::print_summary_on(outputStream* out, bool print_sum) const {
+  out->print("%-25s", title());
+  uint start = 0;
+  while (start < _length && get(start) == uninitialized()) {
+    start++;
   }
-  T diff = max - min;
-  double avg = sum / (double) active_threads;
-  WDAPrinter::summary(out, title(), min, avg, max, diff, sum, print_sum);
+  if (start < _length) {
+    T min = get(start);
+    T max = min;
+    T sum = 0;
+    uint contributing_threads = 0;
+    for (uint i = start; i < _length; ++i) {
+      T value = get(i);
+      if (value != uninitialized()) {
+        max = MAX2(max, value);
+        min = MIN2(min, value);
+        sum += value;
+        contributing_threads++;
+      }
+    }
+    T diff = max - min;
+    assert(contributing_threads != 0, "Must be since we found a used value for the start index");
+    double avg = sum / (double) contributing_threads;
+    WDAPrinter::summary(out, min, avg, max, diff, sum, print_sum);
+    out->print_cr(", Workers: %d", contributing_threads);
+  } else {
+    // No data for this phase.
+    out->print_cr(" skipped");
+  }
 }
 
 template <class T>
-void WorkerDataArray<T>::print_details_on(outputStream* out, uint active_threads) const {
-  WDAPrinter::details(this, out, active_threads);
+void WorkerDataArray<T>::print_details_on(outputStream* out) const {
+  WDAPrinter::details(this, out);
 }
 
-#ifndef PRODUCT
 template <typename T>
 void WorkerDataArray<T>::reset() {
   set_all(uninitialized());
@@ -133,27 +153,4 @@
   }
 }
 
-template <typename T>
-void WorkerDataArray<T>::verify(uint active_threads) const {
-  assert(active_threads <= _length, "Wrong number of active threads");
-  for (uint i = 0; i < active_threads; i++) {
-    assert(_data[i] != uninitialized(),
-           "Invalid data for worker %u in '%s'", i, _title);
-  }
-  if (_thread_work_items != NULL) {
-    _thread_work_items->verify(active_threads);
-  }
-}
-
-template <>
-inline size_t WorkerDataArray<size_t>::uninitialized() const {
-  return (size_t)-1;
-}
-
-template <>
-inline double WorkerDataArray<double>::uninitialized() const {
-  return -1.0;
-}
-#endif
-
 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
--- a/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -235,7 +235,7 @@
  private:
   JvmtiGCMarker _jgcm;
  public:
-  typedef enum { MINOR, FULL, OTHER } reason_type;
+  typedef enum { MINOR, FULL, CONCURRENT, OTHER } reason_type;
 
   SvcGCMarker(reason_type reason ) {
     VM_GC_Operation::notify_gc_begin(reason == FULL);
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -152,7 +152,7 @@
     _active_workers = MAX2(1U, _active_workers);
     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
            "Unless dynamic should use total workers");
-    log_info(gc, task)("GC Workers: %d", _active_workers);
+    log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers);
   }
 
   // Return the Ith worker.
--- a/hotspot/src/share/vm/logging/logTag.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -34,6 +34,7 @@
 #define LOG_TAG_LIST \
   LOG_TAG(alloc) \
   LOG_TAG(age) \
+  LOG_TAG(arguments) \
   LOG_TAG(barrier) \
   LOG_TAG(biasedlocking) \
   LOG_TAG(bot) \
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -476,7 +476,7 @@
     // terminating the VM so we check one more time.
 
     // create the zip entry
-    ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
+    ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, true);
     if (zip_entry == NULL) {
       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
     }
@@ -520,7 +520,7 @@
 
     // create the zip entry (which will open the zip file and hence
     // check that the segment is indeed a zip file).
-    ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
+    ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, false);
     if (zip_entry == NULL) {
       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
     }
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -994,10 +994,35 @@
   return NULL;
 }
 
-AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name){
+void log_deprecated_flag(const char* name, bool on, AliasedLoggingFlag alf) {
+  LogTagType tagSet[] = {alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5};
+  // Set tagset string buffer at max size of 256, large enough for any alias tagset
+  const int max_tagset_size = 256;
+  int max_tagset_len = max_tagset_size - 1;
+  char tagset_buffer[max_tagset_size];
+  tagset_buffer[0] = '\0';
+
+  // Write tag-set for aliased logging option, in string list form
+  int max_tags = sizeof(tagSet)/sizeof(tagSet[0]);
+  for (int i = 0; i < max_tags && tagSet[i] != LogTag::__NO_TAG; i++) {
+    if (i > 0) {
+      strncat(tagset_buffer, ",", max_tagset_len - strlen(tagset_buffer));
+    }
+    strncat(tagset_buffer, LogTag::name(tagSet[i]), max_tagset_len - strlen(tagset_buffer));
+  }
+
+  log_warning(arguments)("-XX:%s%s is deprecated. Will use -Xlog:%s=%s instead.",
+                         (on) ? "+" : "-",
+                         name,
+                         tagset_buffer,
+                         (on) ? LogLevel::name(alf.level) : "off");
+}
+
+AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name, bool on){
   for (size_t i = 0; aliased_logging_flags[i].alias_name != NULL; i++) {
     const AliasedLoggingFlag& alf = aliased_logging_flags[i];
     if (strcmp(alf.alias_name, name) == 0) {
+      log_deprecated_flag(name, on, alf);
       return alf;
     }
   }
@@ -1016,7 +1041,7 @@
   bool warn_if_deprecated = true;
 
   if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
-    AliasedLoggingFlag alf = catch_logging_aliases(name);
+    AliasedLoggingFlag alf = catch_logging_aliases(name, false);
     if (alf.alias_name != NULL){
       LogConfiguration::configure_stdout(LogLevel::Off, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5);
       return true;
@@ -1028,7 +1053,7 @@
     return set_bool_flag(real_name, false, origin);
   }
   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
-    AliasedLoggingFlag alf = catch_logging_aliases(name);
+    AliasedLoggingFlag alf = catch_logging_aliases(name, true);
     if (alf.alias_name != NULL){
       LogConfiguration::configure_stdout(alf.level, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5);
       return true;
@@ -1244,8 +1269,9 @@
     else {
       const char* replacement;
       if ((replacement = removed_develop_logging_flag_name(stripped_argname)) != NULL){
-        jio_fprintf(defaultStream::error_stream(),
-                  "%s has been removed. Please use %s instead.\n", stripped_argname, replacement);
+        log_warning(arguments)("%s has been removed. Please use %s instead.",
+                               stripped_argname,
+                               replacement);
         return false;
       }
     }
--- a/hotspot/src/share/vm/runtime/arguments.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -526,7 +526,7 @@
   // Return NULL if the arg has expired.
   static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
   static bool lookup_logging_aliases(const char* arg, char* buffer);
-  static AliasedLoggingFlag catch_logging_aliases(const char* name);
+  static AliasedLoggingFlag catch_logging_aliases(const char* name, bool on);
   static short  CompileOnlyClassesNum;
   static short  CompileOnlyClassesMax;
   static char** CompileOnlyClasses;
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -130,3 +130,36 @@
     return Flag::SUCCESS;
   }
 }
+
+static inline Flag::Error sharedConstraintFunc(const char *name, size_t value, size_t taken, bool verbose) {
+  size_t available = (MAX_SHARED_DELTA-(taken+SHARED_PAGE));
+  if (value > available) {
+    CommandLineError::print(verbose,
+                            "%s (" SIZE_FORMAT ") must be "
+                            "smaller than or equal to (" SIZE_FORMAT ")\n",
+                            name, value, available);
+    return Flag::VIOLATES_CONSTRAINT;
+  } else {
+    return Flag::SUCCESS;
+  }
+}
+
+Flag::Error SharedReadWriteSizeConstraintFunc(size_t value, bool verbose) {
+  size_t taken = (SharedReadOnlySize+SharedMiscDataSize+SharedMiscCodeSize);
+  return sharedConstraintFunc("SharedReadWriteSize", value, taken, verbose);
+}
+
+Flag::Error SharedReadOnlySizeConstraintFunc(size_t value, bool verbose) {
+  size_t taken = (SharedReadWriteSize+SharedMiscDataSize+SharedMiscCodeSize);
+  return sharedConstraintFunc("SharedReadOnlySize", value, taken, verbose);
+}
+
+Flag::Error SharedMiscDataSizeConstraintFunc(size_t value, bool verbose) {
+  size_t taken = (SharedReadWriteSize+SharedReadOnlySize+SharedMiscCodeSize);
+  return sharedConstraintFunc("SharedMiscDataSize", value, taken, verbose);
+}
+
+Flag::Error SharedMiscCodeSizeConstraintFunc(size_t value, bool verbose) {
+  size_t taken = (SharedReadWriteSize+SharedReadOnlySize+SharedMiscDataSize);
+  return sharedConstraintFunc("SharedMiscCodeSize", value, taken, verbose);
+}
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,4 +45,9 @@
 
 Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose);
 
+Flag::Error SharedReadWriteSizeConstraintFunc(size_t value, bool verbose);
+Flag::Error SharedReadOnlySizeConstraintFunc(size_t value, bool verbose);
+Flag::Error SharedMiscDataSizeConstraintFunc(size_t value, bool verbose);
+Flag::Error SharedMiscCodeSizeConstraintFunc(size_t value, bool verbose);
+
 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP */
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Fri Apr 01 03:33:39 2016 +0000
@@ -3972,18 +3972,22 @@
   product(size_t, SharedReadWriteSize, DEFAULT_SHARED_READ_WRITE_SIZE,      \
           "Size of read-write space for metadata (in bytes)")               \
           range(MIN_SHARED_READ_WRITE_SIZE, MAX_SHARED_READ_WRITE_SIZE)     \
+          constraint(SharedReadWriteSizeConstraintFunc,AfterErgo)           \
                                                                             \
   product(size_t, SharedReadOnlySize, DEFAULT_SHARED_READ_ONLY_SIZE,        \
           "Size of read-only space for metadata (in bytes)")                \
           range(MIN_SHARED_READ_ONLY_SIZE, MAX_SHARED_READ_ONLY_SIZE)       \
+          constraint(SharedReadOnlySizeConstraintFunc,AfterErgo)            \
                                                                             \
   product(size_t, SharedMiscDataSize, DEFAULT_SHARED_MISC_DATA_SIZE,        \
           "Size of the shared miscellaneous data area (in bytes)")          \
           range(MIN_SHARED_MISC_DATA_SIZE, MAX_SHARED_MISC_DATA_SIZE)       \
+          constraint(SharedMiscDataSizeConstraintFunc,AfterErgo)            \
                                                                             \
   product(size_t, SharedMiscCodeSize, DEFAULT_SHARED_MISC_CODE_SIZE,        \
           "Size of the shared miscellaneous code area (in bytes)")          \
           range(MIN_SHARED_MISC_CODE_SIZE, MAX_SHARED_MISC_CODE_SIZE)       \
+          constraint(SharedMiscCodeSizeConstraintFunc,AfterErgo)            \
                                                                             \
   product(size_t, SharedBaseAddress, LP64_ONLY(32*G)                        \
           NOT_LP64(LINUX_ONLY(2*G) NOT_LINUX(0)),                           \
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Thu Mar 31 11:39:00 2016 -0400
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Fri Apr 01 03:33:39 2016 +0000
@@ -97,15 +97,6 @@
         excludeTestRange("ThreadStackSize");
 
         /*
-         * JDK-8143958
-         * Temporarily exclude testing of max range for Shared* flags
-         */
-        excludeTestMaxRange("SharedReadWriteSize");
-        excludeTestMaxRange("SharedReadOnlySize");
-        excludeTestMaxRange("SharedMiscDataSize");
-        excludeTestMaxRange("SharedMiscCodeSize");
-
-        /*
          * Remove the flag controlling the size of the stack because the
          * flag has direct influence on the physical memory usage of
          * the VM.