changeset 57531:8f067351c370

Merge
author mikael
date Mon, 05 Aug 2019 16:27:30 -0700
parents b5ab9a71aa95 b2fde6701654
children ddae2da329ed
files .hgtags test/hotspot/jtreg/runtime/cds/CheckDefaultArchiveFile.java test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java
diffstat 8 files changed, 110 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Aug 05 13:18:31 2019 -0700
+++ b/.hgtags	Mon Aug 05 16:27:30 2019 -0700
@@ -577,4 +577,5 @@
 443f7359b34d60e7821216ffc60f88b6ffe0ccdd jdk-14+6
 6a159c6c23ccd0029140ab91653442e412305ce5 jdk-13+31
 28ab01c067551ef158abaef08e154e1051ca0893 jdk-14+7
+929f37a9c35d530d4e866f6e832001aeb4cfb371 jdk-13+32
 c0023e364b6f130cb1e93747b796d8718d544db1 jdk-14+8
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp	Mon Aug 05 16:27:30 2019 -0700
@@ -181,34 +181,33 @@
   }
 };
 
-void ObjectSampleCheckpoint::install(JfrCheckpointWriter& writer, bool class_unload) {
+void ObjectSampleCheckpoint::install(JfrCheckpointWriter& writer, bool class_unload, bool type_set) {
   if (!writer.has_data()) {
     return;
   }
 
   assert(writer.has_data(), "invariant");
   const JfrCheckpointBlobHandle h_cp = writer.checkpoint_blob();
+  CheckpointInstall install(h_cp);
 
   // Class unload implies a safepoint.
   // Not class unload implies the object sampler is locked, because it was claimed exclusively earlier.
   // Therefore: direct access the object sampler instance is safe.
-  const ObjectSampler* const object_sampler = ObjectSampler::sampler();
+  ObjectSampler* const object_sampler = ObjectSampler::sampler();
   assert(object_sampler != NULL, "invariant");
 
   ObjectSample* const last = const_cast<ObjectSample*>(object_sampler->last());
   const ObjectSample* const last_resolved = object_sampler->last_resolved();
-  CheckpointInstall install(h_cp);
 
-  if (class_unload) {
-    // all samples need class unload information
-    do_samples(last, NULL, install);
-    return;
-  }
-
-  // only new samples since last resolved checkpoint
+  // install only to new samples since last resolved checkpoint
   if (last != last_resolved) {
     do_samples(last, last_resolved, install);
-    const_cast<ObjectSampler*>(object_sampler)->set_last_resolved(last);
+    if (class_unload) {
+      return;
+    }
+    if (type_set) {
+      object_sampler->set_last_resolved(last);
+    }
   }
 }
 
@@ -289,6 +288,6 @@
   JfrStackTraceRepository::write_metadata(writer);
 
   // install the stacktrace checkpoint information to the candidates
-  ObjectSampleCheckpoint::install(writer, false);
+  ObjectSampleCheckpoint::install(writer, false, false);
   return true;
 }
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp	Mon Aug 05 16:27:30 2019 -0700
@@ -35,7 +35,7 @@
 
 class ObjectSampleCheckpoint : AllStatic {
  public:
-  static void install(JfrCheckpointWriter& writer, bool class_unload);
+  static void install(JfrCheckpointWriter& writer, bool class_unload, bool type_set);
   static void write(ObjectSampler* sampler, EdgeStore* edge_store, bool emit_all, Thread* thread);
   static int mark(ObjectSampler* sampler, ObjectSampleMarker& marker, bool emit_all);
 };
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Mon Aug 05 16:27:30 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -311,7 +311,7 @@
   if (LeakProfiler::is_running()) {
     JfrCheckpointWriter leakp_writer(false, true, Thread::current());
     type_set.write(writer, &leakp_writer);
-    ObjectSampleCheckpoint::install(leakp_writer, true);
+    ObjectSampleCheckpoint::install(leakp_writer, true, true);
     return;
   }
   type_set.write(writer, NULL);
@@ -322,7 +322,7 @@
   if (LeakProfiler::is_running()) {
     JfrCheckpointWriter leakp_writer(false, true, Thread::current());
     type_set.write(writer, &leakp_writer);
-    ObjectSampleCheckpoint::install(leakp_writer, false);
+    ObjectSampleCheckpoint::install(leakp_writer, false, true);
     return;
   }
   type_set.write(writer, NULL);
--- a/src/java.base/windows/native/libnio/ch/Net.c	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/java.base/windows/native/libnio/ch/Net.c	Mon Aug 05 16:27:30 2019 -0700
@@ -623,9 +623,6 @@
     fd_set rd, wr, ex;
     jint fd = fdval(env, fdo);
 
-    t.tv_sec = (long)(timeout / 1000);
-    t.tv_usec = (timeout % 1000) * 1000;
-
     FD_ZERO(&rd);
     FD_ZERO(&wr);
     FD_ZERO(&ex);
@@ -638,7 +635,12 @@
     }
     FD_SET(fd, &ex);
 
