# HG changeset patch # User jwilhelm # Date 1455815267 -3600 # Node ID bcdde35f856fab9947741650ba531b6c42fa7d55 # Parent 56fcd92b5c138ce9070e0c99b7dae949d37273ee# Parent ba46027ccfb593e4d27100743ed1702e52f77b1e Merge diff -r 56fcd92b5c13 -r bcdde35f856f jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Tue Feb 16 12:09:11 2016 -0800 +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Thu Feb 18 18:07:47 2016 +0100 @@ -778,8 +778,21 @@ return (asTypeCache = wrapper); } + // Customize target if counting happens for too long. + private int invocations = CUSTOMIZE_THRESHOLD; + private void maybeCustomizeTarget() { + int c = invocations; + if (c >= 0) { + if (c == 1) { + target.customize(); + } + invocations = c - 1; + } + } + boolean countDown() { int c = count; + maybeCustomizeTarget(); if (c <= 1) { // Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility. if (isCounting) { diff -r 56fcd92b5c13 -r bcdde35f856f jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Tue Feb 16 12:09:11 2016 -0800 +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Thu Feb 18 18:07:47 2016 +0100 @@ -1231,7 +1231,12 @@ /** @see #getLongUnaligned(Object, long) */ @HotSpotIntrinsicCandidate public final char getCharUnaligned(Object o, long offset) { - return (char)getShortUnaligned(o, offset); + if ((offset & 1) == 0) { + return getChar(o, offset); + } else { + return (char)makeShort(getByte(o, offset), + getByte(o, offset + 1)); + } } /** @see #getLongUnaligned(Object, long, boolean) */