diff src/share/vm/runtime/handles.inline.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children 716c64bda5ba
line wrap: on
line diff
--- a/src/share/vm/runtime/handles.inline.hpp	Fri Aug 31 16:39:35 2012 -0700
+++ b/src/share/vm/runtime/handles.inline.hpp	Sat Sep 01 13:25:18 2012 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,6 +62,63 @@
 }
 #endif // ASSERT
 
+// Constructors for metadata handles
+#define DEF_METADATA_HANDLE_FN(name, type) \
+inline name##Handle::name##Handle(type* obj) : _value(obj), _thread(NULL) {       \
+  if (obj != NULL) {                                                   \
+    assert(((Metadata*)obj)->is_valid(), "obj is valid");              \
+    _thread = Thread::current();                                       \
+    assert (_thread->is_in_stack((address)this), "not on stack?");     \
+    _thread->metadata_handles()->push((Metadata*)obj);                 \
+  }                                                                    \
+}                                                                      \
+inline name##Handle::name##Handle(Thread* thread, type* obj) : _value(obj), _thread(thread) { \
+  if (obj != NULL) {                                                   \
+    assert(((Metadata*)obj)->is_valid(), "obj is valid");              \
+    assert(_thread == Thread::current(), "thread must be current");    \
+    assert (_thread->is_in_stack((address)this), "not on stack?");     \
+    _thread->metadata_handles()->push((Metadata*)obj);                 \
+  }                                                                    \
+}                                                                      \
+inline name##Handle::name##Handle(const name##Handle &h) {             \
+  _value = h._value;                                                   \
+  if (_value != NULL) {                                                \
+    assert(_value->is_valid(), "obj is valid");                        \
+    if (h._thread != NULL) {                                           \
+      assert(h._thread == Thread::current(), "thread must be current");\
+      _thread = h._thread;                                             \
+    } else {                                                           \
+      _thread = Thread::current();                                     \
+    }                                                                  \
+    _thread->metadata_handles()->push((Metadata*)_value);              \
+  }                                                                    \
+}                                                                      \
+inline name##Handle& name##Handle::operator=(const name##Handle &s) {  \
+  remove();                                                            \
+  _value = s._value;                                                   \
+  if (_value != NULL) {                                                \
+    assert(_value->is_valid(), "obj is valid");                        \
+    if (s._thread != NULL) {                                           \
+      assert(s._thread == Thread::current(), "thread must be current");\
+      _thread = s._thread;                                             \
+    } else {                                                           \
+      _thread = Thread::current();                                     \
+    }                                                                  \
+    _thread->metadata_handles()->push((Metadata*)_value);              \
+  }                                                                    \
+  return *this;                                                        \
+}                                                                      \
+inline void name##Handle::remove() {                                   \
+  if (_value != NULL) {                                                \
+    int i = _thread->metadata_handles()->find_from_end((Metadata*)_value); \
+    assert(i!=-1, "not in metadata_handles list");                     \
+    _thread->metadata_handles()->remove_at(i);                         \
+  }                                                                    \
+}                                                                      \
+inline name##Handle::~name##Handle () { remove(); }                    \
+
+DEF_METADATA_HANDLE_FN(method, Method)
+DEF_METADATA_HANDLE_FN(constantPool, ConstantPool)
 
 inline HandleMark::HandleMark() {
   initialize(Thread::current());