/* * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Interface for creating and resolving local/global JNI handles
class JNIHandles : AllStatic { friendclass VMStructs; private: // These are used by the serviceability agent. static OopStorage* _global_handles; static OopStorage* _weak_global_handles; friendvoid jni_handles_init();
// Resolve handle into oop, without keeping the object alive inlinestatic oop resolve_no_keepalive(jobject handle);
// This method is not inlined in order to avoid circular includes between // this header file and thread.hpp. staticbool current_thread_in_native();
public: // Low tag bit in jobject used to distinguish a jweak. jweak is // type equivalent to jobject, but there are places where we need to // be able to distinguish jweak values from other jobjects, and // is_weak_global_handle is unsuitable for performance reasons. To // provide such a test we add weak_tag_value to the (aligned) byte // address designated by the jobject to produce the corresponding // jweak. Accessing the value of a jobject must account for it // being a possibly offset jweak. staticconst uintptr_t weak_tag_size = 1; staticconst uintptr_t weak_tag_alignment = (1u << weak_tag_size); staticconst uintptr_t weak_tag_mask = weak_tag_alignment - 1; staticconstint weak_tag_value = 1;
// Resolve handle into oop inlinestatic oop resolve(jobject handle); // Resolve handle into oop, result guaranteed not to be null inlinestatic oop resolve_non_null(jobject handle); // Resolve externally provided handle into oop with some guards static oop resolve_external_guard(jobject handle);
// Check for equality without keeping objects alive staticbool is_same_object(jobject handle1, jobject handle2);
// Local handles static jobject make_local(oop obj); static jobject make_local(JavaThread* thread, oop obj, // Faster version when current thread is known
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); inlinestaticvoid destroy_local(jobject handle);
// Garbage collection support(global handles only, local handles are traversed from thread) // Traversal of regular global handles staticvoid oops_do(OopClosure* f); // Traversal of weak global handles. staticvoid weak_oops_do(OopClosure* f);
class JNIHandleBlock : public CHeapObj<mtInternal> { friendclass VMStructs; friendclass ZeroInterpreter;
private: enum SomeConstants {
block_size_in_oops = 32 // Number of handles per handle block
};
uintptr_t _handles[block_size_in_oops]; // The handles int _top; // Index of next unused handle int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list
JNIHandleBlock* _next; // Link to next block
// The following instance variables are only used by the first block in a chain. // Having two types of blocks complicates the code and the space overhead in negligible.
JNIHandleBlock* _last; // Last block in use
JNIHandleBlock* _pop_frame_link; // Block to restore on PopLocalFrame call
uintptr_t* _free_list; // Handle free list
staticint _blocks_allocated; // For debugging/printing
// Fill block with bad_handle values void zap() NOT_DEBUG_RETURN;
// Free list computation void rebuild_free_list();
// No more handles in the both the current and following blocks void clear() { _top = 0; }
// Garbage collection support // Traversal of handles void oops_do(OopClosure* f);
// Debugging bool chain_contains(jobject handle) const; // Does this block or following blocks contain handle bool contains(jobject handle) const; // Does this block contain handle
};
#endif// SHARE_RUNTIME_JNIHANDLES_HPP
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.