Merge mips64el-jdk8u222-b11

Thu, 05 Sep 2019 18:52:27 +0800

author
aoqi
date
Thu, 05 Sep 2019 18:52:27 +0800
changeset 9703
2fdf635bcf28
parent 9647
42d198677884
parent 9702
adfdce09acc3
child 9704
02fc94107aa2

Merge

.hgtags file | annotate | diff | comparison | revisions
THIRD_PARTY_README file | annotate | diff | comparison | revisions
agent/src/os/linux/libproc_impl.c file | annotate | diff | comparison | revisions
agent/src/os/linux/libproc_impl.h file | annotate | diff | comparison | revisions
agent/src/os/linux/ps_proc.c file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/HSDB.java file | annotate | diff | comparison | revisions
make/linux/makefiles/amd64.make file | annotate | diff | comparison | revisions
make/linux/makefiles/i486.make file | annotate | diff | comparison | revisions
make/linux/makefiles/ppc64.make file | annotate | diff | comparison | revisions
make/linux/makefiles/zeroshark.make file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/assembler_ppc.hpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/assembler_ppc.inline.hpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/frame_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/globals_ppc.hpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/interpreter_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/macroAssembler_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/macroAssembler_ppc.hpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/register_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/register_ppc.hpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/sharedRuntime_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/stubGenerator_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/vm_version_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/vm_version_ppc.hpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/jniFastGetField_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/sharedRuntime_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/stubGenerator_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/templateInterpreter_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/jniFastGetField_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/jniFastGetField_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/macroAssembler_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/macroAssembler_x86.hpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/templateInterpreter_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/templateInterpreter_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/zero/vm/cppInterpreter_zero.cpp file | annotate | diff | comparison | revisions
src/os/linux/vm/os_linux.cpp file | annotate | diff | comparison | revisions
src/os/linux/vm/os_linux.hpp file | annotate | diff | comparison | revisions
src/os/solaris/vm/os_solaris.cpp file | annotate | diff | comparison | revisions
src/os/solaris/vm/os_solaris.hpp file | annotate | diff | comparison | revisions
src/os/windows/vm/os_windows.cpp file | annotate | diff | comparison | revisions
src/share/vm/classfile/vmSymbols.hpp file | annotate | diff | comparison | revisions
src/share/vm/code/codeCache.cpp file | annotate | diff | comparison | revisions
src/share/vm/code/codeCache.hpp file | annotate | diff | comparison | revisions
src/share/vm/code/nmethod.cpp file | annotate | diff | comparison | revisions
src/share/vm/compiler/compileBroker.cpp file | annotate | diff | comparison | revisions
src/share/vm/compiler/compileBroker.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1MarkSweep.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/genCollectedHeap.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/genCollectedHeap.hpp file | annotate | diff | comparison | revisions
src/share/vm/memory/iterator.hpp file | annotate | diff | comparison | revisions
src/share/vm/memory/referenceProcessor.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/instanceKlass.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/library_call.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/memnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/jni.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/jvmtiEnv.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/whitebox.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/advancedThresholdPolicy.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/javaCalls.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/javaCalls.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/jniHandles.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/jniHandles.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/thread.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vmThread.cpp file | annotate | diff | comparison | revisions
src/share/vm/services/heapDumper.cpp file | annotate | diff | comparison | revisions
src/share/vm/shark/sharkNativeWrapper.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions.hpp file | annotate | diff | comparison | revisions
test/compiler/tiered/NonTieredLevelsTest.java file | annotate | diff | comparison | revisions
test/compiler/tiered/TieredLevelsTest.java file | annotate | diff | comparison | revisions
test/compiler/whitebox/CompilerWhiteBoxTest.java file | annotate | diff | comparison | revisions
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Thu Sep 05 18:40:52 2019 +0800
     1.2 +++ b/.hgtags	Thu Sep 05 18:52:27 2019 +0800
     1.3 @@ -1273,7 +1273,20 @@
     1.4  7a69774c67cb79a79ccb2ac2d6d258a11e22aa6f jdk8u202-b26
     1.5  818b1963f7a227a2368a4f363d5500dd226a529e jdk8u202-ga
     1.6  9ce27f0a4683a2083d3aed59a40d6a3ccfc8e397 jdk8u212-b00
     1.7 +5af8ec63c21c861106d6bf8b137620ae4d3664be jdk8u222-b00
     1.8  9ee244aee077ffad50d1b183a61d9f5fc39a1285 jdk8u212-b01
     1.9  2d94aac71d3337c7c3284bdb101b7ea15ef6d5f5 jdk8u212-b02
    1.10 +96fec237fcc0acfcacea0a2bac07bf8ca919e64b jdk8u212-b03
    1.11 +b2000ea410b0aa80d94a89105ba3dc8bdebd80b7 jdk8u212-b04
    1.12 +96fec237fcc0acfcacea0a2bac07bf8ca919e64b jdk8u212-ga
    1.13  eef07cd490d47755e5169126e0f80060d606d171 mips64el-jdk8u212-b04
    1.14  5734aa7c320f2865a05f8db5ffbf6caf0ac3c79d mips64el-jdk8u212-b05
    1.15 +7fe2cda84af1feec9dd512fd7d17f70bfe91a9d0 jdk8u222-b01
    1.16 +32bc598624bd33a1a8847e84f791559f18a69a49 jdk8u222-b02
    1.17 +af43bab3c5d022f0e0b7890f732d8b365b4364cc jdk8u222-b03
    1.18 +d690709cc3398f8cfd6ffebb89a229105fb3e69a jdk8u222-b04
    1.19 +1ec20e8a3d8a7a29e9113b14567abec9f0240e9d jdk8u222-b05
    1.20 +17778f8991c83d794897f05210dce2d2a7b4eb2d jdk8u222-b06
    1.21 +75f4e02f1113bc353fc60df7330dd5456efc49a3 jdk8u222-b07
    1.22 +36a743eee6721b423b7c21a3ba28ac8d906a5386 jdk8u222-b08
    1.23 +55f693ba975d445d83a59cc32367ec4c2452b0c5 jdk8u222-b09
     2.1 --- a/THIRD_PARTY_README	Thu Sep 05 18:40:52 2019 +0800
     2.2 +++ b/THIRD_PARTY_README	Thu Sep 05 18:52:27 2019 +0800
     2.3 @@ -1612,7 +1612,7 @@
     2.4  
     2.5  -------------------------------------------------------------------------------
     2.6  
     2.7 -%% This notice is provided with respect to GIFLIB 5.1.1 & libungif 4.1.3, 
     2.8 +%% This notice is provided with respect to GIFLIB 5.1.8 & libungif 4.1.3, 
     2.9  which may be included with JRE 8, JDK 8, and OpenJDK 8.
    2.10  
    2.11  --- begin of LICENSE ---
    2.12 @@ -1682,7 +1682,7 @@
    2.13  --- begin of LICENSE ---
    2.14  
    2.15   Mesa 3-D graphics library
    2.16 - Version:  4.1
    2.17 + Version:  5.0
    2.18  
    2.19   Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
    2.20  
    2.21 @@ -2797,61 +2797,8 @@
    2.22  not be used in advertising or otherwise to promote the sale, use or
    2.23  other dealings in this Software without prior written authorization
    2.24  from the X Consortium.
    2.25 -___________________________
    2.26 -The files in motif/lib/Xm/util included this copyright:mkdirhier.man,
    2.27 -xmkmf.man, chownxterm.c, makeg.man, mergelib.cpp, lndir.man, makestrs.man, 
    2.28 -checktree.c, lndir.c, makestrs.c
    2.29 -Copyright (c) 1993, 1994 X Consortium
    2.30 -
    2.31 -Permission is hereby granted, free of charge, to any person obtaining a
    2.32 -copy of this software and associated documentation files (the "Software"),
    2.33 -to deal in the Software without restriction, including without limitation
    2.34 -the rights to use, copy, modify, merge, publish, distribute, sublicense,
    2.35 -and/or sell copies of the Software, and to permit persons to whom the
    2.36 -Software furnished to do so, subject to the following conditions:
    2.37 -
    2.38 -The above copyright notice and this permission notice shall be included in
    2.39 -all copies or substantial portions of the Software.
    2.40 -
    2.41 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.42 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.43 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    2.44 -THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    2.45 -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
    2.46 -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    2.47 -SOFTWARE.
    2.48 -
    2.49 -Except as contained in this notice, the name of the X Consortium shall not
    2.50 -be used in advertising or otherwise to promote the sale, use or other
    2.51 -dealing in this Software without prior written authorization from the
    2.52 -X Consortium.
    2.53 -_____________________________
    2.54 -Xmos_r.h:
    2.55 -/*
    2.56 -Copyright (c) 1996 X Consortium
    2.57 -
    2.58 -Permission is hereby granted, free of charge, to any person obtaining a copy
    2.59 -of this software and associated documentation files (the "Software"), to deal
    2.60 -in the Software without restriction, including without limitation the rights
    2.61 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    2.62 -copies of the Software, and to permit persons to whom the Software is
    2.63 -furnished to do so, subject to the following conditions:
    2.64 -
    2.65 -The above copyright notice and this permission notice shall be included in
    2.66 -all copies or substantial portions of the Software.
    2.67 -
    2.68 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.69 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.70 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.71 -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
    2.72 -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    2.73 -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2.74 -
    2.75 -Except as contained in this notice, the name of the X Consortium shall not be
    2.76 -used in advertising or otherwise to promote the sale, use or other dealings
    2.77 -in this Software without prior written authorization from the X Consortium.
    2.78 -*/
    2.79 -
    2.80 +
    2.81 +--- end of LICENSE ---
    2.82  _____________________________
    2.83  Copyright notice for HPkeysym.h:
    2.84  /*
    2.85 @@ -2906,55 +2853,6 @@
    2.86  performance, or use of this material.
    2.87  
    2.88  */
    2.89 -_____________________________________
    2.90 -Copyright notice in keysym2ucs.h:
    2.91 -
    2.92 -Copyright 1987, 1994, 1998 The Open Group
    2.93 -
    2.94 -Permission to use, copy, modify, distribute, and sell this software and its
    2.95 -documentation for any purpose is hereby granted without fee, provided that
    2.96 -the above copyright notice appear in all copies and that both that
    2.97 -copyright notice and this permission notice appear in supporting
    2.98 -documentation.
    2.99 -
   2.100 -The above copyright notice and this permission notice shall be included
   2.101 -in all copies or substantial portions of the Software.
   2.102 -
   2.103 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   2.104 -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   2.105 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   2.106 -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
   2.107 -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   2.108 -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   2.109 -OTHER DEALINGS IN THE SOFTWARE.
   2.110 -
   2.111 -Except as contained in this notice, the name of The Open Group shall
   2.112 -not be used in advertising or otherwise to promote the sale, use or
   2.113 -other dealings in this Software without prior written authorization
   2.114 -from The Open Group.
   2.115 -
   2.116 -
   2.117 -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts
   2.118 -
   2.119 -All Rights Reserved
   2.120 -
   2.121 -Permission to use, copy, modify, and distribute this software and its
   2.122 -documentation for any purpose and without fee is hereby granted,
   2.123 -provided that the above copyright notice appear in all copies and that
   2.124 -both that copyright notice and this permission notice appear in
   2.125 -supporting documentation, and that the name of Digital not be
   2.126 -used in advertising or publicity pertaining to distribution of the
   2.127 -software without specific, written prior permission.
   2.128 -
   2.129 -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
   2.130 -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
   2.131 -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
   2.132 -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   2.133 -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
   2.134 -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
   2.135 -SOFTWARE.
   2.136 -
   2.137 -*/
   2.138  
   2.139  --- end of LICENSE ---
   2.140  
   2.141 @@ -3000,7 +2898,7 @@
   2.142    Apache Jakarta BCEL 5.1 
   2.143    Apache Jakarta Regexp 1.4 
   2.144    Apache Santuario XML Security for Java 1.5.4
   2.145 -  Apache Xalan-Java 2.7.1 
   2.146 +  Apache Xalan-Java 2.7.2
   2.147    Apache Xerces Java 2.10.0 
   2.148    Apache XML Resolver 1.1 
   2.149  
     3.1 --- a/agent/src/os/linux/libproc_impl.c	Thu Sep 05 18:40:52 2019 +0800
     3.2 +++ b/agent/src/os/linux/libproc_impl.c	Thu Sep 05 18:52:27 2019 +0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -256,6 +256,26 @@
    3.11     return newthr;
    3.12  }
    3.13  
    3.14 +void delete_thread_info(struct ps_prochandle* ph, thread_info* thr_to_be_removed) {
    3.15 +    thread_info* current_thr = ph->threads;
    3.16 +
    3.17 +    if (thr_to_be_removed == ph->threads) {
    3.18 +      ph->threads = ph->threads->next;
    3.19 +    } else {
    3.20 +      thread_info* previous_thr;
    3.21 +      while (current_thr && current_thr != thr_to_be_removed) {
    3.22 +        previous_thr = current_thr;
    3.23 +        current_thr = current_thr->next;
    3.24 +      }
    3.25 +      if (current_thr == NULL) {
    3.26 +        print_error("Could not find the thread to be removed");
    3.27 +        return;
    3.28 +      }
    3.29 +      previous_thr->next = current_thr->next;
    3.30 +    }
    3.31 +    ph->num_threads--;
    3.32 +    free(current_thr);
    3.33 +}
    3.34  
    3.35  // struct used for client data from thread_db callback
    3.36  struct thread_db_client_data {
    3.37 @@ -278,6 +298,11 @@
    3.38  
    3.39    print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
    3.40  
    3.41 +  if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) {
    3.42 +    print_debug("Skipping pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
    3.43 +    return TD_OK;
    3.44 +  }
    3.45 +
    3.46    if (ptr->callback(ptr->ph, ti.ti_tid, ti.ti_lid) != true)
    3.47      return TD_ERR;
    3.48  
     4.1 --- a/agent/src/os/linux/libproc_impl.h	Thu Sep 05 18:40:52 2019 +0800
     4.2 +++ b/agent/src/os/linux/libproc_impl.h	Thu Sep 05 18:52:27 2019 +0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -113,6 +113,9 @@
    4.11  // reads thread info using libthread_db and calls above callback for each thread
    4.12  bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
    4.13  
    4.14 +// deletes a thread from the thread list
    4.15 +void delete_thread_info(struct ps_prochandle* ph, thread_info* thr);
    4.16 +
    4.17  // adds a new shared object to lib list, returns NULL on failure
    4.18  lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
    4.19  
     5.1 --- a/agent/src/os/linux/ps_proc.c	Thu Sep 05 18:40:52 2019 +0800
     5.2 +++ b/agent/src/os/linux/ps_proc.c	Thu Sep 05 18:52:27 2019 +0800
     5.3 @@ -28,6 +28,7 @@
     5.4  #include <signal.h>
     5.5  #include <errno.h>
     5.6  #include <elf.h>
     5.7 +#include <ctype.h>
     5.8  #include <sys/types.h>
     5.9  #include <sys/wait.h>
    5.10  #include <sys/ptrace.h>
    5.11 @@ -45,6 +46,12 @@
    5.12  // This file has the libproc implementation specific to live process
    5.13  // For core files, refer to ps_core.c
    5.14  
    5.15 +typedef enum {
    5.16 +  ATTACH_SUCCESS,
    5.17 +  ATTACH_FAIL,
    5.18 +  ATTACH_THREAD_DEAD
    5.19 +} attach_state_t;
    5.20 +
    5.21  static inline uintptr_t align(uintptr_t ptr, size_t size) {
    5.22    return (ptr & ~(size - 1));
    5.23  }
    5.24 @@ -167,9 +174,10 @@
    5.25  
    5.26  // waits until the ATTACH has stopped the process
    5.27  // by signal SIGSTOP
    5.28 -static bool ptrace_waitpid(pid_t pid) {
    5.29 +static attach_state_t ptrace_waitpid(pid_t pid) {
    5.30    int ret;
    5.31    int status;
    5.32 +  errno = 0;
    5.33    while (true) {
    5.34      // Wait for debuggee to stop.
    5.35      ret = waitpid(pid, &status, 0);
    5.36 @@ -184,15 +192,15 @@
    5.37          // will go to sleep.
    5.38          if (WSTOPSIG(status) == SIGSTOP) {
    5.39            // Debuggee stopped by SIGSTOP.
    5.40 -          return true;
    5.41 +          return ATTACH_SUCCESS;
    5.42          }
    5.43          if (!ptrace_continue(pid, WSTOPSIG(status))) {
    5.44            print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
    5.45 -          return false;
    5.46 +          return ATTACH_FAIL;
    5.47          }
    5.48        } else {
    5.49 -        print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
    5.50 -        return false;
    5.51 +        print_debug("waitpid(): Child process %d exited/terminated (status = 0x%x)\n", pid, status);
    5.52 +        return ATTACH_THREAD_DEAD;
    5.53        }
    5.54      } else {
    5.55        switch (errno) {
    5.56 @@ -201,29 +209,89 @@
    5.57            break;
    5.58          case ECHILD:
    5.59            print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
    5.60 -          break;
    5.61 +          return ATTACH_THREAD_DEAD;
    5.62          case EINVAL:
    5.63 -          print_debug("waitpid() failed. Invalid options argument.\n");
    5.64 -          break;
    5.65 +          print_error("waitpid() failed. Invalid options argument.\n");
    5.66 +          return ATTACH_FAIL;
    5.67          default:
    5.68 -          print_debug("waitpid() failed. Unexpected error %d\n",errno);
    5.69 -          break;
    5.70 +          print_error("waitpid() failed. Unexpected error %d\n",errno);
    5.71 +          return ATTACH_FAIL;
    5.72        }
    5.73 -      return false;
    5.74 +    } // else
    5.75 +  } // while
    5.76 +}
    5.77 +
    5.78 +// checks the state of the thread/process specified by "pid", by reading
    5.79 +// in the 'State:' value from the /proc/<pid>/status file. From the proc
    5.80 +// man page, "Current state of the process. One of "R (running)",
    5.81 +// "S (sleeping)", "D (disk sleep)", "T (stopped)", "T (tracing stop)",
    5.82 +// "Z (zombie)", or "X (dead)"." Assumes that the thread is dead if we
    5.83 +// don't find the status file or if the status is 'X' or 'Z'.
    5.84 +static bool process_doesnt_exist(pid_t pid) {
    5.85 +  char fname[32];
    5.86 +  char buf[30];
    5.87 +  FILE *fp = NULL;
    5.88 +  const char state_string[] = "State:";
    5.89 +
    5.90 +  sprintf(fname, "/proc/%d/status", pid);
    5.91 +  fp = fopen(fname, "r");
    5.92 +  if (fp == NULL) {
    5.93 +    print_debug("can't open /proc/%d/status file\n", pid);
    5.94 +    // Assume the thread does not exist anymore.
    5.95 +    return true;
    5.96 +  }
    5.97 +  bool found_state = false;
    5.98 +  size_t state_len = strlen(state_string);
    5.99 +  while (fgets(buf, sizeof(buf), fp) != NULL) {
   5.100 +    char *state = NULL;
   5.101 +    if (strncmp (buf, state_string, state_len) == 0) {
   5.102 +      found_state = true;
   5.103 +      state = buf + state_len;
   5.104 +      // Skip the spaces
   5.105 +      while (isspace(*state)) {
   5.106 +        state++;
   5.107 +      }
   5.108 +      // A state value of 'X' indicates that the thread is dead. 'Z'
   5.109 +      // indicates that the thread is a zombie.
   5.110 +      if (*state == 'X' || *state == 'Z') {
   5.111 +        fclose (fp);
   5.112 +        return true;
   5.113 +      }
   5.114 +      break;
   5.115      }
   5.116    }
   5.117 +  // If the state value is not 'X' or 'Z', the thread exists.
   5.118 +  if (!found_state) {
   5.119 +    // We haven't found the line beginning with 'State:'.
   5.120 +    // Assuming the thread exists.
   5.121 +    print_error("Could not find the 'State:' string in the /proc/%d/status file\n", pid);
   5.122 +  }
   5.123 +  fclose (fp);
   5.124 +  return false;
   5.125  }
   5.126  
   5.127  // attach to a process/thread specified by "pid"
   5.128 -static bool ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
   5.129 +static attach_state_t ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
   5.130 +  errno = 0;
   5.131    if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
   5.132 +    if (errno == EPERM || errno == ESRCH) {
   5.133 +      // Check if the process/thread is exiting or is a zombie
   5.134 +      if (process_doesnt_exist(pid)) {
   5.135 +        print_debug("Thread with pid %d does not exist\n", pid);
   5.136 +        return ATTACH_THREAD_DEAD;
   5.137 +      }
   5.138 +    }
   5.139      char buf[200];
   5.140      char* msg = strerror_r(errno, buf, sizeof(buf));
   5.141      snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: %s", pid, msg);
   5.142 -    print_debug("%s\n", err_buf);
   5.143 -    return false;
   5.144 +    print_error("%s\n", err_buf);
   5.145 +    return ATTACH_FAIL;
   5.146    } else {
   5.147 -    return ptrace_waitpid(pid);
   5.148 +    attach_state_t wait_ret = ptrace_waitpid(pid);
   5.149 +    if (wait_ret == ATTACH_THREAD_DEAD) {
   5.150 +      print_debug("Thread with pid %d does not exist\n", pid);
   5.151 +    }
   5.152 +    return wait_ret;
   5.153    }
   5.154  }
   5.155  
   5.156 @@ -345,16 +413,20 @@
   5.157  struct ps_prochandle* Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) {
   5.158    struct ps_prochandle* ph = NULL;
   5.159    thread_info* thr = NULL;
   5.160 +  attach_state_t attach_status = ATTACH_SUCCESS;
   5.161  
   5.162    if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
   5.163 -     snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
   5.164 -     print_debug("%s\n", err_buf);
   5.165 -     return NULL;
   5.166 +    snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
   5.167 +    print_debug("%s\n", err_buf);
   5.168 +    return NULL;
   5.169    }
   5.170  
   5.171 -  if (ptrace_attach(pid, err_buf, err_buf_len) != true) {
   5.172 -     free(ph);
   5.173 -     return NULL;
   5.174 +  if ((attach_status = ptrace_attach(pid, err_buf, err_buf_len)) != ATTACH_SUCCESS) {
   5.175 +    if (attach_status == ATTACH_THREAD_DEAD) {
   5.176 +       print_error("The process with pid %d does not exist.\n", pid);
   5.177 +    }
   5.178 +    free(ph);
   5.179 +    return NULL;
   5.180    }
   5.181  
   5.182    // initialize ps_prochandle
   5.183 @@ -373,14 +445,23 @@
   5.184  
   5.185    // attach to the threads
   5.186    thr = ph->threads;
   5.187 +
   5.188    while (thr) {
   5.189 -     // don't attach to the main thread again
   5.190 -    if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id, err_buf, err_buf_len) != true) {
   5.191 -        // even if one attach fails, we get return NULL
   5.192 -        Prelease(ph);
   5.193 -        return NULL;
   5.194 -     }
   5.195 -     thr = thr->next;
   5.196 +    thread_info* current_thr = thr;
   5.197 +    thr = thr->next;
   5.198 +    // don't attach to the main thread again
   5.199 +    if (ph->pid != current_thr->lwp_id) {
   5.200 +      if ((attach_status = ptrace_attach(current_thr->lwp_id, err_buf, err_buf_len)) != ATTACH_SUCCESS) {
   5.201 +        if (attach_status == ATTACH_THREAD_DEAD) {
   5.202 +          // Remove this thread from the threads list
   5.203 +          delete_thread_info(ph, current_thr);
   5.204 +        }
   5.205 +        else {
   5.206 +          Prelease(ph);
   5.207 +          return NULL;
   5.208 +        } // ATTACH_THREAD_DEAD
   5.209 +      } // !ATTACH_SUCCESS
   5.210 +    }
   5.211    }
   5.212    return ph;
   5.213  }
     6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Thu Sep 05 18:40:52 2019 +0800
     6.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Thu Sep 05 18:52:27 2019 +0800
     6.3 @@ -128,10 +128,14 @@
     6.4      }
     6.5    }
     6.6  
     6.7 -  // close this tool without calling System.exit
     6.8 -  protected void closeUI() {
     6.9 -      workerThread.shutdown();
    6.10 -      frame.dispose();
    6.11 +  private class CloseUI extends WindowAdapter {
    6.12 +
    6.13 +      @Override
    6.14 +      public void windowClosing(WindowEvent e) {
    6.15 +          workerThread.shutdown();
    6.16 +          frame.dispose();
    6.17 +      }
    6.18 +
    6.19    }
    6.20  
    6.21    public void run() {
    6.22 @@ -147,7 +151,8 @@
    6.23  
    6.24      frame = new JFrame("HSDB - HotSpot Debugger");
    6.25      frame.setSize(800, 600);
    6.26 -    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    6.27 +    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    6.28 +    frame.addWindowListener(new CloseUI());
    6.29  
    6.30      JMenuBar menuBar = new JMenuBar();
    6.31  
    6.32 @@ -210,7 +215,8 @@
    6.33      item = createMenuItem("Exit",
    6.34                              new ActionListener() {
    6.35                                  public void actionPerformed(ActionEvent e) {
    6.36 -                                  closeUI();
    6.37 +                                  workerThread.shutdown();
    6.38 +                                  frame.dispose();
    6.39                                  }
    6.40                                });
    6.41      item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
     7.1 --- a/make/bsd/makefiles/amd64.make	Thu Sep 05 18:40:52 2019 +0800
     7.2 +++ b/make/bsd/makefiles/amd64.make	Thu Sep 05 18:52:27 2019 +0800
     7.3 @@ -22,11 +22,16 @@
     7.4  #  
     7.5  #
     7.6  
     7.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
     7.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
     7.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
    7.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
    7.11 -# Must also specify if CPU is little endian
    7.12 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
    7.13 +# the compiler so as to be able to produce optimized objects
    7.14 +# without losing precision.
    7.15 +ifneq ($(FDLIBM_CFLAGS),)
    7.16 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    7.17 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    7.18 +else
    7.19 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    7.20 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
    7.21 +endif
    7.22  CFLAGS += -DVM_LITTLE_ENDIAN
    7.23  
    7.24  CFLAGS += -D_LP64=1
     8.1 --- a/make/bsd/makefiles/i486.make	Thu Sep 05 18:40:52 2019 +0800
     8.2 +++ b/make/bsd/makefiles/i486.make	Thu Sep 05 18:52:27 2019 +0800
     8.3 @@ -24,10 +24,16 @@
     8.4  
     8.5  # TLS helper, assembled from .s file
     8.6  
     8.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
     8.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
     8.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
    8.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
    8.11 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
    8.12 +# the compiler so as to be able to produce optimized objects
    8.13 +# without losing precision.
    8.14 +ifneq ($(FDLIBM_CFLAGS),)
    8.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    8.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    8.17 +else
    8.18 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    8.19 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
    8.20 +endif
    8.21  # Must also specify if CPU is little endian
    8.22  CFLAGS += -DVM_LITTLE_ENDIAN
    8.23  
     9.1 --- a/make/bsd/makefiles/ppc.make	Thu Sep 05 18:40:52 2019 +0800
     9.2 +++ b/make/bsd/makefiles/ppc.make	Thu Sep 05 18:52:27 2019 +0800
     9.3 @@ -22,8 +22,16 @@
     9.4  #  
     9.5  #
     9.6  
     9.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
     9.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
     9.9 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
    9.10 +# the compiler so as to be able to produce optimized objects
    9.11 +# without losing precision.
    9.12 +ifneq ($(FDLIBM_CFLAGS),)
    9.13 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    9.14 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
    9.15 +else
    9.16 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    9.17 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
    9.18 +endif
    9.19  
    9.20  # Must also specify if CPU is big endian
    9.21  CFLAGS += -DVM_BIG_ENDIAN
    10.1 --- a/make/bsd/makefiles/zeroshark.make	Thu Sep 05 18:40:52 2019 +0800
    10.2 +++ b/make/bsd/makefiles/zeroshark.make	Thu Sep 05 18:52:27 2019 +0800
    10.3 @@ -25,10 +25,16 @@
    10.4  
    10.5  # Setup common to Zero (non-Shark) and Shark versions of VM
    10.6  
    10.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
    10.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    10.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
   10.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   10.11 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
   10.12 +# the compiler so as to be able to produce optimized objects
   10.13 +# without losing precision.
   10.14 +ifneq ($(FDLIBM_CFLAGS),)
   10.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   10.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   10.17 +else
   10.18 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
   10.19 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   10.20 +endif
   10.21  
   10.22  # Specify that the CPU is little endian, if necessary
   10.23  ifeq ($(ZERO_ENDIANNESS), little)
    11.1 --- a/make/linux/makefiles/amd64.make	Thu Sep 05 18:40:52 2019 +0800
    11.2 +++ b/make/linux/makefiles/amd64.make	Thu Sep 05 18:52:27 2019 +0800
    11.3 @@ -22,10 +22,16 @@
    11.4  #  
    11.5  #
    11.6  
    11.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
    11.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    11.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
   11.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   11.11 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
   11.12 +# the compiler so as to be able to produce optimized objects
   11.13 +# without losing precision.
   11.14 +ifneq ($(FDLIBM_CFLAGS),)
   11.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   11.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   11.17 +else
   11.18 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
   11.19 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   11.20 +endif
   11.21  # Must also specify if CPU is little endian
   11.22  CFLAGS += -DVM_LITTLE_ENDIAN
   11.23  
    12.1 --- a/make/linux/makefiles/i486.make	Thu Sep 05 18:40:52 2019 +0800
    12.2 +++ b/make/linux/makefiles/i486.make	Thu Sep 05 18:52:27 2019 +0800
    12.3 @@ -24,10 +24,16 @@
    12.4  
    12.5  # TLS helper, assembled from .s file
    12.6  
    12.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
    12.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    12.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
   12.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   12.11 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
   12.12 +# the compiler so as to be able to produce optimized objects
   12.13 +# without losing precision.
   12.14 +ifneq ($(FDLIBM_CFLAGS),)
   12.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   12.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   12.17 +else
   12.18 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
   12.19 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   12.20 +endif
   12.21  # Must also specify if CPU is little endian
   12.22  CFLAGS += -DVM_LITTLE_ENDIAN
   12.23  
    13.1 --- a/make/linux/makefiles/ppc64.make	Thu Sep 05 18:40:52 2019 +0800
    13.2 +++ b/make/linux/makefiles/ppc64.make	Thu Sep 05 18:52:27 2019 +0800
    13.3 @@ -49,3 +49,14 @@
    13.4    # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
    13.5    CFLAGS += -mcpu=power7 -mtune=power8 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string
    13.6  endif
    13.7 +
    13.8 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
    13.9 +# the compiler so as to be able to produce optimized objects
   13.10 +# without losing precision.
   13.11 +ifneq ($(FDLIBM_CFLAGS),)
   13.12 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   13.13 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   13.14 +else
   13.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
   13.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   13.17 +endif
    14.1 --- a/make/linux/makefiles/zeroshark.make	Thu Sep 05 18:40:52 2019 +0800
    14.2 +++ b/make/linux/makefiles/zeroshark.make	Thu Sep 05 18:52:27 2019 +0800
    14.3 @@ -28,10 +28,16 @@
    14.4  # override this from the main file because some version of llvm do not like -Wundef
    14.5  WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wunused-function -Wunused-value
    14.6  
    14.7 -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
    14.8 -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
    14.9 -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
   14.10 -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   14.11 +# If FDLIBM_CFLAGS is non-empty it holds CFLAGS needed to be passed to
   14.12 +# the compiler so as to be able to produce optimized objects
   14.13 +# without losing precision.
   14.14 +ifneq ($(FDLIBM_CFLAGS),)
   14.15 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   14.16 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(FDLIBM_CFLAGS)
   14.17 +else
   14.18 +  OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
   14.19 +  OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
   14.20 +endif
   14.21  
   14.22  # Specify that the CPU is little endian, if necessary
   14.23  ifeq ($(ZERO_ENDIANNESS), little)
    15.1 --- a/src/cpu/ppc/vm/assembler_ppc.hpp	Thu Sep 05 18:40:52 2019 +0800
    15.2 +++ b/src/cpu/ppc/vm/assembler_ppc.hpp	Thu Sep 05 18:52:27 2019 +0800
    15.3 @@ -469,8 +469,15 @@
    15.4      LVSR_OPCODE    = (31u << OPCODE_SHIFT |   38u << 1),
    15.5  
    15.6      // Vector-Scalar (VSX) instruction support.
    15.7 +    LXVD2X_OPCODE  = (31u << OPCODE_SHIFT |  844u << 1),
    15.8 +    STXVD2X_OPCODE = (31u << OPCODE_SHIFT |  972u << 1),
    15.9      MTVSRD_OPCODE  = (31u << OPCODE_SHIFT |  179u << 1),
   15.10 +    MTVSRWZ_OPCODE = (31u << OPCODE_SHIFT |  243u << 1),
   15.11      MFVSRD_OPCODE  = (31u << OPCODE_SHIFT |   51u << 1),
   15.12 +    MFVSRWZ_OPCODE = (31u << OPCODE_SHIFT |  115u << 1),
   15.13 +    XXPERMDI_OPCODE= (60u << OPCODE_SHIFT |   10u << 3),
   15.14 +    XXMRGHW_OPCODE = (60u << OPCODE_SHIFT |   18u << 3),
   15.15 +    XXMRGLW_OPCODE = (60u << OPCODE_SHIFT |   50u << 3),
   15.16  
   15.17      // Vector Permute and Formatting
   15.18      VPKPX_OPCODE   = (4u  << OPCODE_SHIFT |  782u     ),
   15.19 @@ -520,6 +527,7 @@
   15.20      VADDUBM_OPCODE = (4u  << OPCODE_SHIFT |    0u     ),
   15.21      VADDUWM_OPCODE = (4u  << OPCODE_SHIFT |  128u     ),
   15.22      VADDUHM_OPCODE = (4u  << OPCODE_SHIFT |   64u     ),
   15.23 +    VADDUDM_OPCODE = (4u  << OPCODE_SHIFT |  192u     ),
   15.24      VADDUBS_OPCODE = (4u  << OPCODE_SHIFT |  512u     ),
   15.25      VADDUWS_OPCODE = (4u  << OPCODE_SHIFT |  640u     ),
   15.26      VADDUHS_OPCODE = (4u  << OPCODE_SHIFT |  576u     ),
   15.27 @@ -670,8 +678,10 @@
   15.28      // Atomics.
   15.29      LWARX_OPCODE   = (31u << OPCODE_SHIFT |   20u << 1),
   15.30      LDARX_OPCODE   = (31u << OPCODE_SHIFT |   84u << 1),
   15.31 +    LQARX_OPCODE   = (31u << OPCODE_SHIFT |  276u << 1),
   15.32      STWCX_OPCODE   = (31u << OPCODE_SHIFT |  150u << 1),
   15.33 -    STDCX_OPCODE   = (31u << OPCODE_SHIFT |  214u << 1)
   15.34 +    STDCX_OPCODE   = (31u << OPCODE_SHIFT |  214u << 1),
   15.35 +    STQCX_OPCODE   = (31u << OPCODE_SHIFT |  182u << 1)
   15.36  
   15.37    };
   15.38  
   15.39 @@ -1052,6 +1062,22 @@
   15.40    static int vrs(   VectorRegister r)  { return  vrs(r->encoding());}
   15.41    static int vrt(   VectorRegister r)  { return  vrt(r->encoding());}
   15.42  
   15.43 +  // Only used on SHA sigma instructions (VX-form)
   15.44 +  static int vst(      int         x)  { return  opp_u_field(x,             16, 16); }
   15.45 +  static int vsix(     int         x)  { return  opp_u_field(x,             20, 17); }
   15.46 +
   15.47 +  // Support Vector-Scalar (VSX) instructions.
   15.48 +  static int vsra(      int         x)  { return  opp_u_field(x & 0x1F,     15, 11) | opp_u_field((x & 0x20) >> 5, 29, 29); }
   15.49 +  static int vsrb(      int         x)  { return  opp_u_field(x & 0x1F,     20, 16) | opp_u_field((x & 0x20) >> 5, 30, 30); }
   15.50 +  static int vsrs(      int         x)  { return  opp_u_field(x & 0x1F,     10,  6) | opp_u_field((x & 0x20) >> 5, 31, 31); }
   15.51 +  static int vsrt(      int         x)  { return  vsrs(x); }
   15.52 +  static int vsdm(      int         x)  { return  opp_u_field(x,            23, 22); }
   15.53 +
   15.54 +  static int vsra(   VectorSRegister r)  { return  vsra(r->encoding());}
   15.55 +  static int vsrb(   VectorSRegister r)  { return  vsrb(r->encoding());}
   15.56 +  static int vsrs(   VectorSRegister r)  { return  vsrs(r->encoding());}
   15.57 +  static int vsrt(   VectorSRegister r)  { return  vsrt(r->encoding());}
   15.58 +
   15.59    static int vsplt_uim( int        x)  { return  opp_u_field(x,             15, 12); } // for vsplt* instructions
   15.60    static int vsplti_sim(int        x)  { return  opp_u_field(x,             15, 11); } // for vsplti* instructions
   15.61    static int vsldoi_shb(int        x)  { return  opp_u_field(x,             25, 22); } // for vsldoi instruction
   15.62 @@ -1663,11 +1689,14 @@
   15.63    // atomics
   15.64    inline void lwarx_unchecked(Register d, Register a, Register b, int eh1 = 0);
   15.65    inline void ldarx_unchecked(Register d, Register a, Register b, int eh1 = 0);
   15.66 +  inline void lqarx_unchecked(Register d, Register a, Register b, int eh1 = 0);
   15.67    inline bool lxarx_hint_exclusive_access();
   15.68    inline void lwarx(  Register d, Register a, Register b, bool hint_exclusive_access = false);
   15.69    inline void ldarx(  Register d, Register a, Register b, bool hint_exclusive_access = false);
   15.70 +  inline void lqarx(  Register d, Register a, Register b, bool hint_exclusive_access = false);
   15.71    inline void stwcx_( Register s, Register a, Register b);
   15.72    inline void stdcx_( Register s, Register a, Register b);
   15.73 +  inline void stqcx_( Register s, Register a, Register b);
   15.74  
   15.75    // Instructions for adjusting thread priority for simultaneous
   15.76    // multithreading (SMT) on Power5.
   15.77 @@ -1849,6 +1878,7 @@
   15.78    inline void vaddubm(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.79    inline void vadduwm(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.80    inline void vadduhm(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.81 +  inline void vaddudm(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.82    inline void vaddubs(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.83    inline void vadduws(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.84    inline void vadduhs(  VectorRegister d, VectorRegister a, VectorRegister b);
   15.85 @@ -1924,6 +1954,7 @@
   15.86    inline void vandc(    VectorRegister d, VectorRegister a, VectorRegister b);
   15.87    inline void vnor(     VectorRegister d, VectorRegister a, VectorRegister b);
   15.88    inline void vor(      VectorRegister d, VectorRegister a, VectorRegister b);
   15.89 +  inline void vmr(      VectorRegister d, VectorRegister a);
   15.90    inline void vxor(     VectorRegister d, VectorRegister a, VectorRegister b);
   15.91    inline void vrld(     VectorRegister d, VectorRegister a, VectorRegister b);
   15.92    inline void vrlb(     VectorRegister d, VectorRegister a, VectorRegister b);
   15.93 @@ -1943,8 +1974,23 @@
   15.94    inline void mfvscr(   VectorRegister d);
   15.95  
   15.96    // Vector-Scalar (VSX) instructions.
   15.97 +  inline void lxvd2x(   VectorSRegister d, Register a);
   15.98 +  inline void lxvd2x(   VectorSRegister d, Register a, Register b);
   15.99 +  inline void stxvd2x(  VectorSRegister d, Register a);
  15.100 +  inline void stxvd2x(  VectorSRegister d, Register a, Register b);
  15.101 +  inline void mtvrwz(   VectorRegister  d, Register a);
  15.102 +  inline void mfvrwz(   Register        a, VectorRegister d);
  15.103    inline void mtvrd(    VectorRegister  d, Register a);
  15.104    inline void mfvrd(    Register        a, VectorRegister d);
  15.105 +  inline void xxpermdi( VectorSRegister d, VectorSRegister a, VectorSRegister b, int dm);
  15.106 +  inline void xxmrghw(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
  15.107 +  inline void xxmrglw(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
  15.108 +
  15.109 +  // VSX Extended Mnemonics
  15.110 +  inline void xxspltd(  VectorSRegister d, VectorSRegister a, int x);
  15.111 +  inline void xxmrghd(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
  15.112 +  inline void xxmrgld(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
  15.113 +  inline void xxswapd(  VectorSRegister d, VectorSRegister a);
  15.114  
  15.115    // AES (introduced with Power 8)
  15.116    inline void vcipher(     VectorRegister d, VectorRegister a, VectorRegister b);
  15.117 @@ -2022,10 +2068,13 @@
  15.118    // Atomics: use ra0mem to disallow R0 as base.
  15.119    inline void lwarx_unchecked(Register d, Register b, int eh1);
  15.120    inline void ldarx_unchecked(Register d, Register b, int eh1);
  15.121 +  inline void lqarx_unchecked(Register d, Register b, int eh1);
  15.122    inline void lwarx( Register d, Register b, bool hint_exclusive_access);
  15.123    inline void ldarx( Register d, Register b, bool hint_exclusive_access);
  15.124 +  inline void lqarx( Register d, Register b, bool hint_exclusive_access);
  15.125    inline void stwcx_(Register s, Register b);
  15.126    inline void stdcx_(Register s, Register b);
  15.127 +  inline void stqcx_(Register s, Register b);
  15.128    inline void lfs(   FloatRegister d, int si16);
  15.129    inline void lfsx(  FloatRegister d, Register b);
  15.130    inline void lfd(   FloatRegister d, int si16);
    16.1 --- a/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Thu Sep 05 18:40:52 2019 +0800
    16.2 +++ b/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Thu Sep 05 18:52:27 2019 +0800
    16.3 @@ -1,6 +1,6 @@
    16.4  /*
    16.5 - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
    16.6 - * Copyright (c) 2012, 2018, SAP SE. All rights reserved.
    16.7 + * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
    16.8 + * Copyright (c) 2012, 2019, SAP SE. All rights reserved.
    16.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   16.10   *
   16.11   * This code is free software; you can redistribute it and/or modify it
   16.12 @@ -504,11 +504,14 @@
   16.13  // Use ra0mem to disallow R0 as base.
   16.14  inline void Assembler::lwarx_unchecked(Register d, Register a, Register b, int eh1)           { emit_int32( LWARX_OPCODE | rt(d) | ra0mem(a) | rb(b) | eh(eh1)); }
   16.15  inline void Assembler::ldarx_unchecked(Register d, Register a, Register b, int eh1)           { emit_int32( LDARX_OPCODE | rt(d) | ra0mem(a) | rb(b) | eh(eh1)); }
   16.16 +inline void Assembler::lqarx_unchecked(Register d, Register a, Register b, int eh1)           { emit_int32( LQARX_OPCODE | rt(d) | ra0mem(a) | rb(b) | eh(eh1)); }
   16.17  inline bool Assembler::lxarx_hint_exclusive_access()                                          { return VM_Version::has_lxarxeh(); }
   16.18  inline void Assembler::lwarx( Register d, Register a, Register b, bool hint_exclusive_access) { lwarx_unchecked(d, a, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.19  inline void Assembler::ldarx( Register d, Register a, Register b, bool hint_exclusive_access) { ldarx_unchecked(d, a, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.20 +inline void Assembler::lqarx( Register d, Register a, Register b, bool hint_exclusive_access) { lqarx_unchecked(d, a, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.21  inline void Assembler::stwcx_(Register s, Register a, Register b)                             { emit_int32( STWCX_OPCODE | rs(s) | ra0mem(a) | rb(b) | rc(1)); }
   16.22  inline void Assembler::stdcx_(Register s, Register a, Register b)                             { emit_int32( STDCX_OPCODE | rs(s) | ra0mem(a) | rb(b) | rc(1)); }
   16.23 +inline void Assembler::stqcx_(Register s, Register a, Register b)                             { emit_int32( STQCX_OPCODE | rs(s) | ra0mem(a) | rb(b) | rc(1)); }
   16.24  
   16.25  // Instructions for adjusting thread priority
   16.26  // for simultaneous multithreading (SMT) on POWER5.
   16.27 @@ -624,8 +627,23 @@
   16.28  inline void Assembler::lvsr(  VectorRegister d, Register s1, Register s2) { emit_int32( LVSR_OPCODE   | vrt(d) | ra0mem(s1) | rb(s2)); }
   16.29  
   16.30  // Vector-Scalar (VSX) instructions.
   16.31 -inline void Assembler::mtvrd(  VectorRegister  d, Register a)               { emit_int32( MTVSRD_OPCODE  | vrt(d)  | ra(a)  | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
   16.32 -inline void Assembler::mfvrd(  Register        a, VectorRegister d)         { emit_int32( MFVSRD_OPCODE  | vrt(d)  | ra(a)  | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
   16.33 +inline void Assembler::lxvd2x(  VectorSRegister d, Register s1)              { emit_int32( LXVD2X_OPCODE  | vsrt(d) | ra(0) | rb(s1)); }
   16.34 +inline void Assembler::lxvd2x(  VectorSRegister d, Register s1, Register s2) { emit_int32( LXVD2X_OPCODE  | vsrt(d) | ra0mem(s1) | rb(s2)); }
   16.35 +inline void Assembler::stxvd2x( VectorSRegister d, Register s1)              { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra(0) | rb(s1)); }
   16.36 +inline void Assembler::stxvd2x( VectorSRegister d, Register s1, Register s2) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra0mem(s1) | rb(s2)); }
   16.37 +inline void Assembler::mtvrd(   VectorRegister  d, Register a)               { emit_int32( MTVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
   16.38 +inline void Assembler::mfvrd(   Register        a, VectorRegister d)         { emit_int32( MFVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
   16.39 +inline void Assembler::mtvrwz(  VectorRegister  d, Register a)               { emit_int32( MTVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
   16.40 +inline void Assembler::mfvrwz(  Register        a, VectorRegister d)         { emit_int32( MFVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
   16.41 +inline void Assembler::xxpermdi(VectorSRegister d, VectorSRegister a, VectorSRegister b, int dm) { emit_int32( XXPERMDI_OPCODE | vsrt(d) | vsra(a) | vsrb(b) | vsdm(dm)); }
   16.42 +inline void Assembler::xxmrghw( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXMRGHW_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
   16.43 +inline void Assembler::xxmrglw( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXMRGHW_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
   16.44 +
   16.45 +// VSX Extended Mnemonics
   16.46 +inline void Assembler::xxspltd( VectorSRegister d, VectorSRegister a, int x)             { xxpermdi(d, a, a, x ? 3 : 0); }
   16.47 +inline void Assembler::xxmrghd( VectorSRegister d, VectorSRegister a, VectorSRegister b) { xxpermdi(d, a, b, 0); }
   16.48 +inline void Assembler::xxmrgld( VectorSRegister d, VectorSRegister a, VectorSRegister b) { xxpermdi(d, a, b, 3); }
   16.49 +inline void Assembler::xxswapd( VectorSRegister d, VectorSRegister a)                    { xxpermdi(d, a, a, 2); }
   16.50  
   16.51  inline void Assembler::vpkpx(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKPX_OPCODE   | vrt(d) | vra(a) | vrb(b)); }
   16.52  inline void Assembler::vpkshss( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKSHSS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.53 @@ -668,6 +686,7 @@
   16.54  inline void Assembler::vaddubm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUBM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.55  inline void Assembler::vadduwm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUWM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.56  inline void Assembler::vadduhm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUHM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.57 +inline void Assembler::vaddudm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUDM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.58  inline void Assembler::vaddubs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUBS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.59  inline void Assembler::vadduws( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUWS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.60  inline void Assembler::vadduhs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUHS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
   16.61 @@ -744,6 +763,7 @@
   16.62  inline void Assembler::vandc(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VANDC_OPCODE    | vrt(d) | vra(a) | vrb(b)); }
   16.63  inline void Assembler::vnor(    VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VNOR_OPCODE     | vrt(d) | vra(a) | vrb(b)); }
   16.64  inline void Assembler::vor(     VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VOR_OPCODE      | vrt(d) | vra(a) | vrb(b)); }
   16.65 +inline void Assembler::vmr(     VectorRegister d, VectorRegister a)                   { emit_int32( VOR_OPCODE      | vrt(d) | vra(a) | vrb(a)); }
   16.66  inline void Assembler::vxor(    VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VXOR_OPCODE     | vrt(d) | vra(a) | vrb(b)); }
   16.67  inline void Assembler::vrld(    VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VRLD_OPCODE     | vrt(d) | vra(a) | vrb(b)); }
   16.68  inline void Assembler::vrlb(    VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VRLB_OPCODE     | vrt(d) | vra(a) | vrb(b)); }
   16.69 @@ -833,10 +853,13 @@
   16.70  // ra0 version
   16.71  inline void Assembler::lwarx_unchecked(Register d, Register b, int eh1)          { emit_int32( LWARX_OPCODE | rt(d) | rb(b) | eh(eh1)); }
   16.72  inline void Assembler::ldarx_unchecked(Register d, Register b, int eh1)          { emit_int32( LDARX_OPCODE | rt(d) | rb(b) | eh(eh1)); }
   16.73 +inline void Assembler::lqarx_unchecked(Register d, Register b, int eh1)          { emit_int32( LQARX_OPCODE | rt(d) | rb(b) | eh(eh1)); }
   16.74  inline void Assembler::lwarx( Register d, Register b, bool hint_exclusive_access){ lwarx_unchecked(d, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.75  inline void Assembler::ldarx( Register d, Register b, bool hint_exclusive_access){ ldarx_unchecked(d, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.76 +inline void Assembler::lqarx( Register d, Register b, bool hint_exclusive_access){ lqarx_unchecked(d, b, (hint_exclusive_access && lxarx_hint_exclusive_access() && UseExtendedLoadAndReserveInstructionsPPC64) ? 1 : 0); }
   16.77  inline void Assembler::stwcx_(Register s, Register b)                            { emit_int32( STWCX_OPCODE | rs(s) | rb(b) | rc(1)); }
   16.78  inline void Assembler::stdcx_(Register s, Register b)                            { emit_int32( STDCX_OPCODE | rs(s) | rb(b) | rc(1)); }
   16.79 +inline void Assembler::stqcx_(Register s, Register b)                            { emit_int32( STQCX_OPCODE | rs(s) | rb(b) | rc(1)); }
   16.80  
   16.81  // ra0 version
   16.82  inline void Assembler::lfs( FloatRegister d, int si16)   { emit_int32( LFS_OPCODE  | frt(d) | simm(si16,16)); }
    17.1 --- a/src/cpu/ppc/vm/frame_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    17.2 +++ b/src/cpu/ppc/vm/frame_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    17.3 @@ -1,6 +1,6 @@
    17.4  /*
    17.5 - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
    17.6 - * Copyright 2012, 2014 SAP AG. All rights reserved.
    17.7 + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
    17.8 + * Copyright (c) 2012, 2017 SAP AG. All rights reserved.
    17.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   17.10   *
   17.11   * This code is free software; you can redistribute it and/or modify it
   17.12 @@ -190,10 +190,7 @@
   17.13      switch (method->result_type()) {
   17.14        case T_OBJECT:
   17.15        case T_ARRAY: {
   17.16 -        oop* obj_p = *(oop**)lresult;
   17.17 -        oop obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
   17.18 -        assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
   17.19 -        *oop_result = obj;
   17.20 +        *oop_result = JNIHandles::resolve(*(jobject*)lresult);
   17.21          break;
   17.22        }
   17.23        // We use std/stfd to store the values.
    18.1 --- a/src/cpu/ppc/vm/globals_ppc.hpp	Thu Sep 05 18:40:52 2019 +0800
    18.2 +++ b/src/cpu/ppc/vm/globals_ppc.hpp	Thu Sep 05 18:52:27 2019 +0800
    18.3 @@ -1,6 +1,6 @@
    18.4  /*
    18.5 - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 - * Copyright 2012, 2013 SAP AG. All rights reserved.
    18.7 + * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
    18.8 + * Copyright 2012, 2018 SAP AG. All rights reserved.
    18.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   18.10   *
   18.11   * This code is free software; you can redistribute it and/or modify it
   18.12 @@ -81,6 +81,19 @@
   18.13    product(bool, ReoptimizeCallSequences, true,                              \
   18.14            "Reoptimize code-sequences of calls at runtime.")                 \
   18.15                                                                              \
   18.16 +  /* Power 8: Configure Data Stream Control Register. */                    \
   18.17 +  product(uint64_t,DSCR_PPC64, (uintx)-1,                                   \
   18.18 +          "Power8 or later: Specify encoded value for Data Stream Control " \
   18.19 +          "Register")                                                       \
   18.20 +  product(uint64_t,DSCR_DPFD_PPC64, 8,                                      \
   18.21 +          "Power8 or later: DPFD (default prefetch depth) value of the "    \
   18.22 +          "Data Stream Control Register."                                   \
   18.23 +          " 0: hardware default, 1: none, 2-7: min-max, 8: don't touch")    \
   18.24 +  product(uint64_t,DSCR_URG_PPC64, 8,                                       \
   18.25 +          "Power8 or later: URG (depth attainment urgency) value of the "   \
   18.26 +          "Data Stream Control Register."                                   \
   18.27 +          " 0: hardware default, 1: none, 2-7: min-max, 8: don't touch")    \
   18.28 +                                                                            \
   18.29    product(bool, UseLoadInstructionsForStackBangingPPC64, false,             \
   18.30            "Use load instructions for stack banging.")                       \
   18.31                                                                              \
    19.1 --- a/src/cpu/ppc/vm/interpreter_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    19.2 +++ b/src/cpu/ppc/vm/interpreter_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    19.3 @@ -1,6 +1,6 @@
    19.4  /*
    19.5 - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    19.6 - * Copyright 2012, 2015 SAP AG. All rights reserved.
    19.7 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    19.8 + * Copyright (c) 2012, 2017 SAP AG. All rights reserved.
    19.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   19.10   *
   19.11   * This code is free software; you can redistribute it and/or modify it
   19.12 @@ -413,11 +413,8 @@
   19.13    case T_LONG:
   19.14       break;
   19.15    case T_OBJECT:
   19.16 -    // unbox result if not null
   19.17 -    __ cmpdi(CCR0, R3_RET, 0);
   19.18 -    __ beq(CCR0, done);
   19.19 -    __ ld(R3_RET, 0, R3_RET);
   19.20 -    __ verify_oop(R3_RET);
   19.21 +    // JNIHandles::resolve result.
   19.22 +    __ resolve_jobject(R3_RET, R11_scratch1, R12_scratch2, /* needs_frame */ true); // kills R31
   19.23      break;
   19.24    case T_FLOAT:
   19.25       break;
    20.1 --- a/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    20.2 +++ b/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    20.3 @@ -1,6 +1,6 @@
    20.4  /*
    20.5 - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
    20.6 - * Copyright (c) 2012, 2018, SAP SE. All rights reserved.
    20.7 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    20.8 + * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
    20.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   20.10   *
   20.11   * This code is free software; you can redistribute it and/or modify it
   20.12 @@ -2220,6 +2220,34 @@
   20.13    stbx(R0, Rtmp, Robj);
   20.14  }
   20.15  
   20.16 +// Kills R31 if value is a volatile register.
   20.17 +void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame) {
   20.18 +  Label done;
   20.19 +  cmpdi(CCR0, value, 0);
   20.20 +  beq(CCR0, done);         // Use NULL as-is.
   20.21 +
   20.22 +  clrrdi(tmp1, value, JNIHandles::weak_tag_size);
   20.23 +#if INCLUDE_ALL_GCS
   20.24 +  if (UseG1GC) { andi_(tmp2, value, JNIHandles::weak_tag_mask); }
   20.25 +#endif
   20.26 +  ld(value, 0, tmp1);      // Resolve (untagged) jobject.
   20.27 +
   20.28 +#if INCLUDE_ALL_GCS
   20.29 +  if (UseG1GC) {
   20.30 +    Label not_weak;
   20.31 +    beq(CCR0, not_weak);   // Test for jweak tag.
   20.32 +    verify_oop(value);
   20.33 +    g1_write_barrier_pre(noreg, // obj
   20.34 +                         noreg, // offset
   20.35 +                         value, // pre_val
   20.36 +                         tmp1, tmp2, needs_frame);
   20.37 +    bind(not_weak);
   20.38 +  }
   20.39 +#endif // INCLUDE_ALL_GCS
   20.40 +  verify_oop(value);
   20.41 +  bind(done);
   20.42 +}
   20.43 +
   20.44  #if INCLUDE_ALL_GCS
   20.45  // General G1 pre-barrier generator.
   20.46  // Goal: record the previous value if it is not null.
   20.47 @@ -2281,7 +2309,7 @@
   20.48  
   20.49    bind(runtime);
   20.50  
   20.51 -  // VM call need frame to access(write) O register.
   20.52 +  // May need to preserve LR. Also needed if current frame is not compatible with C calling convention.
   20.53    if (needs_frame) {
   20.54      save_LR_CR(Rtmp1);
   20.55      push_frame_reg_args(0, Rtmp2);
    21.1 --- a/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Sep 05 18:40:52 2019 +0800
    21.2 +++ b/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Sep 05 18:52:27 2019 +0800
    21.3 @@ -1,6 +1,6 @@
    21.4  /*
    21.5   * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
    21.6 - * Copyright 2012, 2017 SAP AG. All rights reserved.
    21.7 + * Copyright (c) 2012, 2017 SAP AG. All rights reserved.
    21.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.9   *
   21.10   * This code is free software; you can redistribute it and/or modify it
   21.11 @@ -516,6 +516,8 @@
   21.12    void card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp);
   21.13    void card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj);
   21.14  
   21.15 +  void resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame);
   21.16 +
   21.17  #if INCLUDE_ALL_GCS
   21.18    // General G1 pre-barrier generator.
   21.19    void g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val,
    22.1 --- a/src/cpu/ppc/vm/register_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    22.2 +++ b/src/cpu/ppc/vm/register_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    22.3 @@ -1,6 +1,6 @@
    22.4  /*
    22.5 - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 - * Copyright 2012, 2013 SAP AG. All rights reserved.
    22.7 + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    22.8 + * Copyright 2012, 2018 SAP AG. All rights reserved.
    22.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   22.10   *
   22.11   * This code is free software; you can redistribute it and/or modify it
   22.12 @@ -75,3 +75,23 @@
   22.13    };
   22.14    return is_valid() ? names[encoding()] : "vnoreg";
   22.15  }
   22.16 +
   22.17 +const char* VectorSRegisterImpl::name() const {
   22.18 +  const char* names[number_of_registers] = {
   22.19 +    "VSR0",  "VSR1",  "VSR2",  "VSR3",  "VSR4",  "VSR5",  "VSR6",  "VSR7",
   22.20 +    "VSR8",  "VSR9",  "VSR10", "VSR11", "VSR12", "VSR13", "VSR14", "VSR15",
   22.21 +    "VSR16", "VSR17", "VSR18", "VSR19", "VSR20", "VSR21", "VSR22", "VSR23",
   22.22 +    "VSR24", "VSR25", "VSR26", "VSR27", "VSR28", "VSR29", "VSR30", "VSR31",
   22.23 +    "VSR32", "VSR33", "VSR34", "VSR35", "VSR36", "VSR37", "VSR38", "VSR39",
   22.24 +    "VSR40", "VSR41", "VSR42", "VSR43", "VSR44", "VSR45", "VSR46", "VSR47",
   22.25 +    "VSR48", "VSR49", "VSR50", "VSR51", "VSR52", "VSR53", "VSR54", "VSR55",
   22.26 +    "VSR56", "VSR57", "VSR58", "VSR59", "VSR60", "VSR61", "VSR62", "VSR63"
   22.27 +  };
   22.28 +  return is_valid() ? names[encoding()] : "vsnoreg";
   22.29 +}
   22.30 +
   22.31 +// Method to convert a VectorRegister to a Vector-Scalar Register (VectorSRegister)
   22.32 +VectorSRegister VectorRegisterImpl::to_vsr() const {
   22.33 +  if (this == vnoreg) { return vsnoregi; }
   22.34 +  return as_VectorSRegister(encoding() + 32);
   22.35 +}
    23.1 --- a/src/cpu/ppc/vm/register_ppc.hpp	Thu Sep 05 18:40:52 2019 +0800
    23.2 +++ b/src/cpu/ppc/vm/register_ppc.hpp	Thu Sep 05 18:52:27 2019 +0800
    23.3 @@ -1,6 +1,6 @@
    23.4  /*
    23.5 - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    23.6 - * Copyright 2012, 2014 SAP AG. All rights reserved.
    23.7 + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    23.8 + * Copyright 2012, 2018 SAP AG. All rights reserved.
    23.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   23.10   *
   23.11   * This code is free software; you can redistribute it and/or modify it
   23.12 @@ -399,6 +399,11 @@
   23.13    return (VectorRegister)(intptr_t)encoding;
   23.14  }
   23.15  
   23.16 +// Forward declaration
   23.17 +// Use VectorSRegister as a shortcut.
   23.18 +class VectorSRegisterImpl;
   23.19 +typedef VectorSRegisterImpl* VectorSRegister;
   23.20 +
   23.21  // The implementation of vector registers for the Power architecture
   23.22  class VectorRegisterImpl: public AbstractRegisterImpl {
   23.23   public:
   23.24 @@ -416,6 +421,9 @@
   23.25    bool is_valid()       const { return   0 <=  value()       &&  value() < number_of_registers; }
   23.26  
   23.27    const char* name() const;
   23.28 +
   23.29 +  // convert to VSR
   23.30 +  VectorSRegister to_vsr() const;
   23.31  };
   23.32  
   23.33  // The Vector registers of the Power architecture
   23.34 @@ -492,6 +500,166 @@
   23.35  #endif // DONT_USE_REGISTER_DEFINES
   23.36  
   23.37  
   23.38 +inline VectorSRegister as_VectorSRegister(int encoding) {
   23.39 +  return (VectorSRegister)(intptr_t)encoding;
   23.40 +}
   23.41 +
   23.42 +// The implementation of Vector-Scalar (VSX) registers on POWER architecture.
   23.43 +class VectorSRegisterImpl: public AbstractRegisterImpl {
   23.44 + public:
   23.45 +  enum {
   23.46 +    number_of_registers = 64
   23.47 +  };
   23.48 +
   23.49 +  // construction
   23.50 +  inline friend VectorSRegister as_VectorSRegister(int encoding);
   23.51 +
   23.52 +  // accessors
   23.53 +  int encoding() const { assert(is_valid(), "invalid register"); return value(); }
   23.54 +
   23.55 +  // testers
   23.56 +  bool is_valid() const { return 0 <=  value() &&  value() < number_of_registers; }
   23.57 +
   23.58 +  const char* name() const;
   23.59 +};
   23.60 +
   23.61 +// The Vector-Scalar (VSX) registers of the POWER architecture.
   23.62 +
   23.63 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, vsnoreg, (-1));
   23.64 +
   23.65 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR0,  ( 0));
   23.66 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR1,  ( 1));
   23.67 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR2,  ( 2));
   23.68 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR3,  ( 3));
   23.69 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR4,  ( 4));
   23.70 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR5,  ( 5));
   23.71 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR6,  ( 6));
   23.72 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR7,  ( 7));
   23.73 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR8,  ( 8));
   23.74 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR9,  ( 9));
   23.75 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR10, (10));
   23.76 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR11, (11));
   23.77 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR12, (12));
   23.78 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR13, (13));
   23.79 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR14, (14));
   23.80 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR15, (15));
   23.81 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR16, (16));
   23.82 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR17, (17));
   23.83 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR18, (18));
   23.84 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR19, (19));
   23.85 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR20, (20));
   23.86 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR21, (21));
   23.87 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR22, (22));
   23.88 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR23, (23));
   23.89 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR24, (24));
   23.90 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR25, (25));
   23.91 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR26, (26));
   23.92 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR27, (27));
   23.93 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR28, (28));
   23.94 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR29, (29));
   23.95 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR30, (30));
   23.96 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR31, (31));
   23.97 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR32, (32));
   23.98 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR33, (33));
   23.99 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR34, (34));
  23.100 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR35, (35));
  23.101 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR36, (36));
  23.102 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR37, (37));
  23.103 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR38, (38));
  23.104 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR39, (39));
  23.105 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR40, (40));
  23.106 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR41, (41));
  23.107 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR42, (42));
  23.108 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR43, (43));
  23.109 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR44, (44));
  23.110 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR45, (45));
  23.111 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR46, (46));
  23.112 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR47, (47));
  23.113 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR48, (48));
  23.114 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR49, (49));
  23.115 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR50, (50));
  23.116 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR51, (51));
  23.117 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR52, (52));
  23.118 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR53, (53));
  23.119 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR54, (54));
  23.120 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR55, (55));
  23.121 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR56, (56));
  23.122 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR57, (57));
  23.123 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR58, (58));
  23.124 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR59, (59));
  23.125 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR60, (60));
  23.126 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR61, (61));
  23.127 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR62, (62));
  23.128 +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR63, (63));
  23.129 +
  23.130 +#ifndef DONT_USE_REGISTER_DEFINES
  23.131 +#define vsnoregi ((VectorSRegister)(vsnoreg_VectorSRegisterEnumValue))
  23.132 +#define VSR0    ((VectorSRegister)(   VSR0_VectorSRegisterEnumValue))
  23.133 +#define VSR1    ((VectorSRegister)(   VSR1_VectorSRegisterEnumValue))
  23.134 +#define VSR2    ((VectorSRegister)(   VSR2_VectorSRegisterEnumValue))
  23.135 +#define VSR3    ((VectorSRegister)(   VSR3_VectorSRegisterEnumValue))
  23.136 +#define VSR4    ((VectorSRegister)(   VSR4_VectorSRegisterEnumValue))
  23.137 +#define VSR5    ((VectorSRegister)(   VSR5_VectorSRegisterEnumValue))
  23.138 +#define VSR6    ((VectorSRegister)(   VSR6_VectorSRegisterEnumValue))
  23.139 +#define VSR7    ((VectorSRegister)(   VSR7_VectorSRegisterEnumValue))
  23.140 +#define VSR8    ((VectorSRegister)(   VSR8_VectorSRegisterEnumValue))
  23.141 +#define VSR9    ((VectorSRegister)(   VSR9_VectorSRegisterEnumValue))
  23.142 +#define VSR10   ((VectorSRegister)(  VSR10_VectorSRegisterEnumValue))
  23.143 +#define VSR11   ((VectorSRegister)(  VSR11_VectorSRegisterEnumValue))
  23.144 +#define VSR12   ((VectorSRegister)(  VSR12_VectorSRegisterEnumValue))
  23.145 +#define VSR13   ((VectorSRegister)(  VSR13_VectorSRegisterEnumValue))
  23.146 +#define VSR14   ((VectorSRegister)(  VSR14_VectorSRegisterEnumValue))
  23.147 +#define VSR15   ((VectorSRegister)(  VSR15_VectorSRegisterEnumValue))
  23.148 +#define VSR16   ((VectorSRegister)(  VSR16_VectorSRegisterEnumValue))
  23.149 +#define VSR17   ((VectorSRegister)(  VSR17_VectorSRegisterEnumValue))
  23.150 +#define VSR18   ((VectorSRegister)(  VSR18_VectorSRegisterEnumValue))
  23.151 +#define VSR19   ((VectorSRegister)(  VSR19_VectorSRegisterEnumValue))
  23.152 +#define VSR20   ((VectorSRegister)(  VSR20_VectorSRegisterEnumValue))
  23.153 +#define VSR21   ((VectorSRegister)(  VSR21_VectorSRegisterEnumValue))
  23.154 +#define VSR22   ((VectorSRegister)(  VSR22_VectorSRegisterEnumValue))
  23.155 +#define VSR23   ((VectorSRegister)(  VSR23_VectorSRegisterEnumValue))
  23.156 +#define VSR24   ((VectorSRegister)(  VSR24_VectorSRegisterEnumValue))
  23.157 +#define VSR25   ((VectorSRegister)(  VSR25_VectorSRegisterEnumValue))
  23.158 +#define VSR26   ((VectorSRegister)(  VSR26_VectorSRegisterEnumValue))
  23.159 +#define VSR27   ((VectorSRegister)(  VSR27_VectorSRegisterEnumValue))
  23.160 +#define VSR28   ((VectorSRegister)(  VSR28_VectorSRegisterEnumValue))
  23.161 +#define VSR29   ((VectorSRegister)(  VSR29_VectorSRegisterEnumValue))
  23.162 +#define VSR30   ((VectorSRegister)(  VSR30_VectorSRegisterEnumValue))
  23.163 +#define VSR31   ((VectorSRegister)(  VSR31_VectorSRegisterEnumValue))
  23.164 +#define VSR32   ((VectorSRegister)(  VSR32_VectorSRegisterEnumValue))
  23.165 +#define VSR33   ((VectorSRegister)(  VSR33_VectorSRegisterEnumValue))
  23.166 +#define VSR34   ((VectorSRegister)(  VSR34_VectorSRegisterEnumValue))
  23.167 +#define VSR35   ((VectorSRegister)(  VSR35_VectorSRegisterEnumValue))
  23.168 +#define VSR36   ((VectorSRegister)(  VSR36_VectorSRegisterEnumValue))
  23.169 +#define VSR37   ((VectorSRegister)(  VSR37_VectorSRegisterEnumValue))
  23.170 +#define VSR38   ((VectorSRegister)(  VSR38_VectorSRegisterEnumValue))
  23.171 +#define VSR39   ((VectorSRegister)(  VSR39_VectorSRegisterEnumValue))
  23.172 +#define VSR40   ((VectorSRegister)(  VSR40_VectorSRegisterEnumValue))
  23.173 +#define VSR41   ((VectorSRegister)(  VSR41_VectorSRegisterEnumValue))
  23.174 +#define VSR42   ((VectorSRegister)(  VSR42_VectorSRegisterEnumValue))
  23.175 +#define VSR43   ((VectorSRegister)(  VSR43_VectorSRegisterEnumValue))
  23.176 +#define VSR44   ((VectorSRegister)(  VSR44_VectorSRegisterEnumValue))
  23.177 +#define VSR45   ((VectorSRegister)(  VSR45_VectorSRegisterEnumValue))
  23.178 +#define VSR46   ((VectorSRegister)(  VSR46_VectorSRegisterEnumValue))
  23.179 +#define VSR47   ((VectorSRegister)(  VSR47_VectorSRegisterEnumValue))
  23.180 +#define VSR48   ((VectorSRegister)(  VSR48_VectorSRegisterEnumValue))
  23.181 +#define VSR49   ((VectorSRegister)(  VSR49_VectorSRegisterEnumValue))
  23.182 +#define VSR50   ((VectorSRegister)(  VSR50_VectorSRegisterEnumValue))
  23.183 +#define VSR51   ((VectorSRegister)(  VSR51_VectorSRegisterEnumValue))
  23.184 +#define VSR52   ((VectorSRegister)(  VSR52_VectorSRegisterEnumValue))
  23.185 +#define VSR53   ((VectorSRegister)(  VSR53_VectorSRegisterEnumValue))
  23.186 +#define VSR54   ((VectorSRegister)(  VSR54_VectorSRegisterEnumValue))
  23.187 +#define VSR55   ((VectorSRegister)(  VSR55_VectorSRegisterEnumValue))
  23.188 +#define VSR56   ((VectorSRegister)(  VSR56_VectorSRegisterEnumValue))
  23.189 +#define VSR57   ((VectorSRegister)(  VSR57_VectorSRegisterEnumValue))
  23.190 +#define VSR58   ((VectorSRegister)(  VSR58_VectorSRegisterEnumValue))
  23.191 +#define VSR59   ((VectorSRegister)(  VSR59_VectorSRegisterEnumValue))
  23.192 +#define VSR60   ((VectorSRegister)(  VSR60_VectorSRegisterEnumValue))
  23.193 +#define VSR61   ((VectorSRegister)(  VSR61_VectorSRegisterEnumValue))
  23.194 +#define VSR62   ((VectorSRegister)(  VSR62_VectorSRegisterEnumValue))
  23.195 +#define VSR63   ((VectorSRegister)(  VSR63_VectorSRegisterEnumValue))
  23.196 +#endif // DONT_USE_REGISTER_DEFINES
  23.197 +
  23.198  // Maximum number of incoming arguments that can be passed in i registers.
  23.199  const int PPC_ARGS_IN_REGS_NUM = 8;
  23.200  
  23.201 @@ -510,7 +678,7 @@
  23.202        * 2                                          // register halves
  23.203        + ConditionRegisterImpl::number_of_registers // condition code registers
  23.204        + SpecialRegisterImpl::number_of_registers   // special registers
  23.205 -      + VectorRegisterImpl::number_of_registers    // vector registers
  23.206 +      + VectorRegisterImpl::number_of_registers    // VSX registers
  23.207    };
  23.208  
  23.209    static const int max_gpr;
    24.1 --- a/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    24.2 +++ b/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    24.3 @@ -1,6 +1,6 @@
    24.4  /*
    24.5   * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    24.6 - * Copyright 2012, 2014 SAP AG. All rights reserved.
    24.7 + * Copyright (c) 2012, 2017 SAP AG. All rights reserved.
    24.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.9   *
   24.10   * This code is free software; you can redistribute it and/or modify it
   24.11 @@ -2513,16 +2513,11 @@
   24.12  
   24.13    __ reset_last_Java_frame();
   24.14  
   24.15 -  // Unpack oop result.
   24.16 +  // Unbox oop result, e.g. JNIHandles::resolve value.
   24.17    // --------------------------------------------------------------------------
   24.18  
   24.19    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   24.20 -    Label skip_unboxing;
   24.21 -    __ cmpdi(CCR0, R3_RET, 0);
   24.22 -    __ beq(CCR0, skip_unboxing);
   24.23 -    __ ld(R3_RET, 0, R3_RET);
   24.24 -    __ bind(skip_unboxing);
   24.25 -    __ verify_oop(R3_RET);
   24.26 +    __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, /* needs_frame */ false); // kills R31
   24.27    }
   24.28  
   24.29  
    25.1 --- a/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    25.2 +++ b/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    25.3 @@ -1,6 +1,6 @@
    25.4  /*
    25.5 - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
    25.6 - * Copyright (c) 2012, 2018, SAP SE. All rights reserved.
    25.7 + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
    25.8 + * Copyright (c) 2012, 2019, SAP SE. All rights reserved.
    25.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   25.10   *
   25.11   * This code is free software; you can redistribute it and/or modify it
   25.12 @@ -1131,8 +1131,11 @@
   25.13      Register tmp3 = R8_ARG6;
   25.14      Register tmp4 = R9_ARG7;
   25.15  
   25.16 -
   25.17 -    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9;
   25.18 +    VectorSRegister tmp_vsr1  = VSR1;
   25.19 +    VectorSRegister tmp_vsr2  = VSR2;
   25.20 +
   25.21 +    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9, l_10;
   25.22 +
   25.23      // Don't try anything fancy if arrays don't have many elements.
   25.24      __ li(tmp3, 0);
   25.25      __ cmpwi(CCR0, R5_ARG3, 17);
   25.26 @@ -1186,6 +1189,8 @@
   25.27        __ andi_(R5_ARG3, R5_ARG3, 31);
   25.28        __ mtctr(tmp1);
   25.29  
   25.30 +     if (!VM_Version::has_vsx()) {
   25.31 +
   25.32        __ bind(l_8);
   25.33        // Use unrolled version for mass copying (copy 32 elements a time)
   25.34        // Load feeding store gets zero latency on Power6, however not on Power5.
   25.35 @@ -1201,7 +1206,44 @@
   25.36        __ addi(R3_ARG1, R3_ARG1, 32);
   25.37        __ addi(R4_ARG2, R4_ARG2, 32);
   25.38        __ bdnz(l_8);
   25.39 -    }
   25.40 +
   25.41 +    } else { // Processor supports VSX, so use it to mass copy.
   25.42 +
   25.43 +      // Prefetch the data into the L2 cache.
   25.44 +      __ dcbt(R3_ARG1, 0);
   25.45 +
   25.46 +      // If supported set DSCR pre-fetch to deepest.
   25.47 +      if (VM_Version::has_mfdscr()) {
   25.48 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
   25.49 +        __ mtdscr(tmp2);
   25.50 +      }
   25.51 +
   25.52 +      __ li(tmp1, 16);
   25.53 +
   25.54 +      // Backbranch target aligned to 32-byte. Not 16-byte align as
   25.55 +      // loop contains < 8 instructions that fit inside a single
   25.56 +      // i-cache sector.
   25.57 +      __ align(32);
   25.58 +
   25.59 +      __ bind(l_10);
   25.60 +      // Use loop with VSX load/store instructions to
   25.61 +      // copy 32 elements a time.
   25.62 +      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
   25.63 +      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
   25.64 +      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
   25.65 +      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
   25.66 +      __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
   25.67 +      __ addi(R4_ARG2, R4_ARG2, 32);       // Update dsc+=32
   25.68 +      __ bdnz(l_10);                       // Dec CTR and loop if not zero.
   25.69 +
   25.70 +      // Restore DSCR pre-fetch value.
   25.71 +      if (VM_Version::has_mfdscr()) {
   25.72 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
   25.73 +        __ mtdscr(tmp2);
   25.74 +      }
   25.75 +
   25.76 +    } // VSX
   25.77 +   } // FasterArrayCopy
   25.78  
   25.79      __ bind(l_6);
   25.80  
   25.81 @@ -1352,9 +1394,13 @@
   25.82      Register tmp3 = R8_ARG6;
   25.83      Register tmp4 = R9_ARG7;
   25.84  
   25.85 +    VectorSRegister tmp_vsr1  = VSR1;
   25.86 +    VectorSRegister tmp_vsr2  = VSR2;
   25.87 +
   25.88      address start = __ function_entry();
   25.89  
   25.90 -      Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8;
   25.91 +    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9;
   25.92 +
   25.93      // don't try anything fancy if arrays don't have many elements
   25.94      __ li(tmp3, 0);
   25.95      __ cmpwi(CCR0, R5_ARG3, 9);
   25.96 @@ -1412,22 +1458,60 @@
   25.97        __ andi_(R5_ARG3, R5_ARG3, 15);
   25.98        __ mtctr(tmp1);
   25.99  
  25.100 -      __ bind(l_8);
  25.101 -      // Use unrolled version for mass copying (copy 16 elements a time).
  25.102 -      // Load feeding store gets zero latency on Power6, however not on Power5.
  25.103 -      // Therefore, the following sequence is made for the good of both.
  25.104 -      __ ld(tmp1, 0, R3_ARG1);
  25.105 -      __ ld(tmp2, 8, R3_ARG1);
  25.106 -      __ ld(tmp3, 16, R3_ARG1);
  25.107 -      __ ld(tmp4, 24, R3_ARG1);
  25.108 -      __ std(tmp1, 0, R4_ARG2);
  25.109 -      __ std(tmp2, 8, R4_ARG2);
  25.110 -      __ std(tmp3, 16, R4_ARG2);
  25.111 -      __ std(tmp4, 24, R4_ARG2);
  25.112 -      __ addi(R3_ARG1, R3_ARG1, 32);
  25.113 -      __ addi(R4_ARG2, R4_ARG2, 32);
  25.114 -      __ bdnz(l_8);
  25.115 -    }
  25.116 +      if (!VM_Version::has_vsx()) {
  25.117 +
  25.118 +        __ bind(l_8);
  25.119 +        // Use unrolled version for mass copying (copy 16 elements a time).
  25.120 +        // Load feeding store gets zero latency on Power6, however not on Power5.
  25.121 +        // Therefore, the following sequence is made for the good of both.
  25.122 +        __ ld(tmp1, 0, R3_ARG1);
  25.123 +        __ ld(tmp2, 8, R3_ARG1);
  25.124 +        __ ld(tmp3, 16, R3_ARG1);
  25.125 +        __ ld(tmp4, 24, R3_ARG1);
  25.126 +        __ std(tmp1, 0, R4_ARG2);
  25.127 +        __ std(tmp2, 8, R4_ARG2);
  25.128 +        __ std(tmp3, 16, R4_ARG2);
  25.129 +        __ std(tmp4, 24, R4_ARG2);
  25.130 +        __ addi(R3_ARG1, R3_ARG1, 32);
  25.131 +        __ addi(R4_ARG2, R4_ARG2, 32);
  25.132 +        __ bdnz(l_8);
  25.133 +
  25.134 +      } else { // Processor supports VSX, so use it to mass copy.
  25.135 +
  25.136 +        // Prefetch src data into L2 cache.
  25.137 +        __ dcbt(R3_ARG1, 0);
  25.138 +
  25.139 +        // If supported set DSCR pre-fetch to deepest.
  25.140 +        if (VM_Version::has_mfdscr()) {
  25.141 +          __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
  25.142 +          __ mtdscr(tmp2);
  25.143 +        }
  25.144 +        __ li(tmp1, 16);
  25.145 +
  25.146 +        // Backbranch target aligned to 32-byte. It's not aligned 16-byte
  25.147 +        // as loop contains < 8 instructions that fit inside a single
  25.148 +        // i-cache sector.
  25.149 +        __ align(32);
  25.150 +
  25.151 +        __ bind(l_9);
  25.152 +        // Use loop with VSX load/store instructions to
  25.153 +        // copy 16 elements a time.
  25.154 +        __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load from src.
  25.155 +        __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst.
  25.156 +        __ lxvd2x(tmp_vsr2, R3_ARG1, tmp1);  // Load from src + 16.
  25.157 +        __ stxvd2x(tmp_vsr2, R4_ARG2, tmp1); // Store to dst + 16.
  25.158 +        __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32.
  25.159 +        __ addi(R4_ARG2, R4_ARG2, 32);       // Update dsc+=32.
  25.160 +        __ bdnz(l_9);                        // Dec CTR and loop if not zero.
  25.161 +
  25.162 +        // Restore DSCR pre-fetch value.
  25.163 +        if (VM_Version::has_mfdscr()) {
  25.164 +          __ load_const_optimized(tmp2, VM_Version::_dscr_val);
  25.165 +          __ mtdscr(tmp2);
  25.166 +        }
  25.167 +
  25.168 +      }
  25.169 +    } // FasterArrayCopy
  25.170      __ bind(l_6);
  25.171  
  25.172      // copy 2 elements at a time
  25.173 @@ -1528,7 +1612,11 @@
  25.174      Register tmp3 = R8_ARG6;
  25.175      Register tmp4 = R0;
  25.176  
  25.177 -    Label l_1, l_2, l_3, l_4, l_5, l_6;
  25.178 +    VectorSRegister tmp_vsr1  = VSR1;
  25.179 +    VectorSRegister tmp_vsr2  = VSR2;
  25.180 +
  25.181 +    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7;
  25.182 +
  25.183      // for short arrays, just do single element copy
  25.184      __ li(tmp3, 0);
  25.185      __ cmpwi(CCR0, R5_ARG3, 5);
  25.186 @@ -1563,6 +1651,8 @@
  25.187        __ andi_(R5_ARG3, R5_ARG3, 7);
  25.188        __ mtctr(tmp1);
  25.189  
  25.190 +     if (!VM_Version::has_vsx()) {
  25.191 +
  25.192        __ bind(l_6);
  25.193        // Use unrolled version for mass copying (copy 8 elements a time).
  25.194        // Load feeding store gets zero latency on power6, however not on power 5.
  25.195 @@ -1578,7 +1668,44 @@
  25.196        __ addi(R3_ARG1, R3_ARG1, 32);
  25.197        __ addi(R4_ARG2, R4_ARG2, 32);
  25.198        __ bdnz(l_6);
  25.199 -    }
  25.200 +
  25.201 +    } else { // Processor supports VSX, so use it to mass copy.
  25.202 +
  25.203 +      // Prefetch the data into the L2 cache.
  25.204 +      __ dcbt(R3_ARG1, 0);
  25.205 +
  25.206 +      // If supported set DSCR pre-fetch to deepest.
  25.207 +      if (VM_Version::has_mfdscr()) {
  25.208 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
  25.209 +        __ mtdscr(tmp2);
  25.210 +      }
  25.211 +
  25.212 +      __ li(tmp1, 16);
  25.213 +
  25.214 +      // Backbranch target aligned to 32-byte. Not 16-byte align as
  25.215 +      // loop contains < 8 instructions that fit inside a single
  25.216 +      // i-cache sector.
  25.217 +      __ align(32);
  25.218 +
  25.219 +      __ bind(l_7);
  25.220 +      // Use loop with VSX load/store instructions to
  25.221 +      // copy 8 elements a time.
  25.222 +      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
  25.223 +      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
  25.224 +      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
  25.225 +      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
  25.226 +      __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
  25.227 +      __ addi(R4_ARG2, R4_ARG2, 32);       // Update dsc+=32
  25.228 +      __ bdnz(l_7);                        // Dec CTR and loop if not zero.
  25.229 +
  25.230 +      // Restore DSCR pre-fetch value.
  25.231 +      if (VM_Version::has_mfdscr()) {
  25.232 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
  25.233 +        __ mtdscr(tmp2);
  25.234 +      }
  25.235 +
  25.236 +    } // VSX
  25.237 +   } // FasterArrayCopy
  25.238  
  25.239      // copy 1 element at a time
  25.240      __ bind(l_2);
  25.241 @@ -1629,13 +1756,16 @@
  25.242      // Do reverse copy.  We assume the case of actual overlap is rare enough
  25.243      // that we don't have to optimize it.
  25.244  
  25.245 -    Label l_1, l_2, l_3, l_4, l_5, l_6;
  25.246 +    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7;
  25.247  
  25.248      Register tmp1 = R6_ARG4;
  25.249      Register tmp2 = R7_ARG5;
  25.250      Register tmp3 = R8_ARG6;
  25.251      Register tmp4 = R0;
  25.252  
  25.253 +    VectorSRegister tmp_vsr1  = VSR1;
  25.254 +    VectorSRegister tmp_vsr2  = VSR2;
  25.255 +
  25.256      { // FasterArrayCopy
  25.257        __ cmpwi(CCR0, R5_ARG3, 0);
  25.258        __ beq(CCR0, l_6);
  25.259 @@ -1645,6 +1775,25 @@
  25.260        __ add(R4_ARG2, R4_ARG2, R5_ARG3);
  25.261        __ srdi(R5_ARG3, R5_ARG3, 2);
  25.262  
  25.263 +      if (!aligned) {
  25.264 +        // check if arrays have same alignment mod 8.
  25.265 +        __ xorr(tmp1, R3_ARG1, R4_ARG2);
  25.266 +        __ andi_(R0, tmp1, 7);
  25.267 +        // Not the same alignment, but ld and std just need to be 4 byte aligned.
  25.268 +        __ bne(CCR0, l_7); // to OR from is 8 byte aligned -> copy 2 at a time
  25.269 +
  25.270 +        // copy 1 element to align to and from on an 8 byte boundary
  25.271 +        __ andi_(R0, R3_ARG1, 7);
  25.272 +        __ beq(CCR0, l_7);
  25.273 +
  25.274 +        __ addi(R3_ARG1, R3_ARG1, -4);
  25.275 +        __ addi(R4_ARG2, R4_ARG2, -4);
  25.276 +        __ addi(R5_ARG3, R5_ARG3, -1);
  25.277 +        __ lwzx(tmp2, R3_ARG1);
  25.278 +        __ stwx(tmp2, R4_ARG2);
  25.279 +        __ bind(l_7);
  25.280 +      }
  25.281 +
  25.282        __ cmpwi(CCR0, R5_ARG3, 7);
  25.283        __ ble(CCR0, l_5); // copy 1 at a time if less than 8 elements remain
  25.284  
  25.285 @@ -1652,6 +1801,7 @@
  25.286        __ andi(R5_ARG3, R5_ARG3, 7);
  25.287        __ mtctr(tmp1);
  25.288  
  25.289 +     if (!VM_Version::has_vsx()) {
  25.290        __ bind(l_4);
  25.291        // Use unrolled version for mass copying (copy 4 elements a time).
  25.292        // Load feeding store gets zero latency on Power6, however not on Power5.
  25.293 @@ -1667,6 +1817,40 @@
  25.294        __ std(tmp2, 8, R4_ARG2);
  25.295        __ std(tmp1, 0, R4_ARG2);
  25.296        __ bdnz(l_4);
  25.297 +     } else {  // Processor supports VSX, so use it to mass copy.
  25.298 +      // Prefetch the data into the L2 cache.
  25.299 +      __ dcbt(R3_ARG1, 0);
  25.300 +
  25.301 +      // If supported set DSCR pre-fetch to deepest.
  25.302 +      if (VM_Version::has_mfdscr()) {
  25.303 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
  25.304 +        __ mtdscr(tmp2);
  25.305 +      }
  25.306 +
  25.307 +      __ li(tmp1, 16);
  25.308 +
  25.309 +      // Backbranch target aligned to 32-byte. Not 16-byte align as
  25.310 +      // loop contains < 8 instructions that fit inside a single
  25.311 +      // i-cache sector.
  25.312 +      __ align(32);
  25.313 +
  25.314 +      __ bind(l_4);
  25.315 +      // Use loop with VSX load/store instructions to
  25.316 +      // copy 8 elements a time.
  25.317 +      __ addi(R3_ARG1, R3_ARG1, -32);      // Update src-=32
  25.318 +      __ addi(R4_ARG2, R4_ARG2, -32);      // Update dsc-=32
  25.319 +      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src+16
  25.320 +      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
  25.321 +      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst+16
  25.322 +      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
  25.323 +      __ bdnz(l_4);
  25.324 +
  25.325 +      // Restore DSCR pre-fetch value.
  25.326 +      if (VM_Version::has_mfdscr()) {
  25.327 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
  25.328 +        __ mtdscr(tmp2);
  25.329 +      }
  25.330 +     }
  25.331  
  25.332        __ cmpwi(CCR0, R5_ARG3, 0);
  25.333        __ beq(CCR0, l_6);
  25.334 @@ -1730,7 +1914,10 @@
  25.335      Register tmp3 = R8_ARG6;
  25.336      Register tmp4 = R0;
  25.337  
  25.338 -    Label l_1, l_2, l_3, l_4;
  25.339 +    Label l_1, l_2, l_3, l_4, l_5;
  25.340 +
  25.341 +    VectorSRegister tmp_vsr1  = VSR1;
  25.342 +    VectorSRegister tmp_vsr2  = VSR2;
  25.343  
  25.344      { // FasterArrayCopy
  25.345        __ cmpwi(CCR0, R5_ARG3, 3);
  25.346 @@ -1740,6 +1927,7 @@
  25.347        __ andi_(R5_ARG3, R5_ARG3, 3);
  25.348        __ mtctr(tmp1);
  25.349  
  25.350 +    if (!VM_Version::has_vsx()) {
  25.351        __ bind(l_4);
  25.352        // Use unrolled version for mass copying (copy 4 elements a time).
  25.353        // Load feeding store gets zero latency on Power6, however not on Power5.
  25.354 @@ -1755,7 +1943,44 @@
  25.355        __ addi(R3_ARG1, R3_ARG1, 32);
  25.356        __ addi(R4_ARG2, R4_ARG2, 32);
  25.357        __ bdnz(l_4);
  25.358 -    }
  25.359 +
  25.360 +    } else { // Processor supports VSX, so use it to mass copy.
  25.361 +
  25.362 +      // Prefetch the data into the L2 cache.
  25.363 +      __ dcbt(R3_ARG1, 0);
  25.364 +
  25.365 +      // If supported set DSCR pre-fetch to deepest.
  25.366 +      if (VM_Version::has_mfdscr()) {
  25.367 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
  25.368 +        __ mtdscr(tmp2);
  25.369 +      }
  25.370 +
  25.371 +      __ li(tmp1, 16);
  25.372 +
  25.373 +      // Backbranch target aligned to 32-byte. Not 16-byte align as
  25.374 +      // loop contains < 8 instructions that fit inside a single
  25.375 +      // i-cache sector.
  25.376 +      __ align(32);
  25.377 +
  25.378 +      __ bind(l_5);
  25.379 +      // Use loop with VSX load/store instructions to
  25.380 +      // copy 4 elements a time.
  25.381 +      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
  25.382 +      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
  25.383 +      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
  25.384 +      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
  25.385 +      __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
  25.386 +      __ addi(R4_ARG2, R4_ARG2, 32);       // Update dsc+=32
  25.387 +      __ bdnz(l_5);                        // Dec CTR and loop if not zero.
  25.388 +
  25.389 +      // Restore DSCR pre-fetch value.
  25.390 +      if (VM_Version::has_mfdscr()) {
  25.391 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
  25.392 +        __ mtdscr(tmp2);
  25.393 +      }
  25.394 +
  25.395 +    } // VSX
  25.396 +   } // FasterArrayCopy
  25.397  
  25.398      // copy 1 element at a time
  25.399      __ bind(l_3);
  25.400 @@ -1808,6 +2033,9 @@
  25.401      Register tmp3 = R8_ARG6;
  25.402      Register tmp4 = R0;
  25.403  
  25.404 +    VectorSRegister tmp_vsr1  = VSR1;
  25.405 +    VectorSRegister tmp_vsr2  = VSR2;
  25.406 +
  25.407      Label l_1, l_2, l_3, l_4, l_5;
  25.408  
  25.409      __ cmpwi(CCR0, R5_ARG3, 0);
  25.410 @@ -1826,6 +2054,7 @@
  25.411        __ andi(R5_ARG3, R5_ARG3, 3);
  25.412        __ mtctr(tmp1);
  25.413  
  25.414 +     if (!VM_Version::has_vsx()) {
  25.415        __ bind(l_4);
  25.416        // Use unrolled version for mass copying (copy 4 elements a time).
  25.417        // Load feeding store gets zero latency on Power6, however not on Power5.
  25.418 @@ -1841,6 +2070,40 @@
  25.419        __ std(tmp2, 8, R4_ARG2);
  25.420        __ std(tmp1, 0, R4_ARG2);
  25.421        __ bdnz(l_4);
  25.422 +     } else { // Processor supports VSX, so use it to mass copy.
  25.423 +      // Prefetch the data into the L2 cache.
  25.424 +      __ dcbt(R3_ARG1, 0);
  25.425 +
  25.426 +      // If supported set DSCR pre-fetch to deepest.
  25.427 +      if (VM_Version::has_mfdscr()) {
  25.428 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
  25.429 +        __ mtdscr(tmp2);
  25.430 +      }
  25.431 +
  25.432 +      __ li(tmp1, 16);
  25.433 +
  25.434 +      // Backbranch target aligned to 32-byte. Not 16-byte align as
  25.435 +      // loop contains < 8 instructions that fit inside a single
  25.436 +      // i-cache sector.
  25.437 +      __ align(32);
  25.438 +
  25.439 +      __ bind(l_4);
  25.440 +      // Use loop with VSX load/store instructions to
  25.441 +      // copy 4 elements a time.
  25.442 +      __ addi(R3_ARG1, R3_ARG1, -32);      // Update src-=32
  25.443 +      __ addi(R4_ARG2, R4_ARG2, -32);      // Update dsc-=32
  25.444 +      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src+16
  25.445 +      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
  25.446 +      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst+16
  25.447 +      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
  25.448 +      __ bdnz(l_4);
  25.449 +
  25.450 +      // Restore DSCR pre-fetch value.
  25.451 +      if (VM_Version::has_mfdscr()) {
  25.452 +        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
  25.453 +        __ mtdscr(tmp2);
  25.454 +      }
  25.455 +     }
  25.456  
  25.457        __ cmpwi(CCR0, R5_ARG3, 0);
  25.458        __ beq(CCR0, l_1);
    26.1 --- a/src/cpu/ppc/vm/vm_version_ppc.cpp	Thu Sep 05 18:40:52 2019 +0800
    26.2 +++ b/src/cpu/ppc/vm/vm_version_ppc.cpp	Thu Sep 05 18:52:27 2019 +0800
    26.3 @@ -1,6 +1,6 @@
    26.4  /*
    26.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    26.6 - * Copyright 2012, 2014 SAP AG. All rights reserved.
    26.7 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
    26.8 + * Copyright 2012, 2018 SAP AG. All rights reserved.
    26.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   26.10   *
   26.11   * This code is free software; you can redistribute it and/or modify it
   26.12 @@ -45,7 +45,7 @@
   26.13  int VM_Version::_measured_cache_line_size = 128; // default value
   26.14  const char* VM_Version::_features_str = "";
   26.15  bool VM_Version::_is_determine_features_test_running = false;
   26.16 -
   26.17 +uint64_t VM_Version::_dscr_val = 0;
   26.18  
   26.19  #define MSG(flag)   \
   26.20    if (flag && !FLAG_IS_DEFAULT(flag))                                  \
   26.21 @@ -60,7 +60,9 @@
   26.22  
   26.23    // If PowerArchitecturePPC64 hasn't been specified explicitly determine from features.
   26.24    if (FLAG_IS_DEFAULT(PowerArchitecturePPC64)) {
   26.25 -    if (VM_Version::has_popcntw()) {
   26.26 +    if (VM_Version::has_lqarx()) {
   26.27 +      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 8);
   26.28 +    } else if (VM_Version::has_popcntw()) {
   26.29        FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 7);
   26.30      } else if (VM_Version::has_cmpb()) {
   26.31        FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 6);
   26.32 @@ -71,8 +73,14 @@
   26.33      }
   26.34    }
   26.35    guarantee(PowerArchitecturePPC64 == 0 || PowerArchitecturePPC64 == 5 ||
   26.36 -            PowerArchitecturePPC64 == 6 || PowerArchitecturePPC64 == 7,
   26.37 -            "PowerArchitecturePPC64 should be 0, 5, 6 or 7");
   26.38 +            PowerArchitecturePPC64 == 6 || PowerArchitecturePPC64 == 7 ||
   26.39 +            PowerArchitecturePPC64 == 8,
   26.40 +            "PowerArchitecturePPC64 should be 0, 5, 6, 7, or 8");
   26.41 +
   26.42 +  // Power 8: Configure Data Stream Control Register.
   26.43 +  if (PowerArchitecturePPC64 >= 8) {
   26.44 +    config_dscr();
   26.45 +  }
   26.46  
   26.47    if (!UseSIGTRAP) {
   26.48      MSG(TrapBasedICMissChecks);
   26.49 @@ -102,7 +110,7 @@
   26.50    // Create and print feature-string.
   26.51    char buf[(num_features+1) * 16]; // Max 16 chars per feature.
   26.52    jio_snprintf(buf, sizeof(buf),
   26.53 -               "ppc64%s%s%s%s%s%s%s%s%s%s",
   26.54 +               "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s",
   26.55                 (has_fsqrt()   ? " fsqrt"   : ""),
   26.56                 (has_isel()    ? " isel"    : ""),
   26.57                 (has_lxarxeh() ? " lxarxeh" : ""),
   26.58 @@ -112,12 +120,17 @@
   26.59                 (has_popcntw() ? " popcntw" : ""),
   26.60                 (has_fcfids()  ? " fcfids"  : ""),
   26.61                 (has_vand()    ? " vand"    : ""),
   26.62 +               (has_lqarx()   ? " lqarx"   : ""),
   26.63                 (has_vcipher() ? " aes"     : ""),
   26.64 -               (has_vpmsumb() ? " vpmsumb" : "")
   26.65 +               (has_vpmsumb() ? " vpmsumb" : ""),
   26.66 +               (has_mfdscr()  ? " mfdscr"  : ""),
   26.67 +               (has_vsx()     ? " vsx"     : "")
   26.68                 // Make sure number of %s matches num_features!
   26.69                );
   26.70    _features_str = strdup(buf);
   26.71 -  NOT_PRODUCT(if (Verbose) print_features(););
   26.72 +  if (Verbose) {
   26.73 +    print_features();
   26.74 +  }
   26.75  
   26.76    // PPC64 supports 8-byte compare-exchange operations (see
   26.77    // Atomic::cmpxchg and StubGenerator::generate_atomic_cmpxchg_ptr)
   26.78 @@ -485,8 +498,11 @@
   26.79    a->popcntw(R7, R5);                          // code[7] -> popcntw
   26.80    a->fcfids(F3, F4);                           // code[8] -> fcfids
   26.81    a->vand(VR0, VR0, VR0);                      // code[9] -> vand
   26.82 -  a->vcipher(VR0, VR1, VR2);                   // code[10] -> vcipher
   26.83 -  a->vpmsumb(VR0, VR1, VR2);                   // code[11] -> vpmsumb
   26.84 +  a->lqarx_unchecked(R7, R3_ARG1, R4_ARG2, 1); // code[10] -> lqarx_m
   26.85 +  a->vcipher(VR0, VR1, VR2);                   // code[11] -> vcipher
   26.86 +  a->vpmsumb(VR0, VR1, VR2);                   // code[12] -> vpmsumb
   26.87 +  a->mfdscr(R0);                               // code[13] -> mfdscr
   26.88 +  a->lxvd2x(VSR0, R3_ARG1);                    // code[14] -> vsx
   26.89    a->blr();
   26.90  
   26.91    // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
   26.92 @@ -530,8 +546,11 @@
   26.93    if (code[feature_cntr++]) features |= popcntw_m;
   26.94    if (code[feature_cntr++]) features |= fcfids_m;
   26.95    if (code[feature_cntr++]) features |= vand_m;
   26.96 +  if (code[feature_cntr++]) features |= lqarx_m;
   26.97    if (code[feature_cntr++]) features |= vcipher_m;
   26.98    if (code[feature_cntr++]) features |= vpmsumb_m;
   26.99 +  if (code[feature_cntr++]) features |= mfdscr_m;
  26.100 +  if (code[feature_cntr++]) features |= vsx_m;
  26.101  
  26.102    // Print the detection code.
  26.103    if (PrintAssembly) {
  26.104 @@ -543,6 +562,69 @@
  26.105    _features = features;
  26.106  }
  26.107  
  26.108 +// Power 8: Configure Data Stream Control Register.
  26.109 +void VM_Version::config_dscr() {
  26.110 +  assert(has_lqarx(), "Only execute on Power 8 or later!");
  26.111 +
  26.112 +  // 7 InstWords for each call (function descriptor + blr instruction).
  26.113 +  const int code_size = (2+2*7)*BytesPerInstWord;
  26.114 +
  26.115 +  // Allocate space for the code.
  26.116 +  ResourceMark rm;
  26.117 +  CodeBuffer cb("config_dscr", code_size, 0);
  26.118 +  MacroAssembler* a = new MacroAssembler(&cb);
  26.119 +
  26.120 +  // Emit code.
  26.121 +  uint64_t (*get_dscr)() = (uint64_t(*)())(void *)a->function_entry();
  26.122 +  uint32_t *code = (uint32_t *)a->pc();
  26.123 +  a->mfdscr(R3);
  26.124 +  a->blr();
  26.125 +
  26.126 +  void (*set_dscr)(long) = (void(*)(long))(void *)a->function_entry();
  26.127 +  a->mtdscr(R3);
  26.128 +  a->blr();
  26.129 +
  26.130 +  uint32_t *code_end = (uint32_t *)a->pc();
  26.131 +  a->flush();
  26.132 +
  26.133 +  // Print the detection code.
  26.134 +  if (PrintAssembly) {
  26.135 +    ttyLocker ttyl;
  26.136 +    tty->print_cr("Decoding dscr configuration stub at " INTPTR_FORMAT " before execution:", p2i(code));
  26.137 +    Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
  26.138 +  }
  26.139 +
  26.140 +  // Apply the configuration if needed.
  26.141 +  _dscr_val = (*get_dscr)();
  26.142 +  if (Verbose) {
  26.143 +    tty->print_cr("dscr value was 0x%lx" , _dscr_val);
  26.144 +  }
  26.145 +  bool change_requested = false;
  26.146 +  if (DSCR_PPC64 != (uintx)-1) {
  26.147 +    _dscr_val = DSCR_PPC64;
  26.148 +    change_requested = true;
  26.149 +  }
  26.150 +  if (DSCR_DPFD_PPC64 <= 7) {
  26.151 +    uint64_t mask = 0x7;
  26.152 +    if ((_dscr_val & mask) != DSCR_DPFD_PPC64) {
  26.153 +      _dscr_val = (_dscr_val & ~mask) | (DSCR_DPFD_PPC64);
  26.154 +      change_requested = true;
  26.155 +    }
  26.156 +  }
  26.157 +  if (DSCR_URG_PPC64 <= 7) {
  26.158 +    uint64_t mask = 0x7 << 6;
  26.159 +    if ((_dscr_val & mask) != DSCR_DPFD_PPC64 << 6) {
  26.160 +      _dscr_val = (_dscr_val & ~mask) | (DSCR_URG_PPC64 << 6);
  26.161 +      change_requested = true;
  26.162 +    }
  26.163 +  }
  26.164 +  if (change_requested) {
  26.165 +    (*set_dscr)(_dscr_val);
  26.166 +    if (Verbose) {
  26.167 +      tty->print_cr("dscr was set to 0x%lx" , (*get_dscr)());
  26.168 +    }
  26.169 +  }
  26.170 +}
  26.171  
  26.172  static int saved_features = 0;
  26.173  
    27.1 --- a/src/cpu/ppc/vm/vm_version_ppc.hpp	Thu Sep 05 18:40:52 2019 +0800
    27.2 +++ b/src/cpu/ppc/vm/vm_version_ppc.hpp	Thu Sep 05 18:52:27 2019 +0800
    27.3 @@ -1,6 +1,6 @@
    27.4  /*
    27.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    27.6 - * Copyright 2012, 2014 SAP AG. All rights reserved.
    27.7 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
    27.8 + * Copyright 2012, 2018 SAP AG. All rights reserved.
    27.9   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   27.10   *
   27.11   * This code is free software; you can redistribute it and/or modify it
   27.12 @@ -42,8 +42,11 @@
   27.13      fcfids,
   27.14      vand,
   27.15      dcba,
   27.16 +    lqarx,
   27.17      vcipher,
   27.18      vpmsumb,
   27.19 +    mfdscr,
   27.20 +    vsx,
   27.21      num_features // last entry to count features
   27.22    };
   27.23    enum Feature_Flag_Set {
   27.24 @@ -58,8 +61,11 @@
   27.25      fcfids_m              = (1 << fcfids ),
   27.26      vand_m                = (1 << vand   ),
   27.27      dcba_m                = (1 << dcba   ),
   27.28 +    lqarx_m               = (1 << lqarx  ),
   27.29      vcipher_m             = (1 << vcipher),
   27.30      vpmsumb_m             = (1 << vpmsumb),
   27.31 +    mfdscr_m              = (1 << mfdscr ),
   27.32 +    vsx_m                 = (1 << vsx    ),
   27.33      all_features_m        = -1
   27.34    };
   27.35    static int  _features;
   27.36 @@ -69,6 +75,7 @@
   27.37  
   27.38    static void print_features();
   27.39    static void determine_features(); // also measures cache line size
   27.40 +  static void config_dscr(); // Power 8: Configure Data Stream Control Register.
   27.41    static void determine_section_size();
   27.42    static void power6_micro_bench();
   27.43  public:
   27.44 @@ -87,8 +94,11 @@
   27.45    static bool has_fcfids()  { return (_features & fcfids_m) != 0; }
   27.46    static bool has_vand()    { return (_features & vand_m) != 0; }
   27.47    static bool has_dcba()    { return (_features & dcba_m) != 0; }
   27.48 +  static bool has_lqarx()   { return (_features & lqarx_m) != 0; }
   27.49    static bool has_vcipher() { return (_features & vcipher_m) != 0; }
   27.50    static bool has_vpmsumb() { return (_features & vpmsumb_m) != 0; }
   27.51 +  static bool has_mfdscr()  { return (_features & mfdscr_m) != 0; }
   27.52 +  static bool has_vsx()     { return (_features & vsx_m) != 0; }
   27.53  
   27.54    static const char* cpu_features() { return _features_str; }
   27.55  
   27.56 @@ -97,6 +107,9 @@
   27.57    // Assembler testing
   27.58    static void allow_all();
   27.59    static void revert();
   27.60 +
   27.61 +  // POWER 8: DSCR current value.
   27.62 +  static uint64_t _dscr_val;
   27.63  };
   27.64  
   27.65  #endif // CPU_PPC_VM_VM_VERSION_PPC_HPP
    28.1 --- a/src/cpu/sparc/vm/jniFastGetField_sparc.cpp	Thu Sep 05 18:40:52 2019 +0800
    28.2 +++ b/src/cpu/sparc/vm/jniFastGetField_sparc.cpp	Thu Sep 05 18:52:27 2019 +0800
    28.3 @@ -1,5 +1,5 @@
    28.4  /*
    28.5 - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
    28.6 + * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
    28.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8   *
    28.9   * This code is free software; you can redistribute it and/or modify it
   28.10 @@ -68,6 +68,7 @@
   28.11    __ andcc (G4, 1, G0);
   28.12    __ br (Assembler::notZero, false, Assembler::pn, label1);
   28.13    __ delayed()->srl (O2, 2, O4);
   28.14 +  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   28.15    __ ld_ptr (O1, 0, O5);
   28.16  
   28.17    assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   28.18 @@ -147,6 +148,7 @@
   28.19    __ andcc (G4, 1, G0);
   28.20    __ br (Assembler::notZero, false, Assembler::pn, label1);
   28.21    __ delayed()->srl (O2, 2, O4);
   28.22 +  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   28.23    __ ld_ptr (O1, 0, O5);
   28.24    __ add (O5, O4, O5);
   28.25  
   28.26 @@ -219,6 +221,7 @@
   28.27    __ andcc (G4, 1, G0);
   28.28    __ br (Assembler::notZero, false, Assembler::pn, label1);
   28.29    __ delayed()->srl (O2, 2, O4);
   28.30 +  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   28.31    __ ld_ptr (O1, 0, O5);
   28.32  
   28.33    assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
    29.1 --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Sep 05 18:40:52 2019 +0800
    29.2 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Sep 05 18:52:27 2019 +0800
    29.3 @@ -2706,15 +2706,30 @@
    29.4    __ verify_thread(); // G2_thread must be correct
    29.5    __ reset_last_Java_frame();
    29.6  
    29.7 -  // Unpack oop result
    29.8 +  // Unbox oop result, e.g. JNIHandles::resolve value in I0.
    29.9    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   29.10 -      Label L;
   29.11 -      __ addcc(G0, I0, G0);
   29.12 -      __ brx(Assembler::notZero, true, Assembler::pt, L);
   29.13 -      __ delayed()->ld_ptr(I0, 0, I0);
   29.14 -      __ mov(G0, I0);
   29.15 -      __ bind(L);
   29.16 -      __ verify_oop(I0);
   29.17 +    Label done, not_weak;
   29.18 +    __ br_null(I0, false, Assembler::pn, done); // Use NULL as-is.
   29.19 +    __ delayed()->andcc(I0, JNIHandles::weak_tag_mask, G0); // Test for jweak
   29.20 +    __ brx(Assembler::zero, true, Assembler::pt, not_weak);
   29.21 +    __ delayed()->ld_ptr(I0, 0, I0); // Maybe resolve (untagged) jobject.
   29.22 +    // Resolve jweak.
   29.23 +    __ ld_ptr(I0, -JNIHandles::weak_tag_value, I0);
   29.24 +#if INCLUDE_ALL_GCS
   29.25 +    if (UseG1GC) {
   29.26 +      // Copy to O0 because macro doesn't allow pre_val in input reg.
   29.27 +      __ mov(I0, O0);
   29.28 +      __ g1_write_barrier_pre(noreg /* obj */,
   29.29 +                              noreg /* index */,
   29.30 +                              0 /* offset */,
   29.31 +                              O0 /* pre_val */,
   29.32 +                              G3_scratch /* tmp */,
   29.33 +                              true /* preserve_o_regs */);
   29.34 +    }
   29.35 +#endif // INCLUDE_ALL_GCS
   29.36 +    __ bind(not_weak);
   29.37 +    __ verify_oop(I0);
   29.38 +    __ bind(done);
   29.39    }
   29.40  
   29.41    if (!is_critical_native) {
    30.1 --- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Thu Sep 05 18:40:52 2019 +0800
    30.2 +++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Thu Sep 05 18:52:27 2019 +0800
    30.3 @@ -4483,7 +4483,7 @@
    30.4      // save F48:F54 in temp registers
    30.5      __ movdtox(F54,G2);
    30.6      __ movdtox(F52,G3);
    30.7 -    __ movdtox(F50,G6);
    30.8 +    __ movdtox(F50,L6);
    30.9      __ movdtox(F48,G1);
   30.10      for ( int i = 46;  i >= 14; i -= 8 ) {
   30.11        __ aes_dround23(as_FloatRegister(i), F0, F2, F4);
   30.12 @@ -4511,7 +4511,7 @@
   30.13      // re-init F48:F54 with their original values
   30.14      __ movxtod(G2,F54);
   30.15      __ movxtod(G3,F52);
   30.16 -    __ movxtod(G6,F50);
   30.17 +    __ movxtod(L6,F50);
   30.18      __ movxtod(G1,F48);
   30.19  
   30.20      __ movxtod(L0,F6);
    31.1 --- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Thu Sep 05 18:40:52 2019 +0800
    31.2 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Thu Sep 05 18:52:27 2019 +0800
    31.3 @@ -1,5 +1,5 @@
    31.4  /*
    31.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    31.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    31.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.8   *
    31.9   * This code is free software; you can redistribute it and/or modify it
   31.10 @@ -1160,11 +1160,23 @@
   31.11  
   31.12      __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
   31.13      __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
   31.14 -    __ addcc(G0, O0, O0);
   31.15 -    __ brx(Assembler::notZero, true, Assembler::pt, store_result);     // if result is not NULL:
   31.16 -    __ delayed()->ld_ptr(O0, 0, O0);                                   // unbox it
   31.17 -    __ mov(G0, O0);
   31.18 -
   31.19 +    // Unbox oop result, e.g. JNIHandles::resolve value in O0.
   31.20 +    __ br_null(O0, false, Assembler::pn, store_result); // Use NULL as-is.
   31.21 +    __ delayed()->andcc(O0, JNIHandles::weak_tag_mask, G0); // Test for jweak
   31.22 +    __ brx(Assembler::zero, true, Assembler::pt, store_result);
   31.23 +    __ delayed()->ld_ptr(O0, 0, O0); // Maybe resolve (untagged) jobject.
   31.24 +    // Resolve jweak.
   31.25 +    __ ld_ptr(O0, -JNIHandles::weak_tag_value, O0);
   31.26 +#if INCLUDE_ALL_GCS
   31.27 +    if (UseG1GC) {
   31.28 +      __ g1_write_barrier_pre(noreg /* obj */,
   31.29 +                              noreg /* index */,
   31.30 +                              0 /* offset */,
   31.31 +                              O0 /* pre_val */,
   31.32 +                              G3_scratch /* tmp */,
   31.33 +                              true /* preserve_o_regs */);
   31.34 +    }
   31.35 +#endif // INCLUDE_ALL_GCS
   31.36      __ bind(store_result);
   31.37      // Store it where gc will look for it and result handler expects it.
   31.38      __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
    32.1 --- a/src/cpu/x86/vm/jniFastGetField_x86_32.cpp	Thu Sep 05 18:40:52 2019 +0800
    32.2 +++ b/src/cpu/x86/vm/jniFastGetField_x86_32.cpp	Thu Sep 05 18:52:27 2019 +0800
    32.3 @@ -1,5 +1,5 @@
    32.4  /*
    32.5 - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
    32.6 + * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
    32.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8   *
    32.9   * This code is free software; you can redistribute it and/or modify it
   32.10 @@ -79,14 +79,17 @@
   32.11      __ mov(rax, rcx);
   32.12      __ andptr(rax, 1);                         // rax, must end up 0
   32.13      __ movptr(rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
   32.14 -                                              // obj, notice rax, is 0.
   32.15 -                                              // rdx is data dependent on rcx.
   32.16 +                                               // obj, notice rax, is 0.
   32.17 +                                               // rdx is data dependent on rcx.
   32.18    } else {
   32.19 -    __ movptr (rdx, Address(rsp, 2*wordSize));  // obj
   32.20 +    __ movptr (rdx, Address(rsp, 2*wordSize)); // obj
   32.21    }
   32.22    __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
   32.23 +
   32.24 +  __ clear_jweak_tag(rdx);
   32.25 +
   32.26    __ movptr(rdx, Address(rdx, 0));           // *obj
   32.27 -  __ shrptr (rax, 2);                         // offset
   32.28 +  __ shrptr (rax, 2);                        // offset
   32.29  
   32.30    assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   32.31    speculative_load_pclist[count] = __ pc();
   32.32 @@ -194,14 +197,17 @@
   32.33    __ jcc (Assembler::notZero, slow);
   32.34    if (os::is_MP()) {
   32.35      __ mov(rax, rcx);
   32.36 -    __ andptr(rax, 1);                         // rax, must end up 0
   32.37 +    __ andptr(rax, 1);                        // rax, must end up 0
   32.38      __ movptr(rdx, Address(rsp, rax, Address::times_1, 3*wordSize));
   32.39                                                // obj, notice rax, is 0.
   32.40                                                // rdx is data dependent on rcx.
   32.41    } else {
   32.42 -    __ movptr(rdx, Address(rsp, 3*wordSize));  // obj
   32.43 +    __ movptr(rdx, Address(rsp, 3*wordSize)); // obj
   32.44    }
   32.45    __ movptr(rsi, Address(rsp, 4*wordSize));  // jfieldID
   32.46 +
   32.47 +  __ clear_jweak_tag(rdx);
   32.48 +
   32.49    __ movptr(rdx, Address(rdx, 0));           // *obj
   32.50    __ shrptr(rsi, 2);                         // offset
   32.51  
   32.52 @@ -283,7 +289,7 @@
   32.53    __ jcc (Assembler::notZero, slow);
   32.54    if (os::is_MP()) {
   32.55      __ mov(rax, rcx);
   32.56 -    __ andptr(rax, 1);                         // rax, must end up 0
   32.57 +    __ andptr(rax, 1);                        // rax, must end up 0
   32.58      __ movptr(rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
   32.59                                                // obj, notice rax, is 0.
   32.60                                                // rdx is data dependent on rcx.
   32.61 @@ -291,6 +297,9 @@
   32.62      __ movptr(rdx, Address(rsp, 2*wordSize)); // obj
   32.63    }
   32.64    __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
   32.65 +
   32.66 +  __ clear_jweak_tag(rdx);
   32.67 +
   32.68    __ movptr(rdx, Address(rdx, 0));           // *obj
   32.69    __ shrptr(rax, 2);                         // offset
   32.70  
    33.1 --- a/src/cpu/x86/vm/jniFastGetField_x86_64.cpp	Thu Sep 05 18:40:52 2019 +0800
    33.2 +++ b/src/cpu/x86/vm/jniFastGetField_x86_64.cpp	Thu Sep 05 18:52:27 2019 +0800
    33.3 @@ -1,5 +1,5 @@
    33.4  /*
    33.5 - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
    33.6 + * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
    33.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.8   *
    33.9   * This code is free software; you can redistribute it and/or modify it
   33.10 @@ -76,13 +76,16 @@
   33.11    __ jcc (Assembler::notZero, slow);
   33.12    if (os::is_MP()) {
   33.13      __ xorptr(robj, rcounter);
   33.14 -    __ xorptr(robj, rcounter);                   // obj, since
   33.15 +    __ xorptr(robj, rcounter);                  // obj, since
   33.16                                                  // robj ^ rcounter ^ rcounter == robj
   33.17                                                  // robj is data dependent on rcounter.
   33.18    }
   33.19 -  __ movptr(robj, Address(robj, 0));             // *obj
   33.20 +
   33.21 +  __ clear_jweak_tag(robj);
   33.22 +
   33.23 +  __ movptr(robj, Address(robj, 0));            // *obj
   33.24    __ mov   (roffset, c_rarg2);
   33.25 -  __ shrptr(roffset, 2);                         // offset
   33.26 +  __ shrptr(roffset, 2);                        // offset
   33.27  
   33.28    assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   33.29    speculative_load_pclist[count] = __ pc();
   33.30 @@ -174,13 +177,16 @@
   33.31    __ jcc (Assembler::notZero, slow);
   33.32    if (os::is_MP()) {
   33.33      __ xorptr(robj, rcounter);
   33.34 -    __ xorptr(robj, rcounter);                   // obj, since
   33.35 +    __ xorptr(robj, rcounter);                  // obj, since
   33.36                                                  // robj ^ rcounter ^ rcounter == robj
   33.37                                                  // robj is data dependent on rcounter.
   33.38    }
   33.39 -  __ movptr(robj, Address(robj, 0));             // *obj
   33.40 +
   33.41 +  __ clear_jweak_tag(robj);
   33.42 +
   33.43 +  __ movptr(robj, Address(robj, 0));            // *obj
   33.44    __ mov   (roffset, c_rarg2);
   33.45 -  __ shrptr(roffset, 2);                         // offset
   33.46 +  __ shrptr(roffset, 2);                        // offset
   33.47  
   33.48    assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   33.49    speculative_load_pclist[count] = __ pc();
    34.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Thu Sep 05 18:40:52 2019 +0800
    34.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Thu Sep 05 18:52:27 2019 +0800
    34.3 @@ -4119,6 +4119,42 @@
    34.4    }
    34.5  }
    34.6  
    34.7 +void MacroAssembler::resolve_jobject(Register value,
    34.8 +                                     Register thread,
    34.9 +                                     Register tmp) {
   34.10 +  assert_different_registers(value, thread, tmp);
   34.11 +  Label done, not_weak;
   34.12 +  testptr(value, value);
   34.13 +  jcc(Assembler::zero, done);                // Use NULL as-is.
   34.14 +  testptr(value, JNIHandles::weak_tag_mask); // Test for jweak tag.
   34.15 +  jcc(Assembler::zero, not_weak);
   34.16 +  // Resolve jweak.
   34.17 +  movptr(value, Address(value, -JNIHandles::weak_tag_value));
   34.18 +  verify_oop(value);
   34.19 +#if INCLUDE_ALL_GCS
   34.20 +  if (UseG1GC) {
   34.21 +    g1_write_barrier_pre(noreg /* obj */,
   34.22 +                         value /* pre_val */,
   34.23 +                         thread /* thread */,
   34.24 +                         tmp /* tmp */,
   34.25 +                         true /* tosca_live */,
   34.26 +                         true /* expand_call */);
   34.27 +  }
   34.28 +#endif // INCLUDE_ALL_GCS
   34.29 +  jmp(done);
   34.30 +  bind(not_weak);
   34.31 +  // Resolve (untagged) jobject.
   34.32 +  movptr(value, Address(value, 0));
   34.33 +  verify_oop(value);
   34.34 +  bind(done);
   34.35 +}
   34.36 +
   34.37 +void MacroAssembler::clear_jweak_tag(Register possibly_jweak) {
   34.38 +  const int32_t inverted_jweak_mask = ~static_cast<int32_t>(JNIHandles::weak_tag_mask);
   34.39 +  STATIC_ASSERT(inverted_jweak_mask == -2); // otherwise check this code
   34.40 +  // The inverted mask is sign-extended
   34.41 +  andptr(possibly_jweak, inverted_jweak_mask);
   34.42 +}
   34.43  
   34.44  //////////////////////////////////////////////////////////////////////////////////
   34.45  #if INCLUDE_ALL_GCS
    35.1 --- a/src/cpu/x86/vm/macroAssembler_x86.hpp	Thu Sep 05 18:40:52 2019 +0800
    35.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.hpp	Thu Sep 05 18:52:27 2019 +0800
    35.3 @@ -298,6 +298,9 @@
    35.4    void store_check(Register obj);                // store check for obj - register is destroyed afterwards
    35.5    void store_check(Register obj, Address dst);   // same as above, dst is exact store location (reg. is destroyed)
    35.6  
    35.7 +  void resolve_jobject(Register value, Register thread, Register tmp);
    35.8 +  void clear_jweak_tag(Register possibly_jweak);
    35.9 +
   35.10  #if INCLUDE_ALL_GCS
   35.11  
   35.12    void g1_write_barrier_pre(Register obj,
    36.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Sep 05 18:40:52 2019 +0800
    36.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Sep 05 18:52:27 2019 +0800
    36.3 @@ -2253,14 +2253,11 @@
    36.4  
    36.5    __ reset_last_Java_frame(thread, false);
    36.6  
    36.7 -  // Unpack oop result
    36.8 +  // Unbox oop result, e.g. JNIHandles::resolve value.
    36.9    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   36.10 -      Label L;
   36.11 -      __ cmpptr(rax, (int32_t)NULL_WORD);
   36.12 -      __ jcc(Assembler::equal, L);
   36.13 -      __ movptr(rax, Address(rax, 0));
   36.14 -      __ bind(L);
   36.15 -      __ verify_oop(rax);
   36.16 +    __ resolve_jobject(rax /* value */,
   36.17 +                       thread /* thread */,
   36.18 +                       rcx /* tmp */);
   36.19    }
   36.20  
   36.21    if (!is_critical_native) {
    37.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Sep 05 18:40:52 2019 +0800
    37.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Sep 05 18:52:27 2019 +0800
    37.3 @@ -2499,14 +2499,11 @@
    37.4  
    37.5    __ reset_last_Java_frame(false);
    37.6  
    37.7 -  // Unpack oop result
    37.8 +  // Unbox oop result, e.g. JNIHandles::resolve value.
    37.9    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   37.10 -      Label L;
   37.11 -      __ testptr(rax, rax);
   37.12 -      __ jcc(Assembler::zero, L);
   37.13 -      __ movptr(rax, Address(rax, 0));
   37.14 -      __ bind(L);
   37.15 -      __ verify_oop(rax);
   37.16 +    __ resolve_jobject(rax /* value */,
   37.17 +                       r15_thread /* thread */,
   37.18 +                       rcx /* tmp */);
   37.19    }
   37.20  
   37.21    if (!is_critical_native) {
    38.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Thu Sep 05 18:40:52 2019 +0800
    38.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Thu Sep 05 18:52:27 2019 +0800
    38.3 @@ -1,5 +1,5 @@
    38.4  /*
    38.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    38.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    38.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.8   *
    38.9   * This code is free software; you can redistribute it and/or modify it
   38.10 @@ -1296,19 +1296,18 @@
   38.11    __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
   38.12  
   38.13    // If result was an oop then unbox and save it in the frame
   38.14 -  { Label L;
   38.15 -    Label no_oop, store_result;
   38.16 +  {
   38.17 +    Label no_oop;
   38.18      ExternalAddress handler(AbstractInterpreter::result_handler(T_OBJECT));
   38.19      __ cmpptr(Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize),
   38.20                handler.addr());
   38.21      __ jcc(Assembler::notEqual, no_oop);
   38.22      __ cmpptr(Address(rsp, 0), (int32_t)NULL_WORD);
   38.23      __ pop(ltos);
   38.24 -    __ testptr(rax, rax);
   38.25 -    __ jcc(Assembler::zero, store_result);
   38.26 -    // unbox
   38.27 -    __ movptr(rax, Address(rax, 0));
   38.28 -    __ bind(store_result);
   38.29 +    // Unbox oop result, e.g. JNIHandles::resolve value.
   38.30 +    __ resolve_jobject(rax /* value */,
   38.31 +                       thread /* thread */,
   38.32 +                       t /* tmp */);
   38.33      __ movptr(Address(rbp, (frame::interpreter_frame_oop_temp_offset)*wordSize), rax);
   38.34      // keep stack depth as expected by pushing oop which will eventually be discarded
   38.35      __ push(ltos);
    39.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Thu Sep 05 18:40:52 2019 +0800
    39.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Thu Sep 05 18:52:27 2019 +0800
    39.3 @@ -1,5 +1,5 @@
    39.4  /*
    39.5 - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    39.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
    39.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.8   *
    39.9   * This code is free software; you can redistribute it and/or modify it
   39.10 @@ -1272,16 +1272,16 @@
   39.11    // and result handler will pick it up
   39.12  
   39.13    {
   39.14 -    Label no_oop, store_result;
   39.15 +    Label no_oop;
   39.16      __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
   39.17      __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize));
   39.18      __ jcc(Assembler::notEqual, no_oop);
   39.19      // retrieve result
   39.20      __ pop(ltos);
   39.21 -    __ testptr(rax, rax);
   39.22 -    __ jcc(Assembler::zero, store_result);
   39.23 -    __ movptr(rax, Address(rax, 0));
   39.24 -    __ bind(store_result);
   39.25 +    // Unbox oop result, e.g. JNIHandles::resolve value.
   39.26 +    __ resolve_jobject(rax /* value */,
   39.27 +                       r15_thread /* thread */,
   39.28 +                       t /* tmp */);
   39.29      __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize), rax);
   39.30      // keep stack depth as expected by pushing oop which will eventually be discarde
   39.31      __ push(ltos);
    40.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Sep 05 18:40:52 2019 +0800
    40.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Sep 05 18:52:27 2019 +0800
    40.3 @@ -1,5 +1,5 @@
    40.4  /*
    40.5 - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    40.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
    40.7   * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
    40.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.9   *
   40.10 @@ -405,10 +405,12 @@
   40.11    // oop_temp where the garbage collector can see it before
   40.12    // we release the handle it might be protected by.
   40.13    if (handler->result_type() == &ffi_type_pointer) {
   40.14 -    if (result[0])
   40.15 -      istate->set_oop_temp(*(oop *) result[0]);
   40.16 -    else
   40.17 +    if (result[0] == 0) {
   40.18        istate->set_oop_temp(NULL);
   40.19 +    } else {
   40.20 +      jobject handle = reinterpret_cast<jobject>(result[0]);
   40.21 +      istate->set_oop_temp(JNIHandles::resolve(handle));
   40.22 +    }
   40.23    }
   40.24  
   40.25    // Reset handle block
    41.1 --- a/src/os/linux/vm/os_linux.cpp	Thu Sep 05 18:40:52 2019 +0800
    41.2 +++ b/src/os/linux/vm/os_linux.cpp	Thu Sep 05 18:52:27 2019 +0800
    41.3 @@ -136,6 +136,7 @@
    41.4  
    41.5  int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
    41.6  int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
    41.7 +int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
    41.8  Mutex* os::Linux::_createThread_lock = NULL;
    41.9  pthread_t os::Linux::_main_thread;
   41.10  int os::Linux::_page_size = -1;
   41.11 @@ -5065,6 +5066,11 @@
   41.12      StackRedPages = 1;
   41.13      StackShadowPages = round_to((StackShadowPages*Linux::vm_default_page_size()), vm_page_size()) / vm_page_size();
   41.14    }
   41.15 +
   41.16 +  // retrieve entry point for pthread_setname_np
   41.17 +  Linux::_pthread_setname_np =
   41.18 +    (int(*)(pthread_t, const char*))dlsym(RTLD_DEFAULT, "pthread_setname_np");
   41.19 +
   41.20  }
   41.21  
   41.22  // To install functions for atexit system call
   41.23 @@ -5329,8 +5335,14 @@
   41.24  }
   41.25  
   41.26  void os::set_native_thread_name(const char *name) {
   41.27 -  // Not yet implemented.
   41.28 -  return;
   41.29 +  if (Linux::_pthread_setname_np) {
   41.30 +    char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
   41.31 +    snprintf(buf, sizeof(buf), "%s", name);
   41.32 +    buf[sizeof(buf) - 1] = '\0';
   41.33 +    const int rc = Linux::_pthread_setname_np(pthread_self(), buf);
   41.34 +    // ERANGE should not happen; all other errors should just be ignored.
   41.35 +    assert(rc != ERANGE, "pthread_setname_np failed");
   41.36 +  }
   41.37  }
   41.38  
   41.39  bool os::distribute_processes(uint length, uint* distribution) {
    42.1 --- a/src/os/linux/vm/os_linux.hpp	Thu Sep 05 18:40:52 2019 +0800
    42.2 +++ b/src/os/linux/vm/os_linux.hpp	Thu Sep 05 18:52:27 2019 +0800
    42.3 @@ -56,6 +56,7 @@
    42.4  
    42.5    static int (*_clock_gettime)(clockid_t, struct timespec *);
    42.6    static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
    42.7 +  static int (*_pthread_setname_np)(pthread_t, const char*);
    42.8  
    42.9    static address   _initial_thread_stack_bottom;
   42.10    static uintptr_t _initial_thread_stack_size;
    43.1 --- a/src/os/solaris/vm/os_solaris.cpp	Thu Sep 05 18:40:52 2019 +0800
    43.2 +++ b/src/os/solaris/vm/os_solaris.cpp	Thu Sep 05 18:52:27 2019 +0800
    43.3 @@ -160,6 +160,7 @@
    43.4  
    43.5  address os::Solaris::_main_stack_base = NULL;  // 4352906 workaround
    43.6  
    43.7 +os::Solaris::pthread_setname_np_func_t os::Solaris::_pthread_setname_np = NULL;
    43.8  
    43.9  // "default" initializers for missing libc APIs
   43.10  extern "C" {
   43.11 @@ -519,8 +520,15 @@
   43.12  }
   43.13  
   43.14  void os::set_native_thread_name(const char *name) {
   43.15 -  // Not yet implemented.
   43.16 -  return;
   43.17 +  if (Solaris::_pthread_setname_np != NULL) {
   43.18 +    // Only the first 31 bytes of 'name' are processed by pthread_setname_np
   43.19 +    // but we explicitly copy into a size-limited buffer to avoid any
   43.20 +    // possible overflow.
   43.21 +    char buf[32];
   43.22 +    snprintf(buf, sizeof(buf), "%s", name);
   43.23 +    buf[sizeof(buf) - 1] = '\0';
   43.24 +    Solaris::_pthread_setname_np(pthread_self(), buf);
   43.25 +  }
   43.26  }
   43.27  
   43.28  bool os::distribute_processes(uint length, uint* distribution) {
   43.29 @@ -4921,6 +4929,13 @@
   43.30    // the minimum of what the OS supports (thr_min_stack()), and
   43.31    // enough to allow the thread to get to user bytecode execution.
   43.32    Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed);
   43.33 +
   43.34 +  // retrieve entry point for pthread_setname_np
   43.35 +  void * handle = dlopen("libc.so.1", RTLD_LAZY);
   43.36 +  if (handle != NULL) {
   43.37 +    Solaris::_pthread_setname_np =
   43.38 +        (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
   43.39 +  }
   43.40    // If the pagesize of the VM is greater than 8K determine the appropriate
   43.41    // number of initial guard pages.  The user can change this with the
   43.42    // command line arguments, if needed.
    44.1 --- a/src/os/solaris/vm/os_solaris.hpp	Thu Sep 05 18:40:52 2019 +0800
    44.2 +++ b/src/os/solaris/vm/os_solaris.hpp	Thu Sep 05 18:52:27 2019 +0800
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -132,6 +132,9 @@
   44.11    static void set_SIGinterrupt(int newsig) { _SIGinterrupt = newsig; }
   44.12    static void set_SIGasync(int newsig) { _SIGasync = newsig; }
   44.13  
   44.14 +  typedef int (*pthread_setname_np_func_t)(pthread_t, const char*);
   44.15 +  static pthread_setname_np_func_t _pthread_setname_np;
   44.16 +
   44.17   public:
   44.18    // Large Page Support--ISM.
   44.19    static bool largepage_range(char* addr, size_t size);
    45.1 --- a/src/os/windows/vm/os_windows.cpp	Thu Sep 05 18:40:52 2019 +0800
    45.2 +++ b/src/os/windows/vm/os_windows.cpp	Thu Sep 05 18:52:27 2019 +0800
    45.3 @@ -744,8 +744,29 @@
    45.4  }
    45.5  
    45.6  void os::set_native_thread_name(const char *name) {
    45.7 -  // Not yet implemented.
    45.8 -  return;
    45.9 +
   45.10 +  // See: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
   45.11 +  //
   45.12 +  // Note that unfortunately this only works if the process
   45.13 +  // is already attached to a debugger; debugger must observe
   45.14 +  // the exception below to show the correct name.
   45.15 +
   45.16 +  const DWORD MS_VC_EXCEPTION = 0x406D1388;
   45.17 +  struct {
   45.18 +    DWORD dwType;     // must be 0x1000
   45.19 +    LPCSTR szName;    // pointer to name (in user addr space)
   45.20 +    DWORD dwThreadID; // thread ID (-1=caller thread)
   45.21 +    DWORD dwFlags;    // reserved for future use, must be zero
   45.22 +  } info;
   45.23 +
   45.24 +  info.dwType = 0x1000;
   45.25 +  info.szName = name;
   45.26 +  info.dwThreadID = -1;
   45.27 +  info.dwFlags = 0;
   45.28 +
   45.29 +  __try {
   45.30 +    RaiseException (MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info );
   45.31 +  } __except(EXCEPTION_CONTINUE_EXECUTION) {}
   45.32  }
   45.33  
   45.34  bool os::distribute_processes(uint length, uint* distribution) {
    46.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Thu Sep 05 18:40:52 2019 +0800
    46.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Thu Sep 05 18:52:27 2019 +0800
    46.3 @@ -832,21 +832,21 @@
    46.4    do_class(com_sun_crypto_provider_aescrypt,      "com/sun/crypto/provider/AESCrypt")                                   \
    46.5    do_intrinsic(_aescrypt_encryptBlock, com_sun_crypto_provider_aescrypt, encryptBlock_name, byteArray_int_byteArray_int_signature, F_R)   \
    46.6    do_intrinsic(_aescrypt_decryptBlock, com_sun_crypto_provider_aescrypt, decryptBlock_name, byteArray_int_byteArray_int_signature, F_R)   \
    46.7 -   do_name(     encryptBlock_name,                                 "encryptBlock")                                      \
    46.8 -   do_name(     decryptBlock_name,                                 "decryptBlock")                                      \
    46.9 +   do_name(     encryptBlock_name,                                 "implEncryptBlock")                                  \
   46.10 +   do_name(     decryptBlock_name,                                 "implDecryptBlock")                                  \
   46.11     do_signature(byteArray_int_byteArray_int_signature,             "([BI[BI)V")                                         \
   46.12                                                                                                                          \
   46.13    do_class(com_sun_crypto_provider_cipherBlockChaining,            "com/sun/crypto/provider/CipherBlockChaining")       \
   46.14     do_intrinsic(_cipherBlockChaining_encryptAESCrypt, com_sun_crypto_provider_cipherBlockChaining, encrypt_name, byteArray_int_int_byteArray_int_signature, F_R)   \
   46.15     do_intrinsic(_cipherBlockChaining_decryptAESCrypt, com_sun_crypto_provider_cipherBlockChaining, decrypt_name, byteArray_int_int_byteArray_int_signature, F_R)   \
   46.16 -   do_name(     encrypt_name,                                      "encrypt")                                           \
   46.17 -   do_name(     decrypt_name,                                      "decrypt")                                           \
   46.18 +   do_name(     encrypt_name,                                      "implEncrypt")                                       \
   46.19 +   do_name(     decrypt_name,                                      "implDecrypt")                                       \
   46.20     do_signature(byteArray_int_int_byteArray_int_signature,         "([BII[BI)I")                                        \
   46.21                                                                                                                          \
   46.22    /* support for sun.security.provider.SHA */                                                                           \
   46.23    do_class(sun_security_provider_sha,                              "sun/security/provider/SHA")                         \
   46.24    do_intrinsic(_sha_implCompress, sun_security_provider_sha, implCompress_name, implCompress_signature, F_R)            \
   46.25 -   do_name(     implCompress_name,                                 "implCompress")                                      \
   46.26 +   do_name(     implCompress_name,                                 "implCompress0")                                     \
   46.27     do_signature(implCompress_signature,                            "([BI)V")                                            \
   46.28                                                                                                                          \
   46.29    /* support for sun.security.provider.SHA2 */                                                                          \
   46.30 @@ -860,7 +860,7 @@
   46.31    /* support for sun.security.provider.DigestBase */                                                                    \
   46.32    do_class(sun_security_provider_digestbase,                       "sun/security/provider/DigestBase")                  \
   46.33    do_intrinsic(_digestBase_implCompressMB, sun_security_provider_digestbase, implCompressMB_name, implCompressMB_signature, F_R)   \
   46.34 -   do_name(     implCompressMB_name,                               "implCompressMultiBlock")                            \
   46.35 +   do_name(     implCompressMB_name,                               "implCompressMultiBlock0")                           \
   46.36     do_signature(implCompressMB_signature,                          "([BII)I")                                           \
   46.37                                                                                                                          \
   46.38    /* support for java.util.zip */                                                                                       \
    47.1 --- a/src/share/vm/code/codeCache.cpp	Thu Sep 05 18:40:52 2019 +0800
    47.2 +++ b/src/share/vm/code/codeCache.cpp	Thu Sep 05 18:52:27 2019 +0800
    47.3 @@ -336,16 +336,19 @@
    47.4  }
    47.5  
    47.6  // Walk the list of methods which might contain non-perm oops.
    47.7 -void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
    47.8 +void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
    47.9    assert_locked_or_safepoint(CodeCache_lock);
   47.10  
   47.11    if (UseG1GC) {
   47.12      return;
   47.13    }
   47.14  
   47.15 +  const bool fix_relocations = f->fix_relocations();
   47.16    debug_only(mark_scavenge_root_nmethods());
   47.17  
   47.18 -  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
   47.19 +  nmethod* prev = NULL;
   47.20 +  nmethod* cur = scavenge_root_nmethods();
   47.21 +  while (cur != NULL) {
   47.22      debug_only(cur->clear_scavenge_root_marked());
   47.23      assert(cur->scavenge_root_not_marked(), "");
   47.24      assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
   47.25 @@ -360,6 +363,18 @@
   47.26        // Perform cur->oops_do(f), maybe just once per nmethod.
   47.27        f->do_code_blob(cur);
   47.28      }
   47.29 +    nmethod* const next = cur->scavenge_root_link();
   47.30 +    // The scavengable nmethod list must contain all methods with scavengable
   47.31 +    // oops. It is safe to include more nmethod on the list, but we do not
   47.32 +    // expect any live non-scavengable nmethods on the list.
   47.33 +    if (fix_relocations) {
   47.34 +      if (!is_live || !cur->detect_scavenge_root_oops()) {
   47.35 +        unlink_scavenge_root_nmethod(cur, prev);
   47.36 +      } else {
   47.37 +        prev = cur;
   47.38 +      }
   47.39 +    }
   47.40 +    cur = next;
   47.41    }
   47.42  
   47.43    // Check for stray marks.
   47.44 @@ -379,6 +394,24 @@
   47.45    print_trace("add_scavenge_root", nm);
   47.46  }
   47.47  
   47.48 +void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
   47.49 +  assert_locked_or_safepoint(CodeCache_lock);
   47.50 +
   47.51 +  assert((prev == NULL && scavenge_root_nmethods() == nm) ||
   47.52 +         (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
   47.53 +
   47.54 +  assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
   47.55 +
   47.56 +  print_trace("unlink_scavenge_root", nm);
   47.57 +  if (prev == NULL) {
   47.58 +    set_scavenge_root_nmethods(nm->scavenge_root_link());
   47.59 +  } else {
   47.60 +    prev->set_scavenge_root_link(nm->scavenge_root_link());
   47.61 +  }
   47.62 +  nm->set_scavenge_root_link(NULL);
   47.63 +  nm->clear_on_scavenge_root_list();
   47.64 +}
   47.65 +
   47.66  void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
   47.67    assert_locked_or_safepoint(CodeCache_lock);
   47.68  
   47.69 @@ -387,20 +420,13 @@
   47.70    }
   47.71  
   47.72    print_trace("drop_scavenge_root", nm);
   47.73 -  nmethod* last = NULL;
   47.74 -  nmethod* cur = scavenge_root_nmethods();
   47.75 -  while (cur != NULL) {
   47.76 -    nmethod* next = cur->scavenge_root_link();
   47.77 +  nmethod* prev = NULL;
   47.78 +  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
   47.79      if (cur == nm) {
   47.80 -      if (last != NULL)
   47.81 -            last->set_scavenge_root_link(next);
   47.82 -      else  set_scavenge_root_nmethods(next);
   47.83 -      nm->set_scavenge_root_link(NULL);
   47.84 -      nm->clear_on_scavenge_root_list();
   47.85 +      unlink_scavenge_root_nmethod(cur, prev);
   47.86        return;
   47.87      }
   47.88 -    last = cur;
   47.89 -    cur = next;
   47.90 +    prev = cur;
   47.91    }
   47.92    assert(false, "should have been on list");
   47.93  }
   47.94 @@ -429,11 +455,7 @@
   47.95      } else {
   47.96        // Prune it from the list, so we don't have to look at it any more.
   47.97        print_trace("prune_scavenge_root", cur);
   47.98 -      cur->set_scavenge_root_link(NULL);
   47.99 -      cur->clear_on_scavenge_root_list();
  47.100 -      if (last != NULL)
  47.101 -            last->set_scavenge_root_link(next);
  47.102 -      else  set_scavenge_root_nmethods(next);
  47.103 +      unlink_scavenge_root_nmethod(cur, last);
  47.104      }
  47.105      cur = next;
  47.106    }
    48.1 --- a/src/share/vm/code/codeCache.hpp	Thu Sep 05 18:40:52 2019 +0800
    48.2 +++ b/src/share/vm/code/codeCache.hpp	Thu Sep 05 18:52:27 2019 +0800
    48.3 @@ -1,5 +1,5 @@
    48.4  /*
    48.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    48.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    48.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.8   *
    48.9   * This code is free software; you can redistribute it and/or modify it
   48.10 @@ -65,6 +65,10 @@
   48.11  
   48.12    static int _codemem_full_count;
   48.13  
   48.14 +  static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
   48.15 +  static void prune_scavenge_root_nmethods();
   48.16 +  static void unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev);
   48.17 +
   48.18   public:
   48.19  
   48.20    // Initialization
   48.21 @@ -135,13 +139,17 @@
   48.22    // to "true" iff some code got unloaded.
   48.23    static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
   48.24    static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
   48.25 -  static void scavenge_root_nmethods_do(CodeBlobClosure* f);
   48.26 +
   48.27 +  // Apply f to every live code blob in scavengable nmethods. Prune nmethods
   48.28 +  // from the list of scavengable nmethods if f->fix_relocations() and a nmethod
   48.29 +  // no longer has scavengable oops.  If f->fix_relocations(), then f must copy
   48.30 +  // objects to their new location immediately to avoid fixing nmethods on the
   48.31 +  // basis of the old object locations.
   48.32 +  static void scavenge_root_nmethods_do(CodeBlobToOopClosure* f);
   48.33  
   48.34    static nmethod* scavenge_root_nmethods()          { return _scavenge_root_nmethods; }
   48.35 -  static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
   48.36    static void add_scavenge_root_nmethod(nmethod* nm);
   48.37    static void drop_scavenge_root_nmethod(nmethod* nm);
   48.38 -  static void prune_scavenge_root_nmethods();
   48.39  
   48.40    // Printing/debugging
   48.41    static void print();                           // prints summary
    49.1 --- a/src/share/vm/code/nmethod.cpp	Thu Sep 05 18:40:52 2019 +0800
    49.2 +++ b/src/share/vm/code/nmethod.cpp	Thu Sep 05 18:52:27 2019 +0800
    49.3 @@ -1398,7 +1398,6 @@
    49.4    assert(_method == NULL, "Tautology");
    49.5  
    49.6    set_osr_link(NULL);
    49.7 -  //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods
    49.8    NMethodSweeper::report_state_change(this);
    49.9  }
   49.10  
   49.11 @@ -2182,6 +2181,7 @@
   49.12          }
   49.13        } else if (iter.type() == relocInfo::virtual_call_type) {
   49.14          // Check compiledIC holders associated with this nmethod
   49.15 +        ResourceMark rm;
   49.16          CompiledIC *ic = CompiledIC_at(&iter);
   49.17          if (ic->is_icholder_call()) {
   49.18            CompiledICHolder* cichk = ic->cached_icholder();
    50.1 --- a/src/share/vm/compiler/compileBroker.cpp	Thu Sep 05 18:40:52 2019 +0800
    50.2 +++ b/src/share/vm/compiler/compileBroker.cpp	Thu Sep 05 18:52:27 2019 +0800
    50.3 @@ -1,5 +1,5 @@
    50.4  /*
    50.5 - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
    50.6 + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
    50.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.8   *
    50.9   * This code is free software; you can redistribute it and/or modify it
   50.10 @@ -751,7 +751,9 @@
   50.11      No_Safepoint_Verifier nsv;
   50.12      task = CompilationPolicy::policy()->select_task(this);
   50.13    }
   50.14 -  remove(task);
   50.15 +  if (task != NULL) {
   50.16 +    remove(task);
   50.17 +  }
   50.18    purge_stale_tasks(); // may temporarily release MCQ lock
   50.19    return task;
   50.20  }
    51.1 --- a/src/share/vm/compiler/compileBroker.hpp	Thu Sep 05 18:40:52 2019 +0800
    51.2 +++ b/src/share/vm/compiler/compileBroker.hpp	Thu Sep 05 18:52:27 2019 +0800
    51.3 @@ -1,5 +1,5 @@
    51.4  /*
    51.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    51.6 + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
    51.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.8   *
    51.9   * This code is free software; you can redistribute it and/or modify it
   51.10 @@ -339,7 +339,6 @@
   51.11  
   51.12    static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
   51.13    static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
   51.14 -  static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
   51.15    static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
   51.16    static bool is_compile_blocking      ();
   51.17    static void preload_classes          (methodHandle method, TRAPS);
   51.18 @@ -389,6 +388,7 @@
   51.19      return NULL;
   51.20    }
   51.21  
   51.22 +  static bool compilation_is_complete(methodHandle method, int osr_bci, int comp_level);
   51.23    static bool compilation_is_in_queue(methodHandle method);
   51.24    static int queue_size(int comp_level) {
   51.25      CompileQueue *q = compile_queue(comp_level);
    52.1 --- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Thu Sep 05 18:40:52 2019 +0800
    52.2 +++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Thu Sep 05 18:52:27 2019 +0800
    52.3 @@ -447,8 +447,6 @@
    52.4  }
    52.5  
    52.6  HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold_raw() {
    52.7 -  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
    52.8 -         "just checking");
    52.9    _next_offset_index = _array->index_for_raw(_bottom);
   52.10    _next_offset_index++;
   52.11    _next_offset_threshold =
   52.12 @@ -457,8 +455,6 @@
   52.13  }
   52.14  
   52.15  void G1BlockOffsetArrayContigSpace::zero_bottom_entry_raw() {
   52.16 -  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
   52.17 -         "just checking");
   52.18    size_t bottom_index = _array->index_for_raw(_bottom);
   52.19    assert(_array->address_for_index_raw(bottom_index) == _bottom,
   52.20           "Precondition of call");
   52.21 @@ -466,8 +462,6 @@
   52.22  }
   52.23  
   52.24  HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
   52.25 -  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
   52.26 -         "just checking");
   52.27    _next_offset_index = _array->index_for(_bottom);
   52.28    _next_offset_index++;
   52.29    _next_offset_threshold =
    53.1 --- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp	Thu Sep 05 18:40:52 2019 +0800
    53.2 +++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp	Thu Sep 05 18:52:27 2019 +0800
    53.3 @@ -145,7 +145,7 @@
    53.4  
    53.5    // Array for keeping offsets for retrieving object start fast given an
    53.6    // address.
    53.7 -  u_char* _offset_array;          // byte array keeping backwards offsets
    53.8 +  volatile u_char* _offset_array;          // byte array keeping backwards offsets
    53.9  
   53.10    void check_offset(size_t offset, const char* msg) const {
   53.11      assert(offset <= N_words,
   53.12 @@ -158,9 +158,7 @@
   53.13    // For performance these have to devolve to array accesses in product builds.
   53.14    inline u_char offset_array(size_t index) const;
   53.15  
   53.16 -  void set_offset_array_raw(size_t index, u_char offset) {
   53.17 -    _offset_array[index] = offset;
   53.18 -  }
   53.19 +  inline void set_offset_array_raw(size_t index, u_char offset);
   53.20  
   53.21    inline void set_offset_array(size_t index, u_char offset);
   53.22  
    54.1 --- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Thu Sep 05 18:40:52 2019 +0800
    54.2 +++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Thu Sep 05 18:52:27 2019 +0800
    54.3 @@ -63,6 +63,10 @@
    54.4    return _offset_array[index];
    54.5  }
    54.6  
    54.7 +inline void G1BlockOffsetSharedArray::set_offset_array_raw(size_t index, u_char offset) {
    54.8 +  _offset_array[index] = offset;
    54.9 +}
   54.10 +
   54.11  void G1BlockOffsetSharedArray::set_offset_array(size_t index, u_char offset) {
   54.12    check_index(index, "index out of range");
   54.13    set_offset_array_raw(index, offset);
   54.14 @@ -81,7 +85,7 @@
   54.15    assert(left <= right, "indexes out of order");
   54.16    size_t num_cards = right - left + 1;
   54.17    if (UseMemSetInBOT) {
   54.18 -    memset(&_offset_array[left], offset, num_cards);
   54.19 +    memset(const_cast<u_char*> (&_offset_array[left]), offset, num_cards);
   54.20    } else {
   54.21      size_t i = left;
   54.22      const size_t end = i + num_cards;
    55.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Thu Sep 05 18:40:52 2019 +0800
    55.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Thu Sep 05 18:52:27 2019 +0800
    55.3 @@ -237,12 +237,6 @@
    55.4    }
    55.5  };
    55.6  
    55.7 -class G1AlwaysTrueClosure: public BoolObjectClosure {
    55.8 -public:
    55.9 -  bool do_object_b(oop p) { return true; }
   55.10 -};
   55.11 -static G1AlwaysTrueClosure always_true;
   55.12 -
   55.13  void G1MarkSweep::mark_sweep_phase3() {
   55.14    G1CollectedHeap* g1h = G1CollectedHeap::heap();
   55.15  
   55.16 @@ -266,7 +260,7 @@
   55.17  
   55.18    // Now adjust pointers in remaining weak roots.  (All of which should
   55.19    // have been cleared if they pointed to non-surviving objects.)
   55.20 -  JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
   55.21 +  JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
   55.22  
   55.23    if (G1StringDedup::is_enabled()) {
   55.24      G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
    56.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Thu Sep 05 18:40:52 2019 +0800
    56.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Thu Sep 05 18:52:27 2019 +0800
    56.3 @@ -594,13 +594,6 @@
    56.4    old_gen->precompact();
    56.5  }
    56.6  
    56.7 -// This should be moved to the shared markSweep code!
    56.8 -class PSAlwaysTrueClosure: public BoolObjectClosure {
    56.9 -public:
   56.10 -  bool do_object_b(oop p) { return true; }
   56.11 -};
   56.12 -static PSAlwaysTrueClosure always_true;
   56.13 -
   56.14  void PSMarkSweep::mark_sweep_phase3() {
   56.15    // Adjust the pointers to reflect the new locations
   56.16    GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id());
   56.17 @@ -630,7 +623,7 @@
   56.18    // Now adjust pointers in remaining weak roots.  (All of which should
   56.19    // have been cleared if they pointed to non-surviving objects.)
   56.20    // Global (weak) JNI handles
   56.21 -  JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure());
   56.22 +  JNIHandles::weak_oops_do(adjust_pointer_closure());
   56.23  
   56.24    CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
   56.25    CodeCache::blobs_do(&adjust_from_blobs);
    57.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Thu Sep 05 18:40:52 2019 +0800
    57.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Thu Sep 05 18:52:27 2019 +0800
    57.3 @@ -2447,13 +2447,6 @@
    57.4    cld->oops_do(&mark_and_push_closure, &follow_klass_closure, true);
    57.5  }
    57.6  
    57.7 -// This should be moved to the shared markSweep code!
    57.8 -class PSAlwaysTrueClosure: public BoolObjectClosure {
    57.9 -public:
   57.10 -  bool do_object_b(oop p) { return true; }
   57.11 -};
   57.12 -static PSAlwaysTrueClosure always_true;
   57.13 -
   57.14  void PSParallelCompact::adjust_roots() {
   57.15    // Adjust the pointers to reflect the new locations
   57.16    GCTraceTime tm("adjust roots", print_phases(), true, &_gc_timer, _gc_tracer.gc_id());
   57.17 @@ -2476,7 +2469,7 @@
   57.18    // Now adjust pointers in remaining weak roots.  (All of which should
   57.19    // have been cleared if they pointed to non-surviving objects.)
   57.20    // Global (weak) JNI handles
   57.21 -  JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure());
   57.22 +  JNIHandles::weak_oops_do(adjust_pointer_closure());
   57.23  
   57.24    CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
   57.25    CodeCache::blobs_do(&adjust_from_blobs);
    58.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Thu Sep 05 18:40:52 2019 +0800
    58.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Thu Sep 05 18:52:27 2019 +0800
    58.3 @@ -1,5 +1,5 @@
    58.4  /*
    58.5 - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
    58.6 + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
    58.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.8   *
    58.9   * This code is free software; you can redistribute it and/or modify it
   58.10 @@ -636,12 +636,6 @@
   58.11  
   58.12      NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
   58.13  
   58.14 -    {
   58.15 -      GCTraceTime tm("Prune Scavenge Root Methods", false, false, &_gc_timer, _gc_tracer.gc_id());
   58.16 -
   58.17 -      CodeCache::prune_scavenge_root_nmethods();
   58.18 -    }
   58.19 -
   58.20      // Re-verify object start arrays
   58.21      if (VerifyObjectStartArray &&
   58.22          VerifyAfterGC) {
    59.1 --- a/src/share/vm/memory/genCollectedHeap.cpp	Thu Sep 05 18:40:52 2019 +0800
    59.2 +++ b/src/share/vm/memory/genCollectedHeap.cpp	Thu Sep 05 18:52:27 2019 +0800
    59.3 @@ -1,5 +1,5 @@
    59.4  /*
    59.5 - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
    59.6 + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    59.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    59.8   *
    59.9   * This code is free software; you can redistribute it and/or modify it
   59.10 @@ -619,7 +619,7 @@
   59.11                                       OopClosure* weak_roots,
   59.12                                       CLDClosure* strong_cld_closure,
   59.13                                       CLDClosure* weak_cld_closure,
   59.14 -                                     CodeBlobClosure* code_roots) {
   59.15 +                                     CodeBlobToOopClosure* code_roots) {
   59.16    StrongRootsScope srs(this, activate_scope);
   59.17  
   59.18    // General roots.
   59.19 @@ -638,7 +638,7 @@
   59.20    // Don't process them if they will be processed during the ClassLoaderDataGraph phase.
   59.21    CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL;
   59.22    // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
   59.23 -  CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
   59.24 +  CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
   59.25  
   59.26    Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p);
   59.27  
   59.28 @@ -745,14 +745,8 @@
   59.29  }
   59.30  
   59.31  
   59.32 -class AlwaysTrueClosure: public BoolObjectClosure {
   59.33 -public:
   59.34 -  bool do_object_b(oop p) { return true; }
   59.35 -};
   59.36 -static AlwaysTrueClosure always_true;
   59.37 -
   59.38  void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
   59.39 -  JNIHandles::weak_oops_do(&always_true, root_closure);
   59.40 +  JNIHandles::weak_oops_do(root_closure);
   59.41    for (int i = 0; i < _n_gens; i++) {
   59.42      _gens[i]->ref_processor()->weak_oops_do(root_closure);
   59.43    }
    60.1 --- a/src/share/vm/memory/genCollectedHeap.hpp	Thu Sep 05 18:40:52 2019 +0800
    60.2 +++ b/src/share/vm/memory/genCollectedHeap.hpp	Thu Sep 05 18:52:27 2019 +0800
    60.3 @@ -1,5 +1,5 @@
    60.4  /*
    60.5 - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    60.6 + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    60.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    60.8   *
    60.9   * This code is free software; you can redistribute it and/or modify it
   60.10 @@ -416,7 +416,7 @@
   60.11                       OopClosure* weak_roots,
   60.12                       CLDClosure* strong_cld_closure,
   60.13                       CLDClosure* weak_cld_closure,
   60.14 -                     CodeBlobClosure* code_roots);
   60.15 +                     CodeBlobToOopClosure* code_roots);
   60.16  
   60.17    void gen_process_roots(int level,
   60.18                           bool younger_gens_as_roots,
    61.1 --- a/src/share/vm/memory/iterator.hpp	Thu Sep 05 18:40:52 2019 +0800
    61.2 +++ b/src/share/vm/memory/iterator.hpp	Thu Sep 05 18:52:27 2019 +0800
    61.3 @@ -1,5 +1,5 @@
    61.4  /*
    61.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    61.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    61.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    61.8   *
    61.9   * This code is free software; you can redistribute it and/or modify it
   61.10 @@ -219,6 +219,16 @@
   61.11    virtual bool do_object_b(oop obj) = 0;
   61.12  };
   61.13  
   61.14 +class AlwaysTrueClosure: public BoolObjectClosure {
   61.15 + public:
   61.16 +  bool do_object_b(oop p) { return true; }
   61.17 +};
   61.18 +
   61.19 +class AlwaysFalseClosure : public BoolObjectClosure {
   61.20 + public:
   61.21 +  bool do_object_b(oop p) { return false; }
   61.22 +};
   61.23 +
   61.24  // Applies an oop closure to all ref fields in objects iterated over in an
   61.25  // object iteration.
   61.26  class ObjectToOopClosure: public ObjectClosure {
   61.27 @@ -291,9 +301,12 @@
   61.28   protected:
   61.29    void do_nmethod(nmethod* nm);
   61.30   public:
   61.31 +  // If fix_relocations(), then cl must copy objects to their new location immediately to avoid
   61.32 +  // patching nmethods with the old locations.
   61.33    CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
   61.34    virtual void do_code_blob(CodeBlob* cb);
   61.35  
   61.36 +  bool fix_relocations() const { return _fix_relocations; }
   61.37    const static bool FixRelocations = true;
   61.38  };
   61.39  
    62.1 --- a/src/share/vm/memory/referenceProcessor.cpp	Thu Sep 05 18:40:52 2019 +0800
    62.2 +++ b/src/share/vm/memory/referenceProcessor.cpp	Thu Sep 05 18:52:27 2019 +0800
    62.3 @@ -275,11 +275,6 @@
    62.4  #ifndef PRODUCT
    62.5  // Calculate the number of jni handles.
    62.6  uint ReferenceProcessor::count_jni_refs() {
    62.7 -  class AlwaysAliveClosure: public BoolObjectClosure {
    62.8 -  public:
    62.9 -    virtual bool do_object_b(oop obj) { return true; }
   62.10 -  };
   62.11 -
   62.12    class CountHandleClosure: public OopClosure {
   62.13    private:
   62.14      int _count;
   62.15 @@ -290,8 +285,7 @@
   62.16      int count() { return _count; }
   62.17    };
   62.18    CountHandleClosure global_handle_count;
   62.19 -  AlwaysAliveClosure always_alive;
   62.20 -  JNIHandles::weak_oops_do(&always_alive, &global_handle_count);
   62.21 +  JNIHandles::weak_oops_do(&global_handle_count);
   62.22    return global_handle_count.count();
   62.23  }
   62.24  #endif
    63.1 --- a/src/share/vm/oops/instanceKlass.cpp	Thu Sep 05 18:40:52 2019 +0800
    63.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Thu Sep 05 18:52:27 2019 +0800
    63.3 @@ -1,5 +1,5 @@
    63.4  /*
    63.5 - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
    63.6 + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
    63.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.8   *
    63.9   * This code is free software; you can redistribute it and/or modify it
   63.10 @@ -2925,6 +2925,13 @@
   63.11  
   63.12  // On-stack replacement stuff
   63.13  void InstanceKlass::add_osr_nmethod(nmethod* n) {
   63.14 +#ifndef PRODUCT
   63.15 +  if (TieredCompilation) {
   63.16 +      nmethod * prev = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), n->comp_level(), true);
   63.17 +      assert(prev == NULL || !prev->is_in_use(),
   63.18 +      "redundunt OSR recompilation detected. memory leak in CodeCache!");
   63.19 +  }
   63.20 +#endif
   63.21    // only one compilation can be active
   63.22    NEEDS_CLEANUP
   63.23    // This is a short non-blocking critical region, so the no safepoint check is ok.
   63.24 @@ -3046,7 +3053,9 @@
   63.25      osr = osr->osr_link();
   63.26    }
   63.27    OsrList_lock->unlock();
   63.28 -  if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
   63.29 +
   63.30 +  assert(match_level == false || best == NULL, "shouldn't pick up anything if match_level is set");
   63.31 +  if (best != NULL && best->comp_level() >= comp_level) {
   63.32      return best;
   63.33    }
   63.34    return NULL;
    64.1 --- a/src/share/vm/opto/library_call.cpp	Thu Sep 05 18:40:52 2019 +0800
    64.2 +++ b/src/share/vm/opto/library_call.cpp	Thu Sep 05 18:52:27 2019 +0800
    64.3 @@ -2608,9 +2608,10 @@
    64.4    Node* offset = top();
    64.5    Node* val;
    64.6  
    64.7 +  // The base is either a Java object or a value produced by Unsafe.staticFieldBase
    64.8 +  Node* base = argument(1);  // type: oop
    64.9 +
   64.10    if (!is_native_ptr) {
   64.11 -    // The base is either a Java object or a value produced by Unsafe.staticFieldBase
   64.12 -    Node* base = argument(1);  // type: oop
   64.13      // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset
   64.14      offset = argument(2);  // type: long
   64.15      // We currently rely on the cookies produced by Unsafe.xxxFieldOffset
   64.16 @@ -2630,9 +2631,7 @@
   64.17      val = is_store ? argument(3) : NULL;
   64.18    }
   64.19  
   64.20 -  // Can base be NULL? Otherwise, always on-heap access.
   64.21 -  bool can_access_non_heap = TypePtr::NULL_PTR->higher_equal(_gvn.type(heap_base_oop));
   64.22 -  if (can_access_non_heap && type == T_OBJECT) {
   64.23 +  if ((_gvn.type(base)->isa_ptr() == TypePtr::NULL_PTR) && type == T_OBJECT) {
   64.24      return false; // off-heap oop accesses are not supported
   64.25    }
   64.26  
    65.1 --- a/src/share/vm/opto/memnode.cpp	Thu Sep 05 18:40:52 2019 +0800
    65.2 +++ b/src/share/vm/opto/memnode.cpp	Thu Sep 05 18:52:27 2019 +0800
    65.3 @@ -1514,10 +1514,14 @@
    65.4    Node* ctrl    = in(MemNode::Control);
    65.5    Node* address = in(MemNode::Address);
    65.6  
    65.7 +  bool addr_mark = ((phase->type(address)->isa_oopptr() || phase->type(address)->isa_narrowoop()) &&
    65.8 +         phase->type(address)->is_ptr()->offset() == oopDesc::mark_offset_in_bytes());
    65.9 +
   65.10    // Skip up past a SafePoint control.  Cannot do this for Stores because
   65.11    // pointer stores & cardmarks must stay on the same side of a SafePoint.
   65.12    if( ctrl != NULL && ctrl->Opcode() == Op_SafePoint &&
   65.13 -      phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw ) {
   65.14 +      phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw  &&
   65.15 +      !addr_mark ) {
   65.16      ctrl = ctrl->in(0);
   65.17      set_req(MemNode::Control,ctrl);
   65.18    }
   65.19 @@ -3349,9 +3353,6 @@
   65.20  // within the initialized memory.
   65.21  intptr_t InitializeNode::can_capture_store(StoreNode* st, PhaseTransform* phase, bool can_reshape) {
   65.22    const int FAIL = 0;
   65.23 -  if (st->is_unaligned_access()) {
   65.24 -    return FAIL;
   65.25 -  }
   65.26    if (st->req() != MemNode::ValueIn + 1)
   65.27      return FAIL;                // an inscrutable StoreNode (card mark?)
   65.28    Node* ctl = st->in(MemNode::Control);
   65.29 @@ -3367,6 +3368,10 @@
   65.30      return FAIL;                // inscrutable address
   65.31    if (alloc != allocation())
   65.32      return FAIL;                // wrong allocation!  (store needs to float up)
   65.33 +  int size_in_bytes = st->memory_size();
   65.34 +  if ((size_in_bytes != 0) && (offset % size_in_bytes) != 0) {
   65.35 +    return FAIL;                // mismatched access
   65.36 +  }
   65.37    Node* val = st->in(MemNode::ValueIn);
   65.38    int complexity_count = 0;
   65.39    if (!detect_init_independence(val, complexity_count))
    66.1 --- a/src/share/vm/prims/jni.cpp	Thu Sep 05 18:40:52 2019 +0800
    66.2 +++ b/src/share/vm/prims/jni.cpp	Thu Sep 05 18:52:27 2019 +0800
    66.3 @@ -709,6 +709,7 @@
    66.4  
    66.5    THROW_OOP_(JNIHandles::resolve(obj), JNI_OK);
    66.6    ShouldNotReachHere();
    66.7 +  return 0; // Mute compiler.
    66.8  JNI_END
    66.9  
   66.10  #ifndef USDT2
   66.11 @@ -735,6 +736,7 @@
   66.12    Handle protection_domain (THREAD, k->protection_domain());
   66.13    THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK);
   66.14    ShouldNotReachHere();
   66.15 +  return 0; // Mute compiler.
   66.16  JNI_END
   66.17  
   66.18  
   66.19 @@ -1140,8 +1142,7 @@
   66.20    inline void get_long()   { _arguments->push_long(va_arg(_ap, jlong)); }
   66.21    inline void get_float()  { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg
   66.22    inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); }
   66.23 -  inline void get_object() { jobject l = va_arg(_ap, jobject);
   66.24 -                             _arguments->push_oop(Handle((oop *)l, false)); }
   66.25 +  inline void get_object() { _arguments->push_jobject(va_arg(_ap, jobject)); }
   66.26  
   66.27    inline void set_ap(va_list rap) {
   66.28  #ifdef va_copy
   66.29 @@ -1235,7 +1236,7 @@
   66.30    inline void get_long()   { _arguments->push_long((_ap++)->j);  }
   66.31    inline void get_float()  { _arguments->push_float((_ap++)->f); }
   66.32    inline void get_double() { _arguments->push_double((_ap++)->d);}
   66.33 -  inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); }
   66.34 +  inline void get_object() { _arguments->push_jobject((_ap++)->l); }
   66.35  
   66.36    inline void set_ap(const jvalue *rap) { _ap = rap; }
   66.37  
   66.38 @@ -5121,6 +5122,7 @@
   66.39      run_unit_test(TestMetachunk_test());
   66.40      run_unit_test(TestVirtualSpaceNode_test());
   66.41      run_unit_test(GlobalDefinitions::test_globals());
   66.42 +    run_unit_test(GlobalDefinitions::test_proper_unit());
   66.43      run_unit_test(GCTimerAllTest::all());
   66.44      run_unit_test(arrayOopDesc::test_max_array_length());
   66.45      run_unit_test(CollectedHeap::test_is_in());
    67.1 --- a/src/share/vm/prims/jvmtiEnv.cpp	Thu Sep 05 18:40:52 2019 +0800
    67.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp	Thu Sep 05 18:52:27 2019 +0800
    67.3 @@ -1,5 +1,5 @@
    67.4  /*
    67.5 - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
    67.6 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
    67.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    67.8   *
    67.9   * This code is free software; you can redistribute it and/or modify it
   67.10 @@ -1621,6 +1621,13 @@
   67.11      }
   67.12    }
   67.13  
   67.14 +  if (initial_object != NULL) {
   67.15 +    oop init_obj = JNIHandles::resolve_external_guard(initial_object);
   67.16 +    if (init_obj == NULL) {
   67.17 +      return JVMTI_ERROR_INVALID_OBJECT;
   67.18 +    }
   67.19 +  }
   67.20 +
   67.21    Thread *thread = Thread::current();
   67.22    HandleMark hm(thread);
   67.23    KlassHandle kh (thread, k_oop);
    68.1 --- a/src/share/vm/prims/whitebox.cpp	Thu Sep 05 18:40:52 2019 +0800
    68.2 +++ b/src/share/vm/prims/whitebox.cpp	Thu Sep 05 18:52:27 2019 +0800
    68.3 @@ -1,5 +1,5 @@
    68.4  /*
    68.5 - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
    68.6 + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
    68.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    68.8   *
    68.9   * This code is free software; you can redistribute it and/or modify it
   68.10 @@ -26,6 +26,7 @@
   68.11  
   68.12  #include "memory/metadataFactory.hpp"
   68.13  #include "memory/metaspaceShared.hpp"
   68.14 +#include "memory/iterator.hpp"
   68.15  #include "memory/universe.hpp"
   68.16  #include "oops/oop.inline.hpp"
   68.17  
   68.18 @@ -583,11 +584,6 @@
   68.19    bool allow_nested_vm_operations() const        { return true; }
   68.20  };
   68.21  
   68.22 -class AlwaysFalseClosure : public BoolObjectClosure {
   68.23 - public:
   68.24 -  bool do_object_b(oop p) { return false; }
   68.25 -};
   68.26 -
   68.27  static AlwaysFalseClosure always_false;
   68.28  
   68.29  class VM_WhiteBoxCleanMethodData : public VM_WhiteBoxOperation {
   68.30 @@ -637,6 +633,25 @@
   68.31    }
   68.32  WB_END
   68.33  
   68.34 +WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method))
   68.35 +  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   68.36 +  CHECK_JNI_EXCEPTION(env);
   68.37 +  methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   68.38 +
   68.39 +  MethodData* mdo = mh->method_data();
   68.40 +  if (mdo == NULL) {
   68.41 +    Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
   68.42 +    mdo = mh->method_data();
   68.43 +  }
   68.44 +  mdo->init();
   68.45 +  InvocationCounter* icnt = mdo->invocation_counter();
   68.46 +  InvocationCounter* bcnt = mdo->backedge_counter();
   68.47 +  // set i-counter according to AdvancedThresholdPolicy::is_method_profiled
   68.48 +  // because SimpleThresholdPolicy::call_predicate_helper uses > in jdk8u, that's why we need to plus one.
   68.49 +  icnt->set(InvocationCounter::wait_for_compile, Tier4MinInvocationThreshold + 1);
   68.50 +  bcnt->set(InvocationCounter::wait_for_compile, Tier4CompileThreshold + 1);
   68.51 +WB_END
   68.52 +
   68.53  template <typename T>
   68.54  static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) {
   68.55    if (name == NULL) {
   68.56 @@ -852,19 +867,23 @@
   68.57    ThreadToNativeFromVM ttn(thread);
   68.58    jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string());
   68.59    CHECK_JNI_EXCEPTION_(env, NULL);
   68.60 -  result = env->NewObjectArray(2, clazz, NULL);
   68.61 +  result = env->NewObjectArray(3, clazz, NULL);
   68.62    if (result == NULL) {
   68.63      return result;
   68.64    }
   68.65  
   68.66 -  jobject obj = integerBox(thread, env, code->comp_level());
   68.67 +  jobject level = integerBox(thread, env, code->comp_level());
   68.68    CHECK_JNI_EXCEPTION_(env, NULL);
   68.69 -  env->SetObjectArrayElement(result, 0, obj);
   68.70 +  env->SetObjectArrayElement(result, 0, level);
   68.71 +
   68.72 +  jobject id = integerBox(thread, env, code->compile_id());
   68.73 +  CHECK_JNI_EXCEPTION_(env, NULL);
   68.74 +  env->SetObjectArrayElement(result, 1, id);
   68.75  
   68.76    jbyteArray insts = env->NewByteArray(insts_size);
   68.77    CHECK_JNI_EXCEPTION_(env, NULL);
   68.78    env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin());
   68.79 -  env->SetObjectArrayElement(result, 1, insts);
   68.80 +  env->SetObjectArrayElement(result, 2, insts);
   68.81  
   68.82    return result;
   68.83  WB_END
   68.84 @@ -1123,6 +1142,8 @@
   68.85        CC"(Ljava/lang/reflect/Executable;II)Z",        (void*)&WB_EnqueueMethodForCompilation},
   68.86    {CC"clearMethodState",
   68.87        CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_ClearMethodState},
   68.88 +  {CC"markMethodProfiled",
   68.89 +      CC"(Ljava/lang/reflect/Executable;)V",          (void*)&WB_MarkMethodProfiled},
   68.90    {CC"setBooleanVMFlag",   CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
   68.91    {CC"setIntxVMFlag",      CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
   68.92    {CC"setUintxVMFlag",     CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
    69.1 --- a/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Sep 05 18:40:52 2019 +0800
    69.2 +++ b/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Sep 05 18:52:27 2019 +0800
    69.3 @@ -1,5 +1,5 @@
    69.4  /*
    69.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    69.6 + * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
    69.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    69.8   *
    69.9   * This code is free software; you can redistribute it and/or modify it
   69.10 @@ -196,6 +196,16 @@
   69.11  
   69.12    if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
   69.13        && is_method_profiled(max_method)) {
   69.14 +
   69.15 +    if (CompileBroker::compilation_is_complete(max_method, max_task->osr_bci(), CompLevel_limited_profile)) {
   69.16 +      if (PrintTieredEvents) {
   69.17 +        print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
   69.18 +      }
   69.19 +      compile_queue->remove_and_mark_stale(max_task);
   69.20 +      max_method->clear_queued_for_compilation();
   69.21 +      return NULL;
   69.22 +    }
   69.23 +
   69.24      max_task->set_comp_level(CompLevel_limited_profile);
   69.25      if (PrintTieredEvents) {
   69.26        print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
    70.1 --- a/src/share/vm/runtime/javaCalls.cpp	Thu Sep 05 18:40:52 2019 +0800
    70.2 +++ b/src/share/vm/runtime/javaCalls.cpp	Thu Sep 05 18:52:27 2019 +0800
    70.3 @@ -1,5 +1,5 @@
    70.4  /*
    70.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    70.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    70.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    70.8   *
    70.9   * This code is free software; you can redistribute it and/or modify it
   70.10 @@ -325,9 +325,9 @@
   70.11    // Verify the arguments
   70.12  
   70.13    if (CheckJNICalls)  {
   70.14 -    args->verify(method, result->get_type(), thread);
   70.15 +    args->verify(method, result->get_type());
   70.16    }
   70.17 -  else debug_only(args->verify(method, result->get_type(), thread));
   70.18 +  else debug_only(args->verify(method, result->get_type()));
   70.19  
   70.20    // Ignore call if method is empty
   70.21    if (method->is_empty_method()) {
   70.22 @@ -429,12 +429,42 @@
   70.23  //--------------------------------------------------------------------------------------
   70.24  // Implementation of JavaCallArguments
   70.25  
   70.26 +inline bool is_value_state_indirect_oop(uint state) {
   70.27 +  assert(state != JavaCallArguments::value_state_oop,
   70.28 +         "Checking for handles after removal");
   70.29 +  assert(state < JavaCallArguments::value_state_limit, "Invalid value state");
   70.30 +  return state != JavaCallArguments::value_state_primitive;
   70.31 +}
   70.32 +
   70.33 +inline oop resolve_indirect_oop(intptr_t value, uint state) {
   70.34 +  switch (state) {
   70.35 +  case JavaCallArguments::value_state_handle:
   70.36 +  {
   70.37 +    oop* ptr = reinterpret_cast<oop*>(value);
   70.38 +    return Handle::raw_resolve(ptr);
   70.39 +  }
   70.40 +
   70.41 +  case JavaCallArguments::value_state_jobject:
   70.42 +  {
   70.43 +    jobject obj = reinterpret_cast<jobject>(value);
   70.44 +    return JNIHandles::resolve(obj);
   70.45 +  }
   70.46 +
   70.47 +  default:
   70.48 +    ShouldNotReachHere();
   70.49 +    return NULL;
   70.50 +  }
   70.51 +}
   70.52 +
   70.53  intptr_t* JavaCallArguments::parameters() {
   70.54    // First convert all handles to oops
   70.55    for(int i = 0; i < _size; i++) {
   70.56 -    if (_is_oop[i]) {
   70.57 -      // Handle conversion
   70.58 -      _value[i] = cast_from_oop<intptr_t>(Handle::raw_resolve((oop *)_value[i]));
   70.59 +    uint state = _value_state[i];
   70.60 +    assert(state != value_state_oop, "Multiple handle conversions");
   70.61 +    if (is_value_state_indirect_oop(state)) {
   70.62 +      oop obj = resolve_indirect_oop(_value[i], state);
   70.63 +      _value[i] = cast_from_oop<intptr_t>(obj);
   70.64 +      _value_state[i] = value_state_oop;
   70.65      }
   70.66    }
   70.67    // Return argument vector
   70.68 @@ -444,30 +474,40 @@
   70.69  
   70.70  class SignatureChekker : public SignatureIterator {
   70.71   private:
   70.72 -   bool *_is_oop;
   70.73 -   int   _pos;
   70.74 -   BasicType _return_type;
   70.75 -   intptr_t*   _value;
   70.76 -   Thread* _thread;
   70.77 +  int _pos;
   70.78 +  BasicType _return_type;
   70.79 +  u_char* _value_state;
   70.80 +  intptr_t* _value;
   70.81  
   70.82   public:
   70.83    bool _is_return;
   70.84  
   70.85 -  SignatureChekker(Symbol* signature, BasicType return_type, bool is_static, bool* is_oop, intptr_t* value, Thread* thread) : SignatureIterator(signature) {
   70.86 -    _is_oop = is_oop;
   70.87 -    _is_return = false;
   70.88 -    _return_type = return_type;
   70.89 -    _pos = 0;
   70.90 -    _value = value;
   70.91 -    _thread = thread;
   70.92 -
   70.93 +  SignatureChekker(Symbol* signature,
   70.94 +                   BasicType return_type,
   70.95 +                   bool is_static,
   70.96 +                   u_char* value_state,
   70.97 +                   intptr_t* value) :
   70.98 +    SignatureIterator(signature),
   70.99 +    _pos(0),
  70.100 +    _return_type(return_type),
  70.101 +    _value_state(value_state),
  70.102 +    _value(value),
  70.103 +    _is_return(false)
  70.104 +  {
  70.105      if (!is_static) {
  70.106        check_value(true); // Receiver must be an oop
  70.107      }
  70.108    }
  70.109  
  70.110    void check_value(bool type) {
  70.111 -    guarantee(_is_oop[_pos++] == type, "signature does not match pushed arguments");
  70.112 +    uint state = _value_state[_pos++];
  70.113 +    if (type) {
  70.114 +      guarantee(is_value_state_indirect_oop(state),
  70.115 +                "signature does not match pushed arguments");
  70.116 +    } else {
  70.117 +      guarantee(state == JavaCallArguments::value_state_primitive,
  70.118 +                "signature does not match pushed arguments");
  70.119 +    }
  70.120    }
  70.121  
  70.122    void check_doing_return(bool state) { _is_return = state; }
  70.123 @@ -502,24 +542,19 @@
  70.124        return;
  70.125      }
  70.126  
  70.127 -    // verify handle and the oop pointed to by handle
  70.128 -    int p = _pos;
  70.129 -    bool bad = false;
  70.130 -    // If argument is oop
  70.131 -    if (_is_oop[p]) {
  70.132 -      intptr_t v = _value[p];
  70.133 -      if (v != 0 ) {
  70.134 -        size_t t = (size_t)v;
  70.135 -        bad = (t < (size_t)os::vm_page_size() ) || !Handle::raw_resolve((oop *)v)->is_oop_or_null(true);
  70.136 -        if (CheckJNICalls && bad) {
  70.137 -          ReportJNIFatalError((JavaThread*)_thread, "Bad JNI oop argument");
  70.138 -        }
  70.139 -      }
  70.140 -      // for the regular debug case.
  70.141 -      assert(!bad, "Bad JNI oop argument");
  70.142 +    intptr_t v = _value[_pos];
  70.143 +    if (v != 0) {
  70.144 +      // v is a "handle" referring to an oop, cast to integral type.
  70.145 +      // There shouldn't be any handles in very low memory.
  70.146 +      guarantee((size_t)v >= (size_t)os::vm_page_size(),
  70.147 +                "Bad JNI oop argument");
  70.148 +      // Verify the pointee.
  70.149 +      oop vv = resolve_indirect_oop(v, _value_state[_pos]);
  70.150 +      guarantee(vv->is_oop_or_null(true),
  70.151 +                "Bad JNI oop argument");
  70.152      }
  70.153  
  70.154 -    check_value(true);
  70.155 +    check_value(true);          // Verify value state.
  70.156    }
  70.157  
  70.158    void do_bool()                       { check_int(T_BOOLEAN);       }
  70.159 @@ -536,8 +571,7 @@
  70.160  };
  70.161  
  70.162  
  70.163 -void JavaCallArguments::verify(methodHandle method, BasicType return_type,
  70.164 -  Thread *thread) {
  70.165 +void JavaCallArguments::verify(methodHandle method, BasicType return_type) {
  70.166    guarantee(method->size_of_parameters() == size_of_parameters(), "wrong no. of arguments pushed");
  70.167  
  70.168    // Treat T_OBJECT and T_ARRAY as the same
  70.169 @@ -546,7 +580,11 @@
  70.170    // Check that oop information is correct
  70.171    Symbol* signature = method->signature();
  70.172  
  70.173 -  SignatureChekker sc(signature, return_type, method->is_static(),_is_oop, _value, thread);
  70.174 +  SignatureChekker sc(signature,
  70.175 +                      return_type,
  70.176 +                      method->is_static(),
  70.177 +                      _value_state,
  70.178 +                      _value);
  70.179    sc.iterate_parameters();
  70.180    sc.check_doing_return(true);
  70.181    sc.iterate_returntype();
    71.1 --- a/src/share/vm/runtime/javaCalls.hpp	Thu Sep 05 18:40:52 2019 +0800
    71.2 +++ b/src/share/vm/runtime/javaCalls.hpp	Thu Sep 05 18:52:27 2019 +0800
    71.3 @@ -1,5 +1,5 @@
    71.4  /*
    71.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    71.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    71.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.8   *
    71.9   * This code is free software; you can redistribute it and/or modify it
   71.10 @@ -101,25 +101,42 @@
   71.11     _default_size = 8    // Must be at least # of arguments in JavaCalls methods
   71.12    };
   71.13  
   71.14 -  intptr_t    _value_buffer [_default_size + 1];
   71.15 -  bool        _is_oop_buffer[_default_size + 1];
   71.16 +  intptr_t    _value_buffer      [_default_size + 1];
   71.17 +  u_char      _value_state_buffer[_default_size + 1];
   71.18  
   71.19    intptr_t*   _value;
   71.20 -  bool*       _is_oop;
   71.21 +  u_char*     _value_state;
   71.22    int         _size;
   71.23    int         _max_size;
   71.24    bool        _start_at_zero;      // Support late setting of receiver
   71.25  
   71.26    void initialize() {
   71.27      // Starts at first element to support set_receiver.
   71.28 -    _value    = &_value_buffer[1];
   71.29 -    _is_oop   = &_is_oop_buffer[1];
   71.30 +    _value       = &_value_buffer[1];
   71.31 +    _value_state = &_value_state_buffer[1];
   71.32  
   71.33      _max_size = _default_size;
   71.34      _size = 0;
   71.35      _start_at_zero = false;
   71.36    }
   71.37  
   71.38 +  // Helper for push_oop and the like.  The value argument is a
   71.39 +  // "handle" that refers to an oop.  We record the address of the
   71.40 +  // handle rather than the designated oop.  The handle is later
   71.41 +  // resolved to the oop by parameters().  This delays the exposure of
   71.42 +  // naked oops until it is GC-safe.
   71.43 +  template<typename T>
   71.44 +  inline int push_oop_impl(T handle, int size) {
   71.45 +    // JNITypes::put_obj expects an oop value, so we play fast and
   71.46 +    // loose with the type system.  The cast from handle type to oop
   71.47 +    // *must* use a C-style cast.  In a product build it performs a
   71.48 +    // reinterpret_cast. In a debug build (more accurately, in a
   71.49 +    // CHECK_UNHANDLED_OOPS build) it performs a static_cast, invoking
   71.50 +    // the debug-only oop class's conversion from void* constructor.
   71.51 +    JNITypes::put_obj((oop)handle, _value, size); // Updates size.
   71.52 +    return size;                // Return the updated size.
   71.53 +  }
   71.54 +
   71.55   public:
   71.56    JavaCallArguments() { initialize(); }
   71.57  
   71.58 @@ -130,11 +147,12 @@
   71.59  
   71.60    JavaCallArguments(int max_size) {
   71.61      if (max_size > _default_size) {
   71.62 -      _value  = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
   71.63 -      _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1);
   71.64 +      _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
   71.65 +      _value_state = NEW_RESOURCE_ARRAY(u_char, max_size + 1);
   71.66  
   71.67 -      // Reserve room for potential receiver in value and is_oop
   71.68 -      _value++; _is_oop++;
   71.69 +      // Reserve room for potential receiver in value and state
   71.70 +      _value++;
   71.71 +      _value_state++;
   71.72  
   71.73        _max_size = max_size;
   71.74        _size = 0;
   71.75 @@ -144,25 +162,52 @@
   71.76      }
   71.77    }
   71.78  
   71.79 -  inline void push_oop(Handle h)    { _is_oop[_size] = true;
   71.80 -                               JNITypes::put_obj((oop)h.raw_value(), _value, _size); }
   71.81 +  // The possible values for _value_state elements.
   71.82 +  enum {
   71.83 +    value_state_primitive,
   71.84 +    value_state_oop,
   71.85 +    value_state_handle,
   71.86 +    value_state_jobject,
   71.87 +    value_state_limit
   71.88 +  };
   71.89  
   71.90 -  inline void push_int(int i)       { _is_oop[_size] = false;
   71.91 -                               JNITypes::put_int(i, _value, _size); }
   71.92 +  inline void push_oop(Handle h) {
   71.93 +    _value_state[_size] = value_state_handle;
   71.94 +    _size = push_oop_impl(h.raw_value(), _size);
   71.95 +  }
   71.96  
   71.97 -  inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false;
   71.98 -                               JNITypes::put_double(d, _value, _size); }
   71.99 +  inline void push_jobject(jobject h) {
  71.100 +    _value_state[_size] = value_state_jobject;
  71.101 +    _size = push_oop_impl(h, _size);
  71.102 +  }
  71.103  
  71.104 -  inline void push_long(jlong l)    { _is_oop[_size] = false; _is_oop[_size + 1] = false;
  71.105 -                               JNITypes::put_long(l, _value, _size); }
  71.106 +  inline void push_int(int i) {
  71.107 +    _value_state[_size] = value_state_primitive;
  71.108 +    JNITypes::put_int(i, _value, _size);
  71.109 +  }
  71.110  
  71.111 -  inline void push_float(float f)   { _is_oop[_size] = false;
  71.112 -                               JNITypes::put_float(f, _value, _size); }
  71.113 +  inline void push_double(double d) {
  71.114 +    _value_state[_size] = value_state_primitive;
  71.115 +    _value_state[_size + 1] = value_state_primitive;
  71.116 +    JNITypes::put_double(d, _value, _size);
  71.117 +  }
  71.118 +
  71.119 +  inline void push_long(jlong l) {
  71.120 +    _value_state[_size] = value_state_primitive;
  71.121 +    _value_state[_size + 1] = value_state_primitive;
  71.122 +    JNITypes::put_long(l, _value, _size);
  71.123 +  }
  71.124 +
  71.125 +  inline void push_float(float f) {
  71.126 +    _value_state[_size] = value_state_primitive;
  71.127 +    JNITypes::put_float(f, _value, _size);
  71.128 +  }
  71.129  
  71.130    // receiver
  71.131    Handle receiver() {
  71.132      assert(_size > 0, "must at least be one argument");
  71.133 -    assert(_is_oop[0], "first argument must be an oop");
  71.134 +    assert(_value_state[0] == value_state_handle,
  71.135 +           "first argument must be an oop");
  71.136      assert(_value[0] != 0, "receiver must be not-null");
  71.137      return Handle((oop*)_value[0], false);
  71.138    }
  71.139 @@ -170,11 +215,11 @@
  71.140    void set_receiver(Handle h) {
  71.141      assert(_start_at_zero == false, "can only be called once");
  71.142      _start_at_zero = true;
  71.143 -    _is_oop--;
  71.144 +    _value_state--;
  71.145      _value--;
  71.146      _size++;
  71.147 -    _is_oop[0] = true;
  71.148 -    _value[0] = (intptr_t)h.raw_value();
  71.149 +    _value_state[0] = value_state_handle;
  71.150 +    push_oop_impl(h.raw_value(), 0);
  71.151    }
  71.152  
  71.153    // Converts all Handles to oops, and returns a reference to parameter vector
  71.154 @@ -182,7 +227,7 @@
  71.155    int   size_of_parameters() const { return _size; }
  71.156  
  71.157    // Verify that pushed arguments fits a given method
  71.158 -  void verify(methodHandle method, BasicType return_type, Thread *thread);
  71.159 +  void verify(methodHandle method, BasicType return_type);
  71.160  };
  71.161  
  71.162  // All calls to Java have to go via JavaCalls. Sets up the stack frame
    72.1 --- a/src/share/vm/runtime/jniHandles.cpp	Thu Sep 05 18:40:52 2019 +0800
    72.2 +++ b/src/share/vm/runtime/jniHandles.cpp	Thu Sep 05 18:52:27 2019 +0800
    72.3 @@ -24,11 +24,15 @@
    72.4  
    72.5  #include "precompiled.hpp"
    72.6  #include "classfile/systemDictionary.hpp"
    72.7 +#include "memory/iterator.hpp"
    72.8  #include "oops/oop.inline.hpp"
    72.9  #include "prims/jvmtiExport.hpp"
   72.10  #include "runtime/jniHandles.hpp"
   72.11  #include "runtime/mutexLocker.hpp"
   72.12  #include "runtime/thread.inline.hpp"
   72.13 +#if INCLUDE_ALL_GCS
   72.14 +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
   72.15 +#endif
   72.16  
   72.17  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
   72.18  
   72.19 @@ -86,34 +90,52 @@
   72.20    return res;
   72.21  }
   72.22  
   72.23 -
   72.24  jobject JNIHandles::make_weak_global(Handle obj) {
   72.25    assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
   72.26    jobject res = NULL;
   72.27    if (!obj.is_null()) {
   72.28      // ignore null handles
   72.29 -    MutexLocker ml(JNIGlobalHandle_lock);
   72.30 -    assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
   72.31 -    res = _weak_global_handles->allocate_handle(obj());
   72.32 +    {
   72.33 +      MutexLocker ml(JNIGlobalHandle_lock);
   72.34 +      assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
   72.35 +      res = _weak_global_handles->allocate_handle(obj());
   72.36 +    }
   72.37 +    // Add weak tag.
   72.38 +    assert(is_ptr_aligned(res, weak_tag_alignment), "invariant");
   72.39 +    char* tptr = reinterpret_cast<char*>(res) + weak_tag_value;
   72.40 +    res = reinterpret_cast<jobject>(tptr);
   72.41    } else {
   72.42      CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
   72.43    }
   72.44    return res;
   72.45  }
   72.46  
   72.47 +template<bool external_guard>
   72.48 +oop JNIHandles::resolve_jweak(jweak handle) {
   72.49 +  assert(is_jweak(handle), "precondition");
   72.50 +  oop result = jweak_ref(handle);
   72.51 +  result = guard_value<external_guard>(result);
   72.52 +#if INCLUDE_ALL_GCS
   72.53 +  if (result != NULL && UseG1GC) {
   72.54 +    G1SATBCardTableModRefBS::enqueue(result);
   72.55 +  }
   72.56 +#endif // INCLUDE_ALL_GCS
   72.57 +  return result;
   72.58 +}
   72.59 +
   72.60 +template oop JNIHandles::resolve_jweak<true>(jweak);
   72.61 +template oop JNIHandles::resolve_jweak<false>(jweak);
   72.62  
   72.63  void JNIHandles::destroy_global(jobject handle) {
   72.64    if (handle != NULL) {
   72.65      assert(is_global_handle(handle), "Invalid delete of global JNI handle");
   72.66 -    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
   72.67 +    jobject_ref(handle) = deleted_handle();
   72.68    }
   72.69  }
   72.70  
   72.71 -
   72.72  void JNIHandles::destroy_weak_global(jobject handle) {
   72.73    if (handle != NULL) {
   72.74 -    assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle");
   72.75 -    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
   72.76 +    jweak_ref(handle) = deleted_handle();
   72.77    }
   72.78  }
   72.79  
   72.80 @@ -129,6 +151,12 @@
   72.81  }
   72.82  
   72.83  
   72.84 +void JNIHandles::weak_oops_do(OopClosure* f) {
   72.85 +  AlwaysTrueClosure always_true;
   72.86 +  weak_oops_do(&always_true, f);
   72.87 +}
   72.88 +
   72.89 +
   72.90  void JNIHandles::initialize() {
   72.91    _global_handles      = JNIHandleBlock::allocate_block();
   72.92    _weak_global_handles = JNIHandleBlock::allocate_block();
   72.93 @@ -186,11 +214,6 @@
   72.94  }
   72.95  
   72.96  
   72.97 -class AlwaysAliveClosure: public BoolObjectClosure {
   72.98 -public:
   72.99 -  bool do_object_b(oop obj) { return true; }
  72.100 -};
  72.101 -
  72.102  class CountHandleClosure: public OopClosure {
  72.103  private:
  72.104    int _count;
  72.105 @@ -212,9 +235,8 @@
  72.106           "JNIHandles not initialized");
  72.107  
  72.108    CountHandleClosure global_handle_count;
  72.109 -  AlwaysAliveClosure always_alive;
  72.110    oops_do(&global_handle_count);
  72.111 -  weak_oops_do(&always_alive, &global_handle_count);
  72.112 +  weak_oops_do(&global_handle_count);
  72.113  
  72.114    st->print_cr("JNI global references: %d", global_handle_count.count());
  72.115    st->cr();
  72.116 @@ -231,10 +253,9 @@
  72.117  
  72.118  void JNIHandles::verify() {
  72.119    VerifyHandleClosure verify_handle;
  72.120 -  AlwaysAliveClosure always_alive;
  72.121  
  72.122    oops_do(&verify_handle);
  72.123 -  weak_oops_do(&always_alive, &verify_handle);
  72.124 +  weak_oops_do(&verify_handle);
  72.125  }
  72.126  
  72.127  
    73.1 --- a/src/share/vm/runtime/jniHandles.hpp	Thu Sep 05 18:40:52 2019 +0800
    73.2 +++ b/src/share/vm/runtime/jniHandles.hpp	Thu Sep 05 18:52:27 2019 +0800
    73.3 @@ -1,5 +1,5 @@
    73.4  /*
    73.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    73.6 + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
    73.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    73.8   *
    73.9   * This code is free software; you can redistribute it and/or modify it
   73.10 @@ -40,7 +40,28 @@
   73.11    static JNIHandleBlock* _weak_global_handles;        // First weak global handle block
   73.12    static oop _deleted_handle;                         // Sentinel marking deleted handles
   73.13  
   73.14 +  inline static bool is_jweak(jobject handle);
   73.15 +  inline static oop& jobject_ref(jobject handle); // NOT jweak!
   73.16 +  inline static oop& jweak_ref(jobject handle);
   73.17 +
   73.18 +  template<bool external_guard> inline static oop guard_value(oop value);
   73.19 +  template<bool external_guard> inline static oop resolve_impl(jobject handle);
   73.20 +  template<bool external_guard> static oop resolve_jweak(jweak handle);
   73.21 +
   73.22   public:
   73.23 +  // Low tag bit in jobject used to distinguish a jweak.  jweak is
   73.24 +  // type equivalent to jobject, but there are places where we need to
   73.25 +  // be able to distinguish jweak values from other jobjects, and
   73.26 +  // is_weak_global_handle is unsuitable for performance reasons.  To
   73.27 +  // provide such a test we add weak_tag_value to the (aligned) byte
   73.28 +  // address designated by the jobject to produce the corresponding
   73.29 +  // jweak.  Accessing the value of a jobject must account for it
   73.30 +  // being a possibly offset jweak.
   73.31 +  static const uintptr_t weak_tag_size = 1;
   73.32 +  static const uintptr_t weak_tag_alignment = (1u << weak_tag_size);
   73.33 +  static const uintptr_t weak_tag_mask = weak_tag_alignment - 1;
   73.34 +  static const int weak_tag_value = 1;
   73.35 +
   73.36    // Resolve handle into oop
   73.37    inline static oop resolve(jobject handle);
   73.38    // Resolve externally provided handle into oop with some guards
   73.39 @@ -86,6 +107,8 @@
   73.40    static void oops_do(OopClosure* f);
   73.41    // Traversal of weak global handles. Unreachable oops are cleared.
   73.42    static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
   73.43 +  // Traversal of weak global handles.
   73.44 +  static void weak_oops_do(OopClosure* f);
   73.45  };
   73.46  
   73.47  
   73.48 @@ -171,36 +194,85 @@
   73.49    #endif
   73.50  };
   73.51  
   73.52 +inline bool JNIHandles::is_jweak(jobject handle) {
   73.53 +  STATIC_ASSERT(weak_tag_size == 1);
   73.54 +  STATIC_ASSERT(weak_tag_value == 1);
   73.55 +  return (reinterpret_cast<uintptr_t>(handle) & weak_tag_mask) != 0;
   73.56 +}
   73.57 +
   73.58 +inline oop& JNIHandles::jobject_ref(jobject handle) {
   73.59 +  assert(!is_jweak(handle), "precondition");
   73.60 +  return *reinterpret_cast<oop*>(handle);
   73.61 +}
   73.62 +
   73.63 +inline oop& JNIHandles::jweak_ref(jobject handle) {
   73.64 +  assert(is_jweak(handle), "precondition");
   73.65 +  char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
   73.66 +  return *reinterpret_cast<oop*>(ptr);
   73.67 +}
   73.68 +
   73.69 +// external_guard is true if called from resolve_external_guard.
   73.70 +// Treat deleted (and possibly zapped) as NULL for external_guard,
   73.71 +// else as (asserted) error.
   73.72 +template<bool external_guard>
   73.73 +inline oop JNIHandles::guard_value(oop value) {
   73.74 +  if (!external_guard) {
   73.75 +    assert(value != badJNIHandle, "Pointing to zapped jni handle area");
   73.76 +    assert(value != deleted_handle(), "Used a deleted global handle");
   73.77 +  } else if ((value == badJNIHandle) || (value == deleted_handle())) {
   73.78 +    value = NULL;
   73.79 +  }
   73.80 +  return value;
   73.81 +}
   73.82 +
   73.83 +// external_guard is true if called from resolve_external_guard.
   73.84 +template<bool external_guard>
   73.85 +inline oop JNIHandles::resolve_impl(jobject handle) {
   73.86 +  assert(handle != NULL, "precondition");
   73.87 +  oop result;
   73.88 +  if (is_jweak(handle)) {       // Unlikely
   73.89 +    result = resolve_jweak<external_guard>(handle);
   73.90 +  } else {
   73.91 +    result = jobject_ref(handle);
   73.92 +    // Construction of jobjects canonicalize a null value into a null
   73.93 +    // jobject, so for non-jweak the pointee should never be null.
   73.94 +    assert(external_guard || result != NULL,
   73.95 +           "Invalid value read from jni handle");
   73.96 +    result = guard_value<external_guard>(result);
   73.97 +  }
   73.98 +  return result;
   73.99 +}
  73.100  
  73.101  inline oop JNIHandles::resolve(jobject handle) {
  73.102 -  oop result = (handle == NULL ? (oop)NULL : *(oop*)handle);
  73.103 -  assert(result != NULL || (handle == NULL || !CheckJNICalls || is_weak_global_handle(handle)), "Invalid value read from jni handle");
  73.104 -  assert(result != badJNIHandle, "Pointing to zapped jni handle area");
  73.105 +  oop result = NULL;
  73.106 +  if (handle != NULL) {
  73.107 +    result = resolve_impl<false /* external_guard */ >(handle);
  73.108 +  }
  73.109    return result;
  73.110 -};
  73.111 +}
  73.112  
  73.113 -
  73.114 +// Resolve some erroneous cases to NULL, rather than treating them as
  73.115 +// possibly unchecked errors.  In particular, deleted handles are
  73.116 +// treated as NULL (though a deleted and later reallocated handle
  73.117 +// isn't detected).
  73.118  inline oop JNIHandles::resolve_external_guard(jobject handle) {
  73.119 -  if (handle == NULL) return NULL;
  73.120 -  oop result = *(oop*)handle;
  73.121 -  if (result == NULL || result == badJNIHandle) return NULL;
  73.122 +  oop result = NULL;
  73.123 +  if (handle != NULL) {
  73.124 +    result = resolve_impl<true /* external_guard */ >(handle);
  73.125 +  }
  73.126    return result;
  73.127 -};
  73.128 -
  73.129 +}
  73.130  
  73.131  inline oop JNIHandles::resolve_non_null(jobject handle) {
  73.132    assert(handle != NULL, "JNI handle should not be null");
  73.133 -  oop result = *(oop*)handle;
  73.134 -  assert(result != NULL, "Invalid value read from jni handle");
  73.135 -  assert(result != badJNIHandle, "Pointing to zapped jni handle area");
  73.136 -  // Don't let that private _deleted_handle object escape into the wild.
  73.137 -  assert(result != deleted_handle(), "Used a deleted global handle.");
  73.138 +  oop result = resolve_impl<false /* external_guard */ >(handle);
  73.139 +  assert(result != NULL, "NULL read from jni handle");
  73.140    return result;
  73.141 -};
  73.142 +}
  73.143  
  73.144  inline void JNIHandles::destroy_local(jobject handle) {
  73.145    if (handle != NULL) {
  73.146 -    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
  73.147 +    jobject_ref(handle) = deleted_handle();
  73.148    }
  73.149  }
  73.150  
    74.1 --- a/src/share/vm/runtime/thread.cpp	Thu Sep 05 18:40:52 2019 +0800
    74.2 +++ b/src/share/vm/runtime/thread.cpp	Thu Sep 05 18:52:27 2019 +0800
    74.3 @@ -1316,6 +1316,7 @@
    74.4  
    74.5    this->record_stack_base_and_size();
    74.6    this->initialize_thread_local_storage();
    74.7 +  this->set_native_thread_name(this->name());
    74.8    this->set_active_handles(JNIHandleBlock::allocate_block());
    74.9    while(!_should_terminate) {
   74.10      assert(watcher_thread() == Thread::current(),  "thread consistency check");
    75.1 --- a/src/share/vm/runtime/vmThread.cpp	Thu Sep 05 18:40:52 2019 +0800
    75.2 +++ b/src/share/vm/runtime/vmThread.cpp	Thu Sep 05 18:52:27 2019 +0800
    75.3 @@ -252,6 +252,7 @@
    75.4    assert(this == vm_thread(), "check");
    75.5  
    75.6    this->initialize_thread_local_storage();
    75.7 +  this->set_native_thread_name(this->name());
    75.8    this->record_stack_base_and_size();
    75.9    // Notify_lock wait checks on active_handles() to rewait in
   75.10    // case of spurious wakeup, it should wait on the last
    76.1 --- a/src/share/vm/services/heapDumper.cpp	Thu Sep 05 18:40:52 2019 +0800
    76.2 +++ b/src/share/vm/services/heapDumper.cpp	Thu Sep 05 18:52:27 2019 +0800
    76.3 @@ -941,8 +941,14 @@
    76.4  // its array classes
    76.5  void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) {
    76.6    Klass* klass = k;
    76.7 -  assert(klass->oop_is_instance(), "not an InstanceKlass");
    76.8 -  InstanceKlass* ik = (InstanceKlass*)klass;
    76.9 +  InstanceKlass* ik = InstanceKlass::cast(k);
   76.10 +
   76.11 +  // We can safepoint and do a heap dump at a point where we have a Klass,
   76.12 +  // but no java mirror class has been setup for it. So we need to check
   76.13 +  // that the class is at least loaded, to avoid crash from a null mirror.
   76.14 +  if (!ik->is_loaded()) {
   76.15 +    return;
   76.16 +  }
   76.17  
   76.18    writer->write_u1(HPROF_GC_CLASS_DUMP);
   76.19  
    77.1 --- a/src/share/vm/shark/sharkNativeWrapper.cpp	Thu Sep 05 18:40:52 2019 +0800
    77.2 +++ b/src/share/vm/shark/sharkNativeWrapper.cpp	Thu Sep 05 18:52:27 2019 +0800
    77.3 @@ -1,5 +1,5 @@
    77.4  /*
    77.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    77.6 + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
    77.7   * Copyright 2009, 2010 Red Hat, Inc.
    77.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    77.9   *
   77.10 @@ -50,6 +50,7 @@
   77.11  
   77.12    // Create and push our stack frame
   77.13    builder()->SetInsertPoint(CreateBlock());
   77.14 +#error Needs to be updated for tagged jweak; see JNIHandles.
   77.15    _stack = SharkStack::CreateBuildAndPushFrame(this, method);
   77.16    NOT_PRODUCT(method = NULL);
   77.17  
    78.1 --- a/src/share/vm/utilities/globalDefinitions.cpp	Thu Sep 05 18:40:52 2019 +0800
    78.2 +++ b/src/share/vm/utilities/globalDefinitions.cpp	Thu Sep 05 18:52:27 2019 +0800
    78.3 @@ -384,4 +384,67 @@
    78.4    }
    78.5  }
    78.6  
    78.7 +#define EXPECT_EQ(expected, actual) \
    78.8 +        assert(expected == actual, "Test failed");
    78.9 +#define EXPECT_STREQ(expected, actual) \
   78.10 +        assert(strcmp(expected, actual) == 0, "Test failed");
   78.11 +
   78.12 +void GlobalDefinitions::test_proper_unit() {
   78.13 +  EXPECT_EQ(0u,     byte_size_in_proper_unit(0u));
   78.14 +  EXPECT_STREQ("B", proper_unit_for_byte_size(0u));
   78.15 +
   78.16 +  EXPECT_EQ(1u,     byte_size_in_proper_unit(1u));
   78.17 +  EXPECT_STREQ("B", proper_unit_for_byte_size(1u));
   78.18 +
   78.19 +  EXPECT_EQ(1023u,  byte_size_in_proper_unit(K - 1));
   78.20 +  EXPECT_STREQ("B", proper_unit_for_byte_size(K - 1));
   78.21 +
   78.22 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(K));
   78.23 +  EXPECT_STREQ("B", proper_unit_for_byte_size(K));
   78.24 +
   78.25 +  EXPECT_EQ(1025u,  byte_size_in_proper_unit(K + 1));
   78.26 +  EXPECT_STREQ("B", proper_unit_for_byte_size(K + 1));
   78.27 +
   78.28 +  EXPECT_EQ(51200u, byte_size_in_proper_unit(50*K));
   78.29 +  EXPECT_STREQ("B", proper_unit_for_byte_size(50*K));
   78.30 +
   78.31 +  EXPECT_EQ(1023u,  byte_size_in_proper_unit(M - 1));
   78.32 +  EXPECT_STREQ("K", proper_unit_for_byte_size(M - 1));
   78.33 +
   78.34 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(M));
   78.35 +  EXPECT_STREQ("K", proper_unit_for_byte_size(M));
   78.36 +
   78.37 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(M + 1));
   78.38 +  EXPECT_STREQ("K", proper_unit_for_byte_size(M + 1));
   78.39 +
   78.40 +  EXPECT_EQ(1025u,  byte_size_in_proper_unit(M + K));
   78.41 +  EXPECT_STREQ("K", proper_unit_for_byte_size(M + K));
   78.42 +
   78.43 +  EXPECT_EQ(51200u, byte_size_in_proper_unit(50*M));
   78.44 +  EXPECT_STREQ("K", proper_unit_for_byte_size(50*M));
   78.45 +
   78.46 +#ifdef _LP64
   78.47 +  EXPECT_EQ(1023u,  byte_size_in_proper_unit(G - 1));
   78.48 +  EXPECT_STREQ("M", proper_unit_for_byte_size(G - 1));
   78.49 +
   78.50 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(G));
   78.51 +  EXPECT_STREQ("M", proper_unit_for_byte_size(G));
   78.52 +
   78.53 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(G + 1));
   78.54 +  EXPECT_STREQ("M", proper_unit_for_byte_size(G + 1));
   78.55 +
   78.56 +  EXPECT_EQ(1024u,  byte_size_in_proper_unit(G + K));
   78.57 +  EXPECT_STREQ("M", proper_unit_for_byte_size(G + K));
   78.58 +
   78.59 +  EXPECT_EQ(1025u,  byte_size_in_proper_unit(G + M));
   78.60 +  EXPECT_STREQ("M", proper_unit_for_byte_size(G + M));
   78.61 +
   78.62 +  EXPECT_EQ(51200u, byte_size_in_proper_unit(50*G));
   78.63 +  EXPECT_STREQ("M", proper_unit_for_byte_size(50*G));
   78.64 +#endif
   78.65 +}
   78.66 +
   78.67 +#undef EXPECT_EQ
   78.68 +#undef EXPECT_STREQ
   78.69 +
   78.70  #endif // PRODUCT
    79.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Thu Sep 05 18:40:52 2019 +0800
    79.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Thu Sep 05 18:52:27 2019 +0800
    79.3 @@ -217,15 +217,20 @@
    79.4  const jlong NANOSECS_PER_SEC      = CONST64(1000000000);
    79.5  const jint  NANOSECS_PER_MILLISEC = 1000000;
    79.6  
    79.7 +// Proper units routines try to maintain at least three significant digits.
    79.8 +// In worst case, it would print five significant digits with lower prefix.
    79.9 +// G is close to MAX_SIZE on 32-bit platforms, so its product can easily overflow,
   79.10 +// and therefore we need to be careful.
   79.11 +
   79.12  inline const char* proper_unit_for_byte_size(size_t s) {
   79.13  #ifdef _LP64
   79.14 -  if (s >= 10*G) {
   79.15 +  if (s >= 100*G) {
   79.16      return "G";
   79.17    }
   79.18  #endif
   79.19 -  if (s >= 10*M) {
   79.20 +  if (s >= 100*M) {
   79.21      return "M";
   79.22 -  } else if (s >= 10*K) {
   79.23 +  } else if (s >= 100*K) {
   79.24      return "K";
   79.25    } else {
   79.26      return "B";
   79.27 @@ -235,13 +240,13 @@
   79.28  template <class T>
   79.29  inline T byte_size_in_proper_unit(T s) {
   79.30  #ifdef _LP64
   79.31 -  if (s >= 10*G) {
   79.32 +  if (s >= 100*G) {
   79.33      return (T)(s/G);
   79.34    }
   79.35  #endif
   79.36 -  if (s >= 10*M) {
   79.37 +  if (s >= 100*M) {
   79.38      return (T)(s/M);
   79.39 -  } else if (s >= 10*K) {
   79.40 +  } else if (s >= 100*K) {
   79.41      return (T)(s/K);
   79.42    } else {
   79.43      return s;
   79.44 @@ -333,7 +338,7 @@
   79.45  // so far from the middle of the road that it is likely to be problematic in
   79.46  // many C++ compilers.
   79.47  //
   79.48 -#define CAST_TO_FN_PTR(func_type, value) ((func_type)(castable_address(value)))
   79.49 +#define CAST_TO_FN_PTR(func_type, value) (reinterpret_cast<func_type>(value))
   79.50  #define CAST_FROM_FN_PTR(new_type, func_ptr) ((new_type)((address_word)(func_ptr)))
   79.51  
   79.52  // Unsigned byte types for os and stream.hpp
   79.53 @@ -1495,6 +1500,7 @@
   79.54  class GlobalDefinitions {
   79.55  public:
   79.56    static void test_globals();
   79.57 +  static void test_proper_unit();
   79.58  };
   79.59  
   79.60  #endif // PRODUCT
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/test/compiler/8209951/TestCipherBlockChainingEncrypt.java	Thu Sep 05 18:52:27 2019 +0800
    80.3 @@ -0,0 +1,136 @@
    80.4 +/*
    80.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
    80.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    80.7 + *
    80.8 + * This code is free software; you can redistribute it and/or modify it
    80.9 + * under the terms of the GNU General Public License version 2 only, as
   80.10 + * published by the Free Software Foundation.
   80.11 + *
   80.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   80.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   80.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   80.15 + * version 2 for more details (a copy is included in the LICENSE file that
   80.16 + * accompanied this code).
   80.17 + *
   80.18 + * You should have received a copy of the GNU General Public License version
   80.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   80.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   80.21 + *
   80.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   80.23 + * or visit www.oracle.com if you need additional information or have any
   80.24 + * questions.
   80.25 + */
   80.26 +
   80.27 +/**
   80.28 + * @test
   80.29 + * @bug 8209951
   80.30 + * @summary SIGBUS in com.sun.crypto.provider.CipherBlockChaining
   80.31 + * @run main/othervm/timeout=300 -Xbatch
   80.32 + *      compiler.codegen.aes.TestCipherBlockChainingEncrypt
   80.33 + */
   80.34 +
   80.35 +package compiler.codegen.aes;
   80.36 +
   80.37 +import java.io.PrintStream;
   80.38 +import java.security.*;
   80.39 +import java.util.Random;
   80.40 +import java.lang.reflect.Method;
   80.41 +import javax.crypto.Cipher;
   80.42 +import javax.crypto.SecretKey;
   80.43 +import javax.crypto.SecretKeyFactory;
   80.44 +import javax.crypto.spec.PBEKeySpec;
   80.45 +
   80.46 +public class TestCipherBlockChainingEncrypt {
   80.47 +    private static String algorithm = "PBEWithHmacSHA1AndAES_256";
   80.48 +    private static final String PBEPASS = "Hush, it's supposed to be a secret!";
   80.49 +
   80.50 +    private static final int INPUT_LENGTH = 800;
   80.51 +    private static final int[] OFFSETS = {0};
   80.52 +    private static final int NUM_PAD_BYTES = 8;
   80.53 +    private static final int PBKDF2_ADD_PAD_BYTES = 8;
   80.54 +
   80.55 +    private static SecretKey key;
   80.56 +    private static Cipher ci;
   80.57 +
   80.58 +    public static void main(String[] args) throws Exception {
   80.59 +     for(int i=0; i<5_000; i++) {
   80.60 +        if (!(new TestCipherBlockChainingEncrypt().test(args))) {
   80.61 +            throw new RuntimeException("TestCipherBlockChainingEncrypt test failed");
   80.62 +       }
   80.63 +     }
   80.64 +   }
   80.65 +
   80.66 +    public boolean test(String[] args) throws Exception {
   80.67 +        boolean result = true;
   80.68 +
   80.69 +        Provider p = Security.getProvider("SunJCE");
   80.70 +        ci = Cipher.getInstance(algorithm, p);
   80.71 +        key = SecretKeyFactory.getInstance(algorithm, p).generateSecret(
   80.72 +                        new PBEKeySpec(PBEPASS.toCharArray()));
   80.73 +
   80.74 +        // generate input data
   80.75 +        byte[] inputText = new byte[INPUT_LENGTH + NUM_PAD_BYTES
   80.76 +                + PBKDF2_ADD_PAD_BYTES];
   80.77 +        new Random().nextBytes(inputText);
   80.78 +
   80.79 +        try {
   80.80 +            // Encrypt
   80.81 +            execute(Cipher.ENCRYPT_MODE,
   80.82 +                    inputText,
   80.83 +                    0,
   80.84 +                    INPUT_LENGTH);
   80.85 +
   80.86 +            // PBKDF2 required 16 byte padding
   80.87 +            int padLength = NUM_PAD_BYTES + PBKDF2_ADD_PAD_BYTES;
   80.88 +
   80.89 +            // Decrypt
   80.90 +            // Note: inputText is implicitly padded by the above encrypt
   80.91 +            // operation so decrypt operation can safely proceed
   80.92 +            execute(Cipher.DECRYPT_MODE,
   80.93 +                    inputText,
   80.94 +                    0,
   80.95 +                    INPUT_LENGTH + padLength);
   80.96 +
   80.97 +        } catch (Exception ex) {
   80.98 +            ex.printStackTrace(System.out);
   80.99 +            result = false;
  80.100 +        }
  80.101 +        return result;
  80.102 +    }
  80.103 +
  80.104 +    private void execute(int edMode, byte[] inputText, int offset, int len) {
  80.105 +        try {
  80.106 +            // init Cipher
  80.107 +            if (Cipher.ENCRYPT_MODE == edMode) {
  80.108 +                ci.init(Cipher.ENCRYPT_MODE, this.key);
  80.109 +            } else {
  80.110 +                ci.init(Cipher.DECRYPT_MODE, this.key, ci.getParameters());
  80.111 +            }
  80.112 +
  80.113 +            // First, generate the cipherText at an allocated buffer
  80.114 +            byte[] outputText = ci.doFinal(inputText, offset, len);
  80.115 +
  80.116 +            // Second, generate cipherText again at the same buffer of plainText
  80.117 +            int myoff = offset / 2;
  80.118 +            int off = ci.update(inputText, offset, len, inputText, myoff);
  80.119 +            ci.doFinal(inputText, myoff + off);
  80.120 +
  80.121 +            // Compare to see whether the two results are the same or not
  80.122 +            boolean e = equalsBlock(inputText, myoff, outputText, 0,
  80.123 +                    outputText.length);
  80.124 +        } catch (Exception ex) {
  80.125 +                System.out.println("Got unexpected exception for " + algorithm);
  80.126 +                ex.printStackTrace(System.out);
  80.127 +        }
  80.128 +    }
  80.129 +
  80.130 +    private boolean equalsBlock(byte[] b1, int off1,
  80.131 +            byte[] b2, int off2, int len) {
  80.132 +        for (int i = off1, j = off2, k = 0; k < len; i++, j++, k++) {
  80.133 +            if (b1[i] != b2[j]) {
  80.134 +                return false;
  80.135 +            }
  80.136 +        }
  80.137 +        return true;
  80.138 +    }
  80.139 +}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/test/compiler/c2/Test8202414.java	Thu Sep 05 18:52:27 2019 +0800
    81.3 @@ -0,0 +1,117 @@
    81.4 +/*
    81.5 + * Copyright (c) 2019, Huawei Technologies Co. Ltd. All rights reserved.
    81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    81.7 + *
    81.8 + * This code is free software; you can redistribute it and/or modify it
    81.9 + * under the terms of the GNU General Public License version 2 only, as
   81.10 + * published by the Free Software Foundation.
   81.11 + *
   81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   81.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   81.15 + * version 2 for more details (a copy is included in the LICENSE file that
   81.16 + * accompanied this code).
   81.17 + *
   81.18 + * You should have received a copy of the GNU General Public License version
   81.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   81.21 + *
   81.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   81.23 + * or visit www.oracle.com if you need additional information or have any
   81.24 + * questions.
   81.25 + */
   81.26 +
   81.27 +/**
   81.28 + * @test
   81.29 + * @bug 8202414
   81.30 + * @summary Unsafe write after primitive array creation may result in array length change
   81.31 + * @requires (os.arch != "sparc") & (os.arch != "sparcv9")
   81.32 + * @run main/othervm compiler.c2.Test8202414
   81.33 + */
   81.34 +
   81.35 +package compiler.c2;
   81.36 +
   81.37 +import sun.misc.Unsafe;
   81.38 +import java.lang.reflect.Field;
   81.39 +import java.security.AccessController;
   81.40 +import java.security.PrivilegedAction;
   81.41 +
   81.42 +public class Test8202414 {
   81.43 +
   81.44 +    public static void main(String[] args) {
   81.45 +        System.err.close();
   81.46 +        int count = 0;
   81.47 +        while (count++ < 120000) {
   81.48 +          test();
   81.49 +        }
   81.50 +    }
   81.51 +
   81.52 +    public static void test() {
   81.53 +        byte[] newBufb = serByte(397);
   81.54 +        short[] newBufs = serShort(397);
   81.55 +        int[] newBufi = serInt(397);
   81.56 +        long[] newBufl = serLong(397);
   81.57 +        if (newBufb.length != 397 || newBufs.length != 397
   81.58 +            || newBufi.length != 397 || newBufl.length != 397) {
   81.59 +            System.out.println("array length internal error");
   81.60 +            throw new RuntimeException("Test failed");
   81.61 +        }
   81.62 +
   81.63 +    }
   81.64 +
   81.65 +    public static byte[] serByte(int bufLen) {
   81.66 +        byte[] buf = new byte[bufLen];
   81.67 +        THE_UNSAFE.putByte(buf, BYTE_ARRAY_BASE_OFFSET + 1, (byte) buf.length);
   81.68 +        System.err.println("ref " + buf);
   81.69 +        return buf;
   81.70 +    }
   81.71 +
   81.72 +    public static short[] serShort(int bufLen) {
   81.73 +        short[] buf = new short[bufLen];
   81.74 +        THE_UNSAFE.putShort(buf, SHORT_ARRAY_BASE_OFFSET + 1, (short) buf.length);
   81.75 +        System.err.println("ref " + buf);
   81.76 +        return buf;
   81.77 +    }
   81.78 +
   81.79 +    public static int[] serInt(int bufLen) {
   81.80 +        int[] buf = new int[bufLen];
   81.81 +        THE_UNSAFE.putInt(buf, INT_ARRAY_BASE_OFFSET + 1, buf.length);
   81.82 +        System.err.println("ref " + buf);
   81.83 +        return buf;
   81.84 +    }
   81.85 +
   81.86 +    public static long[] serLong(int bufLen) {
   81.87 +        long[] buf = new long[bufLen];
   81.88 +        THE_UNSAFE.putLong(buf, LONG_ARRAY_BASE_OFFSET + 1, buf.length);
   81.89 +        System.err.println("ref " + buf);
   81.90 +        return buf;
   81.91 +    }
   81.92 +
   81.93 +    /* Unsafe fields and initialization
   81.94 +     */
   81.95 +    static final Unsafe THE_UNSAFE;
   81.96 +    static final long BYTE_ARRAY_BASE_OFFSET;
   81.97 +    static final long SHORT_ARRAY_BASE_OFFSET;
   81.98 +    static final long INT_ARRAY_BASE_OFFSET;
   81.99 +    static final long LONG_ARRAY_BASE_OFFSET;
  81.100 +    static {
  81.101 +        THE_UNSAFE = (Unsafe) AccessController.doPrivileged (
  81.102 +            new PrivilegedAction<Object>() {
  81.103 +                @Override
  81.104 +                public Object run() {
  81.105 +                    try {
  81.106 +                        Field f = Unsafe.class.getDeclaredField("theUnsafe");
  81.107 +                        f.setAccessible(true);
  81.108 +                        return f.get(null);
  81.109 +                    } catch (NoSuchFieldException | IllegalAccessException e) {
  81.110 +                        throw new Error();
  81.111 +                    }
  81.112 +                }
  81.113 +            }
  81.114 +        );
  81.115 +        BYTE_ARRAY_BASE_OFFSET = THE_UNSAFE.arrayBaseOffset(byte[].class);
  81.116 +        SHORT_ARRAY_BASE_OFFSET = THE_UNSAFE.arrayBaseOffset(short[].class);
  81.117 +        INT_ARRAY_BASE_OFFSET = THE_UNSAFE.arrayBaseOffset(int[].class);
  81.118 +        LONG_ARRAY_BASE_OFFSET = THE_UNSAFE.arrayBaseOffset(long[].class);
  81.119 +    }
  81.120 +}
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/test/compiler/tiered/ConstantGettersTransitionsTest.java	Thu Sep 05 18:52:27 2019 +0800
    82.3 @@ -0,0 +1,193 @@
    82.4 +/*
    82.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    82.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    82.7 + *
    82.8 + * This code is free software; you can redistribute it and/or modify it
    82.9 + * under the terms of the GNU General Public License version 2 only, as
   82.10 + * published by the Free Software Foundation.
   82.11 + *
   82.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   82.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   82.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   82.15 + * version 2 for more details (a copy is included in the LICENSE file that
   82.16 + * accompanied this code).
   82.17 + *
   82.18 + * You should have received a copy of the GNU General Public License version
   82.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   82.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   82.21 + *
   82.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   82.23 + * or visit www.oracle.com if you need additional information or have any
   82.24 + * questions.
   82.25 + */
   82.26 +
   82.27 +import java.lang.reflect.Executable;
   82.28 +import java.util.concurrent.Callable;
   82.29 +
   82.30 +/**
   82.31 + * @test ConstantGettersTransitionsTest
   82.32 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
   82.33 + * @build TransitionsTestExecutor ConstantGettersTransitionsTest
   82.34 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
   82.35 + * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
   82.36 + *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
   82.37 + *                   -XX:CompileCommand=compileonly,ConstantGettersTestCase$TrivialMethods::*
   82.38 + *                   TransitionsTestExecutor ConstantGettersTransitionsTest
   82.39 + * @summary Test the correctness of compilation level transitions for constant getters methods
   82.40 + */
   82.41 +public class ConstantGettersTransitionsTest extends LevelTransitionTest {
   82.42 +    public static void main(String[] args) {
   82.43 +        assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
   82.44 +
   82.45 +        // run test cases
   82.46 +        for (TestCase testCase : ConstantGettersTestCase.values()) {
   82.47 +            new ConstantGettersTransitionsTest(testCase).runTest();
   82.48 +        }
   82.49 +    }
   82.50 +
   82.51 +    @Override
   82.52 +    protected boolean isTrivial() {
   82.53 +        return true;
   82.54 +    }
   82.55 +
   82.56 +    private ConstantGettersTransitionsTest(TestCase testCase) {
   82.57 +        super(testCase);
   82.58 +    }
   82.59 +}
   82.60 +
   82.61 +enum ConstantGettersTestCase implements CompilerWhiteBoxTest.TestCase {
   82.62 +    ICONST_M1,
   82.63 +    ICONST_0,
   82.64 +    ICONST_1,
   82.65 +    ICONST_2,
   82.66 +    ICONST_3,
   82.67 +    ICONST_4,
   82.68 +    ICONST_5,
   82.69 +    LCONST_0,
   82.70 +    LCONST_1,
   82.71 +    FCONST_0,
   82.72 +    FCONST_1,
   82.73 +    FCONST_2,
   82.74 +    DCONST_0,
   82.75 +    DCONST_1,
   82.76 +    DCONST_W,
   82.77 +    BYTE,
   82.78 +    SHORT,
   82.79 +    CHAR;
   82.80 +
   82.81 +    private final Executable executable;
   82.82 +    private final Callable<Integer> callable;
   82.83 +
   82.84 +    @Override
   82.85 +    public Executable getExecutable() {
   82.86 +        return executable;
   82.87 +    }
   82.88 +
   82.89 +    @Override
   82.90 +    public Callable<Integer> getCallable() {
   82.91 +        return callable;
   82.92 +    }
   82.93 +
   82.94 +    @Override
   82.95 +    public boolean isOsr() {
   82.96 +        return false;
   82.97 +    }
   82.98 +
   82.99 +    private ConstantGettersTestCase() {
  82.100 +        String name = "make" + this.name();
  82.101 +        this.executable = LevelTransitionTest.Helper.getMethod(TrivialMethods.class, name);
  82.102 +        this.callable = LevelTransitionTest.Helper.getCallable(new TrivialMethods(), name);
  82.103 +    }
  82.104 +
  82.105 +    /**
  82.106 +     * Contains methods that load constants with certain types of bytecodes
  82.107 +     * See JVMS 2.11.2. Load and Store Instructions
  82.108 +     * Note that it doesn't have a method for ldc_w instruction
  82.109 +     */
  82.110 +    private static class TrivialMethods {
  82.111 +        public static int makeICONST_M1() {
  82.112 +            return -1;
  82.113 +        }
  82.114 +
  82.115 +        public static int makeICONST_0() {
  82.116 +            return 0;
  82.117 +        }
  82.118 +
  82.119 +        public static int makeICONST_1() {
  82.120 +            return 1;
  82.121 +        }
  82.122 +
  82.123 +        public static int makeICONST_2() {
  82.124 +            return 2;
  82.125 +        }
  82.126 +
  82.127 +        public static int makeICONST_3() {
  82.128 +            return 3;
  82.129 +        }
  82.130 +
  82.131 +        public static int makeICONST_4() {
  82.132 +            return 4;
  82.133 +        }
  82.134 +
  82.135 +        public static int makeICONST_5() {
  82.136 +            return 5;
  82.137 +        }
  82.138 +
  82.139 +        public static long makeLCONST_0() {
  82.140 +            return 0L;
  82.141 +        }
  82.142 +
  82.143 +        public static long makeLCONST_1() {
  82.144 +            return 1L;
  82.145 +        }
  82.146 +
  82.147 +        public static float makeFCONST_0() {
  82.148 +            return 0F;
  82.149 +        }
  82.150 +
  82.151 +        public static float makeFCONST_1() {
  82.152 +            return 1F;
  82.153 +        }
  82.154 +
  82.155 +        public static float makeFCONST_2() {
  82.156 +            return 2F;
  82.157 +        }
  82.158 +
  82.159 +        public static double makeDCONST_0() {
  82.160 +            return 0D;
  82.161 +        }
  82.162 +
  82.163 +        public static double makeDCONST_1() {
  82.164 +            return 1D;
  82.165 +        }
  82.166 +
  82.167 +        public static double makeDCONST_W() {
  82.168 +            // ldc2_w
  82.169 +            return Double.MAX_VALUE;
  82.170 +        }
  82.171 +
  82.172 +        public static Object makeOBJECT() {
  82.173 +            // aconst_null
  82.174 +            return null;
  82.175 +        }
  82.176 +
  82.177 +        public static byte makeBYTE() {
  82.178 +            // bipush
  82.179 +            return (byte) 0x7F;
  82.180 +        }
  82.181 +
  82.182 +        public static short makeSHORT() {
  82.183 +            // sipush
  82.184 +            return (short) 0x7FFF;
  82.185 +        }
  82.186 +
  82.187 +        public static char makeCHAR() {
  82.188 +            // ldc
  82.189 +            return (char) 0xFFFF;
  82.190 +        }
  82.191 +
  82.192 +        public static boolean makeBOOLEAN() {
  82.193 +            return true;
  82.194 +        }
  82.195 +    }
  82.196 +}
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/test/compiler/tiered/Level2RecompilationTest.java	Thu Sep 05 18:52:27 2019 +0800
    83.3 @@ -0,0 +1,92 @@
    83.4 +/*
    83.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
    83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    83.7 + *
    83.8 + * This code is free software; you can redistribute it and/or modify it
    83.9 + * under the terms of the GNU General Public License version 2 only, as
   83.10 + * published by the Free Software Foundation.
   83.11 + *
   83.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   83.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   83.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   83.15 + * version 2 for more details (a copy is included in the LICENSE file that
   83.16 + * accompanied this code).
   83.17 + *
   83.18 + * You should have received a copy of the GNU General Public License version
   83.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   83.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   83.21 + *
   83.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   83.23 + * or visit www.oracle.com if you need additional information or have any
   83.24 + * questions.
   83.25 + */
   83.26 +
   83.27 +/**
   83.28 + * @test Level2RecompilationTest
   83.29 + * @summary Test downgrading mechanism from level 3 to level 2 for those profiled methods.
   83.30 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
   83.31 + * @build Level2RecompilationTest
   83.32 + * @run main ClassFileInstaller sun.hotspot.WhiteBox
   83.33 + * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation
   83.34 + *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay
   83.35 + *                   -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
   83.36 + *                   -XX:CompileCommand=print,SimpleTestCase$Helper::*
   83.37 + *                   Level2RecompilationTest
   83.38 + */
   83.39 +public class Level2RecompilationTest extends CompLevelsTest {
   83.40 +    public static void main(String[] args) throws Throwable {
   83.41 +        if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
   83.42 +            throw new RuntimeException("Test isn't applicable for non-tiered mode");
   83.43 +        }
   83.44 +        String[] testcases = {"METHOD_TEST", "OSR_STATIC_TEST"};
   83.45 +        CompilerWhiteBoxTest.main(Level2RecompilationTest::new, testcases);
   83.46 +    }
   83.47 +
   83.48 +    protected Level2RecompilationTest(TestCase testCase) {
   83.49 +        super(testCase);
   83.50 +        // to prevent inlining of #method
   83.51 +        WHITE_BOX.testSetDontInlineMethod(method, true);
   83.52 +    }
   83.53 +
   83.54 +    @Override
   83.55 +    protected void test() throws Exception {
   83.56 +        if (skipXcompOSR()) {
   83.57 +          return;
   83.58 +        }
   83.59 +
   83.60 +        checkNotCompiled();
   83.61 +        int bci = WHITE_BOX.getMethodEntryBci(method);
   83.62 +        WHITE_BOX.markMethodProfiled(method);
   83.63 +        if (testCase.isOsr()) {
   83.64 +            // for OSR compilation, it must be the begin of a BB.
   83.65 +            // c1_GraphBulider.cpp:153  assert(method()->bci_block_start().at(cur_bci), ...
   83.66 +            bci = 0;
   83.67 +        }
   83.68 +
   83.69 +        WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci);
   83.70 +        checkCompiled();
   83.71 +        checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel());
   83.72 +
   83.73 +        for (int i=0; i<100; ++i) {
   83.74 +            WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci);
   83.75 +            waitBackgroundCompilation();
   83.76 +            checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel());
   83.77 +        }
   83.78 +    }
   83.79 +
   83.80 +    @Override
   83.81 +    protected void checkLevel(int expected, int actual) {
   83.82 +        if (expected == COMP_LEVEL_FULL_PROFILE
   83.83 +                && actual == COMP_LEVEL_LIMITED_PROFILE) {
   83.84 +            // for simple method full_profile may be replaced by limited_profile
   83.85 +            if (IS_VERBOSE) {
   83.86 +                System.out.printf("Level check: full profiling was replaced "
   83.87 +                        + "by limited profiling. Expected: %d, actual:%d\n",
   83.88 +                        expected, actual);
   83.89 +            }
   83.90 +            return;
   83.91 +        }
   83.92 +        super.checkLevel(expected, actual);
   83.93 +    }
   83.94 +}
   83.95 +
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/test/compiler/tiered/LevelTransitionTest.java	Thu Sep 05 18:52:27 2019 +0800
    84.3 @@ -0,0 +1,247 @@
    84.4 +/*
    84.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    84.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    84.7 + *
    84.8 + * This code is free software; you can redistribute it and/or modify it
    84.9 + * under the terms of the GNU General Public License version 2 only, as
   84.10 + * published by the Free Software Foundation.
   84.11 + *
   84.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   84.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   84.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   84.15 + * version 2 for more details (a copy is included in the LICENSE file that
   84.16 + * accompanied this code).
   84.17 + *
   84.18 + * You should have received a copy of the GNU General Public License version
   84.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   84.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   84.21 + *
   84.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   84.23 + * or visit www.oracle.com if you need additional information or have any
   84.24 + * questions.
   84.25 + */
   84.26 +
   84.27 +import java.lang.reflect.Executable;
   84.28 +import java.lang.reflect.Method;
   84.29 +import java.util.Objects;
   84.30 +import java.util.concurrent.Callable;
   84.31 +
   84.32 +/**
   84.33 + * @test LevelTransitionTest
   84.34 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
   84.35 + * @build TransitionsTestExecutor LevelTransitionTest
   84.36 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
   84.37 + * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
   84.38 + *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
   84.39 + *                   -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
   84.40 + *                   -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::*
   84.41 + *                   TransitionsTestExecutor LevelTransitionTest
   84.42 + * @summary Test the correctness of compilation level transitions for different methods
   84.43 + */
   84.44 +public class LevelTransitionTest extends TieredLevelsTest {
   84.45 +    /** Shows if method was profiled by being executed on levels 2 or 3 */
   84.46 +    protected boolean isMethodProfiled;
   84.47 +    private int transitionCount;
   84.48 +
   84.49 +    public static void main(String[] args) throws Throwable {
   84.50 +        assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
   84.51 +
   84.52 +        CompilerWhiteBoxTest.main(LevelTransitionTest::new, args);
   84.53 +        // run extended test cases
   84.54 +        for (TestCase testCase : ExtendedTestCase.values()) {
   84.55 +            new LevelTransitionTest(testCase).runTest();
   84.56 +        }
   84.57 +    }
   84.58 +
   84.59 +    protected LevelTransitionTest(TestCase testCase) {
   84.60 +        super(testCase);
   84.61 +        isMethodProfiled = testCase.isOsr(); // OSR methods were already profiled by warmup
   84.62 +        transitionCount = 0;
   84.63 +    }
   84.64 +
   84.65 +    @Override
   84.66 +    protected void test() throws Exception {
   84.67 +        checkTransitions();
   84.68 +        deoptimize();
   84.69 +        printInfo();
   84.70 +        if (testCase.isOsr()) {
   84.71 +            // deoptimization makes the following transitions be unstable
   84.72 +            // methods go to level 3 before 4 because of uncommon_trap and reprofile
   84.73 +            return;
   84.74 +        }
   84.75 +        checkTransitions();
   84.76 +    }
   84.77 +
   84.78 +    /**
   84.79 +     * Makes and verifies transitions between compilation levels
   84.80 +     */
   84.81 +    protected void checkTransitions() {
   84.82 +        checkNotCompiled();
   84.83 +        boolean finish = false;
   84.84 +        while (!finish) {
   84.85 +            System.out.printf("Level transition #%d%n", ++transitionCount);
   84.86 +            int newLevel;
   84.87 +            int current = getCompLevel();
   84.88 +            int expected = getNextLevel(current);
   84.89 +            if (current == expected) {
   84.90 +                // if we are on expected level, just execute it more
   84.91 +                // to ensure that the level won't change
   84.92 +                System.out.printf("Method %s is already on expected level %d%n", method, expected);
   84.93 +                compile();
   84.94 +                newLevel = getCompLevel();
   84.95 +                finish = true;
   84.96 +            } else {
   84.97 +                newLevel = changeCompLevel();
   84.98 +                finish = false;
   84.99 +            }
  84.100 +            System.out.printf("Method %s is compiled on level %d. Expected level is %d%n", method, newLevel, expected);
  84.101 +            checkLevel(expected, newLevel);
  84.102 +            printInfo();
  84.103 +        };
  84.104 +    }
  84.105 +
  84.106 +    /**
  84.107 +     * Gets next expected level for the test case on each transition.
  84.108 +     *
  84.109 +     * @param currentLevel a level the test case is compiled on
  84.110 +     * @return expected compilation level
  84.111 +     */
  84.112 +    protected int getNextLevel(int currentLevel) {
  84.113 +        int nextLevel = currentLevel;
  84.114 +        switch (currentLevel) {
  84.115 +            case CompilerWhiteBoxTest.COMP_LEVEL_NONE:
  84.116 +                nextLevel = isMethodProfiled ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
  84.117 +                        : CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE;
  84.118 +                break;
  84.119 +            case CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE:
  84.120 +            case CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE:
  84.121 +                nextLevel = CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION;
  84.122 +                isMethodProfiled = true;
  84.123 +                break;
  84.124 +        }
  84.125 +        nextLevel = isTrivial() ? CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE : nextLevel;
  84.126 +        return Math.min(nextLevel, CompilerWhiteBoxTest.TIERED_STOP_AT_LEVEL);
  84.127 +    }
  84.128 +
  84.129 +    /**
  84.130 +     * Determines if tested method should be handled as trivial
  84.131 +     *
  84.132 +     * @return {@code true} for trivial methods, {@code false} otherwise
  84.133 +     */
  84.134 +    protected boolean isTrivial() {
  84.135 +        return testCase == ExtendedTestCase.ACCESSOR_TEST
  84.136 +                || testCase == SimpleTestCase.METHOD_TEST
  84.137 +                || testCase == SimpleTestCase.STATIC_TEST
  84.138 +                || (testCase == ExtendedTestCase.TRIVIAL_CODE_TEST && isMethodProfiled);
  84.139 +    }
  84.140 +
  84.141 +    /**
  84.142 +     * Invokes {@linkplain #method} until its compilation level is changed.
  84.143 +     * Note that if the level won't change, it will be an endless loop
  84.144 +     *
  84.145 +     * @return compilation level the {@linkplain #method} was compiled on
  84.146 +     */
  84.147 +    protected int changeCompLevel() {
  84.148 +        int currentLevel = getCompLevel();
  84.149 +        int newLevel = currentLevel;
  84.150 +        int result = 0;
  84.151 +        while (currentLevel == newLevel) {
  84.152 +            result = compile(1);
  84.153 +            if (WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
  84.154 +                newLevel = getCompLevel();
  84.155 +            }
  84.156 +        }
  84.157 +        return newLevel;
  84.158 +    }
  84.159 +
  84.160 +    protected static class Helper {
  84.161 +        /**
  84.162 +         * Gets method from a specified class using its name
  84.163 +         *
  84.164 +         * @param aClass type method belongs to
  84.165 +         * @param name   the name of the method
  84.166 +         * @return {@link Method} that represents corresponding class method
  84.167 +         */
  84.168 +        public static Method getMethod(Class<?> aClass, String name) {
  84.169 +            Method method;
  84.170 +            try {
  84.171 +                method = aClass.getDeclaredMethod(name);
  84.172 +            } catch (NoSuchMethodException e) {
  84.173 +                throw new Error("TESTBUG: Unable to get method " + name, e);
  84.174 +            }
  84.175 +            return method;
  84.176 +        }
  84.177 +
  84.178 +        /**
  84.179 +         * Gets {@link Callable} that invokes given method from the given object
  84.180 +         *
  84.181 +         * @param object the object the specified method is invoked from
  84.182 +         * @param name   the name of the method
  84.183 +         */
  84.184 +        public static Callable<Integer> getCallable(Object object, String name) {
  84.185 +            Method method = getMethod(object.getClass(), name);
  84.186 +            return () -> {
  84.187 +                try {
  84.188 +                    return Objects.hashCode(method.invoke(object));
  84.189 +                } catch (ReflectiveOperationException e) {
  84.190 +                    throw new Error("TESTBUG: Invocation failure", e);
  84.191 +                }
  84.192 +            };
  84.193 +        }
  84.194 +    }
  84.195 +}
  84.196 +
  84.197 +enum ExtendedTestCase implements CompilerWhiteBoxTest.TestCase {
  84.198 +    ACCESSOR_TEST("accessor"),
  84.199 +    NONTRIVIAL_METHOD_TEST("nonTrivialMethod"),
  84.200 +    TRIVIAL_CODE_TEST("trivialCode");
  84.201 +
  84.202 +    private final Executable executable;
  84.203 +    private final Callable<Integer> callable;
  84.204 +
  84.205 +    @Override
  84.206 +    public Executable getExecutable() {
  84.207 +        return executable;
  84.208 +    }
  84.209 +
  84.210 +    @Override
  84.211 +    public Callable<Integer> getCallable() {
  84.212 +        return callable;
  84.213 +    }
  84.214 +
  84.215 +    @Override
  84.216 +    public boolean isOsr() {
  84.217 +        return false;
  84.218 +    }
  84.219 +
  84.220 +    private ExtendedTestCase(String methodName) {
  84.221 +        this.executable = LevelTransitionTest.Helper.getMethod(CompileMethodHolder.class, methodName);
  84.222 +        this.callable = LevelTransitionTest.Helper.getCallable(new CompileMethodHolder(), methodName);
  84.223 +    }
  84.224 +
  84.225 +    private static class CompileMethodHolder {
  84.226 +        private final int iter = 10;
  84.227 +        private int field = 42;
  84.228 +
  84.229 +        /** Non-trivial method for threshold policy: contains loops */
  84.230 +        public int nonTrivialMethod() {
  84.231 +            int acc = 0;
  84.232 +            for (int i = 0; i < iter; i++) {
  84.233 +                acc += i;
  84.234 +            }
  84.235 +            return acc;
  84.236 +        }
  84.237 +
  84.238 +        /** Field accessor method */
  84.239 +        public int accessor() {
  84.240 +            return field;
  84.241 +        }
  84.242 +
  84.243 +        /** Method considered as trivial by amount of code */
  84.244 +        public int trivialCode() {
  84.245 +            int var = 0xBAAD_C0DE;
  84.246 +            var *= field;
  84.247 +            return var;
  84.248 +        }
  84.249 +    }
  84.250 +}
    85.1 --- a/test/compiler/tiered/NonTieredLevelsTest.java	Thu Sep 05 18:40:52 2019 +0800
    85.2 +++ b/test/compiler/tiered/NonTieredLevelsTest.java	Thu Sep 05 18:52:27 2019 +0800
    85.3 @@ -54,9 +54,7 @@
    85.4  
    85.5      }
    85.6      public static void main(String[] args) throws Exception {
    85.7 -        if (TIERED_COMPILATION) {
    85.8 -            System.err.println("Test isn't applicable w/ enabled "
    85.9 -                    + "TieredCompilation. Skip test.");
   85.10 +        if (CompilerWhiteBoxTest.skipOnTieredCompilation(true)) {
   85.11              return;
   85.12          }
   85.13          CompilerWhiteBoxTest.main(NonTieredLevelsTest::new, args);
    86.1 --- a/test/compiler/tiered/TieredLevelsTest.java	Thu Sep 05 18:40:52 2019 +0800
    86.2 +++ b/test/compiler/tiered/TieredLevelsTest.java	Thu Sep 05 18:52:27 2019 +0800
    86.3 @@ -34,16 +34,14 @@
    86.4   * @author igor.ignatyev@oracle.com
    86.5   */
    86.6  public class TieredLevelsTest extends CompLevelsTest {
    86.7 -    public static void main(String[] args) throws Exception {
    86.8 -        if (!TIERED_COMPILATION) {
    86.9 -            System.err.println("Test isn't applicable w/ disabled "
   86.10 -                    + "TieredCompilation. Skip test.");
   86.11 +    public static void main(String[] args) throws Exception, Throwable {
   86.12 +        if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
   86.13              return;
   86.14          }
   86.15          CompilerWhiteBoxTest.main(TieredLevelsTest::new, args);
   86.16      }
   86.17  
   86.18 -    private TieredLevelsTest(TestCase testCase) {
   86.19 +    protected TieredLevelsTest(TestCase testCase) {
   86.20          super(testCase);
   86.21          // to prevent inlining of #method
   86.22          WHITE_BOX.testSetDontInlineMethod(method, true);
   86.23 @@ -76,14 +74,18 @@
   86.24          }
   86.25      }
   86.26  
   86.27 -
   86.28      @Override
   86.29      protected void checkLevel(int expected, int actual) {
   86.30          if (expected == COMP_LEVEL_FULL_PROFILE
   86.31                  && actual == COMP_LEVEL_LIMITED_PROFILE) {
   86.32              // for simple method full_profile may be replaced by limited_profile
   86.33 +            if (IS_VERBOSE) {
   86.34 +                System.out.printf("Level check: full profiling was replaced "
   86.35 +                        + "by limited profiling. Expected: %d, actual:%d",
   86.36 +                        expected, actual);
   86.37 +            }
   86.38              return;
   86.39          }
   86.40          super.checkLevel(expected, actual);
   86.41 -   }
   86.42 +    }
   86.43  }
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/test/compiler/tiered/TransitionsTestExecutor.java	Thu Sep 05 18:52:27 2019 +0800
    87.3 @@ -0,0 +1,66 @@
    87.4 +/*
    87.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.7 + *
    87.8 + * This code is free software; you can redistribute it and/or modify it
    87.9 + * under the terms of the GNU General Public License version 2 only, as
   87.10 + * published by the Free Software Foundation.
   87.11 + *
   87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   87.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   87.15 + * version 2 for more details (a copy is included in the LICENSE file that
   87.16 + * accompanied this code).
   87.17 + *
   87.18 + * You should have received a copy of the GNU General Public License version
   87.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   87.21 + *
   87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   87.23 + * or visit www.oracle.com if you need additional information or have any
   87.24 + * questions.
   87.25 + */
   87.26 +
   87.27 +import com.oracle.java.testlibrary.OutputAnalyzer;
   87.28 +import com.oracle.java.testlibrary.ProcessTools;
   87.29 +
   87.30 +import java.lang.management.ManagementFactory;
   87.31 +import java.lang.management.RuntimeMXBean;
   87.32 +import java.util.ArrayList;
   87.33 +import java.util.Collections;
   87.34 +import java.util.List;
   87.35 +
   87.36 +/**
   87.37 + * Executes given test in a separate VM with enabled Tiered Compilation for
   87.38 + * CompilationPolicyChoice 2 and 3
   87.39 + */
   87.40 +public class TransitionsTestExecutor {
   87.41 +    public static void main(String[] args) throws Throwable {
   87.42 +        if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
   87.43 +            return;
   87.44 +        }
   87.45 +        if (args.length != 1) {
   87.46 +            throw new Error("TESTBUG: Test name should be specified");
   87.47 +        }
   87.48 +        executeTestFor(2, args[0]);
   87.49 +        executeTestFor(3, args[0]);
   87.50 +    }
   87.51 +
   87.52 +    private static void executeTestFor(int compilationPolicy, String testName) throws Throwable {
   87.53 +        String policy = "-XX:CompilationPolicyChoice=" + compilationPolicy;
   87.54 +
   87.55 +        // Get runtime arguments including VM options given to this executor
   87.56 +        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
   87.57 +        List<String> vmArgs = runtime.getInputArguments();
   87.58 +
   87.59 +        // Construct execution command with compilation policy choice and test name
   87.60 +        List<String> args = new ArrayList<>(vmArgs);
   87.61 +        Collections.addAll(args, policy, testName);
   87.62 +
   87.63 +        OutputAnalyzer out = ProcessTools.executeTestJvm(args.toArray(new String[args.size()]));
   87.64 +        int exitCode = out.getExitValue();
   87.65 +        if (exitCode != 0) {
   87.66 +            throw new Error("Test execution failed with exit code " + exitCode);
   87.67 +        }
   87.68 +    }
   87.69 +}
    88.1 --- a/test/compiler/whitebox/CompilerWhiteBoxTest.java	Thu Sep 05 18:40:52 2019 +0800
    88.2 +++ b/test/compiler/whitebox/CompilerWhiteBoxTest.java	Thu Sep 05 18:52:27 2019 +0800
    88.3 @@ -1,5 +1,5 @@
    88.4  /*
    88.5 - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
    88.6 + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
    88.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.8   *
    88.9   * This code is free software; you can redistribute it and/or modify it
   88.10 @@ -41,19 +41,19 @@
   88.11   */
   88.12  public abstract class CompilerWhiteBoxTest {
   88.13      /** {@code CompLevel::CompLevel_none} -- Interpreter */
   88.14 -    protected static int COMP_LEVEL_NONE = 0;
   88.15 +    protected static final int COMP_LEVEL_NONE = 0;
   88.16      /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
   88.17 -    protected static int COMP_LEVEL_ANY = -1;
   88.18 +    protected static final int COMP_LEVEL_ANY = -1;
   88.19      /** {@code CompLevel::CompLevel_simple} -- C1 */
   88.20 -    protected static int COMP_LEVEL_SIMPLE = 1;
   88.21 +    protected static final int COMP_LEVEL_SIMPLE = 1;
   88.22      /** {@code CompLevel::CompLevel_limited_profile} -- C1, invocation &amp; backedge counters */
   88.23 -    protected static int COMP_LEVEL_LIMITED_PROFILE = 2;
   88.24 +    protected static final int COMP_LEVEL_LIMITED_PROFILE = 2;
   88.25      /** {@code CompLevel::CompLevel_full_profile} -- C1, invocation &amp; backedge counters + mdo */
   88.26 -    protected static int COMP_LEVEL_FULL_PROFILE = 3;
   88.27 +    protected static final int COMP_LEVEL_FULL_PROFILE = 3;
   88.28      /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
   88.29 -    protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
   88.30 +    protected static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
   88.31      /** Maximal value for CompLevel */
   88.32 -    protected static int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
   88.33 +    protected static final int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
   88.34  
   88.35      /** Instance of WhiteBox */
   88.36      protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
   88.37 @@ -328,11 +328,11 @@
   88.38              return;
   88.39          }
   88.40          final Object obj = new Object();
   88.41 -        for (int i = 0; i < 10
   88.42 +        for (int i = 0; i < 100
   88.43                  && WHITE_BOX.isMethodQueuedForCompilation(executable); ++i) {
   88.44              synchronized (obj) {
   88.45                  try {
   88.46 -                    obj.wait(1000);
   88.47 +                    obj.wait(100);
   88.48                  } catch (InterruptedException e) {
   88.49                      Thread.currentThread().interrupt();
   88.50                  }
   88.51 @@ -347,14 +347,22 @@
   88.52          System.out.printf("%n%s:%n", method);
   88.53          System.out.printf("\tcompilable:\t%b%n",
   88.54                  WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false));
   88.55 -        System.out.printf("\tcompiled:\t%b%n",
   88.56 -                WHITE_BOX.isMethodCompiled(method, false));
   88.57 +        boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false);
   88.58 +        System.out.printf("\tcompiled:\t%b%n", isCompiled);
   88.59 +        if (isCompiled) {
   88.60 +            System.out.printf("\tcompile_id:\t%d%n",
   88.61 +                    NMethod.get(method, false).compile_id);
   88.62 +        }
   88.63          System.out.printf("\tcomp_level:\t%d%n",
   88.64                  WHITE_BOX.getMethodCompilationLevel(method, false));
   88.65          System.out.printf("\tosr_compilable:\t%b%n",
   88.66                  WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true));
   88.67 -        System.out.printf("\tosr_compiled:\t%b%n",
   88.68 -                WHITE_BOX.isMethodCompiled(method, true));
   88.69 +        isCompiled = WHITE_BOX.isMethodCompiled(method, true);
   88.70 +        System.out.printf("\tosr_compiled:\t%b%n", isCompiled);
   88.71 +        if (isCompiled) {
   88.72 +            System.out.printf("\tosr_compile_id:\t%d%n",
   88.73 +                    NMethod.get(method, true).compile_id);
   88.74 +        }
   88.75          System.out.printf("\tosr_comp_level:\t%d%n",
   88.76                  WHITE_BOX.getMethodCompilationLevel(method, true));
   88.77          System.out.printf("\tin_queue:\t%b%n",
   88.78 @@ -437,6 +445,22 @@
   88.79          }
   88.80          return result;
   88.81      }
   88.82 +
   88.83 +    /**
   88.84 +     * Skip the test for the specified value of Tiered Compilation
   88.85 +     * @param value of TieredCompilation the test should not run with
   88.86 +     * @return {@code true} if the test should be skipped,
   88.87 +     *         {@code false} otherwise
   88.88 +     */
   88.89 +    protected static boolean skipOnTieredCompilation(boolean value) {
   88.90 +        if (value == CompilerWhiteBoxTest.TIERED_COMPILATION) {
   88.91 +            System.err.println("Test isn't applicable w/ "
   88.92 +                    + (value ? "enabled" : "disabled")
   88.93 +                    + "TieredCompilation. Skip test.");
   88.94 +            return true;
   88.95 +        }
   88.96 +        return false;
   88.97 +    }
   88.98  }
   88.99  
  88.100  enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
    89.1 --- a/test/runtime/NMT/NMTWithCDS.java	Thu Sep 05 18:40:52 2019 +0800
    89.2 +++ b/test/runtime/NMT/NMTWithCDS.java	Thu Sep 05 18:52:27 2019 +0800
    89.3 @@ -34,14 +34,15 @@
    89.4  
    89.5    public static void main(String[] args) throws Exception {
    89.6      ProcessBuilder pb;
    89.7 -    pb = ProcessTools.createJavaProcessBuilder("-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
    89.8 +    pb = ProcessTools.createJavaProcessBuilder(
    89.9 +        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
   89.10      OutputAnalyzer output = new OutputAnalyzer(pb.start());
   89.11      try {
   89.12        output.shouldContain("Loading classes to share");
   89.13        output.shouldHaveExitValue(0);
   89.14  
   89.15        pb = ProcessTools.createJavaProcessBuilder(
   89.16 -        "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version");
   89.17 +        "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version");
   89.18        output = new OutputAnalyzer(pb.start());
   89.19        output.shouldContain("sharing");
   89.20        output.shouldHaveExitValue(0);
    90.1 --- a/test/runtime/containers/docker/TestCPUAwareness.java	Thu Sep 05 18:40:52 2019 +0800
    90.2 +++ b/test/runtime/containers/docker/TestCPUAwareness.java	Thu Sep 05 18:52:27 2019 +0800
    90.3 @@ -1,5 +1,5 @@
    90.4  /*
    90.5 - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
    90.6 + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
    90.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.8   *
    90.9   * This code is free software; you can redistribute it and/or modify it
   90.10 @@ -125,7 +125,8 @@
   90.11      private static void testCpus(int valueToSet, int expectedTraceValue) throws Exception {
   90.12          Common.logNewTestCase("test cpus: " + valueToSet);
   90.13          DockerRunOptions opts = Common.newOpts(imageName)
   90.14 -            .addDockerOpts("--cpus", "" + valueToSet);
   90.15 +            .addDockerOpts("--cpu-period=" + 10000)
   90.16 +            .addDockerOpts("--cpu-quota=" + valueToSet * 10000);
   90.17          Common.run(opts)
   90.18              .shouldMatch("active_processor_count.*" + expectedTraceValue);
   90.19      }
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/runtime/jni/CallWithJNIWeak/CallWithJNIWeak.c	Thu Sep 05 18:52:27 2019 +0800
    91.3 @@ -0,0 +1,142 @@
    91.4 +/*
    91.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    91.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 + *
    91.8 + * This code is free software; you can redistribute it and/or modify it
    91.9 + * under the terms of the GNU General Public License version 2 only, as
   91.10 + * published by the Free Software Foundation.
   91.11 + *
   91.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   91.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.15 + * version 2 for more details (a copy is included in the LICENSE file that
   91.16 + * accompanied this code).
   91.17 + *
   91.18 + * You should have received a copy of the GNU General Public License version
   91.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   91.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.21 + *
   91.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   91.23 + * or visit www.oracle.com if you need additional information or have any
   91.24 + * questions.
   91.25 + */
   91.26 +
   91.27 +#include <jni.h>
   91.28 +
   91.29 +/*
   91.30 + * Class:     CallWithJNIWeak
   91.31 + * Method:    testJNIFieldAccessors
   91.32 + * Signature: (LCallWithJNIWeak;)V
   91.33 + */
   91.34 +JNIEXPORT void JNICALL
   91.35 +Java_CallWithJNIWeak_testJNIFieldAccessors(JNIEnv *env, jclass clazz, jobject this) {
   91.36 +  // Make sure that we have a weak reference to the receiver
   91.37 +
   91.38 +  jweak self = (*env)->NewWeakGlobalRef(env, this);
   91.39 +
   91.40 +  jclass this_class = (*env)->GetObjectClass(env, self);
   91.41 +
   91.42 +  jclass exception = (*env)->FindClass(env, "java/lang/RuntimeException");
   91.43 +
   91.44 +  jfieldID id_i = (*env)->GetFieldID(env, this_class, "i", "I");
   91.45 +  jfieldID id_j = (*env)->GetFieldID(env, this_class, "j", "J");
   91.46 +  jfieldID id_z = (*env)->GetFieldID(env, this_class, "z", "Z");
   91.47 +  jfieldID id_c = (*env)->GetFieldID(env, this_class, "c", "C");
   91.48 +  jfieldID id_s = (*env)->GetFieldID(env, this_class, "s", "S");
   91.49 +  jfieldID id_f = (*env)->GetFieldID(env, this_class, "f", "F");
   91.50 +  jfieldID id_d = (*env)->GetFieldID(env, this_class, "d", "D");
   91.51 +  jfieldID id_l = (*env)->GetFieldID(env, this_class, "l", "Ljava/lang/Object;");
   91.52 +  jvalue v;
   91.53 +
   91.54 +#define CHECK(variable, expected)                                   \
   91.55 +  do {                                                              \
   91.56 +    if ((variable) != (expected)) {                                 \
   91.57 +      (*env)->ThrowNew(env, exception,  #variable" != " #expected); \
   91.58 +      return;                                                       \
   91.59 +    }                                                               \
   91.60 +  } while(0)
   91.61 +
   91.62 +  // The values checked below must be kept in sync with the Java source file.
   91.63 +
   91.64 +  v.i = (*env)->GetIntField(env, self, id_i);
   91.65 +  CHECK(v.i, 1);
   91.66 +
   91.67 +  v.j = (*env)->GetLongField(env, self, id_j);
   91.68 +  CHECK(v.j, 2);
   91.69 +
   91.70 +  v.z = (*env)->GetBooleanField(env, self, id_z);
   91.71 +  CHECK(v.z, JNI_TRUE);
   91.72 +
   91.73 +  v.c = (*env)->GetCharField(env, self, id_c);
   91.74 +  CHECK(v.c, 'a');
   91.75 +
   91.76 +  v.s = (*env)->GetShortField(env, self, id_s);
   91.77 +  CHECK(v.s, 3);
   91.78 +
   91.79 +  v.f = (*env)->GetFloatField(env, self, id_f);
   91.80 +  CHECK(v.f, 1.0f);
   91.81 +
   91.82 +  v.d = (*env)->GetDoubleField(env, self, id_d);
   91.83 +  CHECK(v.d, 2.0);
   91.84 +
   91.85 +#undef CHECK
   91.86 +
   91.87 +  v.l = (*env)->GetObjectField(env, self, id_l);
   91.88 +  if (v.l == NULL) {
   91.89 +    (*env)->ThrowNew(env, exception, "Object field was null");
   91.90 +    return;
   91.91 +  }
   91.92 +  {
   91.93 +    jclass clz = (*env)->GetObjectClass(env, v.l);
   91.94 +    if (!(*env)->IsSameObject(env, clazz, clz)) {
   91.95 +      (*env)->ThrowNew(env, exception, "Bad object class");
   91.96 +    }
   91.97 +  }
   91.98 +
   91.99 +  (*env)->DeleteWeakGlobalRef(env, self);
  91.100 +}
  91.101 +
  91.102 +/*
  91.103 + * Class:     CallWithJNIWeak
  91.104 + * Method:    runTests
  91.105 + * Signature: (LCallWithJNIWeak;)V
  91.106 + */
  91.107 +JNIEXPORT void JNICALL
  91.108 +Java_CallWithJNIWeak_runTests(JNIEnv *env, jclass clazz, jobject this) {
  91.109 +  jweak that = (*env)->NewWeakGlobalRef(env, this);
  91.110 +  {
  91.111 +    jmethodID method = (*env)->GetStaticMethodID(env,
  91.112 +                                                 clazz, "testJNIFieldAccessors", "(LCallWithJNIWeak;)V");
  91.113 +    (*env)->CallStaticVoidMethod(env, clazz, method, that);
  91.114 +    if ((*env)->ExceptionCheck(env)) {
  91.115 +      return;
  91.116 +    }
  91.117 +  }
  91.118 +
  91.119 +  {
  91.120 +    jmethodID method = (*env)->GetMethodID(env, clazz, "weakReceiverTest", "()V");
  91.121 +    (*env)->CallVoidMethod(env, that, method);
  91.122 +    if ((*env)->ExceptionCheck(env)) {
  91.123 +      return;
  91.124 +    }
  91.125 +  }
  91.126 +
  91.127 +  {
  91.128 +    jmethodID method = (*env)->GetMethodID(env, clazz, "synchonizedWeakReceiverTest", "()V");
  91.129 +    (*env)->CallVoidMethod(env, that, method);
  91.130 +    if ((*env)->ExceptionCheck(env)) {
  91.131 +      return;
  91.132 +    }
  91.133 +  }
  91.134 +  (*env)->DeleteWeakGlobalRef(env, that);
  91.135 +}
  91.136 +
  91.137 +/*
  91.138 + * Class:     CallWithJNIWeak
  91.139 + * Method:    weakReceiverTest0
  91.140 + * Signature: ()V
  91.141 + */
  91.142 +JNIEXPORT void JNICALL
  91.143 +Java_CallWithJNIWeak_weakReceiverTest0(JNIEnv *env, jobject obj) {
  91.144 +  (*env)->GetObjectClass(env, obj);
  91.145 +}
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/test/runtime/jni/CallWithJNIWeak/CallWithJNIWeak.java	Thu Sep 05 18:52:27 2019 +0800
    92.3 @@ -0,0 +1,63 @@
    92.4 +/*
    92.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    92.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.7 + *
    92.8 + * This code is free software; you can redistribute it and/or modify it
    92.9 + * under the terms of the GNU General Public License version 2 only, as
   92.10 + * published by the Free Software Foundation.
   92.11 + *
   92.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   92.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   92.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   92.15 + * version 2 for more details (a copy is included in the LICENSE file that
   92.16 + * accompanied this code).
   92.17 + *
   92.18 + * You should have received a copy of the GNU General Public License version
   92.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   92.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   92.21 + *
   92.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   92.23 + * or visit www.oracle.com if you need additional information or have any
   92.24 + * questions.
   92.25 + */
   92.26 +
   92.27 +public class CallWithJNIWeak {
   92.28 +    static {
   92.29 +        System.loadLibrary("CallWithJNIWeak");
   92.30 +    }
   92.31 +
   92.32 +    private static native void testJNIFieldAccessors(CallWithJNIWeak o);
   92.33 +
   92.34 +    // The field initializations must be kept in sync with the JNI code
   92.35 +    // which reads verifies the values of these fields.
   92.36 +    private int i = 1;
   92.37 +    private long j = 2;
   92.38 +    private boolean z = true;
   92.39 +    private char c = 'a';
   92.40 +    private short s = 3;
   92.41 +    private float f = 1.0f;
   92.42 +    private double d = 2.0;
   92.43 +    private Object l;
   92.44 +
   92.45 +    private CallWithJNIWeak() {
   92.46 +        this.l = this;
   92.47 +    }
   92.48 +
   92.49 +    private native void weakReceiverTest0();
   92.50 +    private void weakReceiverTest() {
   92.51 +        weakReceiverTest0();
   92.52 +    }
   92.53 +
   92.54 +    private synchronized void synchonizedWeakReceiverTest() {
   92.55 +        this.notifyAll();
   92.56 +    }
   92.57 +
   92.58 +    private static native void runTests(CallWithJNIWeak o);
   92.59 +
   92.60 +    public static void main(String[] args) {
   92.61 +        CallWithJNIWeak w = new CallWithJNIWeak();
   92.62 +        for (int i = 0; i < 20000; i++) {
   92.63 +            runTests(w);
   92.64 +        }
   92.65 +    }
   92.66 +}
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/test/runtime/jni/CallWithJNIWeak/test.sh	Thu Sep 05 18:52:27 2019 +0800
    93.3 @@ -0,0 +1,93 @@
    93.4 +#!/bin/sh
    93.5 +
    93.6 +#
    93.7 +#  Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
    93.8 +#  Copyright (c) 2011 SAP AG.  All Rights Reserved.
    93.9 +#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   93.10 +#
   93.11 +#  This code is free software; you can redistribute it and/or modify it
   93.12 +#  under the terms of the GNU General Public License version 2 only, as
   93.13 +#  published by the Free Software Foundation.
   93.14 +#
   93.15 +#  This code is distributed in the hope that it will be useful, but WITHOUT
   93.16 +#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   93.17 +#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   93.18 +#  version 2 for more details (a copy is included in the LICENSE file that
   93.19 +#  accompanied this code).
   93.20 +#
   93.21 +#  You should have received a copy of the GNU General Public License version
   93.22 +#  2 along with this work; if not, write to the Free Software Foundation,
   93.23 +#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   93.24 +#
   93.25 +#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   93.26 +#  or visit www.oracle.com if you need additional information or have any
   93.27 +#  questions.
   93.28 +#
   93.29 +
   93.30 +## @test test.sh
   93.31 +## @bug 8166188
   93.32 +## @requires vm.opt.ExplicitGCInvokesConcurrent != true
   93.33 +## @summary Test call of native function with JNI weak global ref.
   93.34 +## @run shell test.sh
   93.35 +
   93.36 +if [ "${TESTSRC}" = "" ]
   93.37 +then
   93.38 +  TESTSRC=${PWD}
   93.39 +  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
   93.40 +fi
   93.41 +echo "TESTSRC=${TESTSRC}"
   93.42 +## Adding common setup Variables for running shell tests.
   93.43 +. ${TESTSRC}/../../../test_env.sh
   93.44 +
   93.45 +# set platform-dependent variables
   93.46 +OS=`uname -s`
   93.47 +echo "Testing on " $OS
   93.48 +case "$OS" in
   93.49 +  Linux)
   93.50 +    cc_cmd=`which gcc`
   93.51 +    if [ "x$cc_cmd" == "x" ]; then
   93.52 +        echo "WARNING: gcc not found. Cannot execute test." 2>&1
   93.53 +        exit 0;
   93.54 +    fi
   93.55 +    ;;
   93.56 +  Solaris)
   93.57 +    cc_cmd=`which cc`
   93.58 +    if [ "x$cc_cmd" == "x" ]; then
   93.59 +        echo "WARNING: cc not found. Cannot execute test." 2>&1
   93.60 +        exit 0;
   93.61 +    fi
   93.62 +    ;;
   93.63 +  *)
   93.64 +    echo "Test passed; only valid for Linux and Solaris"
   93.65 +    exit 0;
   93.66 +    ;;
   93.67 +esac
   93.68 +
   93.69 +THIS_DIR=.
   93.70 +
   93.71 +cp ${TESTSRC}${FS}*.java ${THIS_DIR}
   93.72 +${TESTJAVA}${FS}bin${FS}javac *.java
   93.73 +
   93.74 +$cc_cmd -fPIC -shared -o libCallWithJNIWeak.so \
   93.75 +    -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
   93.76 +    ${TESTSRC}${FS}CallWithJNIWeak.c
   93.77 +
   93.78 +LD_LIBRARY_PATH=${THIS_DIR}
   93.79 +echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
   93.80 +export LD_LIBRARY_PATH
   93.81 +
   93.82 +echo
   93.83 +echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint CallWithJNIWeak
   93.84 +${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint CallWithJNIWeak
   93.85 +JAVA_RETVAL=$?
   93.86 +
   93.87 +if [ "$JAVA_RETVAL" == "0" ]
   93.88 +then
   93.89 +  echo
   93.90 +  echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp CallWithJNIWeak
   93.91 +  ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp CallWithJNIWeak
   93.92 +
   93.93 +  JAVA_RETVAL=$?
   93.94 +fi
   93.95 +
   93.96 +exit $JAVA_RETVAL
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/test/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.c	Thu Sep 05 18:52:27 2019 +0800
    94.3 @@ -0,0 +1,52 @@
    94.4 +/*
    94.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    94.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    94.7 + *
    94.8 + * This code is free software; you can redistribute it and/or modify it
    94.9 + * under the terms of the GNU General Public License version 2 only, as
   94.10 + * published by the Free Software Foundation.
   94.11 + *
   94.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   94.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   94.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   94.15 + * version 2 for more details (a copy is included in the LICENSE file that
   94.16 + * accompanied this code).
   94.17 + *
   94.18 + * You should have received a copy of the GNU General Public License version
   94.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   94.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   94.21 + *
   94.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   94.23 + * or visit www.oracle.com if you need additional information or have any
   94.24 + * questions.
   94.25 + */
   94.26 +
   94.27 +/*
   94.28 + * Native support for ReturnJNIWeak test.
   94.29 + */
   94.30 +
   94.31 +#include "jni.h"
   94.32 +
   94.33 +static jweak registered = NULL;
   94.34 +
   94.35 +JNIEXPORT void JNICALL
   94.36 +Java_ReturnJNIWeak_registerObject(JNIEnv* env,
   94.37 +                                  jclass jclazz,
   94.38 +                                  jobject value) {
   94.39 +  // assert registered == NULL
   94.40 +  registered = (*env)->NewWeakGlobalRef(env, value);
   94.41 +}
   94.42 +
   94.43 +JNIEXPORT void JNICALL
   94.44 +Java_ReturnJNIWeak_unregisterObject(JNIEnv* env, jclass jclazz) {
   94.45 +  if (registered != NULL) {
   94.46 +    (*env)->DeleteWeakGlobalRef(env, registered);
   94.47 +    registered = NULL;
   94.48 +  }
   94.49 +}
   94.50 +
   94.51 +JNIEXPORT jobject JNICALL
   94.52 +Java_ReturnJNIWeak_getObject(JNIEnv* env, jclass jclazz) {
   94.53 +  // assert registered != NULL
   94.54 +  return registered;
   94.55 +}
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/test/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java	Thu Sep 05 18:52:27 2019 +0800
    95.3 @@ -0,0 +1,122 @@
    95.4 +/*
    95.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    95.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    95.7 + *
    95.8 + * This code is free software; you can redistribute it and/or modify it
    95.9 + * under the terms of the GNU General Public License version 2 only, as
   95.10 + * published by the Free Software Foundation.
   95.11 + *
   95.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   95.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   95.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   95.15 + * version 2 for more details (a copy is included in the LICENSE file that
   95.16 + * accompanied this code).
   95.17 + *
   95.18 + * You should have received a copy of the GNU General Public License version
   95.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   95.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   95.21 + *
   95.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   95.23 + * or visit www.oracle.com if you need additional information or have any
   95.24 + * questions.
   95.25 + */
   95.26 +
   95.27 +public final class ReturnJNIWeak {
   95.28 +    static {
   95.29 +        System.loadLibrary("ReturnJNIWeak");
   95.30 +    }
   95.31 +
   95.32 +    private static final class TestObject {
   95.33 +        public final int value;
   95.34 +
   95.35 +        public TestObject(int value) {
   95.36 +            this.value = value;
   95.37 +        }
   95.38 +    }
   95.39 +
   95.40 +    private static volatile TestObject testObject = null;
   95.41 +
   95.42 +    private static native void registerObject(Object o);
   95.43 +    private static native void unregisterObject();
   95.44 +    private static native Object getObject();
   95.45 +
   95.46 +    // Create the test object and record it both strongly and weakly.
   95.47 +    private static void remember(int value) {
   95.48 +        TestObject o = new TestObject(value);
   95.49 +        registerObject(o);
   95.50 +        testObject = o;
   95.51 +    }
   95.52 +
   95.53 +    // Remove both strong and weak references to the current test object.
   95.54 +    private static void forget() {
   95.55 +        unregisterObject();
   95.56 +        testObject = null;
   95.57 +    }
   95.58 +
   95.59 +    // Verify the weakly recorded object
   95.60 +    private static void checkValue(int value) throws Exception {
   95.61 +        Object o = getObject();
   95.62 +        if (o == null) {
   95.63 +            throw new RuntimeException("Weak reference unexpectedly null");
   95.64 +        }
   95.65 +        TestObject t = (TestObject)o;
   95.66 +        if (t.value != value) {
   95.67 +            throw new RuntimeException("Incorrect value");
   95.68 +        }
   95.69 +    }
   95.70 +
   95.71 +    // Verify we can create a weak reference and get it back.
   95.72 +    private static void testSanity() throws Exception {
   95.73 +        System.out.println("running testSanity");
   95.74 +        int value = 5;
   95.75 +        try {
   95.76 +            remember(value);
   95.77 +            checkValue(value);
   95.78 +        } finally {
   95.79 +            forget();
   95.80 +        }
   95.81 +    }
   95.82 +
   95.83 +    // Verify weak ref value survives across collection if strong ref exists.
   95.84 +    private static void testSurvival() throws Exception {
   95.85 +        System.out.println("running testSurvival");
   95.86 +        int value = 10;
   95.87 +        try {
   95.88 +            remember(value);
   95.89 +            checkValue(value);
   95.90 +            System.gc();
   95.91 +            // Verify weak ref still has expected value.
   95.92 +            checkValue(value);
   95.93 +        } finally {
   95.94 +            forget();
   95.95 +        }
   95.96 +    }
   95.97 +
   95.98 +    // Verify weak ref cleared if no strong ref exists.
   95.99 +    private static void testClear() throws Exception {
  95.100 +        System.out.println("running testClear");
  95.101 +        int value = 15;
  95.102 +        try {
  95.103 +            remember(value);
  95.104 +            checkValue(value);
  95.105 +            // Verify still good.
  95.106 +            checkValue(value);
  95.107 +            // Drop reference.
  95.108 +            testObject = null;
  95.109 +            System.gc();
  95.110 +            // Verify weak ref cleared as expected.
  95.111 +            Object recorded = getObject();
  95.112 +            if (recorded != null) {
  95.113 +                throw new RuntimeException("expected clear");
  95.114 +            }
  95.115 +        } finally {
  95.116 +            forget();
  95.117 +        }
  95.118 +    }
  95.119 +
  95.120 +    public static void main(String[] args) throws Exception {
  95.121 +        testSanity();
  95.122 +        testSurvival();
  95.123 +        testClear();
  95.124 +    }
  95.125 +}
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/test/runtime/jni/ReturnJNIWeak/test.sh	Thu Sep 05 18:52:27 2019 +0800
    96.3 @@ -0,0 +1,93 @@
    96.4 +#!/bin/sh
    96.5 +
    96.6 +#
    96.7 +#  Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
    96.8 +#  Copyright (c) 2011 SAP AG.  All Rights Reserved.
    96.9 +#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   96.10 +#
   96.11 +#  This code is free software; you can redistribute it and/or modify it
   96.12 +#  under the terms of the GNU General Public License version 2 only, as
   96.13 +#  published by the Free Software Foundation.
   96.14 +#
   96.15 +#  This code is distributed in the hope that it will be useful, but WITHOUT
   96.16 +#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   96.17 +#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   96.18 +#  version 2 for more details (a copy is included in the LICENSE file that
   96.19 +#  accompanied this code).
   96.20 +#
   96.21 +#  You should have received a copy of the GNU General Public License version
   96.22 +#  2 along with this work; if not, write to the Free Software Foundation,
   96.23 +#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   96.24 +#
   96.25 +#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   96.26 +#  or visit www.oracle.com if you need additional information or have any
   96.27 +#  questions.
   96.28 +#
   96.29 +
   96.30 +## @test test.sh
   96.31 +## @bug 8166188
   96.32 +## @requires vm.opt.ExplicitGCInvokesConcurrent != true
   96.33 +## @summary Test return of JNI weak global refs from native calls.
   96.34 +## @run shell test.sh
   96.35 +
   96.36 +if [ "${TESTSRC}" = "" ]
   96.37 +then
   96.38 +  TESTSRC=${PWD}
   96.39 +  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
   96.40 +fi
   96.41 +echo "TESTSRC=${TESTSRC}"
   96.42 +## Adding common setup Variables for running shell tests.
   96.43 +. ${TESTSRC}/../../../test_env.sh
   96.44 +
   96.45 +# set platform-dependent variables
   96.46 +OS=`uname -s`
   96.47 +echo "Testing on " $OS
   96.48 +case "$OS" in
   96.49 +  Linux)
   96.50 +    cc_cmd=`which gcc`
   96.51 +    if [ "x$cc_cmd" == "x" ]; then
   96.52 +        echo "WARNING: gcc not found. Cannot execute test." 2>&1
   96.53 +        exit 0;
   96.54 +    fi
   96.55 +    ;;
   96.56 +  Solaris)
   96.57 +    cc_cmd=`which cc`
   96.58 +    if [ "x$cc_cmd" == "x" ]; then
   96.59 +        echo "WARNING: cc not found. Cannot execute test." 2>&1
   96.60 +        exit 0;
   96.61 +    fi
   96.62 +    ;;
   96.63 +  *)
   96.64 +    echo "Test passed; only valid for Linux and Solaris"
   96.65 +    exit 0;
   96.66 +    ;;
   96.67 +esac
   96.68 +
   96.69 +THIS_DIR=.
   96.70 +
   96.71 +cp ${TESTSRC}${FS}*.java ${THIS_DIR}
   96.72 +${TESTJAVA}${FS}bin${FS}javac *.java
   96.73 +
   96.74 +$cc_cmd -fPIC -shared -o libReturnJNIWeak.so \
   96.75 +    -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
   96.76 +    ${TESTSRC}${FS}ReturnJNIWeak.c
   96.77 +
   96.78 +LD_LIBRARY_PATH=${THIS_DIR}
   96.79 +echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
   96.80 +export LD_LIBRARY_PATH
   96.81 +
   96.82 +echo
   96.83 +echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint ReturnJNIWeak
   96.84 +${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint ReturnJNIWeak
   96.85 +JAVA_RETVAL=$?
   96.86 +
   96.87 +if [ "$JAVA_RETVAL" == "0" ]
   96.88 +then
   96.89 +  echo
   96.90 +  echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp ReturnJNIWeak
   96.91 +  ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp ReturnJNIWeak
   96.92 +
   96.93 +  JAVA_RETVAL=$?
   96.94 +fi
   96.95 +
   96.96 +exit $JAVA_RETVAL
    97.1 --- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Thu Sep 05 18:40:52 2019 +0800
    97.2 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Thu Sep 05 18:52:27 2019 +0800
    97.3 @@ -162,6 +162,7 @@
    97.4    }
    97.5    public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
    97.6    public native void    clearMethodState(Executable method);
    97.7 +  public native void    markMethodProfiled(Executable method);
    97.8    public native int     getMethodEntryBci(Executable method);
    97.9    public native Object[] getNMethod(Executable method, boolean isOsr);
   97.10  
    98.1 --- a/test/testlibrary/whitebox/sun/hotspot/code/NMethod.java	Thu Sep 05 18:40:52 2019 +0800
    98.2 +++ b/test/testlibrary/whitebox/sun/hotspot/code/NMethod.java	Thu Sep 05 18:52:27 2019 +0800
    98.3 @@ -34,18 +34,21 @@
    98.4      return obj == null ? null : new NMethod(obj);
    98.5    }
    98.6    private NMethod(Object[] obj) {
    98.7 -    assert obj.length == 2;
    98.8 +    assert obj.length == 3;
    98.9      comp_level = (Integer) obj[0];
   98.10 -    insts = (byte[]) obj[1];
   98.11 +    compile_id = (Integer) obj[1];
   98.12 +    insts = (byte[]) obj[2];
   98.13    }
   98.14 -  public byte[] insts;
   98.15 -  public int comp_level;
   98.16 +  public final byte[] insts;
   98.17 +  public final int comp_level;
   98.18 +  public final int compile_id;
   98.19  
   98.20    @Override
   98.21    public String toString() {
   98.22      return "NMethod{" +
   98.23          "insts=" + insts +
   98.24          ", comp_level=" + comp_level +
   98.25 +        ", compile_id=" + compile_id +
   98.26          '}';
   98.27    }
   98.28  }

mercurial