src/hotspot/share/oops/oop.cpp
author coleenp
Wed, 24 Jul 2019 10:22:11 -0400
changeset 57511 00ae3b739184
parent 54842 f9c8e16db3dd
child 57777 90ead0febf56
child 58678 9cf78a70fa4f
permissions -rw-r--r--
8228485: JVM crashes when bootstrap method for condy triggers loading of class whose static initializer throws exception Summary: Add case for JVM_CONSTANT_Dynamic in error_message function. Reviewed-by: dholmes, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53156
488773472a63 8216197: Remove unused new_hash methods
redestad
parents: 52062
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    25
#include "precompiled.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    26
#include "classfile/altHashing.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
    27
#include "classfile/javaClasses.inline.hpp"
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52014
diff changeset
    28
#include "memory/heapShared.inline.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 37190
diff changeset
    29
#include "memory/resourceArea.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54780
diff changeset
    30
#include "memory/universe.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47998
diff changeset
    31
#include "oops/access.inline.hpp"
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54377
diff changeset
    32
#include "oops/compressedOops.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    33
#include "oops/oop.inline.hpp"
29084
1b732f2836ce 8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents: 29081
diff changeset
    34
#include "oops/verifyOopClosure.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    35
#include "runtime/handles.inline.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 13728
diff changeset
    36
