duke@435: /* coleenp@4037: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "memory/allocation.inline.hpp" stefank@2314: #include "oops/instanceKlass.hpp" coleenp@4037: #include "oops/method.hpp" stefank@2314: #include "oops/oop.inline.hpp" stefank@2314: #include "prims/privilegedStack.hpp" stefank@2314: #include "runtime/vframe.hpp" duke@435: duke@435: duke@435: void PrivilegedElement::initialize(vframeStream* vfst, oop context, PrivilegedElement* next, TRAPS) { coleenp@4037: Method* method = vfst->method(); duke@435: _klass = method->method_holder(); duke@435: _privileged_context = context; duke@435: #ifdef CHECK_UNHANDLED_OOPS duke@435: THREAD->allow_unhandled_oop(&_privileged_context); duke@435: #endif // CHECK_UNHANDLED_OOPS duke@435: _frame_id = vfst->frame_id(); duke@435: _next = next; duke@435: assert(_privileged_context == NULL || _privileged_context->is_oop(), "must be an oop"); duke@435: assert(protection_domain() == NULL || protection_domain()->is_oop(), "must be an oop"); duke@435: } duke@435: duke@435: void PrivilegedElement::oops_do(OopClosure* f) { duke@435: PrivilegedElement *cur = this; duke@435: do { duke@435: f->do_oop((oop*) &cur->_privileged_context); duke@435: cur = cur->_next; duke@435: } while(cur != NULL); duke@435: } duke@435: coleenp@4037: void PrivilegedElement::classes_do(KlassClosure* f) { coleenp@4037: PrivilegedElement *cur = this; coleenp@4037: do { coleenp@4037: f->do_klass(cur->_klass); coleenp@4037: cur = cur->_next; coleenp@4037: } while(cur != NULL); coleenp@4037: } coleenp@4037: duke@435: //------------------------------------------------------------------------------- duke@435: #ifndef PRODUCT duke@435: duke@435: void PrivilegedElement::print_on(outputStream* st) const { duke@435: st->print(" 0x%lx ", _frame_id); duke@435: _klass->print_value_on(st); duke@435: if (protection_domain() != NULL) { duke@435: st->print(" "); duke@435: protection_domain()->print_value_on(st); duke@435: } duke@435: st->cr(); duke@435: } duke@435: duke@435: bool PrivilegedElement::contains(address addr) { duke@435: PrivilegedElement *e = (PrivilegedElement *)addr; duke@435: if (e >= this && e < this+1) return true; duke@435: duke@435: if (_next != NULL) { duke@435: return _next->contains(addr); duke@435: } else { duke@435: return false; duke@435: } duke@435: } duke@435: duke@435: #endif