src/hotspot/share/jvmci/jniAccessMark.inline.hpp
author kvn
Wed, 01 May 2019 12:31:29 -0700
changeset 54669 ad45b3802d4e
permissions -rw-r--r--
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library Reviewed-by: dnsimon, never, stefank, rehn, neliasso, dholmes, kbarrett, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     1
/*
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     4
 *
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     8
 *
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    13
 * accompanied this code).
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    14
 *
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    18
 *
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    21
 * questions.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    22
 *
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    23
 */
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    24
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    25
#ifndef SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    26
#define SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    27
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    28
#include "jvmci/jvmciEnv.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    29
#include "runtime/interfaceSupport.inline.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    30
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    31
// Wrapper for a JNI call into the JVMCI shared library.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    32
// This performs a ThreadToNativeFromVM transition so that the VM
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    33
// will not be blocked if the call takes a long time (e.g., due
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    34
// to a GC in the shared library).
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    35
class JNIAccessMark : public StackObj {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    36
 private:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    37
  ThreadToNativeFromVM ttnfv;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    38
  HandleMark hm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    39
  JNIEnv* _env;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    40
 public:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    41
  inline JNIAccessMark(JVMCIEnv* jvmci_env) :
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    42
    ttnfv(JavaThread::current()), hm(JavaThread::current()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    43
    _env = jvmci_env->_env;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    44
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    45
  JNIEnv* env() const { return _env; }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    46
  JNIEnv* operator () () const { return _env; }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    47
};
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    48
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
diff changeset
    49
#endif // SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP