1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_CLASSFILE_BACKTRACE_HPP 26 #define SHARE_VM_CLASSFILE_BACKTRACE_HPP 27 28 #include "memory/allocation.hpp" 29 #include "memory/iterator.hpp" 30 #include "oops/oop.inline.hpp" 31 32 // Backtrace management - Method* on backtraces need to be preserved for 33 // RedefineClasses, so we keep a list and mark them as on_stack so that the Method* 34 // doesn't get deallocatd. 35 // This list is managed as a weak root, but doesn't use jweak because 36 // the cost of creating these objects is performance critical. 37 38 class Backtrace : public CHeapObj<mtClass> { 39 oop _throwable; 40 Backtrace* _next; 41 42 public: 43 Backtrace(oop throwable) : _throwable(throwable), _next(NULL) {} 44 oop throwable() { return _throwable; } 45 Backtrace* next() const { return _next; } 46 void set_next(Backtrace* bt) { _next = bt; } 47 // GC support 48 void oops_do(OopClosure* f); 49 }; 50 51 class BacktraceList : public AllStatic { 52 // List of backtraces to mark Method pointers. 53 static Backtrace* _backtraces_head; 54 static volatile int _bt_count; 55 56 public: 57 static void mark_on_stack(); 58 static void unlink(BoolObjectClosure* is_alive); 59 static void add(oop throwable); 60 static void oops_do(OopClosure* f); 61 }; 62 63 #endif // SHARE_VM_CLASSFILE_BACKTRACE_HPP