hotspot/src/share/vm/oops/oop.cpp
author jrose
Fri, 20 Mar 2009 23:19:36 -0700
changeset 2332 5c7b6f4ce0a1
parent 670 ddf3e9583f2f
child 4584 e2a449e8cc6f
permissions -rw-r--r--
6814659: separable cleanups and subroutines for 6655638 Summary: preparatory but separable changes for method handles Reviewed-by: kvn, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 670
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_oop.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
bool always_do_update_barrier = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
BarrierSet* oopDesc::_bs = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
#ifdef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
void oopDesc::print_on(outputStream* st) const {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
void oopDesc::print_value_on(outputStream* st) const {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
void oopDesc::print_address_on(outputStream* st) const {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
char* oopDesc::print_value_string() { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
char* oopDesc::print_string() { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
void oopDesc::print()         {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
void oopDesc::print_value()   {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
void oopDesc::print_address() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
void oopDesc::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  if (this == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    st->print_cr("NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    blueprint()->oop_print_on(oop(this), st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  }
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_value_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  oop obj = oop(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  if (this == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    st->print("NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  } else if (java_lang_String::is_instance(obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    java_lang_String::print(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    if (PrintOopAddress) print_address_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  } else if (!Universe::heap()->is_in(obj) || !Universe::heap()->is_in(klass())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    st->print("### BAD OOP %p ###", (address)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    blueprint()->oop_print_value_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
void oopDesc::print_address_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  if (PrintOopAddress) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 670
diff changeset
    68
    st->print("{"INTPTR_FORMAT"}", this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
void oopDesc::print()         { print_on(tty);         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
void oopDesc::print_value()   { print_value_on(tty);   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
void oopDesc::print_address() { print_address_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
char* oopDesc::print_string() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  stringStream* st = new stringStream();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  return st->as_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
char* oopDesc::print_value_string() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  stringStream* st = new stringStream();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  return st->as_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
void oopDesc::verify_on(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  if (this != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    blueprint()->oop_verify_on(this, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
void oopDesc::verify() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  verify_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   104
// XXX verify_old_oop doesn't do anything (should we remove?)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
void oopDesc::verify_old_oop(oop* p, bool allow_dirty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  blueprint()->oop_verify_old_oop(this, p, allow_dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
void oopDesc::verify_old_oop(narrowOop* p, bool allow_dirty) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
  blueprint()->oop_verify_old_oop(this, p, allow_dirty);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
bool oopDesc::partially_loaded() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  return blueprint()->oop_partially_loaded(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
void oopDesc::set_partially_loaded() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  blueprint()->oop_set_partially_loaded(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
intptr_t oopDesc::slow_identity_hash() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // slow case; we have to acquire the micro lock in order to locate the header
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  HandleMark hm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  Handle object((oop)this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  assert(!is_shared_readonly(), "using identity hash on readonly object?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  return ObjectSynchronizer::identity_hash_value_for(object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
VerifyOopClosure VerifyOopClosure::verify_oop;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   133
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
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
   135
void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }