hotspot/src/share/vm/runtime/handles.inline.hpp
author zgu
Thu, 28 Jun 2012 17:03:16 -0400
changeset 13195 be27e1b6a4b9
parent 10565 dc90c239f4ec
child 13728 882756847a04
permissions -rw-r--r--
6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1998, 2010, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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: 5547
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_HANDLES_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_HANDLES_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#ifdef TARGET_OS_FAMILY_linux
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
# include "thread_linux.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#ifdef TARGET_OS_FAMILY_solaris
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
# include "thread_solaris.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#ifdef TARGET_OS_FAMILY_windows
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
# include "thread_windows.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    38
#ifdef TARGET_OS_FAMILY_bsd
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    39
# include "thread_bsd.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    40
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// these inline functions are in a separate file to break an include cycle
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// between Thread and Handle
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
inline Handle::Handle(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  if (obj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _handle = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    _handle = Thread::current()->handle_area()->allocate_handle(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
#ifndef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
inline Handle::Handle(Thread* thread, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  assert(thread == Thread::current(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  if (obj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    _handle = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    _handle = thread->handle_area()->allocate_handle(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
inline HandleMark::HandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  initialize(Thread::current());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
inline void HandleMark::push() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // This is intentionally a NOP. pop_and_restore will reset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // values to the HandleMark further down the stack, typically
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // in JavaCalls::call_helper.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  debug_only(_area->_handle_mark_nesting++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
inline void HandleMark::pop_and_restore() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  HandleArea* area = _area;   // help compilers with poor alias analysis
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Delete later chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  if( _chunk->next() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    _chunk->next_chop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Roll back arena to saved top markers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  area->_chunk = _chunk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  area->_hwm = _hwm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  area->_max = _max;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10565
diff changeset
    88
  area->set_size_in_bytes(_size_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  debug_only(area->_handle_mark_nesting--);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    91
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    92
#endif // SHARE_VM_RUNTIME_HANDLES_INLINE_HPP