8183039: Re-examine methodHandle methods uninlined by 8144256
authorcoleenp
Thu, 27 Jul 2017 18:06:41 -0400
changeset 46727 6e4a84748e2c
parent 46726 7801367e3cc9
child 46728 a1bee305515d
8183039: Re-examine methodHandle methods uninlined by 8144256 Summary: Add more const references so out-of-line methodHandle destructor and copy ctor called infrequently Reviewed-by: hseigel, redestad
hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp
hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.hpp
hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
hotspot/src/cpu/arm/vm/interpreterRT_arm.cpp
hotspot/src/cpu/arm/vm/interpreterRT_arm.hpp
hotspot/src/cpu/arm/vm/sharedRuntime_arm.cpp
hotspot/src/cpu/ppc/vm/interpreterRT_ppc.hpp
hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
hotspot/src/cpu/s390/vm/interpreterRT_s390.hpp
hotspot/src/cpu/sparc/vm/interpreterRT_sparc.cpp
hotspot/src/cpu/sparc/vm/interpreterRT_sparc.hpp
hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
hotspot/src/cpu/x86/vm/interpreterRT_x86.hpp
hotspot/src/cpu/x86/vm/interpreterRT_x86_32.cpp
hotspot/src/cpu/x86/vm/interpreterRT_x86_64.cpp
hotspot/src/cpu/x86/vm/sharedRuntime_x86.cpp
hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp
hotspot/src/share/vm/c1/c1_Runtime1.cpp
hotspot/src/share/vm/ci/ciMethod.cpp
hotspot/src/share/vm/ci/ciMethod.hpp
hotspot/src/share/vm/classfile/classFileParser.cpp
hotspot/src/share/vm/classfile/classLoader.cpp
hotspot/src/share/vm/code/codeCache.cpp
hotspot/src/share/vm/code/codeCache.hpp
hotspot/src/share/vm/compiler/compilerDirectives.cpp
hotspot/src/share/vm/compiler/compilerDirectives.hpp
hotspot/src/share/vm/compiler/compilerOracle.cpp
hotspot/src/share/vm/interpreter/abstractInterpreter.cpp
hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
hotspot/src/share/vm/interpreter/bytecode.cpp
hotspot/src/share/vm/interpreter/bytecode.hpp
hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
hotspot/src/share/vm/interpreter/interpreterRuntime.hpp
hotspot/src/share/vm/interpreter/invocationCounter.cpp
hotspot/src/share/vm/interpreter/invocationCounter.hpp
hotspot/src/share/vm/interpreter/linkResolver.cpp
hotspot/src/share/vm/interpreter/linkResolver.hpp
hotspot/src/share/vm/interpreter/oopMapCache.cpp
hotspot/src/share/vm/interpreter/rewriter.cpp
hotspot/src/share/vm/interpreter/rewriter.hpp
hotspot/src/share/vm/jvmci/jvmciCompiler.cpp
hotspot/src/share/vm/jvmci/jvmciRuntime.cpp
hotspot/src/share/vm/jvmci/jvmciRuntime.hpp
hotspot/src/share/vm/oops/cpCache.cpp
hotspot/src/share/vm/oops/cpCache.hpp
hotspot/src/share/vm/oops/klassVtable.cpp
hotspot/src/share/vm/oops/klassVtable.hpp
hotspot/src/share/vm/oops/method.cpp
hotspot/src/share/vm/oops/method.hpp
hotspot/src/share/vm/oops/methodCounters.cpp
hotspot/src/share/vm/oops/methodCounters.hpp
hotspot/src/share/vm/prims/jvm.cpp
hotspot/src/share/vm/prims/jvmtiExport.cpp
hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
hotspot/src/share/vm/runtime/compilationPolicy.cpp
hotspot/src/share/vm/runtime/compilationPolicy.hpp
hotspot/src/share/vm/runtime/deoptimization.cpp
hotspot/src/share/vm/runtime/deoptimization.hpp
hotspot/src/share/vm/runtime/javaCalls.cpp
hotspot/src/share/vm/runtime/javaCalls.hpp
hotspot/src/share/vm/runtime/reflection.cpp
hotspot/src/share/vm/runtime/sharedRuntime.hpp
hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp
hotspot/src/share/vm/utilities/xmlstream.cpp
hotspot/src/share/vm/utilities/xmlstream.hpp
--- a/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -369,7 +369,7 @@
   }
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to)
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to)
     : NativeSignatureIterator(method)
   {
     _from = from;
--- a/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -47,7 +47,7 @@
 
  public:
   // Creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
     _num_int_args = (method->is_static() ? 1 : 0);
     _num_fp_args = 0;
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1207,7 +1207,7 @@
 }
 
 static void verify_oop_args(MacroAssembler* masm,
-                            methodHandle method,
+                            const methodHandle& method,
                             const BasicType* sig_bt,
                             const VMRegPair* regs) {
   Register temp_reg = r19;  // not part of any compiled calling seq
@@ -1229,7 +1229,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/arm/vm/interpreterRT_arm.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/arm/vm/interpreterRT_arm.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -422,7 +422,7 @@
 #endif // !__ABI_HARD__
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to) :
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to) :
     NativeSignatureIterator(method) {
     _from = from;
 
--- a/hotspot/src/cpu/arm/vm/interpreterRT_arm.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/arm/vm/interpreterRT_arm.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
 #endif
  public:
   // Creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
     _abi_offset = 0;
     _ireg = is_static() ? 2 : 1;
--- a/hotspot/src/cpu/arm/vm/sharedRuntime_arm.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/arm/vm/sharedRuntime_arm.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1024,7 +1024,7 @@
 
 
 static void verify_oop_args(MacroAssembler* masm,
-                            methodHandle method,
+                            const methodHandle& method,
                             const BasicType* sig_bt,
                             const VMRegPair* regs) {
   Register temp_reg = Rmethod;  // not part of any compiled calling seq
@@ -1045,7 +1045,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/ppc/vm/interpreterRT_ppc.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/ppc/vm/interpreterRT_ppc.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2014 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -45,7 +45,7 @@
 
  public:
   // Creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
     _num_used_fp_arg_regs = 0;
   }
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1610,7 +1610,7 @@
 }
 
 static void verify_oop_args(MacroAssembler* masm,
-                            methodHandle method,
+                            const methodHandle& method,
                             const BasicType* sig_bt,
                             const VMRegPair* regs) {
   Register temp_reg = R19_method;  // not part of any compiled calling seq
@@ -1632,7 +1632,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/s390/vm/interpreterRT_s390.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/s390/vm/interpreterRT_s390.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2016 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -51,7 +51,7 @@
 
  public:
   // creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
     _fp_arg_nr = 0;
   }
