changeset 8493:9deaba76a094

Merge
author asaha
date Tue, 21 Mar 2017 12:20:10 -0700
parents a6c90d8e1900 36ef3df5edd0
children c4026db66abe 77e13f15e396
files .hgtags src/os/linux/vm/os_linux.cpp src/share/vm/prims/methodHandles.cpp
diffstat 9 files changed, 62 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Mar 21 12:11:02 2017 -0700
+++ b/.hgtags	Tue Mar 21 12:20:10 2017 -0700
@@ -949,6 +949,10 @@
 90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13
 351bf1d4ff9a41137f91e2ec97ec59ed29a38d8b jdk8u121-b31
 41daac438a2ac5a80755dc3de88b76e4ac66750a jdk8u121-b32
+eb9e617d6f64d4ad689feac0707b5e4335b00ce2 jdk8u121-b33
+c60b0994e8eee152666252c3ba4105db65c004db jdk8u121-b34
+0612a789929b88612509668bea4b3138613e91e4 jdk8u121-b35
+0ea269e49511a890e6fabfd468638dd1c0ed0be3 jdk8u121-b36
 c0a1ba0df20fda10ddb8599e888eb56ad98b3874 jdk8u131-b00
 0b85ccd6240991e1a501602ff5addec6b88ae0af jdk8u131-b01
 ef90c721a4e59b01ca36f25619010a1afe9ed4d5 jdk8u131-b02
--- a/src/os/linux/vm/os_linux.cpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/os/linux/vm/os_linux.cpp	Tue Mar 21 12:20:10 2017 -0700
@@ -2859,7 +2859,7 @@
                               // in the library.
   const size_t BitsPerCLong = sizeof(long) * CHAR_BIT;
 
-  size_t cpu_num = os::active_processor_count();
+  size_t cpu_num = processor_count();
   size_t cpu_map_size = NCPUS / BitsPerCLong;
   size_t cpu_map_valid_size =
     MIN2((cpu_num + BitsPerCLong - 1) / BitsPerCLong, cpu_map_size);
--- a/src/share/vm/classfile/javaClasses.cpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/classfile/javaClasses.cpp	Tue Mar 21 12:20:10 2017 -0700
@@ -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
@@ -2852,6 +2852,15 @@
   mname->address_field_put(_vmindex_offset, (address) index);
 }
 
+bool java_lang_invoke_MemberName::equals(oop mn1, oop mn2) {
+  if (mn1 == mn2) {
+     return true;
+  }
+  return (vmtarget(mn1) == vmtarget(mn2) && flags(mn1) == flags(mn2) &&
+          vmindex(mn1) == vmindex(mn2) &&
+          clazz(mn1) == clazz(mn2));
+}
+
 oop java_lang_invoke_LambdaForm::vmentry(oop lform) {
   assert(is_instance(lform), "wrong type");
   return lform->obj_field(_vmentry_offset);
--- a/src/share/vm/classfile/javaClasses.hpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/classfile/javaClasses.hpp	Tue Mar 21 12:20:10 2017 -0700
@@ -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
@@ -1132,6 +1132,8 @@
   static int flags_offset_in_bytes()            { return _flags_offset; }
   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
+
+  static bool equals(oop mt1, oop mt2);
 };
 
 
--- a/src/share/vm/oops/instanceKlass.cpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/oops/instanceKlass.cpp	Tue Mar 21 12:20:10 2017 -0700
@@ -3018,7 +3018,7 @@
   return NULL;
 }
 
-bool InstanceKlass::add_member_name(Handle mem_name) {
+oop InstanceKlass::add_member_name(Handle mem_name, bool intern) {
   jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
   MutexLocker ml(MemberNameTable_lock);
   DEBUG_ONLY(No_Safepoint_Verifier nsv);
@@ -3028,7 +3028,7 @@
   // is called!
   Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name());
   if (method->is_obsolete()) {
-    return false;
+    return NULL;
   } else if (method->is_old()) {
     // Replace method with redefined version
     java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum()));
@@ -3037,8 +3037,11 @@
   if (_member_names == NULL) {
     _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
   }
-  _member_names->add_member_name(mem_name_wref);
-  return true;
+  if (intern) {
+    return _member_names->find_or_add_member_name(mem_name_wref);
+  } else {
+    return _member_names->add_member_name(mem_name_wref);
+  }
 }
 
 // -----------------------------------------------------------------------------------------------------
--- a/src/share/vm/oops/instanceKlass.hpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/oops/instanceKlass.hpp	Tue Mar 21 12:20:10 2017 -0700
@@ -1105,7 +1105,7 @@
   // JSR-292 support
   MemberNameTable* member_names() { return _member_names; }
   void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
