src/share/vm/gc_implementation/shared/copyFailedInfo.hpp

changeset 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/shared/copyFailedInfo.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*
     1.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP
    1.30 +
    1.31 +#include "runtime/thread.hpp"
    1.32 +#include "utilities/globalDefinitions.hpp"
    1.33 +
    1.34 +class CopyFailedInfo : public CHeapObj<mtGC> {
    1.35 +  size_t    _first_size;
    1.36 +  size_t    _smallest_size;
    1.37 +  size_t    _total_size;
    1.38 +  uint      _count;
    1.39 +
    1.40 + public:
    1.41 +  CopyFailedInfo() : _first_size(0), _smallest_size(0), _total_size(0), _count(0) {}
    1.42 +
    1.43 +  virtual void register_copy_failure(size_t size) {
    1.44 +    if (_first_size == 0) {
    1.45 +      _first_size = size;
    1.46 +      _smallest_size = size;
    1.47 +    } else if (size < _smallest_size) {
    1.48 +      _smallest_size = size;
    1.49 +    }
    1.50 +    _total_size += size;
    1.51 +    _count++;
    1.52 +  }
    1.53 +
    1.54 +  virtual void reset() {
    1.55 +    _first_size = 0;
    1.56 +    _smallest_size = 0;
    1.57 +    _total_size = 0;
    1.58 +    _count = 0;
    1.59 +  }
    1.60 +
    1.61 +  bool has_failed() const { return _count != 0; }
    1.62 +  size_t first_size() const { return _first_size; }
    1.63 +  size_t smallest_size() const { return _smallest_size; }
    1.64 +  size_t total_size() const { return _total_size; }
    1.65 +  uint failed_count() const { return _count; }
    1.66 +};
    1.67 +
    1.68 +class PromotionFailedInfo : public CopyFailedInfo {
    1.69 +  OSThread* _thread;
    1.70 +
    1.71 + public:
    1.72 +  PromotionFailedInfo() : CopyFailedInfo(), _thread(NULL) {}
    1.73 +
    1.74 +  void register_copy_failure(size_t size) {
    1.75 +    CopyFailedInfo::register_copy_failure(size);
    1.76 +    if (_thread == NULL) {
    1.77 +      _thread = Thread::current()->osthread();
    1.78 +    } else {
    1.79 +      assert(_thread == Thread::current()->osthread(), "The PromotionFailedInfo should be thread local.");
    1.80 +    }
    1.81 +  }
    1.82 +
    1.83 +  void reset() {
    1.84 +    CopyFailedInfo::reset();
    1.85 +    _thread = NULL;
    1.86 +  }
    1.87 +
    1.88 +  OSThread* thread() const { return _thread; }
    1.89 +};
    1.90 +
    1.91 +class EvacuationFailedInfo : public CopyFailedInfo {};
    1.92 +
    1.93 +#endif /* SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP */

mercurial