--- a/hotspot/src/cpu/sparc/vm/interpreterRT_sparc.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/sparc/vm/interpreterRT_sparc.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -176,7 +176,7 @@
 
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) {
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) {
     _from = from;
     _to   = to;
     _RegArgSignature = RegArgSig;
--- a/hotspot/src/cpu/sparc/vm/interpreterRT_sparc.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/sparc/vm/interpreterRT_sparc.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
 
  public:
   // Creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
   }
 
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1633,7 +1633,7 @@
 }
 
 static void verify_oop_args(MacroAssembler* masm,
-                            methodHandle method,
+                            const methodHandle& method,
                             const BasicType* sig_bt,
                             const VMRegPair* regs) {
   Register temp_reg = G5_method;  // not part of any compiled calling seq
@@ -1657,7 +1657,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/x86/vm/interpreterRT_x86.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/interpreterRT_x86.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
 
  public:
   // Creation
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {
     _masm = new MacroAssembler(buffer);
 #ifdef AMD64
 #ifdef _WIN64
--- a/hotspot/src/cpu/x86/vm/interpreterRT_x86_32.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/interpreterRT_x86_32.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@
    }
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to) :
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to) :
     NativeSignatureIterator(method) {
     _from = from;
     _to   = to + (is_static() ? 2 : 1);
--- a/hotspot/src/cpu/x86/vm/interpreterRT_x86_64.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/interpreterRT_x86_64.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -369,7 +369,7 @@
   }
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to)
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to)
     : NativeSignatureIterator(method)
   {
     _from = from;
@@ -461,7 +461,7 @@
   }
 
  public:
-  SlowSignatureHandler(methodHandle method, address from, intptr_t* to)
+  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to)
     : NativeSignatureIterator(method)
   {
     _from = from;
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 // Since hashCode is usually polymorphic at call sites we can't do this
 // optimization at the call site without a lot of work.
 void SharedRuntime::inline_check_hashcode_from_object_header(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  Register obj_reg,
                                  Register result) {
   Label slowCase;
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1407,7 +1407,7 @@
 }
 
 static void verify_oop_args(MacroAssembler* masm,
-                            methodHandle method,
+                            const methodHandle& method,
                             const BasicType* sig_bt,
                             const VMRegPair* regs) {
   Register temp_reg = rbx;  // not part of any compiled calling seq
@@ -1429,7 +1429,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1740,7 +1740,7 @@
 }
 
 static void gen_special_dispatch(MacroAssembler* masm,
-                                 methodHandle method,
+                                 const methodHandle& method,
                                  const BasicType* sig_bt,
                                  const VMRegPair* regs) {
   verify_oop_args(masm, method, sig_bt, regs);
--- a/hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -67,7 +67,7 @@
   ffi_cif* _cif;
 
  protected:
-  SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif)
+  SignatureHandlerGeneratorBase(const methodHandle& method, ffi_cif *cif)
     : NativeSignatureIterator(method), _cif(cif) {
     _cif->nargs = 0;
   }
@@ -96,7 +96,7 @@
   CodeBuffer* _cb;
 
  public:
-  SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer)
+  SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer)
     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->insts_end()),
       _cb(buffer) {
     _cb->set_insts_end((address) (cif() + 1));
@@ -115,7 +115,7 @@
   intptr_t *_dst;
 
  public:
-  SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf)
+  SlowSignatureHandlerGenerator(const methodHandle& method, intptr_t* buf)
     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) {
     _dst = (intptr_t *) (cif() + 1);
   }
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -743,7 +743,7 @@
 
 #ifndef DEOPTIMIZE_WHEN_PATCHING
 