-  bool add_member_name(Handle member_name);
+  oop add_member_name(Handle member_name, bool intern);
 
 public:
   // JVMTI support
--- a/src/share/vm/prims/jvm.cpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/prims/jvm.cpp	Tue Mar 21 12:20:10 2017 -0700
@@ -643,7 +643,7 @@
       // This can safepoint and redefine method, so need both new_obj and method
       // in a handle, for two different reasons.  new_obj can move, method can be
       // deleted if nothing is using it on the stack.
-      m->method_holder()->add_member_name(new_obj());
+      m->method_holder()->add_member_name(new_obj(), false);
     }
   }
 
--- a/src/share/vm/prims/methodHandles.cpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/prims/methodHandles.cpp	Tue Mar 21 12:20:10 2017 -0700
@@ -173,7 +173,7 @@
   return NULL;
 }
 
-oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
+oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, bool intern) {
   assert(info.resolved_appendix().is_null(), "only normal methods here");
   methodHandle m = info.resolved_method();
   KlassHandle m_klass = m->method_holder();
@@ -270,13 +270,7 @@
   // If relevant, the vtable or itable value is stored as vmindex.
   // This is done eagerly, since it is readily available without
   // constructing any new objects.
-  // TO DO: maybe intern mname_oop
-  if (m->method_holder()->add_member_name(mname)) {
-    return mname();
-  } else {
-    // Redefinition caused this to fail.  Return NULL (and an exception?)
-    return NULL;
-  }
+  return m->method_holder()->add_member_name(mname, intern);
 }
 
 oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) {
@@ -917,7 +911,9 @@
         if (!java_lang_invoke_MemberName::is_instance(result()))
           return -99;  // caller bug!
         CallInfo info(m);
-        oop saved = MethodHandles::init_method_MemberName(result, info);
+        // Since this is going through the methods to create MemberNames, don't search
+        // for matching methods already in the table
+        oop saved = MethodHandles::init_method_MemberName(result, info, /*intern*/false);
         if (saved != result())
           results->obj_at_put(rfill-1, saved);  // show saved instance to user
       } else if (++overflow >= overflow_limit) {
@@ -949,9 +945,34 @@
   }
 }
 
-void MemberNameTable::add_member_name(jweak mem_name_wref) {
+oop MemberNameTable::add_member_name(jweak mem_name_wref) {
   assert_locked_or_safepoint(MemberNameTable_lock);
   this->push(mem_name_wref);
+  return JNIHandles::resolve(mem_name_wref);
+}
+
+oop MemberNameTable::find_or_add_member_name(jweak mem_name_wref) {
+  assert_locked_or_safepoint(MemberNameTable_lock);
+  oop new_mem_name = JNIHandles::resolve(mem_name_wref);
+
+  // Find matching member name in the list.
+  // This is linear because these are short lists.
+  int len = this->length();
+  int new_index = len;
+  for (int idx = 0; idx < len; idx++) {
+    oop mname = JNIHandles::resolve(this->at(idx));
+    if (mname == NULL) {
+      new_index = idx;
+      continue;
+    }
+    if (java_lang_invoke_MemberName::equals(new_mem_name, mname)) {
+      JNIHandles::destroy_weak_global(mem_name_wref);
+      return mname;
+    }
+  }
+  // Not found, push the new one, or reuse empty slot
+  this->at_put_grow(new_index, mem_name_wref);
+  return new_mem_name;
 }
 
 #if INCLUDE_JVMTI
--- a/src/share/vm/prims/methodHandles.hpp	Tue Mar 21 12:11:02 2017 -0700
+++ b/src/share/vm/prims/methodHandles.hpp	Tue Mar 21 12:20:10 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2014, 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
@@ -60,7 +60,7 @@
   static Handle new_MemberName(TRAPS);  // must be followed by init_MemberName
   static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target
   static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false);
-  static oop init_method_MemberName(Handle mname_h, CallInfo& info);
+  static oop init_method_MemberName(Handle mname_h, CallInfo& info, bool intern = true);
   static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true);
   static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig,
                               int mflags, KlassHandle caller,
@@ -236,7 +236,8 @@
  public:
   MemberNameTable(int methods_cnt);
   ~MemberNameTable();
-  void add_member_name(jweak mem_name_ref);
+  oop add_member_name(jweak mem_name_ref);
+  oop find_or_add_member_name(jweak mem_name_ref);
 
 #if INCLUDE_JVMTI
   // RedefineClasses() API support: