< prev index next >

src/hotspot/share/prims/privilegedStack.cpp

Print this page




  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 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "oops/instanceKlass.hpp"
  28 #include "oops/method.hpp"
  29 #include "oops/oop.inline.hpp"

  30 #include "prims/privilegedStack.hpp"
  31 #include "runtime/vframe.hpp"
  32 
  33 void PrivilegedElement::initialize(vframeStream* vfst, oop context, PrivilegedElement* next, TRAPS) {
  34   Method* method        = vfst->method();
  35   _klass                = method->method_holder();
  36   _privileged_context   = context;
  37 #ifdef CHECK_UNHANDLED_OOPS
  38   THREAD->allow_unhandled_oop(&_privileged_context);
  39 #endif // CHECK_UNHANDLED_OOPS
  40   _frame_id             = vfst->frame_id();
  41   _next                 = next;
  42   assert(oopDesc::is_oop_or_null(_privileged_context), "must be an oop");
  43   assert(oopDesc::is_oop_or_null(protection_domain()), "must be an oop");
  44 }
  45 
  46 void PrivilegedElement::oops_do(OopClosure* f) {
  47   PrivilegedElement *cur = this;

  48   do {

  49     f->do_oop((oop*) &cur->_privileged_context);








  50     cur = cur->_next;
  51   } while(cur != NULL);
  52 }
  53 
  54 //-------------------------------------------------------------------------------
  55 #ifndef PRODUCT
  56 
  57 void PrivilegedElement::print_on(outputStream* st) const {
  58   st->print("   " PTR_FORMAT " ", p2i(_frame_id));
  59   _klass->print_value_on(st);
  60   if (protection_domain() != NULL) {
  61     st->print("   ");
  62     protection_domain()->print_value_on(st);
  63   }
  64   st->cr();
  65 }
  66 
  67 bool PrivilegedElement::contains(address addr) {
  68   PrivilegedElement *e = (PrivilegedElement *)addr;
  69   if (e >= this && e < this+1) return true;


  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 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "oops/instanceKlass.hpp"
  28 #include "oops/method.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/valueKlass.hpp"
  31 #include "prims/privilegedStack.hpp"
  32 #include "runtime/vframe.hpp"
  33 
  34 void PrivilegedElement::initialize(vframeStream* vfst, oop context, PrivilegedElement* next, TRAPS) {
  35   Method* method        = vfst->method();
  36   _klass                = method->method_holder();
  37   _privileged_context   = context;
  38 #ifdef CHECK_UNHANDLED_OOPS
  39   THREAD->allow_unhandled_oop(&_privileged_context);
  40 #endif // CHECK_UNHANDLED_OOPS
  41   _frame_id             = vfst->frame_id();
  42   _next                 = next;
  43   assert(oopDesc::is_oop_or_null(_privileged_context), "must be an oop");
  44   assert(oopDesc::is_oop_or_null(protection_domain()), "must be an oop");
  45 }
  46 
  47 void PrivilegedElement::oops_do(OopClosure* f) {
  48   PrivilegedElement *cur = this;
  49   BufferedValuesDealiaser* dealiaser = NULL;
  50   do {
  51     if (!VTBuffer::is_in_vt_buffer(cur->_privileged_context)) {
  52       f->do_oop((oop*) &cur->_privileged_context);
  53     } else {
  54       if (dealiaser == NULL) {
  55         dealiaser = Thread::current()->buffered_values_dealiaser();
  56       }
  57       oop value = *(oop*) &cur->_privileged_context;
  58       assert(value->is_value(), "Sanity check");
  59       dealiaser->oops_do(f, value);
  60     }
  61     cur = cur->_next;
  62   } while(cur != NULL);
  63 }
  64 
  65 //-------------------------------------------------------------------------------
  66 #ifndef PRODUCT
  67 
  68 void PrivilegedElement::print_on(outputStream* st) const {
  69   st->print("   " PTR_FORMAT " ", p2i(_frame_id));
  70   _klass->print_value_on(st);
  71   if (protection_domain() != NULL) {
  72     st->print("   ");
  73     protection_domain()->print_value_on(st);
  74   }
  75   st->cr();
  76 }
  77 
  78 bool PrivilegedElement::contains(address addr) {
  79   PrivilegedElement *e = (PrivilegedElement *)addr;
  80   if (e >= this && e < this+1) return true;
< prev index next >