1 /*
   2  * Copyright (c) 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_COMPILER_CODECACHE_INLINE_HPP
  26 #define SHARE_VM_COMPILER_CODECACHE_INLINE_HPP
  27 
  28 #include "code/codeCache.hpp"
  29 #include "code/nativeInst.hpp"
  30 
  31 inline CodeBlob* CodeCache::find_blob_fast(void* pc) {
  32   int slot = 0;
  33   return find_blob_and_oopmap(pc, slot);
  34 }
  35 
  36 inline CodeBlob* CodeCache::find_blob_and_oopmap(void* pc, int& slot) {
  37   NativePostCallNop* nop = nativePostCallNop_at((address) pc);
  38   if (LIKELY(nop != NULL)
  39 #ifdef CONT_DOUBLE_NOP
  40       && !nop->is_mode2()
  41 #endif
  42   ) {
  43     CodeBlob* cb;
  44     if (LIKELY(nop->displacement() != 0)) {
  45       int offset = (nop->displacement() & 0xffffff);
  46       cb = (CodeBlob*) ((address) pc - offset);
  47       slot = ((nop->displacement() >> 24) & 0xff);
  48       // tty->print_cr(">>> PATCHED 22"); cb->print_on(tty);
  49     } else {
  50       // tty->print_cr(">>> patching");
  51       cb = CodeCache::patch_nop(nop, pc, slot);
  52     }
  53 #ifdef CONT_DOUBLE_NOP
  54     assert(!nop->is_mode2() == 1, "");
  55 #endif
  56     assert(cb != NULL, "must be");
  57     return cb;
  58   } else {
  59     CodeBlob* cb = CodeCache::find_blob(pc);
  60     slot = -1;
  61     return cb;
  62   }
  63 }
  64 
  65 #endif