Path: blob/master/src/hotspot/share/jvmci/jvmciObject.hpp
40949 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#ifndef SHARE_JVMCI_JVMCIOBJECT_HPP24#define SHARE_JVMCI_JVMCIOBJECT_HPP2526#include "jni.h"27#include "utilities/debug.hpp"2829class JVMCIArray;30class JVMCIPrimitiveArray;31class JVMCIObjectArray;3233class JVMCIObject {3435private:36jobject _object;37bool _is_hotspot;3839public:40JVMCIObject(): _object(NULL), _is_hotspot(false) {}41JVMCIObject(jobject o, bool is_hotspot): _object(o), _is_hotspot(is_hotspot) { }4243static JVMCIObject create(jobject o, bool is_hotspot) { JVMCIObject r(o, is_hotspot); return r; }44jobject as_jobject() { return _object; }45jobject as_jweak() { return (jweak) _object; }46jstring as_jstring() { return (jstring) _object; }47bool is_hotspot() { return _is_hotspot; }4849bool is_null() const { return _object == NULL; }50bool is_non_null() const { return _object != NULL; }5152operator JVMCIArray();53operator JVMCIPrimitiveArray();54operator JVMCIObjectArray();55};5657class JVMCIArray : public JVMCIObject {58public:59JVMCIArray() {}60JVMCIArray(jobject o, bool is_hotspot): JVMCIObject(o, is_hotspot) {}61jarray as_jobject() { return (jarray) JVMCIObject::as_jobject(); }62};6364class JVMCIObjectArray : public JVMCIArray {65public:66JVMCIObjectArray() {}67JVMCIObjectArray(void* v): JVMCIArray() { assert(v == NULL, "must be NULL"); }68JVMCIObjectArray(jobject o, bool is_hotspot): JVMCIArray(o, is_hotspot) {}6970jobjectArray as_jobject() { return (jobjectArray) JVMCIArray::as_jobject(); }71};7273class JVMCIPrimitiveArray : public JVMCIArray {74public:75JVMCIPrimitiveArray() {}76JVMCIPrimitiveArray(void* v): JVMCIArray() { assert(v == NULL, "must be NULL"); }77JVMCIPrimitiveArray(jobject o, bool is_hotspot): JVMCIArray(o, is_hotspot) {}7879jbooleanArray as_jbooleanArray() { return (jbooleanArray) as_jobject(); }80jbyteArray as_jbyteArray() { return (jbyteArray) as_jobject(); }81jcharArray as_jcharArray() { return (jcharArray) as_jobject(); }82jshortArray as_jshortArray() { return (jshortArray) as_jobject(); }83jintArray as_jintArray() { return (jintArray) as_jobject(); }84jfloatArray as_jfloatArray() { return (jfloatArray) as_jobject(); }85jlongArray as_jlongArray() { return (jlongArray) as_jobject(); }86jdoubleArray as_jdoubleArray() { return (jdoubleArray) as_jobject(); }87};8889inline JVMCIObject::operator JVMCIArray() { return JVMCIArray(_object, _is_hotspot); }90inline JVMCIObject::operator JVMCIPrimitiveArray() { return JVMCIPrimitiveArray(_object, _is_hotspot); }91inline JVMCIObject::operator JVMCIObjectArray() { return JVMCIObjectArray(_object, _is_hotspot); }9293#endif // SHARE_JVMCI_JVMCIOBJECT_HPP949596