hotspot/src/share/vm/runtime/handles.cpp
author gziemski
Mon, 07 Mar 2016 10:39:24 -0600
changeset 36583 71f4f42b0fcd
parent 35194 7151995ee79e
child 40655 9f644073d3a0
permissions -rw-r--r--
8146850: Remove TraceHandleAllocation rather than converting to UL 8149850: Remove HandleAllocationLimit and TotalHandleAllocationLimit when removing TraceHandleAllocation Summary: Removed TraceHandleAllocation, HandleAllocationLimit and TotalHandleAllocationLimit flags Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
36583
71f4f42b0fcd 8146850: Remove TraceHandleAllocation rather than converting to UL
gziemski
parents: 35194
diff changeset
     2
 * Copyright (c) 1997, 2016, 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
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "memory/allocation.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    27
#include "oops/constantPool.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "oops/oop.inline.hpp"
25351
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24424
diff changeset
    29
#include "runtime/atomic.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/handles.inline.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 14120
diff changeset
    31
#include "runtime/thread.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
oop* HandleArea::allocate_handle(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark");
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33105
diff changeset
    37
  assert(obj->is_oop(), "not an oop: " INTPTR_FORMAT, p2i(obj));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  return real_allocate_handle(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
Handle::Handle(Thread* thread, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  assert(thread == Thread::current(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  if (obj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    _handle = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    _handle = thread->handle_area()->allocate_handle(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
35194
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    49
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
35194
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    51
// Copy constructors and destructors for metadata handles
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    52
// These do too much to inline.
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    53
#define DEF_METADATA_HANDLE_FN_NOINLINE(name, type) \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    54
name##Handle::name##Handle(const name##Handle &h) {                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    55
  _value = h._value;                                                   \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    56
  if (_value != NULL) {                                                \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    57
    assert(_value->is_valid(), "obj is valid");                        \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    58
    if (h._thread != NULL) {                                           \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    59
      assert(h._thread == Thread::current(), "thread must be current");\
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    60
      _thread = h._thread;                                             \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    61
    } else {                                                           \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    62
      _thread = Thread::current();                                     \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    63
    }                                                                  \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    64
    assert (_thread->is_in_stack((address)this), "not on stack?");     \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    65
    _thread->metadata_handles()->push((Metadata*)_value);              \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    66
  } else {                                                             \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    67
    _thread = NULL;                                                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    68
  }                                                                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    69
}                                                                      \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    70
name##Handle& name##Handle::operator=(const name##Handle &s) {         \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    71
  remove();                                                            \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    72
  _value = s._value;                                                   \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    73
  if (_value != NULL) {                                                \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    74
    assert(_value->is_valid(), "obj is valid");                        \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    75
    if (s._thread != NULL) {                                           \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    76
      assert(s._thread == Thread::current(), "thread must be current");\
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    77
      _thread = s._thread;                                             \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    78
    } else {                                                           \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    79
      _thread = Thread::current();                                     \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    80
    }                                                                  \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    81
    assert (_thread->is_in_stack((address)this), "not on stack?");     \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    82
    _thread->metadata_handles()->push((Metadata*)_value);              \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    83
  } else {                                                             \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    84
    _thread = NULL;                                                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    85
  }                                                                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    86
  return *this;                                                        \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    87
}                                                                      \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    88
inline void name##Handle::remove() {                                   \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    89
  if (_value != NULL) {                                                \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    90
    int i = _thread->metadata_handles()->find_from_end((Metadata*)_value); \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    91
    assert(i!=-1, "not in metadata_handles list");                     \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    92
    _thread->metadata_handles()->remove_at(i);                         \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    93
  }                                                                    \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    94
}                                                                      \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    95
name##Handle::~name##Handle () { remove(); }                           \
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    96
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    97
DEF_METADATA_HANDLE_FN_NOINLINE(method, Method)
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    98
DEF_METADATA_HANDLE_FN_NOINLINE(constantPool, ConstantPool)
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 33611
diff changeset
    99
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
static uintx chunk_oops_do(OopClosure* f, Chunk* chunk, char* chunk_top) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  oop* bottom = (oop*) chunk->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  oop* top    = (oop*) chunk_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  uintx handles_visited = top - bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  assert(top >= bottom && top <= (oop*) chunk->top(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // during GC phase 3, a handle may be a forward pointer that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // is not yet valid, so loosen the assertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  while (bottom < top) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   109
    // This test can be moved up but for now check every oop.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   110
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   111
    assert((*bottom)->is_oop(), "handle should point to oop");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   112
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    f->do_oop(bottom++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return handles_visited;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// Used for debugging handle allocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
NOT_PRODUCT(jint _nof_handlemarks  = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
void HandleArea::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  uintx handles_visited = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // First handle the current chunk. It is filled to the high water mark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  handles_visited += chunk_oops_do(f, _chunk, _hwm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // Then handle all previous chunks. They are completely filled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  Chunk* k = _first;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  while(k != _chunk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    handles_visited += chunk_oops_do(f, k, k->top());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    k = k->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  if (_prev != NULL) _prev->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
void HandleMark::initialize(Thread* thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  _thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  _area  = thread->handle_area();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Save current top
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  _chunk = _area->_chunk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  _hwm   = _area->_hwm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  _max   = _area->_max;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10565
diff changeset
   143
  _size_in_bytes = _area->_size_in_bytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  debug_only(_area->_handle_mark_nesting++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  assert(_area->_handle_mark_nesting > 0, "must stack allocate HandleMarks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  debug_only(Atomic::inc(&_nof_handlemarks);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // Link this in the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  set_previous_handle_mark(thread->last_handle_mark());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  thread->set_last_handle_mark(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
HandleMark::~HandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  HandleArea* area = _area;   // help compilers with poor alias analysis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  assert(area == _thread->handle_area(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  assert(area->_handle_mark_nesting > 0, "must stack allocate HandleMarks" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  debug_only(area->_handle_mark_nesting--);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // Delete later chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  if( _chunk->next() ) {
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   162
    // reset arena size before delete chunks. Otherwise, the total
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   163
    // arena size could exceed total chunk size
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   164
    assert(area->size_in_bytes() > size_in_bytes(), "Sanity check");
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   165
    area->set_size_in_bytes(size_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    _chunk->next_chop();
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   167
  } else {
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 14078
diff changeset
   168
    assert(area->size_in_bytes() == size_in_bytes(), "Sanity check");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // Roll back arena to saved top markers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  area->_chunk = _chunk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  area->_hwm = _hwm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  area->_max = _max;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // clear out first chunk (to detect allocation bugs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  if (ZapVMHandleArea) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    memset(_hwm, badHandleValue, _max - _hwm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  Atomic::dec(&_nof_handlemarks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // Unlink this from the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  _thread->set_last_handle_mark(previous_handle_mark());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 17376
diff changeset
   186
void* HandleMark::operator new(size_t size) throw() {
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   187
  return AllocateHeap(size, mtThread);
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   188
}
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   189
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 17376
diff changeset
   190
void* HandleMark::operator new [] (size_t size) throw() {
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   191
  return AllocateHeap(size, mtThread);
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   192
}
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   193
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   194
void HandleMark::operator delete(void* p) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 25468
diff changeset
   195
  FreeHeap(p);
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   196
}
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   197
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   198
void HandleMark::operator delete[](void* p) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 25468
diff changeset
   199
  FreeHeap(p);
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   200
}
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 14583
diff changeset
   201
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
NoHandleMark::NoHandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  HandleArea* area = Thread::current()->handle_area();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  area->_no_handle_mark_nesting++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  assert(area->_no_handle_mark_nesting > 0, "must stack allocate NoHandleMark" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
NoHandleMark::~NoHandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  HandleArea* area = Thread::current()->handle_area();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  assert(area->_no_handle_mark_nesting > 0, "must stack allocate NoHandleMark" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  area->_no_handle_mark_nesting--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
ResetNoHandleMark::ResetNoHandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  HandleArea* area = Thread::current()->handle_area();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  _no_handle_mark_nesting = area->_no_handle_mark_nesting;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  area->_no_handle_mark_nesting = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
ResetNoHandleMark::~ResetNoHandleMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  HandleArea* area = Thread::current()->handle_area();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  area->_no_handle_mark_nesting = _no_handle_mark_nesting;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
29199
db7ae483ecb2 8073388: Get rid of the depenecy from handles.hpp to oop.inline.hpp
stefank
parents: 27880
diff changeset
   230
bool instanceKlassHandle::is_instanceKlass(const Klass* k) {
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33148
diff changeset
   231
  // Need this to avoid circular include dependency
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33148
diff changeset
   232
  return k->is_instance_klass();
29199
db7ae483ecb2 8073388: Get rid of the depenecy from handles.hpp to oop.inline.hpp
stefank
parents: 27880
diff changeset
   233
}
db7ae483ecb2 8073388: Get rid of the depenecy from handles.hpp to oop.inline.hpp
stefank
parents: 27880
diff changeset
   234
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
#endif