/* * Copyright (c) 1999, 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. *
*/
/////////////////////////////////////////////////////////////// // // class GrowableCache, GrowableElement // Used by : JvmtiBreakpointCache // Used by JVMTI methods: none directly. // // GrowableCache is a permanent CHeap growable array of <GrowableElement *> // // In addition, the GrowableCache maintains a NULL terminated cache array of type address // that's created from the element array using the function: // address GrowableElement::getCacheValue(). // // Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated // block of memory. Additionally, every time the cache changes its position in memory, the // void (*_listener_fun)(void *this_obj, address* cache) // gets called with the cache's new address. This gives the user of the GrowableCache a callback // to update its pointer to the address cache. //
// Array of elements in the collection
GrowableArray<GrowableElement *> *_elements;
// Parallel array of cached values
address *_cache;
// Listener for changes to the _cache field. // Called whenever the _cache field has it's value changed // (but NOT when cached elements are recomputed). void (*_listener_fun)(void *, address*);
staticbool equals(void *, GrowableElement *);
// recache all elements after size change, notify listener void recache();
// number of elements in the collection int length(); // get the value of the index element in the collection
GrowableElement* at(int index); // find the index of the element, -1 if it doesn't exist int find(GrowableElement* e); // append a copy of the element to the end of the collection, notify listener void append(GrowableElement* e); // remove the element at index, notify listener void remove (int index); // clear out all elements and release all heap space, notify listener void clear();
};
/////////////////////////////////////////////////////////////// // // class JvmtiBreakpointCache // Used by : JvmtiBreakpoints // Used by JVMTI methods: none directly. // Note : typesafe wrapper for GrowableCache of JvmtiBreakpoint //
class JvmtiBreakpointCache : public CHeapObj<mtInternal> {
/////////////////////////////////////////////////////////////// // // class JvmtiBreakpoint // Used by : JvmtiBreakpoints // Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints // Note: Extends GrowableElement for use in a GrowableCache // // A JvmtiBreakpoint describes a location (class, method, bci) to break at. //
typedefvoid (Method::*method_action)(int _bci);
class JvmtiBreakpoint : public GrowableElement { private:
Method* _method; int _bci;
OopHandle _class_holder; // keeps _method memory from being deallocated
/////////////////////////////////////////////////////////////// // // class JvmtiBreakpoints // Used by : JvmtiCurrentBreakpoints // Used by JVMTI methods: none directly // Note: A Helper class // // JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint. // All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints. // // Because _bps is only modified at safepoints, its possible to always use the // cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints). // // It would be possible to make JvmtiBreakpoints a static class, but I've made it // CHeap allocated to emphasize its similarity to JvmtiFramePops. //
class JvmtiBreakpoints : public CHeapObj<mtInternal> { private:
JvmtiBreakpointCache _bps;
// These should only be used by VM_ChangeBreakpoints // to insure they only occur at safepoints. // Todo: add checks for safepoint friendclass VM_ChangeBreakpoints; void set_at_safepoint(JvmtiBreakpoint& bp); void clear_at_safepoint(JvmtiBreakpoint& bp);
int set(JvmtiBreakpoint& bp); int clear(JvmtiBreakpoint& bp); void clearall_in_class_at_safepoint(Klass* klass);
};
/////////////////////////////////////////////////////////////// // // class JvmtiCurrentBreakpoints // // A static wrapper class for the JvmtiBreakpoints that provides: // 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint). // 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary, // but I'm copying the code from JvmtiThreadState which needs to lazily initialize // JvmtiFramePops). // 3. An oops_do entry point for GC'ing the breakpoint array. //
class JvmtiCurrentBreakpoints : public AllStatic {
private:
// Current breakpoints, lazily initialized by get_jvmti_breakpoints(); static JvmtiBreakpoints *_jvmti_breakpoints;
// NULL terminated cache of byte-code pointers corresponding to current breakpoints. // Updated only at safepoints (with listener_fun) when the cache is moved. // It exists only to make is_breakpoint fast. static address *_breakpoint_list; staticinlinevoid set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; }
// Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list. staticvoid listener_fun(void *this_obj, address *cache);
// lazily create _jvmti_breakpoints and _breakpoint_list static JvmtiBreakpoints& get_jvmti_breakpoints();
};
/////////////////////////////////////////////////////////////// // // class VM_ChangeBreakpoints // Used by : JvmtiBreakpoints // Used by JVMTI methods: none directly. // Note: A Helper class. // // VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class. //
class VM_ChangeBreakpoints : public VM_Operation { private:
JvmtiBreakpoints* _breakpoints; int _operation;
JvmtiBreakpoint* _bp;
/////////////////////////////////////////////////////////////// // The get/set local operations must only be done by the VM thread // because the interpreter version needs to access oop maps, which can // only safely be done by the VM thread // // I'm told that in 1.5 oop maps are now protected by a lock and // we could get rid of the VM op // However if the VM op is removed then the target thread must // be suspended AND a lock will be needed to prevent concurrent // setting of locals to the same java thread. This lock is needed // to prevent compiledVFrames from trying to add deferred updates // to the thread simultaneously. // class VM_BaseGetOrSetLocal : public VM_Operation { protected:
JavaThread* _calling_thread;
jint _depth;
jint _index;
BasicType _type;
jvalue _value;
javaVFrame* _jvf; bool _set; bool _self;
staticconst jvalue _DEFAULT_VALUE;
// It is possible to get the receiver out of a non-static native wrapper // frame. Use VM_GetReceiver to do this. virtualbool getting_receiver() const { returnfalse; }
// Check that the klass is assignable to a type with the given signature. staticbool is_assignable(constchar* ty_sign, Klass* klass, Thread* thread);
};
class VM_GetOrSetLocal : public VM_BaseGetOrSetLocal { protected:
JavaThread* _thread;
EscapeBarrier _eb;
// VM operation to get or set virtual thread local. class VM_VirtualThreadGetOrSetLocal : public VM_BaseGetOrSetLocal { protected:
JvmtiEnv *_env;
Handle _vthread_h;
/////////////////////////////////////////////////////////////// // // class JvmtiSuspendControl // // Convenience routines for suspending and resuming threads. // // All attempts by JVMTI to suspend and resume threads must go through the // JvmtiSuspendControl interface. // // methods return true if successful // class JvmtiSuspendControl : public AllStatic { public: // suspend the thread, taking it to a safepoint staticbool suspend(JavaThread *java_thread); // resume the thread staticbool resume(JavaThread *java_thread);
staticvoid print();
};
/** * When a thread (such as the compiler thread or VM thread) cannot post a * JVMTI event itself because the event needs to be posted from a Java * thread, then it can defer the event to the Service thread for posting. * The information needed to post the event is encapsulated into this class * and then enqueued onto the JvmtiDeferredEventQueue, where the Service * thread will pick it up and post it. * * This is currently only used for posting compiled-method-load and unload * events, which we don't want posted from the compiler thread.
*/ class JvmtiDeferredEvent { friendclass JvmtiDeferredEventQueue; private: typedefenum {
TYPE_NONE,
TYPE_COMPILED_METHOD_LOAD,
TYPE_COMPILED_METHOD_UNLOAD,
TYPE_DYNAMIC_CODE_GENERATED,
TYPE_CLASS_UNLOAD
} Type;
// Actually posts the event. void post() NOT_JVMTI_RETURN; void post_compiled_method_load_event(JvmtiEnv* env) NOT_JVMTI_RETURN; void run_nmethod_entry_barriers() NOT_JVMTI_RETURN; // GC support to keep nmethods from unloading while in the queue. void nmethods_do(CodeBlobClosure* cf) NOT_JVMTI_RETURN; // GC support to keep nmethod from being unloaded while in the queue. void oops_do(OopClosure* f, CodeBlobClosure* cf) NOT_JVMTI_RETURN;
};
/** * Events enqueued on this queue wake up the Service thread which dequeues * and posts the events. The Service_lock is required to be held * when operating on the queue.
*/ class JvmtiDeferredEventQueue : public CHeapObj<mtInternal> { friendclass JvmtiDeferredEvent; private: class QueueNode : public CHeapObj<mtInternal> { private:
JvmtiDeferredEvent _event;
QueueNode* _next;
// Post all events in the queue for the current Jvmti environment void post(JvmtiEnv* env) NOT_JVMTI_RETURN; void enqueue(JvmtiDeferredEvent event) NOT_JVMTI_RETURN; void run_nmethod_entry_barriers();
// GC support to keep nmethods from unloading while in the queue. void nmethods_do(CodeBlobClosure* cf) NOT_JVMTI_RETURN; // GC support to keep nmethod from being unloaded while in the queue. void oops_do(OopClosure* f, CodeBlobClosure* cf) NOT_JVMTI_RETURN;
};
// Utility macro that checks for NULL pointers: #define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }
#endif// SHARE_PRIMS_JVMTIIMPL_HPP
Messung V0.5
¤ Dauer der Verarbeitung: 0.3 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 und die Messung sind noch experimentell.