-static Klass* resolve_field_return_klass(methodHandle caller, int bci, TRAPS) {
+static Klass* resolve_field_return_klass(const methodHandle& caller, int bci, TRAPS) {
   Bytecode_field field_access(caller, bci);
   // This can be static or non-static field access
   Bytecodes::Code code       = field_access.code();
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -68,7 +68,7 @@
 // ciMethod::ciMethod
 //
 // Loaded method.
-ciMethod::ciMethod(methodHandle h_m, ciInstanceKlass* holder) :
+ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
   ciMetadata(h_m()),
   _holder(holder)
 {
@@ -979,7 +979,7 @@
 //
 // Generate new MethodData* objects at compile time.
 // Return true if allocation was successful or no MDO is required.
-bool ciMethod::ensure_method_data(methodHandle h_m) {
+bool ciMethod::ensure_method_data(const methodHandle& h_m) {
   EXCEPTION_CONTEXT;
   if (is_native() || is_abstract() || h_m()->is_accessor()) {
     return true;
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@
   BCEscapeAnalyzer*   _bcea;
 #endif
 
-  ciMethod(methodHandle h_m, ciInstanceKlass* holder);
+  ciMethod(const methodHandle& h_m, ciInstanceKlass* holder);
   ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
 
   oop loader() const                             { return _holder->loader(); }
@@ -112,7 +112,7 @@
 
   void load_code();
 
-  bool ensure_method_data(methodHandle h_m);
+  bool ensure_method_data(const methodHandle& h_m);
 
   void code_at_put(int bci, Bytecodes::Code code) {
     Bytecodes::check(code);
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1060,7 +1060,7 @@
 class MethodAnnotationCollector : public AnnotationCollector{
 public:
   MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
-  void apply_to(methodHandle m);
+  void apply_to(const methodHandle& m);
 };
 
 class ClassFileParser::ClassAnnotationCollector : public AnnotationCollector{
@@ -2095,7 +2095,7 @@
   MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
 }
 
-void MethodAnnotationCollector::apply_to(methodHandle m) {
+void MethodAnnotationCollector::apply_to(const methodHandle& m) {
   if (has_annotation(_method_CallerSensitive))
     m->set_caller_sensitive(true);
   if (has_annotation(_method_ForceInline))
@@ -3632,7 +3632,7 @@
 #ifndef PRODUCT
 static void print_field_layout(const Symbol* name,
                                Array<u2>* fields,
-                               constantPoolHandle cp,
+                               const constantPoolHandle& cp,
                                int instance_size,
                                int instance_fields_start,
                                int instance_fields_end,
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1887,7 +1887,7 @@
  *
  * TODO:  This should be a private method in a CompileTheWorld class.
  */
-static bool can_be_compiled(methodHandle m, int comp_level) {
+static bool can_be_compiled(const methodHandle& m, int comp_level) {
   assert(CompileTheWorld, "must be");
 
   // It's not valid to compile a native wrapper for MethodHandle methods
--- a/hotspot/src/share/vm/code/codeCache.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1285,7 +1285,7 @@
 
 
 // Flushes compiled methods dependent on dependee
-void CodeCache::flush_dependents_on_method(methodHandle m_h) {
+void CodeCache::flush_dependents_on_method(const methodHandle& m_h) {
   // --- Compile_lock is not held. However we are at a safepoint.
   assert_locked_or_safepoint(Compile_lock);
 
--- a/hotspot/src/share/vm/code/codeCache.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/code/codeCache.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -282,7 +282,7 @@
   static void flush_evol_dependents_on(InstanceKlass* dependee);
 #endif // HOTSWAP
   // Support for fullspeed debugging
-  static void flush_dependents_on_method(methodHandle dependee);
+  static void flush_dependents_on_method(const methodHandle& dependee);
 
   // tells how many nmethods have dependencies
   static int number_of_nmethods_with_dependencies();
--- a/hotspot/src/share/vm/compiler/compilerDirectives.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/compiler/compilerDirectives.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@
   return _next;
 }
 
-bool CompilerDirectives::match(methodHandle method) {
+bool CompilerDirectives::match(const methodHandle& method) {
   if (is_default_directive()) {
     return true;
   }
@@ -232,7 +232,7 @@
 // - Need to free copy after use
 // - Requires a modified bit so we don't overwrite options that is set by directives
 
-DirectiveSet* DirectiveSet::compilecommand_compatibility_init(methodHandle method) {
+DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle& method) {
   // Early bail out - checking all options is expensive - we rely on them not being used
   // Only set a flag if it has not been modified and value changes.
   // Only copy set if a flag needs to be set
@@ -307,7 +307,7 @@
   return _directive;
 }
 
-bool DirectiveSet::matches_inline(methodHandle method, int inline_action) {
+bool DirectiveSet::matches_inline(const methodHandle& method, int inline_action) {
   if (_inlinematchers != NULL) {
     if (_inlinematchers->match(method, inline_action)) {
       return true;
@@ -384,7 +384,7 @@
   }
 }
 
-bool DirectiveSet::is_intrinsic_disabled(methodHandle method) {
+bool DirectiveSet::is_intrinsic_disabled(const methodHandle& method) {
   vmIntrinsics::ID id = method->intrinsic_id();
   assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
 
@@ -543,7 +543,7 @@
   }
 }
 
-DirectiveSet* DirectivesStack::getMatchingDirective(methodHandle method, AbstractCompiler *comp) {
+DirectiveSet* DirectivesStack::getMatchingDirective(const methodHandle& method, AbstractCompiler *comp) {
   assert(_depth > 0, "Must never be empty");
 
   DirectiveSet* match = NULL;
--- a/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,7 @@
   static void pop_inner(); // no lock version of pop
 public:
   static void init();
-  static DirectiveSet* getMatchingDirective(methodHandle mh, AbstractCompiler* comp);
+  static DirectiveSet* getMatchingDirective(const methodHandle& mh, AbstractCompiler* comp);
   static DirectiveSet* getDefaultDirective(AbstractCompiler* comp);
   static void push(CompilerDirectives* directive);
   static void pop(int count);
@@ -109,11 +109,11 @@
   bool should_inline(ciMethod* inlinee);
   bool should_not_inline(ciMethod* inlinee);
   void print_inline(outputStream* st);
-  DirectiveSet* compilecommand_compatibility_init(methodHandle method);
+  DirectiveSet* compilecommand_compatibility_init(const methodHandle& method);
   bool is_exclusive_copy() { return _directive == NULL; }
-  bool matches_inline(methodHandle method, int inline_action);
+  bool matches_inline(const methodHandle& method, int inline_action);
   static DirectiveSet* clone(DirectiveSet const* src);
-  bool is_intrinsic_disabled(methodHandle method);
+  bool is_intrinsic_disabled(const methodHandle& method);
   static ccstrlist canonicalize_disableintrinsic(ccstrlist option_value);
   void finalize(outputStream* st);
 
@@ -170,7 +170,7 @@
   CompilerDirectives* next();
   void set_next(CompilerDirectives* next) {_next = next; }
 
-  bool match(methodHandle method);
+  bool match(const methodHandle& method);
   BasicMatcher* match() { return _match; }
   bool add_match(char* str, const char*& error_msg);
   DirectiveSet* get_for(AbstractCompiler *comp);
--- a/hotspot/src/share/vm/compiler/compilerOracle.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -132,7 +132,7 @@
   }
 
   static TypedMethodOptionMatcher* parse_method_pattern(char*& line, const char*& error_msg);
-  TypedMethodOptionMatcher* match(methodHandle method, const char* opt, OptionType type);
+  TypedMethodOptionMatcher* match(const methodHandle& method, const char* opt, OptionType type);
 
   void init(const char* opt, OptionType type, TypedMethodOptionMatcher* next) {
     _next = next;
@@ -261,7 +261,7 @@
   return tom;
 }
 
-TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(methodHandle method, const char* opt, OptionType type) {
+TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, const char* opt, OptionType type) {
   TypedMethodOptionMatcher* current = this;
   while (current != NULL) {
     // Fastest compare first.
@@ -289,7 +289,7 @@
   return;
 }
 
-static bool check_predicate(OracleCommand command, methodHandle method) {
+static bool check_predicate(OracleCommand command, const methodHandle& method) {
   return ((lists[command] != NULL) &&
           !method.is_null() &&
           lists[command]->match(method));
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -109,7 +109,7 @@
 //------------------------------------------------------------------------------------------------------------------------
 // Entry points
 
-AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(methodHandle m) {
+AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHandle& m) {
   // Abstract method?
   if (m->is_abstract()) return abstract;
 
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -130,11 +130,11 @@
 
 
   // Method activation
-  static MethodKind method_kind(methodHandle m);
+  static MethodKind method_kind(const methodHandle& m);
   static address    entry_for_kind(MethodKind k)                { assert(0 <= k && k < number_of_method_entries, "illegal kind"); return _entry_table[k]; }
-  static address    entry_for_method(methodHandle m)            { return entry_for_kind(method_kind(m)); }
+  static address    entry_for_method(const methodHandle& m)     { return entry_for_kind(method_kind(m)); }
 
-  static address entry_for_cds_method(methodHandle m) {
+  static address entry_for_cds_method(const methodHandle& m) {
     MethodKind k = method_kind(m);
     assert(0 <= k && k < number_of_method_entries, "illegal kind");
     return _cds_entry_table[k];
--- a/hotspot/src/share/vm/interpreter/bytecode.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/bytecode.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -212,7 +212,7 @@
 }
 
 oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
-  assert(_method.not_null(), "must supply method to resolve constant");
+  assert(_method != NULL, "must supply method to resolve constant");
   int index = raw_index();
   ConstantPool* constants = _method->constants();
   if (has_cache_index()) {
--- a/hotspot/src/share/vm/interpreter/bytecode.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/bytecode.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -178,11 +178,11 @@
 
 class Bytecode_member_ref: public Bytecode {
  protected:
-  const methodHandle _method;                          // method containing the bytecode
+  const Method* _method;                          // method containing the bytecode
 
-  Bytecode_member_ref(const methodHandle& method, int bci)  : Bytecode(method(), method()->bcp_from(bci)), _method(method) {}
+  Bytecode_member_ref(const methodHandle& method, int bci)  : Bytecode(method(), method()->bcp_from(bci)), _method(method()) {}
 
-  methodHandle method() const                    { return _method; }
+  const Method* method() const                 { return _method; }
   ConstantPool* constants() const              { return _method->constants(); }
   ConstantPoolCache* cpcache() const           { return _method->constants()->cache(); }
   ConstantPoolCacheEntry* cpcache_entry() const;
@@ -312,15 +312,15 @@
 // Abstraction for ldc, ldc_w and ldc2_w
 class Bytecode_loadconstant: public Bytecode {
  private:
-  const methodHandle _method;
+  const Method* _method;
 
   int raw_index() const;
 
  public:
-  Bytecode_loadconstant(const methodHandle& method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method) { verify(); }
+  Bytecode_loadconstant(const methodHandle& method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method()) { verify(); }
 
   void verify() const {
-    assert(_method.not_null(), "must supply method");
+    assert(_method != NULL, "must supply method");
     Bytecodes::Code stdc = Bytecodes::java_code(code());
     assert(stdc == Bytecodes::_ldc ||
            stdc == Bytecodes::_ldc_w ||
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -232,7 +232,7 @@
 // Exceptions
 
 void InterpreterRuntime::note_trap_inner(JavaThread* thread, int reason,
-                                         methodHandle trap_method, int trap_bci, TRAPS) {
+                                         const methodHandle& trap_method, int trap_bci, TRAPS) {
   if (trap_method.not_null()) {
     MethodData* trap_mdo = trap_method->method_data();
     if (trap_mdo == NULL) {
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
   static ConstantPoolCacheEntry* cache_entry_at(JavaThread *thread, int i)  { return method(thread)->constants()->cache()->entry_at(i); }
   static ConstantPoolCacheEntry* cache_entry(JavaThread *thread)            { return cache_entry_at(thread, Bytes::get_native_u2(bcp(thread) + 1)); }
   static void      note_trap_inner(JavaThread* thread, int reason,
-                                   methodHandle trap_method, int trap_bci, TRAPS);
+                                   const methodHandle& trap_method, int trap_bci, TRAPS);
   static void      note_trap(JavaThread *thread, int reason, TRAPS);
 #ifdef CC_INTERP
   // Profile traps in C++ interpreter.
--- a/hotspot/src/share/vm/interpreter/invocationCounter.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/invocationCounter.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -104,7 +104,7 @@
 }
 
 
-static address do_nothing(methodHandle method, TRAPS) {
+static address do_nothing(const methodHandle& method, TRAPS) {
   // dummy action for inactive invocation counters
   MethodCounters* mcs = method->method_counters();
   assert(mcs != NULL, "");
@@ -114,7 +114,7 @@
 }
 
 
-static address do_decay(methodHandle method, TRAPS) {
+static address do_decay(const methodHandle& method, TRAPS) {
   // decay invocation counters so compilation gets delayed
   MethodCounters* mcs = method->method_counters();
   assert(mcs != NULL, "");
@@ -130,7 +130,7 @@
   _action[state] = action;
 }
 
-address dummy_invocation_counter_overflow(methodHandle m, TRAPS) {
+address dummy_invocation_counter_overflow(const methodHandle& m, TRAPS) {
   ShouldNotReachHere();
   return NULL;
 }
--- a/hotspot/src/share/vm/interpreter/invocationCounter.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/invocationCounter.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
   static int InterpreterBackwardBranchLimit;    // A separate threshold for on stack replacement
   static int InterpreterProfileLimit;           // Profiling threshold scaled for interpreter use
 
-  typedef address (*Action)(methodHandle method, TRAPS);
+  typedef address (*Action)(const methodHandle& method, TRAPS);
 
   enum PublicConstants {
     count_increment      = count_grain,          // use this value to increment the 32bit _counter word
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -235,7 +235,7 @@
 //------------------------------------------------------------------------------------------------------------------------
 // Implementation of LinkInfo
 
-LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) {
+LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) {
    // resolve klass
   _resolved_klass = pool->klass_ref_at(index, CHECK);
 
@@ -315,9 +315,11 @@
 
 // Look up method in klasses, including static methods
 // Then look up local default methods
-methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
-                                                    bool checkpolymorphism,
-                                                    bool in_imethod_resolve, TRAPS) {
+Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
+                                               bool checkpolymorphism,
+                                               bool in_imethod_resolve) {
+  NoSafepointVerifier nsv;  // Method* returned may not be reclaimed
+
   Klass* klass = link_info.resolved_klass();
   Symbol* name = link_info.name();
   Symbol* signature = link_info.signature();
@@ -327,7 +329,7 @@
 
   if (klass->is_array_klass()) {
     // Only consider klass and super klass for arrays
-    return methodHandle(THREAD, result);
+    return result;
   }
 
   InstanceKlass* ik = InstanceKlass::cast(klass);
@@ -363,7 +365,7 @@
       return NULL;
     }
   }
-  return methodHandle(THREAD, result);
+  return result;
 }
 
 // returns first instance method
@@ -418,15 +420,13 @@
   return vtable_index;
 }
 
-methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) {
+Method* LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info) {
   InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass());
 
   // Specify 'true' in order to skip default methods when searching the
   // interfaces.  Function lookup_method_in_klasses() already looked for
   // the method in the default methods table.
-  return methodHandle(THREAD,
-    ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(),
-    Klass::skip_defaults));
+  return ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), Klass::skip_defaults);
 }
 
 methodHandle LinkResolver::lookup_polymorphic_method(
@@ -713,13 +713,12 @@
     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
-
   // 3. lookup method in resolved klass and its super klasses
-  methodHandle resolved_method = lookup_method_in_klasses(link_info, true, false, CHECK_NULL);
+  methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, true, false));
 
   // 4. lookup method in all the interfaces implemented by the resolved klass
   if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy
-    resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL);
+    resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));
 
     if (resolved_method.is_null()) {
       // JSR 292:  see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc
@@ -817,11 +816,11 @@
 
   // lookup method in this interface or its super, java.lang.Object
   // JDK8: also look for static methods
-  methodHandle resolved_method = lookup_method_in_klasses(link_info, false, true, CHECK_NULL);
+  methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true));
 
   if (resolved_method.is_null() && !resolved_klass->is_array_klass()) {
     // lookup method in all the super-interfaces
-    resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL);
+    resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));
   }
 
   if (resolved_method.is_null()) {
--- a/hotspot/src/share/vm/interpreter/linkResolver.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/linkResolver.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -152,7 +152,7 @@
     skip_access_check
   };
 
-  LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS);
+  LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS);
   LinkInfo(const constantPoolHandle& pool, int index, TRAPS);
 
   // Condensed information from other call sites within the vm.
@@ -163,7 +163,7 @@
     _name(name), _signature(signature), _current_klass(current_klass), _current_method(methodHandle()),
     _check_access(check_access == needs_access_check), _tag(tag) {}
 
-  LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, methodHandle current_method,
+  LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, const methodHandle& current_method,
            AccessCheck check_access = needs_access_check,
            constantTag tag = JVM_CONSTANT_Invalid) :
     _resolved_klass(resolved_klass),
@@ -201,10 +201,11 @@
 
  private:
 
-  static methodHandle lookup_method_in_klasses(const LinkInfo& link_info,
-                                               bool checkpolymorphism,
-                                               bool in_imethod_resolve, TRAPS);
-  static methodHandle lookup_method_in_interfaces(const LinkInfo& link_info, TRAPS);
+  static Method* lookup_method_in_klasses(const LinkInfo& link_info,
+                                          bool checkpolymorphism,
+                                          bool in_imethod_resolve);
+  static Method* lookup_method_in_interfaces(const LinkInfo& link_info);
+
   static methodHandle lookup_polymorphic_method(const LinkInfo& link_info,
                                                 Handle *appendix_result_or_null,
                                                 Handle *method_type_result, TRAPS);
--- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,9 +39,9 @@
 
  protected:
   // Initialization
-  void fill(methodHandle method, int bci);
+  void fill(const methodHandle& method, int bci);
   // fills the bit mask for native calls
-  void fill_for_native(methodHandle method);
+  void fill_for_native(const methodHandle& method);
   void set_mask(CellTypeState* vars, CellTypeState* stack, int stack_top);
 
   // Deallocate bit masks and initialize fields
@@ -80,7 +80,7 @@
   virtual void fill_init_vars             (GrowableArray<intptr_t> *init_vars);
 
  public:
-  OopMapForCacheEntry(methodHandle method, int bci, OopMapCacheEntry *entry);
+  OopMapForCacheEntry(const methodHandle& method, int bci, OopMapCacheEntry *entry);
 
   // Computes stack map for (method,bci) and initialize entry
   void compute_map(TRAPS);
@@ -88,7 +88,7 @@
 };
 
 
-OopMapForCacheEntry::OopMapForCacheEntry(methodHandle method, int bci, OopMapCacheEntry* entry) : GenerateOopMap(method) {
+OopMapForCacheEntry::OopMapForCacheEntry(const methodHandle& method, int bci, OopMapCacheEntry* entry) : GenerateOopMap(method) {
   _bci       = bci;
   _entry     = entry;
   _stack_top = -1;
@@ -242,7 +242,7 @@
   void pass_double()                             { /* ignore */ }
   void pass_object()                             { set_one(offset()); }
 
-  MaskFillerForNative(methodHandle method, uintptr_t* mask, int size) : NativeSignatureIterator(method) {
+  MaskFillerForNative(const methodHandle& method, uintptr_t* mask, int size) : NativeSignatureIterator(method) {
     _mask   = mask;
     _size   = size;
     // initialize with 0
@@ -301,7 +301,7 @@
 }
 
 
-void OopMapCacheEntry::fill_for_native(methodHandle mh) {
+void OopMapCacheEntry::fill_for_native(const methodHandle& mh) {
   assert(mh->is_native(), "method must be native method");
   set_mask_size(mh->size_of_parameters() * bits_per_entry);
   allocate_bit_mask();
@@ -311,7 +311,7 @@
 }
 
 
-void OopMapCacheEntry::fill(methodHandle method, int bci) {
+void OopMapCacheEntry::fill(const methodHandle& method, int bci) {
   HandleMark hm;
   // Flush entry to deallocate an existing entry
   flush();
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -117,7 +117,7 @@
 // require that local 0 is never overwritten so it's available as an
 // argument for registration.
 
-void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) {
+void Rewriter::rewrite_Object_init(const methodHandle& method, TRAPS) {
   RawBytecodeStream bcs(method);
   while (!bcs.is_last_bytecode()) {
     Bytecodes::Code opcode = bcs.raw_next();
@@ -491,17 +491,16 @@
 }
 
 // After constant pool is created, revisit methods containing jsrs.
-methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) {
+methodHandle Rewriter::rewrite_jsrs(const methodHandle& method, TRAPS) {
   ResourceMark rm(THREAD);
   ResolveOopMapConflicts romc(method);
-  methodHandle original_method = method;
-  method = romc.do_potential_rewrite(CHECK_(methodHandle()));
+  methodHandle new_method = romc.do_potential_rewrite(CHECK_(methodHandle()));
   // Update monitor matching info.
   if (romc.monitor_safe()) {
-    method->set_guaranteed_monitor_matching();
+    new_method->set_guaranteed_monitor_matching();
   }
 
-  return method;
+  return new_method;
 }
 
 void Rewriter::rewrite_bytecodes(TRAPS) {
--- a/hotspot/src/share/vm/interpreter/rewriter.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/interpreter/rewriter.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -193,7 +193,7 @@
   void compute_index_maps();
   void make_constant_pool_cache(TRAPS);
   void scan_method(Method* m, bool reverse, bool* invokespecial_error);
-  void rewrite_Object_init(methodHandle m, TRAPS);
+  void rewrite_Object_init(const methodHandle& m, TRAPS);
   void rewrite_member_reference(address bcp, int offset, bool reverse);
   void maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse);
   void rewrite_invokedynamic(address bcp, int offset, bool reverse);
@@ -208,7 +208,7 @@
   // Revert bytecodes in case of an exception.
   void restore_bytecodes();
 
-  static methodHandle rewrite_jsrs(methodHandle m, TRAPS);
+  static methodHandle rewrite_jsrs(const methodHandle& m, TRAPS);
  public:
   // Driver routine:
   static void rewrite(InstanceKlass* klass, TRAPS);
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -194,7 +194,7 @@
   }
 }
 
-CompLevel JVMCIRuntime::adjust_comp_level(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) {
+CompLevel JVMCIRuntime::adjust_comp_level(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread) {
   if (!thread->adjusting_comp_level()) {
     thread->set_adjusting_comp_level(true);
     level = adjust_comp_level_inner(method, is_osr, level, thread);
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -822,7 +822,7 @@
   }
 }
 
-CompLevel JVMCIRuntime::adjust_comp_level_inner(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) {
+CompLevel JVMCIRuntime::adjust_comp_level_inner(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread) {
   JVMCICompiler* compiler = JVMCICompiler::instance(thread);
   if (compiler != NULL && compiler->is_bootstrapping()) {
     return level;
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -63,7 +63,7 @@
 
   static bool _shutdown_called;
 
-  static CompLevel adjust_comp_level_inner(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread);
+  static CompLevel adjust_comp_level_inner(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread);
 
  public:
   static bool is_HotSpotJVMCIRuntime_initialized() {
@@ -125,7 +125,7 @@
    * @param thread the current thread
    * @return the compilation level to use for the compilation
    */
-  static CompLevel adjust_comp_level(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread);
+  static CompLevel adjust_comp_level(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread);
 
   static BasicType kindToBasicType(Handle kind, TRAPS);
 
--- a/hotspot/src/share/vm/oops/cpCache.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/cpCache.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -139,7 +139,7 @@
 }
 
 void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_code,
-                                                       methodHandle method,
+                                                       const methodHandle& method,
                                                        int vtable_index,
                                                        bool sender_is_interface) {
   bool is_vtable_call = (vtable_index >= 0);  // FIXME: split this method on this boolean
@@ -241,14 +241,14 @@
   NOT_PRODUCT(verify(tty));
 }
 
-void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method,
+void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, const methodHandle& method,
                                              bool sender_is_interface) {
   int index = Method::nonvirtual_vtable_index;
   // index < 0; FIXME: inline and customize set_direct_or_vtable_call
   set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
 }
 
-void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, methodHandle method, int index) {
+void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, const methodHandle& method, int index) {
   // either the method is a miranda or its holder should accept the given index
   assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
   // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
--- a/hotspot/src/share/vm/oops/cpCache.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/cpCache.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -222,7 +222,7 @@
     int             orig_field_index,            // the original field index in the field holder
     int             field_offset,                // the field offset in words in the field holder
     TosState        field_type,                  // the (machine) field type
-    bool            is_final,                     // the field is final
+    bool            is_final,                    // the field is final
     bool            is_volatile,                 // the field is volatile
     Klass*          root_klass                   // needed by the GC to dirty the klass
   );
@@ -230,7 +230,7 @@
  private:
   void set_direct_or_vtable_call(
     Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
-    methodHandle    method,                      // the method/prototype if any (NULL, otherwise)
+    const methodHandle& method,                  // the method/prototype if any (NULL, otherwise)
     int             vtable_index,                // the vtable index if any, else negative
     bool            sender_is_interface
   );
@@ -238,13 +238,13 @@
  public:
   void set_direct_call(                          // sets entry to exact concrete method entry
     Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
-    methodHandle    method,                      // the method to call
+    const methodHandle& method,                  // the method to call
     bool            sender_is_interface
   );
 
   void set_vtable_call(                          // sets entry to vtable index
     Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
-    methodHandle    method,                      // resolved method which declares the vtable index
+    const methodHandle& method,                  // resolved method which declares the vtable index
     int             vtable_index                 // the vtable index
   );
 
--- a/hotspot/src/share/vm/oops/klassVtable.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -287,7 +287,7 @@
 // Therefore: all package private methods need their own vtable entries for
 // them to be the root of an inheritance overriding decision
 // Package private methods may also override other vtable entries
-InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
+InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, const methodHandle& target_method,
                             int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
   InstanceKlass* superk = initialsuper;
   while (superk != NULL && superk->super() != NULL) {
@@ -329,7 +329,7 @@
   return superk;
 }
 
-static void log_vtables(int i, bool overrides, methodHandle target_method,
+static void log_vtables(int i, bool overrides, const methodHandle& target_method,
                         Klass* target_klass, Method* super_method,
                         Thread* thread) {
 #ifndef PRODUCT
@@ -357,7 +357,7 @@
 // OR return true if a new vtable entry is required.
 // Only called for InstanceKlass's, i.e. not for arrays
 // If that changed, could not use _klass as handle for klass
-bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
+bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHandle& target_method,
                                           int super_vtable_len, int default_index,
                                           bool checkconstraints, TRAPS) {
   ResourceMark rm;
@@ -576,7 +576,7 @@
 // superclass has been loaded.
 // However, the vtable entries are filled in at link time, and therefore
 // the superclass' vtable may not yet have been filled in.
-bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
+bool klassVtable::needs_new_vtable_entry(const methodHandle& target_method,
                                          const Klass* super,
                                          Handle classloader,
                                          Symbol* classname,
--- a/hotspot/src/share/vm/oops/klassVtable.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/klassVtable.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -128,7 +128,7 @@
   int  initialize_from_super(Klass* super);
   int  index_of(Method* m, int len) const; // same as index_of, but search only up to len
   void put_method_at(Method* m, int index);
-  static bool needs_new_vtable_entry(methodHandle m,
+  static bool needs_new_vtable_entry(const methodHandle& m,
                                      const Klass* super,
                                      Handle classloader,
                                      Symbol* classname,
@@ -136,8 +136,8 @@
                                      u2 major_version,
                                      TRAPS);
 
-  bool update_inherited_vtable(InstanceKlass* klass, methodHandle target_method, int super_vtable_len, int default_index, bool checkconstraints, TRAPS);
- InstanceKlass* find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method, int vtable_index,
+  bool update_inherited_vtable(InstanceKlass* klass, const methodHandle& target_method, int super_vtable_len, int default_index, bool checkconstraints, TRAPS);
+ InstanceKlass* find_transitive_override(InstanceKlass* initialsuper, const methodHandle& target_method, int vtable_index,
                                          Handle target_loader, Symbol* target_classname, Thread* THREAD);
 
   // support for miranda methods
--- a/hotspot/src/share/vm/oops/method.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/method.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -175,7 +175,7 @@
   return buf;
 }
 
-int Method::fast_exception_handler_bci_for(methodHandle mh, Klass* ex_klass, int throw_bci, TRAPS) {
+int Method::fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_klass, int throw_bci, TRAPS) {
   // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
   // access exception table
   ExceptionTable table(mh());
@@ -1078,7 +1078,7 @@
 
 }
 
-address Method::make_adapters(methodHandle mh, TRAPS) {
+address Method::make_adapters(const methodHandle& mh, TRAPS) {
   // Adapters for compiled code are made eagerly here.  They are fairly
   // small (generally < 100 bytes) and quick to make (and cached and shared)
   // so making them eagerly shouldn't be too expensive.
@@ -1147,7 +1147,7 @@
 }
 
 // Install compiled code.  Instantly it can execute.
-void Method::set_code(methodHandle mh, CompiledMethod *code) {
+void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
   MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
   assert( code, "use clear_code to remove code" );
   assert( mh->check_code(), "" );
@@ -1350,7 +1350,7 @@
 }
 
 
-methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
+methodHandle Method::clone_with_new_data(const methodHandle& m, u_char* new_code, int new_code_length,
                                                 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) {
   // Code below does not work for native methods - they should never get rewritten anyway
   assert(!m->is_native(), "cannot rewrite native methods");
@@ -1545,7 +1545,7 @@
 }
 
 // These two methods are static since a GC may move the Method
-bool Method::load_signature_classes(methodHandle m, TRAPS) {
+bool Method::load_signature_classes(const methodHandle& m, TRAPS) {
   if (!THREAD->can_call_java()) {
     // There is nothing useful this routine can do from within the Compile thread.
     // Hopefully, the signature contains only well-known classes.
@@ -1579,7 +1579,7 @@
   return sig_is_loaded;
 }
 
-bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
+bool Method::has_unloaded_classes_in_signature(const methodHandle& m, TRAPS) {
   Handle class_loader(THREAD, m->method_holder()->class_loader());
   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
   ResourceMark rm(THREAD);
--- a/hotspot/src/share/vm/oops/method.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/method.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -133,7 +133,7 @@
   void set_constMethod(ConstMethod* xconst)    { _constMethod = xconst; }
 
 
-  static address make_adapters(methodHandle mh, TRAPS);
+  static address make_adapters(const methodHandle& mh, TRAPS);
   volatile address from_compiled_entry() const   { return (address)OrderAccess::load_ptr_acquire(&_from_compiled_entry); }
   volatile address from_compiled_entry_no_trampoline() const;
   volatile address from_interpreted_entry() const{ return (address)OrderAccess::load_ptr_acquire(&_from_interpreted_entry); }
@@ -324,7 +324,7 @@
   // exception handler which caused the exception to be thrown, which
   // is needed for proper retries. See, for example,
   // InterpreterRuntime::exception_handler_for_exception.
-  static int fast_exception_handler_bci_for(methodHandle mh, Klass* ex_klass, int throw_bci, TRAPS);
+  static int fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_klass, int throw_bci, TRAPS);
 
   // method data access
   MethodData* method_data() const              {
@@ -452,7 +452,7 @@
   bool check_code() const;      // Not inline to avoid circular ref
   CompiledMethod* volatile code() const                 { assert( check_code(), "" ); return (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); }
   void clear_code(bool acquire_lock = true);    // Clear out any compiled code
-  static void set_code(methodHandle mh, CompiledMethod* code);
+  static void set_code(const methodHandle& mh, CompiledMethod* code);
   void set_adapter_entry(AdapterHandlerEntry* adapter) {
     constMethod()->set_adapter_entry(adapter);
   }
@@ -776,7 +776,7 @@
   void set_is_prefixed_native()                     { _access_flags.set_is_prefixed_native(); }
 
   // Rewriting support
-  static methodHandle clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
+  static methodHandle clone_with_new_data(const methodHandle& m, u_char* new_code, int new_code_length,
                                           u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS);
 
   // jmethodID handling
@@ -954,10 +954,10 @@
   void clear_queued_for_compilation()  { _access_flags.clear_queued_for_compilation();   }
 
   // Resolve all classes in signature, return 'true' if successful
-  static bool load_signature_classes(methodHandle m, TRAPS);
+  static bool load_signature_classes(const methodHandle& m, TRAPS);
 
   // Return if true if not all classes references in signature, including return type, has been loaded
-  static bool has_unloaded_classes_in_signature(methodHandle m, TRAPS);
+  static bool has_unloaded_classes_in_signature(const methodHandle& m, TRAPS);
 
   // Printing
   void print_short_name(outputStream* st = tty); // prints as klassname::methodname; Exposed so field engineers can debug VM
--- a/hotspot/src/share/vm/oops/methodCounters.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/methodCounters.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 #include "oops/methodCounters.hpp"
 #include "runtime/handles.inline.hpp"
 
-MethodCounters* MethodCounters::allocate(methodHandle mh, TRAPS) {
+MethodCounters* MethodCounters::allocate(const methodHandle& mh, TRAPS) {
   ClassLoaderData* loader_data = mh->method_holder()->class_loader_data();
   return new(loader_data, size(), false, MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh);
 }
--- a/hotspot/src/share/vm/oops/methodCounters.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/oops/methodCounters.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
   u1                _highest_osr_comp_level;      // Same for OSR level
 #endif
 
-  MethodCounters(methodHandle mh) :
+  MethodCounters(const methodHandle& mh) :
 #if INCLUDE_AOT
                                     _method(mh()),
 #endif
@@ -112,7 +112,7 @@
  public:
   virtual bool is_methodCounters() const volatile { return true; }
 
-  static MethodCounters* allocate(methodHandle mh, TRAPS);
+  static MethodCounters* allocate(const methodHandle& mh, TRAPS);
 
   void deallocate_contents(ClassLoaderData* loader_data) {}
 
--- a/hotspot/src/share/vm/prims/jvm.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1686,7 +1686,7 @@
   return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.type_annotations(), THREAD));
 JVM_END
 
-static void bounds_check(constantPoolHandle cp, jint index, TRAPS) {
+static void bounds_check(const constantPoolHandle& cp, jint index, TRAPS) {
   if (!cp->is_within_bounds(index)) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds");
   }
@@ -1794,7 +1794,7 @@
 }
 JVM_END
 
-static bool select_method(methodHandle method, bool want_constructor) {
+static bool select_method(const methodHandle& method, bool want_constructor) {
   if (want_constructor) {
     return (method->is_initializer() && !method->is_static());
   } else {
@@ -1963,7 +1963,7 @@
 }
 JVM_END
 
-static jobject get_method_at_helper(constantPoolHandle cp, jint index, bool force_resolution, TRAPS) {
+static jobject get_method_at_helper(const constantPoolHandle& cp, jint index, bool force_resolution, TRAPS) {
   constantTag tag = cp->tag_at(index);
   if (!tag.is_method() && !tag.is_interface_method()) {
     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -195,7 +195,7 @@
 
   jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); }
 
-  jmethodID to_jmethodID(methodHandle method) { return method->jmethod_id(); }
+  jmethodID to_jmethodID(const methodHandle& method) { return method->jmethod_id(); }
 
   JNIEnv* jni_env() { return _jni_env; }
 };
@@ -229,7 +229,7 @@
   jmethodID _mid;
 
 public:
-  JvmtiMethodEventMark(JavaThread *thread, methodHandle method) :
+  JvmtiMethodEventMark(JavaThread *thread, const methodHandle& method) :
     JvmtiThreadEventMark(thread),
     _mid(to_jmethodID(method)) {};
   jmethodID jni_methodID() { return _mid; }
@@ -240,7 +240,7 @@
   jlocation _loc;
 
 public:
-  JvmtiLocationEventMark(JavaThread *thread, methodHandle method, address location) :
+  JvmtiLocationEventMark(JavaThread *thread, const methodHandle& method, address location) :
     JvmtiMethodEventMark(thread, method),
     _loc(location - method->code_base()) {};
   jlocation location() { return _loc; }
@@ -251,7 +251,7 @@
   jobject _exc;
 
 public:
-  JvmtiExceptionEventMark(JavaThread *thread, methodHandle method, address location, Handle exception) :
+  JvmtiExceptionEventMark(JavaThread *thread, const methodHandle& method, address location, Handle exception) :
     JvmtiLocationEventMark(thread, method, location),
     _exc(to_jobject(exception())) {};
   jobject exception() { return _exc; }
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -32,7 +32,7 @@
 
 #ifdef TIERED
 // Print an event.
-void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh,
+void AdvancedThresholdPolicy::print_specific(EventType type, const methodHandle& mh, const methodHandle& imh,
                                              int bci, CompLevel level) {
   tty->print(" rate=");
   if (mh->prev_time() == 0) tty->print("n/a");
@@ -339,7 +339,7 @@
 }
 
 // Create MDO if necessary.
-void AdvancedThresholdPolicy::create_mdo(methodHandle mh, JavaThread* THREAD) {
+void AdvancedThresholdPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) {
   if (mh->is_native() ||
       mh->is_abstract() ||
       mh->is_accessor() ||
@@ -546,7 +546,7 @@
   CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread);
 }
 
-bool AdvancedThresholdPolicy::maybe_switch_to_aot(methodHandle mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) {
+bool AdvancedThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) {
   if (UseAOT && !delay_compilation_during_startup()) {
     if (cur_level == CompLevel_full_profile || cur_level == CompLevel_none) {
       // If the current level is full profile or interpreter and we're switching to any other level,
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,16 +199,16 @@
   // determines whether we should do that.
   inline bool should_create_mdo(Method* method, CompLevel cur_level);
   // Create MDO if necessary.
-  void create_mdo(methodHandle mh, JavaThread* thread);
+  void create_mdo(const methodHandle& mh, JavaThread* thread);
   // Is method profiled enough?
   bool is_method_profiled(Method* method);
 
   double _increase_threshold_at_ratio;
 
-  bool maybe_switch_to_aot(methodHandle mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread);
+  bool maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread);
 
 protected:
-  void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
+  void print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level);
 
   void set_increase_threshold_at_ratio() { _increase_threshold_at_ratio = 100 / (100 - (double)IncreaseFirstTierCompileThresholdAt); }
   void set_start_time(jlong t) { _start_time = t;    }
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
 // Returns true if m must be compiled before executing it
 // This is intended to force compiles for methods (usually for
 // debugging) that would otherwise be interpreted for some reason.
-bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) {
+bool CompilationPolicy::must_be_compiled(const methodHandle& m, int comp_level) {
   // Don't allow Xcomp to cause compiles in replay mode
   if (ReplayCompiles) return false;
 
@@ -107,7 +107,7 @@
          (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods
 }
 
-void CompilationPolicy::compile_if_required(methodHandle selected_method, TRAPS) {
+void CompilationPolicy::compile_if_required(const methodHandle& selected_method, TRAPS) {
   if (must_be_compiled(selected_method)) {
     // This path is unusual, mostly used by the '-Xcomp' stress test mode.
 
@@ -135,7 +135,7 @@
 }
 
 // Returns true if m is allowed to be compiled
-bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) {
+bool CompilationPolicy::can_be_compiled(const methodHandle& m, int comp_level) {
   // allow any levels for WhiteBox
   assert(WhiteBoxAPI || comp_level == CompLevel_all || is_compile(comp_level), "illegal compilation level");
 
@@ -166,7 +166,7 @@
 }
 
 // Returns true if m is allowed to be osr compiled
-bool CompilationPolicy::can_be_osr_compiled(methodHandle m, int comp_level) {
+bool CompilationPolicy::can_be_osr_compiled(const methodHandle& m, int comp_level) {
   bool result = false;
   if (comp_level == CompLevel_all) {
     if (TieredCompilation) {
--- a/hotspot/src/share/vm/runtime/compilationPolicy.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
   static bool               _in_vm_startup;
 
   // m must be compiled before executing it
-  static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
+  static bool must_be_compiled(const methodHandle& m, int comp_level = CompLevel_all);
 
 public:
   static  void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
@@ -54,12 +54,12 @@
 
   // If m must_be_compiled then request a compilation from the CompileBroker.
   // This supports the -Xcomp option.
-  static void compile_if_required(methodHandle m, TRAPS);
+  static void compile_if_required(const methodHandle& m, TRAPS);
 
   // m is allowed to be compiled
-  static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
+  static bool can_be_compiled(const methodHandle& m, int comp_level = CompLevel_all);
   // m is allowed to be osr compiled
-  static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all);
+  static bool can_be_osr_compiled(const methodHandle& m, int comp_level = CompLevel_all);
   static bool is_compilation_enabled();
   static void set_policy(CompilationPolicy* policy) { _policy = policy; }
   static CompilationPolicy* policy()                { return _policy; }
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1408,7 +1408,7 @@
 JRT_END
 
 MethodData*
-Deoptimization::get_method_data(JavaThread* thread, methodHandle m,
+Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m,
                                 bool create_if_missing) {
   Thread* THREAD = thread;
   MethodData* mdo = m()->method_data();
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -417,7 +417,7 @@
   // returning to a deoptimized caller
   static void popframe_preserve_args(JavaThread* thread, int bytes_to_save, void* start_address);
 
-  static MethodData* get_method_data(JavaThread* thread, methodHandle m, bool create_if_missing);
+  static MethodData* get_method_data(JavaThread* thread, const methodHandle& m, bool create_if_missing);
  private:
   // Update the mdo's count and per-BCI reason bits, returning previous state:
   static ProfileData* query_update_method_data(MethodData* trap_mdo,
--- a/hotspot/src/share/vm/runtime/javaCalls.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/javaCalls.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -49,7 +49,7 @@
 // -----------------------------------------------------
 // Implementation of JavaCallWrapper
 
-JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
+JavaCallWrapper::JavaCallWrapper(const methodHandle& callee_method, Handle receiver, JavaValue* result, TRAPS) {
   JavaThread* thread = (JavaThread *)THREAD;
   bool clear_pending_exception = true;
 
--- a/hotspot/src/share/vm/runtime/javaCalls.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/javaCalls.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -53,7 +53,7 @@
 
  public:
   // Construction/destruction
-   JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS);
+   JavaCallWrapper(const methodHandle& callee_method, Handle receiver, JavaValue* result, TRAPS);
   ~JavaCallWrapper();
 
   // Accessors
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -762,7 +762,7 @@
 }
 
 // Utility method converting a single SignatureStream element into java.lang.Class instance
-static oop get_mirror_from_signature(methodHandle method,
+static oop get_mirror_from_signature(const methodHandle& method,
                                      SignatureStream* ss,
                                      TRAPS) {
 
@@ -788,7 +788,7 @@
   return java_lang_Class::primitive_mirror(ss->type());
 }
 
-static objArrayHandle get_parameter_types(methodHandle method,
+static objArrayHandle get_parameter_types(const methodHandle& method,
                                           int parameter_count,
                                           oop* return_type,
                                           TRAPS) {
@@ -814,7 +814,7 @@
   return mirrors;
 }
 
-static objArrayHandle get_exception_types(methodHandle method, TRAPS) {
+static objArrayHandle get_exception_types(const methodHandle& method, TRAPS) {
   return method->resolved_checked_exceptions(THREAD);
 }
 
@@ -1052,7 +1052,7 @@
 
 // Method call (shared by invoke_method and invoke_constructor)
 static oop invoke(InstanceKlass* klass,
-                  methodHandle reflected_method,
+                  const methodHandle& reflected_method,
                   Handle receiver,
                   bool override,
                   objArrayHandle ptypes,
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -357,7 +357,7 @@
 
 #if defined(X86) && defined(COMPILER1)
   // For Object.hashCode, System.identityHashCode try to pull hashCode from object header if available.
-  static void inline_check_hashcode_from_object_header(MacroAssembler* masm, methodHandle method, Register obj_reg, Register result);
+  static void inline_check_hashcode_from_object_header(MacroAssembler* masm, const methodHandle& method, Register obj_reg, Register result);
 #endif // X86 && COMPILER1
 
  public:
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -35,7 +35,7 @@
 
 #ifdef TIERED
 
-void SimpleThresholdPolicy::print_counters(const char* prefix, methodHandle mh) {
+void SimpleThresholdPolicy::print_counters(const char* prefix, const methodHandle& mh) {
   int invocation_count = mh->invocation_count();
   int backedge_count = mh->backedge_count();
   MethodData* mdh = mh->method_data();
@@ -56,7 +56,7 @@
 }
 
 // Print an event.
-void SimpleThresholdPolicy::print_event(EventType type, methodHandle mh, methodHandle imh,
+void SimpleThresholdPolicy::print_event(EventType type, const methodHandle& mh, const methodHandle& imh,
                                         int bci, CompLevel level) {
   bool inlinee_event = mh() != imh();
 
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
   // loop_event checks if a method should be OSR compiled at a different
   // level.
   CompLevel loop_event(Method* method, CompLevel cur_level, JavaThread* thread);
-  void print_counters(const char* prefix, methodHandle mh);
+  void print_counters(const char* prefix, const methodHandle& mh);
 protected:
   int c1_count() const     { return _c1_count; }
   int c2_count() const     { return _c2_count; }
@@ -65,9 +65,9 @@
   void set_c2_count(int x) { _c2_count = x;    }
 
   enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT };
-  void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
+  void print_event(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level);
   // Print policy-specific information if necessary
-  virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { }
+  virtual void print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level) { }
   // Check if the method can be compiled, change level if necessary
   void compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
   // Submit a given method for compilation
--- a/hotspot/src/share/vm/utilities/xmlstream.cpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/utilities/xmlstream.cpp	Thu Jul 27 18:06:41 2017 -0400
@@ -380,7 +380,7 @@
 // ------------------------------------------------------------------
 // Output a method attribute, in the form " method='pkg/cls name sig'".
 // This is used only when there is no ciMethod available.
-void xmlStream::method(methodHandle method) {
+void xmlStream::method(const methodHandle& method) {
   assert_if_no_error(inside_attrs(), "printing attributes");
   if (method.is_null())  return;
   print_raw(" method='");
@@ -408,7 +408,7 @@
   }
 }
 
-void xmlStream::method_text(methodHandle method) {
+void xmlStream::method_text(const methodHandle& method) {
   ResourceMark rm;
   assert_if_no_error(inside_attrs(), "printing attributes");
   if (method.is_null())  return;
--- a/hotspot/src/share/vm/utilities/xmlstream.hpp	Thu Jul 27 15:36:15 2017 +0200
+++ b/hotspot/src/share/vm/utilities/xmlstream.hpp	Thu Jul 27 18:06:41 2017 -0400
@@ -137,14 +137,14 @@
 
   // commonly used XML attributes
   void          stamp();                 // stamp='1.234'
-  void          method(methodHandle m);  // method='k n s' ...
+  void          method(const methodHandle& m);  // method='k n s' ...
   void          klass(Klass* k);         // klass='name'
   void          name(const Symbol* s);   // name='name'
   void          object(const char* attr, Metadata* val);
   void          object(const char* attr, Handle val);
 
   // print the text alone (sans ''):
-  void          method_text(methodHandle m);
+  void          method_text(const methodHandle& m);
   void          klass_text(Klass* k);         // klass='name'
   void          name_text(const Symbol* s);   // name='name'
   void          object_text(Metadata* x);