Merge

Mon, 26 Jun 2017 22:29:37 -0700

author
asaha
date
Mon, 26 Jun 2017 22:29:37 -0700
changeset 8979
aad15df39b88
parent 8975
40aca961645d
parent 8978
b47c7d21e788
child 8980
8c937a2e846e
child 8986
6470230caf2a

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Mon Jun 26 22:21:49 2017 -0700
     1.2 +++ b/.hgtags	Mon Jun 26 22:29:37 2017 -0700
     1.3 @@ -967,6 +967,8 @@
     1.4  829ea9b92cda9545652f1b309f56c57383024ebb jdk8u131-b11
     1.5  41e0713bcca27cef5d6a9afd44c7ca4811937713 jdk8u131-b31
     1.6  e318654a4fa352a06935dd56eebf88ae387b31f9 jdk8u131-b32
     1.7 +32998fc932dc58c6bbac185cc17d2752fa6dba4c jdk8u131-b33
     1.8 +50b3fa6791f46bc582528bdc7f6311b3b6832c51 jdk8u131-b34
     1.9  692bc6b674dcab72453de08ee9da0856a7e41c0f jdk8u141-b00
    1.10  0cee0db0180b64655751e7058c251103f9660f85 jdk8u141-b01
    1.11  82435799636c8b50a090aebcb5af49946afa7bb5 jdk8u141-b02
     2.1 --- a/src/share/vm/classfile/classLoaderData.cpp	Mon Jun 26 22:21:49 2017 -0700
     2.2 +++ b/src/share/vm/classfile/classLoaderData.cpp	Mon Jun 26 22:29:37 2017 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2012, 2017, 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 @@ -78,7 +78,7 @@
    2.11    // The null-class-loader should always be kept alive.
    2.12    _keep_alive(is_anonymous || h_class_loader.is_null()),
    2.13    _metaspace(NULL), _unloading(false), _klasses(NULL),
    2.14 -  _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
    2.15 +  _claimed(0), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
    2.16    _next(NULL), _dependencies(dependencies),
    2.17    _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) {
    2.18      // empty
    2.19 @@ -96,6 +96,45 @@
    2.20    _list_head = oopFactory::new_objectArray(2, CHECK);
    2.21  }
    2.22  
    2.23 +ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() {
    2.24 +  Chunk* c = _head;
    2.25 +  while (c != NULL) {
    2.26 +    Chunk* next = c->_next;
    2.27 +    delete c;
    2.28 +    c = next;
    2.29 +  }
    2.30 +}
    2.31 +
    2.32 +oop* ClassLoaderData::ChunkedHandleList::add(oop o) {
    2.33 +  if (_head == NULL || _head->_size == Chunk::CAPACITY) {
    2.34 +    Chunk* next = new Chunk(_head);
    2.35 +    OrderAccess::release_store_ptr(&_head, next);
    2.36 +  }
    2.37 +  oop* handle = &_head->_data[_head->_size];
    2.38 +  *handle = o;
    2.39 +  OrderAccess::release_store(&_head->_size, _head->_size + 1);
    2.40 +  return handle;
    2.41 +}
    2.42 +
    2.43 +inline void ClassLoaderData::ChunkedHandleList::oops_do_chunk(OopClosure* f, Chunk* c, const juint size) {
    2.44 +  for (juint i = 0; i < size; i++) {
    2.45 +    if (c->_data[i] != NULL) {
    2.46 +      f->do_oop(&c->_data[i]);
    2.47 +    }
    2.48 +  }
    2.49 +}
    2.50 +
    2.51 +void ClassLoaderData::ChunkedHandleList::oops_do(OopClosure* f) {
    2.52 +  Chunk* head = (Chunk*) OrderAccess::load_ptr_acquire(&_head);
    2.53 +  if (head != NULL) {
    2.54 +    // Must be careful when reading size of head
    2.55 +    oops_do_chunk(f, head, OrderAccess::load_acquire(&head->_size));
    2.56 +    for (Chunk* c = head->_next; c != NULL; c = c->_next) {
    2.57 +      oops_do_chunk(f, c, c->_size);
    2.58 +    }
    2.59 +  }
    2.60 +}
    2.61 +
    2.62  bool ClassLoaderData::claim() {
    2.63    if (_claimed == 1) {
    2.64      return false;
    2.65 @@ -111,7 +150,7 @@
    2.66  
    2.67    f->do_oop(&_class_loader);
    2.68    _dependencies.oops_do(f);
    2.69 -  _handles->oops_do(f);
    2.70 +  _handles.oops_do(f);
    2.71    if (klass_closure != NULL) {
    2.72      classes_do(klass_closure);
    2.73    }
    2.74 @@ -342,11 +381,6 @@
    2.75      _metaspace = NULL;
    2.76      // release the metaspace
    2.77      delete m;
    2.78 -    // release the handles
    2.79 -    if (_handles != NULL) {
    2.80 -      JNIHandleBlock::release_block(_handles);
    2.81 -      _handles = NULL;
    2.82 -    }
    2.83    }
    2.84  
    2.85    // Clear all the JNI handles for methods
    2.86 @@ -406,15 +440,9 @@
    2.87    return _metaspace;
    2.88  }
    2.89  
    2.90 -JNIHandleBlock* ClassLoaderData::handles() const           { return _handles; }
    2.91 -void ClassLoaderData::set_handles(JNIHandleBlock* handles) { _handles = handles; }
    2.92 -
    2.93  jobject ClassLoaderData::add_handle(Handle h) {
    2.94    MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
    2.95 -  if (handles() == NULL) {
    2.96 -    set_handles(JNIHandleBlock::allocate_block());
    2.97 -  }
    2.98 -  return handles()->allocate_handle(h());
    2.99 +  return (jobject) _handles.add(h());
   2.100  }
   2.101  
   2.102  // Add this metadata pointer to be freed when it's safe.  This is only during
   2.103 @@ -479,7 +507,6 @@
   2.104        p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
   2.105    if (claimed()) out->print(" claimed ");
   2.106    if (is_unloading()) out->print(" unloading ");
   2.107 -  out->print(" handles " INTPTR_FORMAT, p2i(handles()));
   2.108    out->cr();
   2.109    if (metaspace_or_null() != NULL) {
   2.110      out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null()));
     3.1 --- a/src/share/vm/classfile/classLoaderData.hpp	Mon Jun 26 22:21:49 2017 -0700
     3.2 +++ b/src/share/vm/classfile/classLoaderData.hpp	Mon Jun 26 22:29:37 2017 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2012, 2017, 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 @@ -51,7 +51,6 @@
    3.11  
    3.12  class ClassLoaderData;
    3.13  class JNIMethodBlock;
    3.14 -class JNIHandleBlock;
    3.15  class Metadebug;
    3.16  
    3.17  // GC root for walking class loader data created
    3.18 @@ -145,6 +144,31 @@
    3.19      void oops_do(OopClosure* f);
    3.20    };
    3.21  
    3.22 +  class ChunkedHandleList VALUE_OBJ_CLASS_SPEC {
    3.23 +    struct Chunk : public CHeapObj<mtClass> {
    3.24 +      static const size_t CAPACITY = 32;
    3.25 +
    3.26 +      oop _data[CAPACITY];
    3.27 +      volatile juint _size;
    3.28 +      Chunk* _next;
    3.29 +
    3.30 +      Chunk(Chunk* c) : _next(c), _size(0) { }
    3.31 +    };
    3.32 +
    3.33 +    Chunk* _head;
    3.34 +
    3.35 +    void oops_do_chunk(OopClosure* f, Chunk* c, const juint size);
    3.36 +
    3.37 +   public:
    3.38 +    ChunkedHandleList() : _head(NULL) {}
    3.39 +    ~ChunkedHandleList();
    3.40 +
    3.41 +    // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
    3.42 +    // However, multiple threads can execute oops_do concurrently with add.
    3.43 +    oop* add(oop o);
    3.44 +    void oops_do(OopClosure* f);
    3.45 +  };
    3.46 +
    3.47    friend class ClassLoaderDataGraph;
    3.48    friend class ClassLoaderDataGraphKlassIteratorAtomic;
    3.49    friend class ClassLoaderDataGraphMetaspaceIterator;
    3.50 @@ -169,7 +193,8 @@
    3.51                             // Has to be an int because we cas it.
    3.52    Klass* _klasses;         // The classes defined by the class loader.
    3.53  
    3.54 -  JNIHandleBlock* _handles; // Handles to constant pool arrays
    3.55 +  ChunkedHandleList _handles; // Handles to constant pool arrays, etc, which
    3.56 +                              // have the same life cycle of the corresponding ClassLoader.
    3.57  
    3.58    // These method IDs are created for the class loader and set to NULL when the
    3.59    // class loader is unloaded.  They are rarely freed, only for redefine classes
    3.60 @@ -196,9 +221,6 @@
    3.61  
    3.62    void set_metaspace(Metaspace* m) { _metaspace = m; }
    3.63  
    3.64 -  JNIHandleBlock* handles() const;
    3.65 -  void set_handles(JNIHandleBlock* handles);
    3.66 -
    3.67    Mutex* metaspace_lock() const { return _metaspace_lock; }
    3.68  
    3.69    // GC interface.

mercurial