This commit is contained in:
Mikael Vidstedt 2019-08-05 16:27:30 -07:00
commit 2e6e33eba1
8 changed files with 110 additions and 21 deletions
.hgtags
src
hotspot/share/jfr
leakprofiler/checkpoint
recorder/checkpoint/types
java.base/windows/native/libnio/ch
java.desktop
share/classes/com/sun/java/swing/plaf/gtk
unix/native/libawt_xawt/awt

@ -577,4 +577,5 @@ e64383344f144217c36196c3c8a2df8f588a2af3 jdk-14+3
443f7359b34d60e7821216ffc60f88b6ffe0ccdd jdk-14+6
6a159c6c23ccd0029140ab91653442e412305ce5 jdk-13+31
28ab01c067551ef158abaef08e154e1051ca0893 jdk-14+7
929f37a9c35d530d4e866f6e832001aeb4cfb371 jdk-13+32
c0023e364b6f130cb1e93747b796d8718d544db1 jdk-14+8

@ -181,34 +181,33 @@ class SampleMark {
}
};
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 @@ bool WriteObjectSampleStacktrace::process() {
JfrStackTraceRepository::write_metadata(writer);
// install the stacktrace checkpoint information to the candidates
ObjectSampleCheckpoint::install(writer, false);
ObjectSampleCheckpoint::install(writer, false, false);
return true;
}

@ -35,7 +35,7 @@ class ObjectSampler;
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);
};

@ -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 @@ void ClassUnloadTypeSet::serialize(JfrCheckpointWriter& writer) {
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 @@ void TypeSet::serialize(JfrCheckpointWriter& writer) {
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);

@ -623,9 +623,6 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo
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 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo
}
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) {

@ -535,6 +535,34 @@ class GTKPainter extends SynthPainter {
}
}
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 @@ class GTKPainter extends SynthPainter {
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)) {

@ -205,6 +205,14 @@ class GTKStyle extends SynthStyle implements GTKConstants {
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.
*

@ -1679,7 +1679,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledN
{
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