src/hotspot/share/gc/shared/locationPrinter.cpp
author eosterlund
Wed, 28 Aug 2019 11:19:09 +0200
changeset 57903 5e2576c303a2
permissions -rw-r--r--
8229278: Improve hs_err location printing to assume less about GC internals Reviewed-by: stefank, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57903
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     1
/*
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     4
 *
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     8
 *
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    14
 *
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    18
 *
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    21
 * questions.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    22
 *
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    23
 */
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    24
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    25
#include "precompiled.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    26
#include "gc/shared/collectedHeap.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    27
#include "gc/shared/locationPrinter.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    28
#include "memory/universe.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    29
#include "runtime/os.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    30
#include "oops/klass.hpp"
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    31
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    32
bool LocationPrinter::is_valid_obj(void* obj) {
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    33
  if (!is_object_aligned(obj)) {
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    34
    return false;
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    35
  }
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    36
  if (obj < (void*)os::min_page_size()) {
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    37
    return false;
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    38
  }
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    39
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    40
  // We need at least the mark and the klass word in the committed region.
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    41
  if (!os::is_readable_range(obj, (HeapWord*)obj + oopDesc::header_size())) {
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    42
    return false;
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    43
  }
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    44
  if (!Universe::heap()->is_in(obj)) {
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    45
    return false;
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    46
  }
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    47
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    48
  Klass* k = (Klass*)oopDesc::load_klass_raw((oopDesc*)obj);
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    49
  return Klass::is_valid(k);
5e2576c303a2 8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
diff changeset
    50
}