Merge

Wed, 07 Feb 2018 13:41:55 -0800

author
asaha
date
Wed, 07 Feb 2018 13:41:55 -0800
changeset 9372
84c22f340c4c
parent 9369
92df9fb273c4
parent 9102
7de5129bb8e6
child 9376
012197c66a78

Merge

.hgtags file | annotate | diff | comparison | revisions
src/share/vm/oops/klass.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Tue Jan 30 15:37:04 2018 -0800
     1.2 +++ b/.hgtags	Wed Feb 07 13:41:55 2018 -0800
     1.3 @@ -1137,8 +1137,10 @@
     1.4  1acd7c1b80241def8fac90f70b0df16356adad47 jdk8u171-b02
     1.5  5587cde50bbc2aa031aefb47eaa36b041f5e7c4b jdk8u171-b03
     1.6  99ef466523302cfbd00496cf6575a00c8637b884 jdk8u171-b04
     1.7 +08326a76b14888908523cf2bb1105de63b43544d jdk8u171-b05
     1.8  f299cf0b7baea1ae85f139f97adb9ab5499f402a jdk8u172-b00
     1.9  d10254debf7c1342416062bf1ba5258f16a8ce00 jdk8u172-b01
    1.10  653d9e0cd3f4023675c9eece7f0d563287f1d34f jdk8u172-b02
    1.11  771d9e1fbe1ae2ec4d5d937ebcbfd18e9c800098 jdk8u172-b03
    1.12  efd7a4e211e8fddf52053d4b033d8d307f356bc3 jdk8u172-b04
    1.13 +4235fb1dceebde1192498ef388a32e56b1ed5a46 jdk8u172-b05
     2.1 --- a/src/share/vm/classfile/javaClasses.cpp	Tue Jan 30 15:37:04 2018 -0800
     2.2 +++ b/src/share/vm/classfile/javaClasses.cpp	Wed Feb 07 13:41:55 2018 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -2679,6 +2679,32 @@
    2.11    *offset = value;
    2.12  }
    2.13  
    2.14 +// Support for java_lang_ref_ReferenceQueue
    2.15 +
    2.16 +oop java_lang_ref_ReferenceQueue::NULL_queue() {
    2.17 +  InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::ReferenceQueue_klass());
    2.18 +  oop mirror = ik->java_mirror();
    2.19 +  return mirror->obj_field(static_NULL_queue_offset);
    2.20 +}
    2.21 +
    2.22 +oop java_lang_ref_ReferenceQueue::ENQUEUED_queue() {
    2.23 +  InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::ReferenceQueue_klass());
    2.24 +  oop mirror = ik->java_mirror();
    2.25 +  return mirror->obj_field(static_ENQUEUED_queue_offset);
    2.26 +}
    2.27 +
    2.28 +void java_lang_ref_ReferenceQueue::compute_offsets() {
    2.29 +  Klass* k = SystemDictionary::ReferenceQueue_klass();
    2.30 +  compute_offset(static_NULL_queue_offset,
    2.31 +                 k,
    2.32 +                 vmSymbols::referencequeue_null_name(),
    2.33 +                 vmSymbols::referencequeue_signature());
    2.34 +  compute_offset(static_ENQUEUED_queue_offset,
    2.35 +                 k,
    2.36 +                 vmSymbols::referencequeue_enqueued_name(),
    2.37 +                 vmSymbols::referencequeue_signature());
    2.38 +}
    2.39 +
    2.40  // Support for java_lang_invoke_DirectMethodHandle
    2.41  
    2.42  int java_lang_invoke_DirectMethodHandle::_member_offset;
    2.43 @@ -3197,6 +3223,8 @@
    2.44  int java_lang_ref_Reference::static_lock_offset;
    2.45  int java_lang_ref_Reference::static_pending_offset;
    2.46  int java_lang_ref_Reference::number_of_fake_oop_fields;
    2.47 +int java_lang_ref_ReferenceQueue::static_NULL_queue_offset;
    2.48 +int java_lang_ref_ReferenceQueue::static_ENQUEUED_queue_offset;
    2.49  int java_lang_ref_SoftReference::timestamp_offset;
    2.50  int java_lang_ref_SoftReference::static_clock_offset;
    2.51  int java_lang_ClassLoader::parent_offset;
    2.52 @@ -3378,6 +3406,8 @@
    2.53    if (JDK_Version::is_jdk18x_version())
    2.54      java_lang_reflect_Parameter::compute_offsets();
    2.55  
    2.56 +  java_lang_ref_ReferenceQueue::compute_offsets();
    2.57 +
    2.58    // generated interpreter code wants to know about the offsets we just computed:
    2.59    AbstractAssembler::update_delayed_values();
    2.60  }
     3.1 --- a/src/share/vm/classfile/javaClasses.hpp	Tue Jan 30 15:37:04 2018 -0800
     3.2 +++ b/src/share/vm/classfile/javaClasses.hpp	Wed Feb 07 13:41:55 2018 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -929,6 +929,12 @@
    3.11    static HeapWord* discovered_addr(oop ref) {
    3.12      return ref->obj_field_addr<HeapWord>(discovered_offset);
    3.13    }
    3.14 +  static inline oop queue(oop ref) {
    3.15 +    return ref->obj_field(queue_offset);
    3.16 +  }
    3.17 +  static inline void set_queue(oop ref, oop value) {
    3.18 +    return ref->obj_field_put(queue_offset, value);
    3.19 +  }
    3.20    // Accessors for statics
    3.21    static oop  pending_list_lock();
    3.22    static oop  pending_list();
    3.23 @@ -962,6 +968,20 @@
    3.24  };
    3.25  
    3.26  
    3.27 +// Interface to java.lang.ref.ReferenceQueue objects
    3.28 +
    3.29 +class java_lang_ref_ReferenceQueue: public AllStatic {
    3.30 +public:
    3.31 +  static int static_NULL_queue_offset;
    3.32 +  static int static_ENQUEUED_queue_offset;
    3.33 +
    3.34 +  // Accessors
    3.35 +  static oop NULL_queue();
    3.36 +  static oop ENQUEUED_queue();
    3.37 +
    3.38 +  static void compute_offsets();
    3.39 +};
    3.40 +
    3.41  // Interface to java.lang.invoke.MethodHandle objects
    3.42  
    3.43  class MethodHandleEntry;
     4.1 --- a/src/share/vm/classfile/systemDictionary.cpp	Tue Jan 30 15:37:04 2018 -0800
     4.2 +++ b/src/share/vm/classfile/systemDictionary.cpp	Wed Feb 07 13:41:55 2018 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -1927,6 +1927,8 @@
    4.11    InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
    4.12    InstanceKlass::cast(WK_KLASS(Cleaner_klass))->set_reference_type(REF_CLEANER);
    4.13  
    4.14 +  initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(ReferenceQueue_klass), scan, CHECK);
    4.15 +
    4.16    // JSR 292 classes
    4.17    WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
    4.18    WKID jsr292_group_end   = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
     5.1 --- a/src/share/vm/classfile/systemDictionary.hpp	Tue Jan 30 15:37:04 2018 -0800
     5.2 +++ b/src/share/vm/classfile/systemDictionary.hpp	Wed Feb 07 13:41:55 2018 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -130,6 +130,7 @@
    5.11    do_klass(PhantomReference_klass,                      java_lang_ref_PhantomReference,            Pre                 ) \
    5.12    do_klass(Cleaner_klass,                               sun_misc_Cleaner,                          Pre                 ) \
    5.13    do_klass(Finalizer_klass,                             java_lang_ref_Finalizer,                   Pre                 ) \
    5.14 +  do_klass(ReferenceQueue_klass,                        java_lang_ref_ReferenceQueue,              Pre                 ) \
    5.15                                                                                                                           \
    5.16    do_klass(Thread_klass,                                java_lang_Thread,                          Pre                 ) \
    5.17    do_klass(ThreadGroup_klass,                           java_lang_ThreadGroup,                     Pre                 ) \
     6.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Tue Jan 30 15:37:04 2018 -0800
     6.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Wed Feb 07 13:41:55 2018 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -81,6 +81,7 @@
    6.11    template(java_lang_ref_PhantomReference,            "java/lang/ref/PhantomReference")           \
    6.12    template(sun_misc_Cleaner,                          "sun/misc/Cleaner")                         \
    6.13    template(java_lang_ref_Finalizer,                   "java/lang/ref/Finalizer")                  \
    6.14 +  template(java_lang_ref_ReferenceQueue,              "java/lang/ref/ReferenceQueue")             \
    6.15    template(java_lang_reflect_AccessibleObject,        "java/lang/reflect/AccessibleObject")       \
    6.16    template(java_lang_reflect_Method,                  "java/lang/reflect/Method")                 \
    6.17    template(java_lang_reflect_Constructor,             "java/lang/reflect/Constructor")            \
    6.18 @@ -417,6 +418,8 @@
    6.19    template(getProtectionDomain_name,                  "getProtectionDomain")                      \
    6.20    template(getProtectionDomain_signature,             "(Ljava/security/CodeSource;)Ljava/security/ProtectionDomain;") \
    6.21    template(url_code_signer_array_void_signature,      "(Ljava/net/URL;[Ljava/security/CodeSigner;)V") \
    6.22 +  template(referencequeue_null_name,                  "NULL")                                     \
    6.23 +  template(referencequeue_enqueued_name,              "ENQUEUED")                                 \
    6.24                                                                                                    \
    6.25    /* non-intrinsic name/signature pairs: */                                                       \
    6.26    template(register_method_name,                      "register")                                 \
    6.27 @@ -508,6 +511,7 @@
    6.28    template(class_signature,                           "Ljava/lang/Class;")                                        \
    6.29    template(string_signature,                          "Ljava/lang/String;")                                       \
    6.30    template(reference_signature,                       "Ljava/lang/ref/Reference;")                                \
    6.31 +  template(referencequeue_signature,                  "Ljava/lang/ref/ReferenceQueue;")                           \
    6.32    template(executable_signature,                      "Ljava/lang/reflect/Executable;")                           \
    6.33    template(concurrenthashmap_signature,               "Ljava/util/concurrent/ConcurrentHashMap;")                 \
    6.34    template(String_StringBuilder_signature,            "(Ljava/lang/String;)Ljava/lang/StringBuilder;")            \
     7.1 --- a/src/share/vm/oops/klass.cpp	Tue Jan 30 15:37:04 2018 -0800
     7.2 +++ b/src/share/vm/oops/klass.cpp	Wed Feb 07 13:41:55 2018 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -48,6 +48,19 @@
    7.11  #include "gc_implementation/parallelScavenge/psScavenge.hpp"
    7.12  #endif // INCLUDE_ALL_GCS
    7.13  
    7.14 +bool Klass::is_cloneable() const {
    7.15 +  return _access_flags.is_cloneable() ||
    7.16 +         is_subtype_of(SystemDictionary::Cloneable_klass());
    7.17 +}
    7.18 +
    7.19 +void Klass::set_is_cloneable() {
    7.20 +  if (oop_is_instance() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {
    7.21 +    // Reference cloning should not be intrinsified and always happen in JVM_Clone.
    7.22 +  } else {
    7.23 +    _access_flags.set_is_cloneable();
    7.24 +  }
    7.25 +}
    7.26 +
    7.27  void Klass::set_name(Symbol* n) {
    7.28    _name = n;
    7.29    if (_name != NULL) _name->increment_refcount();
     8.1 --- a/src/share/vm/oops/klass.hpp	Tue Jan 30 15:37:04 2018 -0800
     8.2 +++ b/src/share/vm/oops/klass.hpp	Wed Feb 07 13:41:55 2018 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -582,8 +582,8 @@
    8.11    bool has_final_method() const         { return _access_flags.has_final_method(); }
    8.12    void set_has_finalizer()              { _access_flags.set_has_finalizer(); }
    8.13    void set_has_final_method()           { _access_flags.set_has_final_method(); }
    8.14 -  bool is_cloneable() const             { return _access_flags.is_cloneable(); }
    8.15 -  void set_is_cloneable()               { _access_flags.set_is_cloneable(); }
    8.16 +  bool is_cloneable() const;
    8.17 +  void set_is_cloneable();
    8.18    bool has_vanilla_constructor() const  { return _access_flags.has_vanilla_constructor(); }
    8.19    void set_has_vanilla_constructor()    { _access_flags.set_has_vanilla_constructor(); }
    8.20    bool has_miranda_methods () const     { return access_flags().has_miranda_methods(); }
     9.1 --- a/src/share/vm/prims/jvm.cpp	Tue Jan 30 15:37:04 2018 -0800
     9.2 +++ b/src/share/vm/prims/jvm.cpp	Wed Feb 07 13:41:55 2018 -0800
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -38,6 +38,7 @@
    9.11  #include "gc_interface/collectedHeap.inline.hpp"
    9.12  #include "interpreter/bytecode.hpp"
    9.13  #include "memory/oopFactory.hpp"
    9.14 +#include "memory/referenceType.hpp"
    9.15  #include "memory/universe.inline.hpp"
    9.16  #include "oops/fieldStreams.hpp"
    9.17  #include "oops/instanceKlass.hpp"
    9.18 @@ -90,6 +91,10 @@
    9.19  # include "jvm_bsd.h"
    9.20  #endif
    9.21  
    9.22 +#if INCLUDE_ALL_GCS
    9.23 +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
    9.24 +#endif // INCLUDE_ALL_GCS
    9.25 +
    9.26  #include <errno.h>
    9.27  
    9.28  #ifndef USDT2
    9.29 @@ -578,6 +583,28 @@
    9.30  JVM_END
    9.31  
    9.32  
    9.33 +static void fixup_cloned_reference(ReferenceType ref_type, oop src, oop clone) {
    9.34 +  // If G1 is enabled then we need to register a non-null referent
    9.35 +  // with the SATB barrier.
    9.36 +#if INCLUDE_ALL_GCS
    9.37 +  if (UseG1GC) {
    9.38 +    oop referent = java_lang_ref_Reference::referent(clone);
    9.39 +    if (referent != NULL) {
    9.40 +      G1SATBCardTableModRefBS::enqueue(referent);
    9.41 +    }
    9.42 +  }
    9.43 +#endif // INCLUDE_ALL_GCS
    9.44 +  if ((java_lang_ref_Reference::next(clone) != NULL) ||
    9.45 +      (java_lang_ref_Reference::queue(clone) == java_lang_ref_ReferenceQueue::ENQUEUED_queue())) {
    9.46 +    // If the source has been enqueued or is being enqueued, don't
    9.47 +    // register the clone with a queue.
    9.48 +    java_lang_ref_Reference::set_queue(clone, java_lang_ref_ReferenceQueue::NULL_queue());
    9.49 +  }
    9.50 +  // discovered and next are list links; the clone is not in those lists.
    9.51 +  java_lang_ref_Reference::set_discovered(clone, NULL);
    9.52 +  java_lang_ref_Reference::set_next(clone, NULL);
    9.53 +}
    9.54 +
    9.55  JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle))
    9.56    JVMWrapper("JVM_Clone");
    9.57    Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
    9.58 @@ -603,12 +630,17 @@
    9.59    }
    9.60  
    9.61    // Make shallow object copy
    9.62 +  ReferenceType ref_type = REF_NONE;
    9.63    const int size = obj->size();
    9.64    oop new_obj_oop = NULL;
    9.65    if (obj->is_array()) {
    9.66      const int length = ((arrayOop)obj())->length();
    9.67      new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
    9.68    } else {
    9.69 +    ref_type = InstanceKlass::cast(klass())->reference_type();
    9.70 +    assert((ref_type == REF_NONE) ==
    9.71 +           !klass->is_subclass_of(SystemDictionary::Reference_klass()),
    9.72 +           "invariant");
    9.73      new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
    9.74    }
    9.75  
    9.76 @@ -632,6 +664,12 @@
    9.77    assert(bs->has_write_region_opt(), "Barrier set does not have write_region");
    9.78    bs->write_region(MemRegion((HeapWord*)new_obj_oop, size));
    9.79  
    9.80 +  // If cloning a Reference, set Reference fields to a safe state.
    9.81 +  // Fixup must be completed before any safepoint.
    9.82 +  if (ref_type != REF_NONE) {
    9.83 +    fixup_cloned_reference(ref_type, obj(), new_obj_oop);
    9.84 +  }
    9.85 +
    9.86    Handle new_obj(THREAD, new_obj_oop);
    9.87    // Special handling for MemberNames.  Since they contain Method* metadata, they
    9.88    // must be registered so that RedefineClasses can fix metadata contained in them.

mercurial