-    rv = select(fd+1, &rd, &wr, &ex, &t);
+    if (timeout >= 0) {
+        t.tv_sec = (long)(timeout / 1000);
+        t.tv_usec = (timeout % 1000) * 1000;
+    }
+
+    rv = select(fd+1, &rd, &wr, &ex, (timeout >= 0) ? &t : NULL);
 
     /* save last winsock error */
     if (rv == SOCKET_ERROR) {
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Mon Aug 05 16:27:30 2019 -0700
@@ -535,6 +535,34 @@
         }
     }
 
+    private int getBrightness(Color c) {
+        return Math.max(c.getRed(), Math.max(c.getGreen(), c.getBlue()));
+    }
+
+    private int getMaxColorDiff(Color c1, Color c2) {
+        return Math.max(Math.abs(c1.getRed() - c2.getRed()),
+                Math.max(Math.abs(c1.getGreen() - c2.getGreen()),
+                        Math.abs(c1.getBlue() - c2.getBlue())));
+    }
+
+    private int scaleColorComponent(int color, double scaleFactor) {
+        return (int)(color + color * scaleFactor);
+    }
+    private Color deriveColor(Color originalColor, int originalBrightness,
+                              int targetBrightness) {
+        int r, g, b;
+        if (originalBrightness == 0) {
+            r = g = b = targetBrightness;
+        } else {
+            double scaleFactor = (targetBrightness - originalBrightness)
+                    / originalBrightness    ;
+            r = scaleColorComponent(originalColor.getRed(), scaleFactor);
+            g = scaleColorComponent(originalColor.getGreen(), scaleFactor);
+            b = scaleColorComponent(originalColor.getBlue(), scaleFactor);
+        }
+        return new Color(r, g, b);
+    }
+
     //
     // MENU
     //
@@ -551,6 +579,57 @@
         int gtkState = GTKLookAndFeel.synthStateToGTKState(
                 context.getRegion(), context.getComponentState());
         if (gtkState == SynthConstants.MOUSE_OVER) {
+            if (GTKLookAndFeel.is3() && context.getRegion() == Region.MENU) {
+                GTKStyle style = (GTKStyle)context.getStyle();
+                Color highlightColor = style.getGTKColor(
+                        GTKEngine.WidgetType.MENU_ITEM.ordinal(),
+                        gtkState, ColorType.BACKGROUND.getID());
+                Color backgroundColor = style.getGTKColor(
+                        GTKEngine.WidgetType.MENU_BAR.ordinal(),
+                        SynthConstants.ENABLED, ColorType.BACKGROUND.getID());
+
+                int minBrightness = 0, maxBrightness = 255;
+                int minBrightnessDifference = 100;
+                int actualBrightnessDifference =
+                        getMaxColorDiff(highlightColor, backgroundColor);
+                if (actualBrightnessDifference < minBrightnessDifference) {
+                    int highlightBrightness =
+                            getBrightness(highlightColor);
+                    int backgroundBrightness =
+                            getBrightness(backgroundColor);
+                    int originalHighlightBrightness =
+                            highlightBrightness;
+                    if (highlightBrightness >= backgroundBrightness) {
+                        if (backgroundBrightness + minBrightnessDifference <=
+                                maxBrightness) {
+                            highlightBrightness =
+                                    backgroundBrightness +
+                                            minBrightnessDifference;
+                        } else {
+                            highlightBrightness =
+                                    backgroundBrightness -
+                                            minBrightnessDifference;
+                        }
+                    } else {
+                        if (backgroundBrightness - minBrightnessDifference >=
+                                minBrightness) {
+                            highlightBrightness =
+                                    backgroundBrightness -
+                                            minBrightnessDifference;
+                        } else {
+                            highlightBrightness =
+                                    backgroundBrightness +
+                                            minBrightnessDifference;
+                        }
+                    }
+
+                    g.setColor(deriveColor(highlightColor,
+                            originalHighlightBrightness,
+                            highlightBrightness));
+                    g.fillRect(x, y, w, h);
+                    return;
+                }
+            }
             Region id = Region.MENU_ITEM;
             synchronized (UNIXToolkit.GTK_LOCK) {
                 if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Mon Aug 05 16:27:30 2019 -0700
@@ -205,6 +205,14 @@
         return getGTKColor(null, state, type);
     }
 
+    Color getGTKColor(int widgetType, int state, int colorType) {
+        synchronized (sun.awt.UNIXToolkit.GTK_LOCK) {
+            int rgb = nativeGetColorForState(widgetType, state,
+                    colorType);
+            return new ColorUIResource(rgb);
+        }
+    }
+
     /**
      * Returns the color for the specified state.
      *
--- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Mon Aug 05 13:18:31 2019 -0700
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Mon Aug 05 16:27:30 2019 -0700
@@ -1679,7 +1679,7 @@
 {
     X11InputMethodData *pX11IMData = NULL;
     char * ret = NULL;
-#if defined(_LP64) && !defined(_LITTLE_ENDIAN)
+#if defined(__linux__) && defined(_LP64) && !defined(_LITTLE_ENDIAN)
     // XIMPreeditState value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
     unsigned int state = XIMPreeditUnKnown;
 #else