#include "runtime/thread.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    37
#include "utilities/copy.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
bool always_do_update_barrier = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
void oopDesc::print_on(outputStream* st) const {
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    42
  klass()->oop_print_on(oop(this), st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
void oopDesc::print_address_on(outputStream* st) const {
37190
09d719d466a6 8146947: Remove PrintOopAddress rather than converting to UL
rprotacio
parents: 33611
diff changeset
    46
  st->print("{" INTPTR_FORMAT "}", p2i(this));
09d719d466a6 8146947: Remove PrintOopAddress rather than converting to UL
rprotacio
parents: 33611
diff changeset
    47
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
void oopDesc::print()         { print_on(tty);         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
void oopDesc::print_address() { print_address_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
char* oopDesc::print_string() {
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    55
  stringStream st;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    56
  print_on(&st);
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    57
  return st.as_string();
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    58
}
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    59
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    60
void oopDesc::print_value() {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    61
  print_value_on(tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
char* oopDesc::print_value_string() {
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    65
  char buf[100];
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    66
  stringStream st(buf, sizeof(buf));
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    67
  print_value_on(&st);
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    68
  return st.as_string();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    71
void oopDesc::print_value_on(outputStream* st) const {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    72
  oop obj = oop(this);
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    73
  if (java_lang_String::is_instance(obj)) {
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    74
    java_lang_String::print(obj, st);
37190
09d719d466a6 8146947: Remove PrintOopAddress rather than converting to UL
rprotacio
parents: 33611
diff changeset
    75
    print_address_on(st);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    76
  } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    77
    klass()->oop_print_value_on(obj, st);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    78
  }
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    79
}
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 2332
diff changeset
    80
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    82
void oopDesc::verify_on(outputStream* st, oopDesc* oop_desc) {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    83
  if (oop_desc != NULL) {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    84
    oop_desc->klass()->oop_verify_on(oop_desc, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    89
void oopDesc::verify(oopDesc* oop_desc) {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50056
diff changeset
    90
  verify_on(tty, oop_desc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
intptr_t oopDesc::slow_identity_hash() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // slow case; we have to acquire the micro lock in order to locate the header
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 37248
diff changeset
    95
  Thread* THREAD = Thread::current();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 37248
diff changeset
    97
  HandleMark hm(THREAD);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 37248
diff changeset
    98
  Handle object(THREAD, this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  return ObjectSynchronizer::identity_hash_value_for(object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   102
// used only for asserts and guarantees
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   103
bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
49851
9082914ccaf2 8202081: Introduce CollectedHeap::is_oop()
stefank
parents: 49722
diff changeset
   104
  if (!Universe::heap()->is_oop(obj)) {
9082914ccaf2 8202081: Introduce CollectedHeap::is_oop()
stefank
parents: 49722
diff changeset
   105
    return false;
9082914ccaf2 8202081: Introduce CollectedHeap::is_oop()
stefank
parents: 49722
diff changeset
   106
  }
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   107
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   108
  // Header verification: the mark is typically non-NULL. If we're
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   109
  // at a safepoint, it must not be null.
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   110
  // Outside of a safepoint, the header could be changing (for example,
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   111
  // another thread could be inflating a lock on this object).
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   112
  if (ignore_mark_word) {
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   113
    return true;
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   114
  }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49592
diff changeset
   115
  if (obj->mark_raw() != NULL) {
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   116
    return true;
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   117
  }
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   118
  return !SafepointSynchronize::is_at_safepoint();
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   119
}
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   120
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   121
// used only for asserts and guarantees
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   122
bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   123
  return obj == NULL ? true : is_oop(obj, ignore_mark_word);
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   124
}
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   125
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   126
#ifndef PRODUCT
51796
9d3a00c8c047 8210864: Reduce the use of metaspaceShared.hpp
iklam
parents: 51516
diff changeset
   127
#if INCLUDE_CDS_JAVA_HEAP
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52014
diff changeset
   128
bool oopDesc::is_archived_object(oop p) {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52014
diff changeset
   129
  return HeapShared::is_archived_object(p);
51796
9d3a00c8c047 8210864: Reduce the use of metaspaceShared.hpp
iklam
parents: 51516
diff changeset
   130
}
9d3a00c8c047 8210864: Reduce the use of metaspaceShared.hpp
iklam
parents: 51516
diff changeset
   131
#endif
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   132
#endif // PRODUCT
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   133
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
VerifyOopClosure VerifyOopClosure::verify_oop;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   135
29084
1b732f2836ce 8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents: 29081
diff changeset
   136
template <class T> void VerifyOopClosure::do_oop_work(T* p) {
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47998
diff changeset
   137
  oop obj = RawAccess<>::oop_load(p);
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   138
  guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
29084
1b732f2836ce 8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents: 29081
diff changeset
   139
}
1b732f2836ce 8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents: 29081
diff changeset
   140
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   141
void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   142
void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   143
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   144
// type test operations that doesn't require inclusion of oop.inline.hpp.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   145
bool oopDesc::is_instance_noinline()          const { return is_instance();            }
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   146
bool oopDesc::is_array_noinline()             const { return is_array();               }
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   147
bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   148
bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   149
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   150
bool oopDesc::has_klass_gap() {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   151
  // Only has a klass gap when compressed class pointers are used.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   152
  return UseCompressedClassPointers;
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
   153
}
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46271
diff changeset
   154
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   155
void* oopDesc::load_klass_raw(oop obj) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   156
  if (UseCompressedClassPointers) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   157
    narrowKlass narrow_klass = *(obj->compressed_klass_addr());
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   158
    if (narrow_klass == 0) return NULL;
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54377
diff changeset
   159
    return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   160
  } else {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   161
    return *(void**)(obj->klass_addr());
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   162
  }
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   163
}
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   164
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   165
void* oopDesc::load_oop_raw(oop obj, int offset) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   166
  uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   167
  if (UseCompressedOops) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   168
    narrowOop narrow_oop = *(narrowOop*)addr;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   169
    if (narrow_oop == 0) return NULL;
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54377
diff changeset
   170
    return (void*)CompressedOops::decode_raw(narrow_oop);
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   171
  } else {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   172
    return *(void**)addr;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   173
  }
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   174
}
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   175
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   176
bool oopDesc::is_valid(oop obj) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   177
  if (!is_object_aligned(obj)) return false;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   178
  if ((size_t)(oopDesc*)obj < os::min_page_size()) return false;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   179
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   180
  // We need at least the mark and the klass word in the committed region.
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   181
  if (!os::is_readable_range(obj, (oopDesc*)obj + 1)) return false;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   182
  if (!Universe::heap()->is_in(obj)) return false;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   183
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   184
  Klass* k = (Klass*)load_klass_raw(obj);
54842
f9c8e16db3dd 8219459: oopDesc::is_valid() is broken
coleenp
parents: 54786
diff changeset
   185
  return Klass::is_valid(k);
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   186
}
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   187
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   188
oop oopDesc::oop_or_null(address addr) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   189
  if (is_valid(oop(addr))) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   190
    // We were just given an oop directly.
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   191
    return oop(addr);
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   192
  }
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   193
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   194
  // Try to find addr using block_start.
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   195
  HeapWord* p = Universe::heap()->block_start(addr);
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   196
  if (p != NULL && Universe::heap()->block_is_obj(p)) {
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   197
    if (!is_valid(oop(p))) return NULL;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   198
    return oop(p);
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   199
  }
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   200
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   201
  // If we can't find it it just may mean that heap wasn't parsable.
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   202
  return NULL;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   203
}
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51796
diff changeset
   204
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   205
oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   206
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   207
void oopDesc::obj_field_put_raw(int offset, oop value)                { RawAccess<>::oop_store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   208
void oopDesc::release_obj_field_put(int offset, oop value)            { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   209
void oopDesc::obj_field_put_volatile(int offset, oop value)           { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   210
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   211
address oopDesc::address_field(int offset) const                      { return HeapAccess<>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   212
address oopDesc::address_field_acquire(int offset) const              { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   213
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   214
void oopDesc::address_field_put(int offset, address value)            { HeapAccess<>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   215
void oopDesc::release_address_field_put(int offset, address value)    { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   216
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   217
Metadata* oopDesc::metadata_field(int offset) const                   { return HeapAccess<>::load_at(as_oop(), offset); }
51516
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 51268
diff changeset
   218
Metadata* oopDesc::metadata_field_raw(int offset) const               { return RawAccess<>::load_at(as_oop(), offset); }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   219
void oopDesc::metadata_field_put(int offset, Metadata* value)         { HeapAccess<>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   220
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   221
Metadata* oopDesc::metadata_field_acquire(int offset) const           { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   222
void oopDesc::release_metadata_field_put(int offset, Metadata* value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   223
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   224
jbyte oopDesc::byte_field_acquire(int offset) const                   { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   225
void oopDesc::release_byte_field_put(int offset, jbyte value)         { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   226
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   227
jchar oopDesc::char_field_acquire(int offset) const                   { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   228
void oopDesc::release_char_field_put(int offset, jchar value)         { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   229
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   230
jboolean oopDesc::bool_field_acquire(int offset) const                { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   231
void oopDesc::release_bool_field_put(int offset, jboolean value)      { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, jboolean(value & 1)); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   232
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   233
jint oopDesc::int_field_acquire(int offset) const                     { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   234
void oopDesc::release_int_field_put(int offset, jint value)           { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   235
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   236
jshort oopDesc::short_field_acquire(int offset) const                 { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   237
void oopDesc::release_short_field_put(int offset, jshort value)       { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   238
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   239
jlong oopDesc::long_field_acquire(int offset) const                   { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   240
void oopDesc::release_long_field_put(int offset, jlong value)         { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   241
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   242
jfloat oopDesc::float_field_acquire(int offset) const                 { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   243
void oopDesc::release_float_field_put(int offset, jfloat value)       { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   244
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   245
jdouble oopDesc::double_field_acquire(int offset) const               { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   246
void oopDesc::release_double_field_put(int offset, jdouble value)     { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }