< prev index next >

src/hotspot/share/code/compiledIC.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2019, 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  *


  35 #include "memory/metadataFactory.hpp"
  36 #include "memory/oopFactory.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "memory/universe.hpp"
  39 #include "oops/method.inline.hpp"
  40 #include "oops/oop.inline.hpp"
  41 #include "oops/symbol.hpp"
  42 #include "runtime/handles.inline.hpp"
  43 #include "runtime/icache.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/stubRoutines.hpp"
  46 #include "utilities/events.hpp"
  47 
  48 
  49 // Every time a compiled IC is changed or its type is being accessed,
  50 // either the CompiledIC_lock must be set or we must be at a safe point.
  51 
  52 CompiledICLocker::CompiledICLocker(CompiledMethod* method)
  53   : _method(method),
  54     _behaviour(CompiledICProtectionBehaviour::current()),
  55     _locked(_behaviour->lock(_method)) {

  56 }
  57 
  58 CompiledICLocker::~CompiledICLocker() {
  59   if (_locked) {
  60     _behaviour->unlock(_method);
  61   }
  62 }
  63 
  64 bool CompiledICLocker::is_safe(CompiledMethod* method) {
  65   return CompiledICProtectionBehaviour::current()->is_safe(method);
  66 }
  67 
  68 bool CompiledICLocker::is_safe(address code) {
  69   CodeBlob* cb = CodeCache::find_blob_unsafe(code);
  70   assert(cb != NULL && cb->is_compiled(), "must be compiled");
  71   CompiledMethod* cm = cb->as_compiled_method();
  72   return CompiledICProtectionBehaviour::current()->is_safe(cm);
  73 }
  74 
  75 //-----------------------------------------------------------------------------


   1 /*
   2  * Copyright (c) 1997, 2018, 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  *


  35 #include "memory/metadataFactory.hpp"
  36 #include "memory/oopFactory.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "memory/universe.hpp"
  39 #include "oops/method.inline.hpp"
  40 #include "oops/oop.inline.hpp"
  41 #include "oops/symbol.hpp"
  42 #include "runtime/handles.inline.hpp"
  43 #include "runtime/icache.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/stubRoutines.hpp"
  46 #include "utilities/events.hpp"
  47 
  48 
  49 // Every time a compiled IC is changed or its type is being accessed,
  50 // either the CompiledIC_lock must be set or we must be at a safe point.
  51 
  52 CompiledICLocker::CompiledICLocker(CompiledMethod* method)
  53   : _method(method),
  54     _behaviour(CompiledICProtectionBehaviour::current()),
  55     _locked(_behaviour->lock(_method)),
  56     _nsv(true, !SafepointSynchronize::is_at_safepoint()) {
  57 }
  58 
  59 CompiledICLocker::~CompiledICLocker() {
  60   if (_locked) {
  61     _behaviour->unlock(_method);
  62   }
  63 }
  64 
  65 bool CompiledICLocker::is_safe(CompiledMethod* method) {
  66   return CompiledICProtectionBehaviour::current()->is_safe(method);
  67 }
  68 
  69 bool CompiledICLocker::is_safe(address code) {
  70   CodeBlob* cb = CodeCache::find_blob_unsafe(code);
  71   assert(cb != NULL && cb->is_compiled(), "must be compiled");
  72   CompiledMethod* cm = cb->as_compiled_method();
  73   return CompiledICProtectionBehaviour::current()->is_safe(cm);
  74 }
  75 
  76 //-----------------------------------------------------------------------------


< prev index next >