src/share/vm/prims/jvmtiImpl.hpp

Fri, 16 Aug 2013 13:22:32 +0200

author
stefank
date
Fri, 16 Aug 2013 13:22:32 +0200
changeset 5578
4c84d351cca9
parent 5237
f2110083203d
child 6063
910026b800b8
permissions
-rw-r--r--

8007074: SIGSEGV at ParMarkBitMap::verify_clear()
Summary: Replace the broken large pages implementation on Linux. New flag: -XX:+UseTransparentHugePages - Linux specific flag to turn on transparent huge page hinting with madvise(..., MAP_HUGETLB). Changed behavior: -XX:+UseLargePages - tries to use -XX:+UseTransparentHugePages before trying other large pages implementations (on Linux). Changed behavior: -XX:+UseHugeTLBFS - Use upfront allocation of Large Pages instead of using the broken implementation to dynamically committing large pages. Changed behavior: -XX:LargePageSizeInBytes - Turned off the ability to use this flag on Linux and provides warning to user if set to a value different than the OS chosen large page size. Changed behavior: Setting no large page size - Now defaults to use -XX:UseTransparentHugePages if the OS supports it. Previously, -XX:+UseHugeTLBFS was chosen if the OS was configured to use large pages.
Reviewed-by: tschatzl, dcubed, brutisso

duke@435 1 /*
zgu@4492 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_PRIMS_JVMTIIMPL_HPP
stefank@2314 26 #define SHARE_VM_PRIMS_JVMTIIMPL_HPP
stefank@2314 27
stefank@2314 28 #include "classfile/systemDictionary.hpp"
stefank@2314 29 #include "jvmtifiles/jvmti.h"
stefank@2314 30 #include "oops/objArrayOop.hpp"
stefank@2314 31 #include "prims/jvmtiEnvThreadState.hpp"
stefank@2314 32 #include "prims/jvmtiEventController.hpp"
stefank@2314 33 #include "prims/jvmtiTrace.hpp"
stefank@2314 34 #include "prims/jvmtiUtil.hpp"
stefank@2314 35 #include "runtime/stackValueCollection.hpp"
stefank@2314 36 #include "runtime/vm_operations.hpp"
stefank@2314 37
duke@435 38 //
duke@435 39 // Forward Declarations
duke@435 40 //
duke@435 41
duke@435 42 class JvmtiBreakpoint;
duke@435 43 class JvmtiBreakpoints;
duke@435 44
duke@435 45
duke@435 46 ///////////////////////////////////////////////////////////////
duke@435 47 //
duke@435 48 // class GrowableCache, GrowableElement
duke@435 49 // Used by : JvmtiBreakpointCache
duke@435 50 // Used by JVMTI methods: none directly.
duke@435 51 //
duke@435 52 // GrowableCache is a permanent CHeap growable array of <GrowableElement *>
duke@435 53 //
duke@435 54 // In addition, the GrowableCache maintains a NULL terminated cache array of type address
duke@435 55 // that's created from the element array using the function:
duke@435 56 // address GrowableElement::getCacheValue().
duke@435 57 //
duke@435 58 // Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated
duke@435 59 // block of memory. Additionally, every time the cache changes its position in memory, the
duke@435 60 // void (*_listener_fun)(void *this_obj, address* cache)
duke@435 61 // gets called with the cache's new address. This gives the user of the GrowableCache a callback
duke@435 62 // to update its pointer to the address cache.
duke@435 63 //
duke@435 64
zgu@3900 65 class GrowableElement : public CHeapObj<mtInternal> {
duke@435 66 public:
duke@435 67 virtual address getCacheValue() =0;
duke@435 68 virtual bool equals(GrowableElement* e) =0;
duke@435 69 virtual bool lessThan(GrowableElement *e)=0;
duke@435 70 virtual GrowableElement *clone() =0;
duke@435 71 virtual void oops_do(OopClosure* f) =0;
duke@435 72 };
duke@435 73
duke@435 74 class GrowableCache VALUE_OBJ_CLASS_SPEC {
duke@435 75
duke@435 76 private:
duke@435 77 // Object pointer passed into cache & listener functions.
duke@435 78 void *_this_obj;
duke@435 79
duke@435 80 // Array of elements in the collection
duke@435 81 GrowableArray<GrowableElement *> *_elements;
duke@435 82
duke@435 83 // Parallel array of cached values
duke@435 84 address *_cache;
duke@435 85
duke@435 86 // Listener for changes to the _cache field.
duke@435 87 // Called whenever the _cache field has it's value changed
duke@435 88 // (but NOT when cached elements are recomputed).
duke@435 89 void (*_listener_fun)(void *, address*);
duke@435 90
duke@435 91 static bool equals(void *, GrowableElement *);
duke@435 92
duke@435 93 // recache all elements after size change, notify listener
duke@435 94 void recache();
duke@435 95
duke@435 96 public:
duke@435 97 GrowableCache();
duke@435 98 ~GrowableCache();
duke@435 99
duke@435 100 void initialize(void *this_obj, void listener_fun(void *, address*) );
duke@435 101
duke@435 102 // number of elements in the collection
duke@435 103 int length();
duke@435 104 // get the value of the index element in the collection
duke@435 105 GrowableElement* at(int index);
duke@435 106 // find the index of the element, -1 if it doesn't exist
duke@435 107 int find(GrowableElement* e);
duke@435 108 // append a copy of the element to the end of the collection, notify listener
duke@435 109 void append(GrowableElement* e);
duke@435 110 // insert a copy of the element using lessthan(), notify listener
duke@435 111 void insert(GrowableElement* e);
duke@435 112 // remove the element at index, notify listener
duke@435 113 void remove (int index);
duke@435 114 // clear out all elements and release all heap space, notify listener
duke@435 115 void clear();
duke@435 116 // apply f to every element and update the cache
duke@435 117 void oops_do(OopClosure* f);
kamg@2467 118 // update the cache after a full gc
kamg@2467 119 void gc_epilogue();
duke@435 120 };
duke@435 121
duke@435 122
duke@435 123 ///////////////////////////////////////////////////////////////
duke@435 124 //
duke@435 125 // class JvmtiBreakpointCache
duke@435 126 // Used by : JvmtiBreakpoints
duke@435 127 // Used by JVMTI methods: none directly.
duke@435 128 // Note : typesafe wrapper for GrowableCache of JvmtiBreakpoint
duke@435 129 //
duke@435 130
zgu@3900 131 class JvmtiBreakpointCache : public CHeapObj<mtInternal> {
duke@435 132
duke@435 133 private:
duke@435 134 GrowableCache _cache;
duke@435 135
duke@435 136 public:
duke@435 137 JvmtiBreakpointCache() {}
duke@435 138 ~JvmtiBreakpointCache() {}
duke@435 139
duke@435 140 void initialize(void *this_obj, void listener_fun(void *, address*) ) {
duke@435 141 _cache.initialize(this_obj,listener_fun);
duke@435 142 }
duke@435 143
duke@435 144 int length() { return _cache.length(); }
duke@435 145 JvmtiBreakpoint& at(int index) { return (JvmtiBreakpoint&) *(_cache.at(index)); }
duke@435 146 int find(JvmtiBreakpoint& e) { return _cache.find((GrowableElement *) &e); }
duke@435 147 void append(JvmtiBreakpoint& e) { _cache.append((GrowableElement *) &e); }
duke@435 148 void remove (int index) { _cache.remove(index); }
duke@435 149 void clear() { _cache.clear(); }
duke@435 150 void oops_do(OopClosure* f) { _cache.oops_do(f); }
kamg@2467 151 void gc_epilogue() { _cache.gc_epilogue(); }
duke@435 152 };
duke@435 153
duke@435 154
duke@435 155 ///////////////////////////////////////////////////////////////
duke@435 156 //
duke@435 157 // class JvmtiBreakpoint
duke@435 158 // Used by : JvmtiBreakpoints
duke@435 159 // Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints
duke@435 160 // Note: Extends GrowableElement for use in a GrowableCache
duke@435 161 //
duke@435 162 // A JvmtiBreakpoint describes a location (class, method, bci) to break at.
duke@435 163 //
duke@435 164
coleenp@4037 165 typedef void (Method::*method_action)(int _bci);
duke@435 166
duke@435 167 class JvmtiBreakpoint : public GrowableElement {
duke@435 168 private:
coleenp@4037 169 Method* _method;
duke@435 170 int _bci;
duke@435 171 Bytecodes::Code _orig_bytecode;
coleenp@4037 172 oop _class_loader;
duke@435 173
duke@435 174 public:
duke@435 175 JvmtiBreakpoint();
coleenp@4037 176 JvmtiBreakpoint(Method* m_method, jlocation location);
duke@435 177 bool equals(JvmtiBreakpoint& bp);
duke@435 178 bool lessThan(JvmtiBreakpoint &bp);
duke@435 179 void copy(JvmtiBreakpoint& bp);
duke@435 180 bool is_valid();
duke@435 181 address getBcp();
duke@435 182 void each_method_version_do(method_action meth_act);
duke@435 183 void set();
duke@435 184 void clear();
duke@435 185 void print();
duke@435 186
coleenp@4037 187 Method* method() { return _method; }
duke@435 188
duke@435 189 // GrowableElement implementation
duke@435 190 address getCacheValue() { return getBcp(); }
duke@435 191 bool lessThan(GrowableElement* e) { Unimplemented(); return false; }
duke@435 192 bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); }
coleenp@4037 193 void oops_do(OopClosure* f) {
coleenp@4037 194 // Mark the method loader as live
coleenp@4037 195 f->do_oop(&_class_loader);
coleenp@4037 196 }
duke@435 197 GrowableElement *clone() {
duke@435 198 JvmtiBreakpoint *bp = new JvmtiBreakpoint();
duke@435 199 bp->copy(*this);
duke@435 200 return bp;
duke@435 201 }
duke@435 202 };
duke@435 203
duke@435 204
duke@435 205 ///////////////////////////////////////////////////////////////
duke@435 206 //
duke@435 207 // class JvmtiBreakpoints
duke@435 208 // Used by : JvmtiCurrentBreakpoints
duke@435 209 // Used by JVMTI methods: none directly
duke@435 210 // Note: A Helper class
duke@435 211 //
duke@435 212 // JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint.
duke@435 213 // All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints.
duke@435 214 //
duke@435 215 // Because _bps is only modified at safepoints, its possible to always use the
duke@435 216 // cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints).
duke@435 217 //
duke@435 218 // It would be possible to make JvmtiBreakpoints a static class, but I've made it
duke@435 219 // CHeap allocated to emphasize its similarity to JvmtiFramePops.
duke@435 220 //
duke@435 221
zgu@3900 222 class JvmtiBreakpoints : public CHeapObj<mtInternal> {
duke@435 223 private:
duke@435 224
duke@435 225 JvmtiBreakpointCache _bps;
duke@435 226
duke@435 227 // These should only be used by VM_ChangeBreakpoints
duke@435 228 // to insure they only occur at safepoints.
duke@435 229 // Todo: add checks for safepoint
duke@435 230 friend class VM_ChangeBreakpoints;
duke@435 231 void set_at_safepoint(JvmtiBreakpoint& bp);
duke@435 232 void clear_at_safepoint(JvmtiBreakpoint& bp);
duke@435 233
duke@435 234 static void do_element(GrowableElement *e);
duke@435 235
duke@435 236 public:
duke@435 237 JvmtiBreakpoints(void listener_fun(void *, address *));
duke@435 238 ~JvmtiBreakpoints();
duke@435 239
duke@435 240 int length();
duke@435 241 void oops_do(OopClosure* f);
duke@435 242 void print();
duke@435 243
duke@435 244 int set(JvmtiBreakpoint& bp);
duke@435 245 int clear(JvmtiBreakpoint& bp);
coleenp@4037 246 void clearall_in_class_at_safepoint(Klass* klass);
kamg@2467 247 void gc_epilogue();
duke@435 248 };
duke@435 249
duke@435 250
duke@435 251 ///////////////////////////////////////////////////////////////
duke@435 252 //
duke@435 253 // class JvmtiCurrentBreakpoints
duke@435 254 //
duke@435 255 // A static wrapper class for the JvmtiBreakpoints that provides:
duke@435 256 // 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint).
duke@435 257 // 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary,
duke@435 258 // but I'm copying the code from JvmtiThreadState which needs to lazily initialize
duke@435 259 // JvmtiFramePops).
duke@435 260 // 3. An oops_do entry point for GC'ing the breakpoint array.
duke@435 261 //
duke@435 262
duke@435 263 class JvmtiCurrentBreakpoints : public AllStatic {
duke@435 264
duke@435 265 private:
duke@435 266
duke@435 267 // Current breakpoints, lazily initialized by get_jvmti_breakpoints();
duke@435 268 static JvmtiBreakpoints *_jvmti_breakpoints;
duke@435 269
duke@435 270 // NULL terminated cache of byte-code pointers corresponding to current breakpoints.
duke@435 271 // Updated only at safepoints (with listener_fun) when the cache is moved.
duke@435 272 // It exists only to make is_breakpoint fast.
duke@435 273 static address *_breakpoint_list;
duke@435 274 static inline void set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; }
duke@435 275 static inline address *get_breakpoint_list() { return _breakpoint_list; }
duke@435 276
duke@435 277 // Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list.
duke@435 278 static void listener_fun(void *this_obj, address *cache);
duke@435 279
duke@435 280 public:
duke@435 281 static void initialize();
duke@435 282 static void destroy();
duke@435 283
duke@435 284 // lazily create _jvmti_breakpoints and _breakpoint_list
duke@435 285 static JvmtiBreakpoints& get_jvmti_breakpoints();
duke@435 286
duke@435 287 // quickly test whether the bcp matches a cached breakpoint in the list
duke@435 288 static inline bool is_breakpoint(address bcp);
duke@435 289
duke@435 290 static void oops_do(OopClosure* f);
kamg@2467 291 static void gc_epilogue();
duke@435 292 };
duke@435 293
duke@435 294 // quickly test whether the bcp matches a cached breakpoint in the list
duke@435 295 bool JvmtiCurrentBreakpoints::is_breakpoint(address bcp) {
duke@435 296 address *bps = get_breakpoint_list();
duke@435 297 if (bps == NULL) return false;
duke@435 298 for ( ; (*bps) != NULL; bps++) {
duke@435 299 if ((*bps) == bcp) return true;
duke@435 300 }
duke@435 301 return false;
duke@435 302 }
duke@435 303
sla@5237 304
sla@5237 305 ///////////////////////////////////////////////////////////////
sla@5237 306 //
sla@5237 307 // class VM_ChangeBreakpoints
sla@5237 308 // Used by : JvmtiBreakpoints
sla@5237 309 // Used by JVMTI methods: none directly.
sla@5237 310 // Note: A Helper class.
sla@5237 311 //
sla@5237 312 // VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class.
sla@5237 313 //
sla@5237 314
sla@5237 315 class VM_ChangeBreakpoints : public VM_Operation {
sla@5237 316 private:
sla@5237 317 JvmtiBreakpoints* _breakpoints;
sla@5237 318 int _operation;
sla@5237 319 JvmtiBreakpoint* _bp;
sla@5237 320
sla@5237 321 public:
sla@5237 322 enum { SET_BREAKPOINT=0, CLEAR_BREAKPOINT=1 };
sla@5237 323
sla@5237 324 VM_ChangeBreakpoints(int operation, JvmtiBreakpoint *bp) {
sla@5237 325 JvmtiBreakpoints& current_bps = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
sla@5237 326 _breakpoints = &current_bps;
sla@5237 327 _bp = bp;
sla@5237 328 _operation = operation;
sla@5237 329 assert(bp != NULL, "bp != NULL");
sla@5237 330 }
sla@5237 331
sla@5237 332 VMOp_Type type() const { return VMOp_ChangeBreakpoints; }
sla@5237 333 void doit();
sla@5237 334 void oops_do(OopClosure* f);
sla@5237 335 };
sla@5237 336
sla@5237 337
duke@435 338 ///////////////////////////////////////////////////////////////
duke@435 339 // The get/set local operations must only be done by the VM thread
duke@435 340 // because the interpreter version needs to access oop maps, which can
duke@435 341 // only safely be done by the VM thread
duke@435 342 //
duke@435 343 // I'm told that in 1.5 oop maps are now protected by a lock and
duke@435 344 // we could get rid of the VM op
duke@435 345 // However if the VM op is removed then the target thread must
duke@435 346 // be suspended AND a lock will be needed to prevent concurrent
duke@435 347 // setting of locals to the same java thread. This lock is needed
duke@435 348 // to prevent compiledVFrames from trying to add deferred updates
duke@435 349 // to the thread simultaneously.
duke@435 350 //
duke@435 351 class VM_GetOrSetLocal : public VM_Operation {
kamg@2361 352 protected:
duke@435 353 JavaThread* _thread;
duke@435 354 JavaThread* _calling_thread;
duke@435 355 jint _depth;
duke@435 356 jint _index;
duke@435 357 BasicType _type;
duke@435 358 jvalue _value;
duke@435 359 javaVFrame* _jvf;
duke@435 360 bool _set;
duke@435 361
kamg@2361 362 // It is possible to get the receiver out of a non-static native wrapper
kamg@2361 363 // frame. Use VM_GetReceiver to do this.
kamg@2361 364 virtual bool getting_receiver() const { return false; }
kamg@2361 365
duke@435 366 jvmtiError _result;
duke@435 367
duke@435 368 vframe* get_vframe();
duke@435 369 javaVFrame* get_java_vframe();
duke@435 370 bool check_slot_type(javaVFrame* vf);
duke@435 371
duke@435 372 public:
duke@435 373 // Constructor for non-object getter
duke@435 374 VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type);
duke@435 375
duke@435 376 // Constructor for object or non-object setter
duke@435 377 VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value);
duke@435 378
duke@435 379 // Constructor for object getter
duke@435 380 VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_thread, jint depth,
duke@435 381 int index);
duke@435 382
duke@435 383 VMOp_Type type() const { return VMOp_GetOrSetLocal; }
duke@435 384 jvalue value() { return _value; }
duke@435 385 jvmtiError result() { return _result; }
duke@435 386
duke@435 387 bool doit_prologue();
duke@435 388 void doit();
duke@435 389 bool allow_nested_vm_operations() const;
duke@435 390 const char* name() const { return "get/set locals"; }
duke@435 391
duke@435 392 // Check that the klass is assignable to a type with the given signature.
duke@435 393 static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread);
duke@435 394 };
duke@435 395
kamg@2361 396 class VM_GetReceiver : public VM_GetOrSetLocal {
kamg@2361 397 protected:
kamg@2361 398 virtual bool getting_receiver() const { return true; }
kamg@2361 399
kamg@2361 400 public:
kamg@2361 401 VM_GetReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth);
kamg@2361 402 const char* name() const { return "get receiver"; }
kamg@2361 403 };
kamg@2361 404
duke@435 405
duke@435 406 ///////////////////////////////////////////////////////////////
duke@435 407 //
duke@435 408 // class JvmtiSuspendControl
duke@435 409 //
duke@435 410 // Convenience routines for suspending and resuming threads.
duke@435 411 //
duke@435 412 // All attempts by JVMTI to suspend and resume threads must go through the
duke@435 413 // JvmtiSuspendControl interface.
duke@435 414 //
duke@435 415 // methods return true if successful
duke@435 416 //
duke@435 417 class JvmtiSuspendControl : public AllStatic {
duke@435 418 public:
duke@435 419 // suspend the thread, taking it to a safepoint
duke@435 420 static bool suspend(JavaThread *java_thread);
duke@435 421 // resume the thread
duke@435 422 static bool resume(JavaThread *java_thread);
duke@435 423
duke@435 424 static void print();
duke@435 425 };
duke@435 426
stefank@2325 427
kamg@2511 428 /**
kamg@2511 429 * When a thread (such as the compiler thread or VM thread) cannot post a
kamg@2511 430 * JVMTI event itself because the event needs to be posted from a Java
kamg@2511 431 * thread, then it can defer the event to the Service thread for posting.
kamg@2511 432 * The information needed to post the event is encapsulated into this class
kamg@2511 433 * and then enqueued onto the JvmtiDeferredEventQueue, where the Service
kamg@2511 434 * thread will pick it up and post it.
kamg@2511 435 *
kamg@2511 436 * This is currently only used for posting compiled-method-load and unload
kamg@2511 437 * events, which we don't want posted from the compiler thread.
kamg@2511 438 */
kamg@2511 439 class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
kamg@2511 440 friend class JvmtiDeferredEventQueue;
kamg@2511 441 private:
kamg@2511 442 typedef enum {
kamg@2511 443 TYPE_NONE,
kamg@2511 444 TYPE_COMPILED_METHOD_LOAD,
kamg@2511 445 TYPE_COMPILED_METHOD_UNLOAD,
kamg@2583 446 TYPE_DYNAMIC_CODE_GENERATED
kamg@2511 447 } Type;
kamg@2511 448
kamg@2511 449 Type _type;
kamg@2511 450 union {
kamg@2511 451 nmethod* compiled_method_load;
kamg@2511 452 struct {
dcubed@2624 453 nmethod* nm;
kamg@2511 454 jmethodID method_id;
kamg@2511 455 const void* code_begin;
kamg@2511 456 } compiled_method_unload;
kamg@2583 457 struct {
kamg@2583 458 const char* name;
kamg@2583 459 const void* code_begin;
kamg@2583 460 const void* code_end;
kamg@2583 461 } dynamic_code_generated;
kamg@2511 462 } _event_data;
kamg@2511 463
kamg@2511 464 JvmtiDeferredEvent(Type t) : _type(t) {}
kamg@2511 465
kamg@2511 466 public:
kamg@2511 467
kamg@2511 468 JvmtiDeferredEvent() : _type(TYPE_NONE) {}
kamg@2511 469
kamg@2511 470 // Factory methods
kamg@2511 471 static JvmtiDeferredEvent compiled_method_load_event(nmethod* nm)
jprovino@4165 472 NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
dcubed@2624 473 static JvmtiDeferredEvent compiled_method_unload_event(nmethod* nm,
jprovino@4165 474 jmethodID id, const void* code) NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
kamg@2583 475 static JvmtiDeferredEvent dynamic_code_generated_event(
kamg@2583 476 const char* name, const void* begin, const void* end)
jprovino@4165 477 NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
kamg@2511 478
kamg@2511 479 // Actually posts the event.
jprovino@4165 480 void post() NOT_JVMTI_RETURN;
kamg@2511 481 };
kamg@2511 482
kamg@2511 483 /**
kamg@2511 484 * Events enqueued on this queue wake up the Service thread which dequeues
kamg@2511 485 * and posts the events. The Service_lock is required to be held
kamg@2511 486 * when operating on the queue (except for the "pending" events).
kamg@2511 487 */
kamg@2511 488 class JvmtiDeferredEventQueue : AllStatic {
kamg@2511 489 friend class JvmtiDeferredEvent;
kamg@2511 490 private:
zgu@3900 491 class QueueNode : public CHeapObj<mtInternal> {
kamg@2511 492 private:
kamg@2511 493 JvmtiDeferredEvent _event;
kamg@2511 494 QueueNode* _next;
kamg@2511 495
kamg@2511 496 public:
kamg@2511 497 QueueNode(const JvmtiDeferredEvent& event)
kamg@2511 498 : _event(event), _next(NULL) {}
kamg@2511 499
kamg@2511 500 const JvmtiDeferredEvent& event() const { return _event; }
kamg@2511 501 QueueNode* next() const { return _next; }
kamg@2511 502
kamg@2511 503 void set_next(QueueNode* next) { _next = next; }
kamg@2511 504 };
kamg@2511 505
kamg@2511 506 static QueueNode* _queue_head; // Hold Service_lock to access
kamg@2511 507 static QueueNode* _queue_tail; // Hold Service_lock to access
kamg@2511 508 static volatile QueueNode* _pending_list; // Uses CAS for read/update
kamg@2511 509
kamg@2511 510 // Transfers events from the _pending_list to the _queue.
jprovino@4165 511 static void process_pending_events() NOT_JVMTI_RETURN;
kamg@2511 512
kamg@2511 513 public:
kamg@2511 514 // Must be holding Service_lock when calling these
jprovino@4165 515 static bool has_events() NOT_JVMTI_RETURN_(false);
jprovino@4165 516 static void enqueue(const JvmtiDeferredEvent& event) NOT_JVMTI_RETURN;
jprovino@4165 517 static JvmtiDeferredEvent dequeue() NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
kamg@2511 518
kamg@2511 519 // Used to enqueue events without using a lock, for times (such as during
kamg@2511 520 // safepoint) when we can't or don't want to lock the Service_lock.
kamg@2511 521 //
kamg@2511 522 // Events will be held off to the side until there's a call to
kamg@2511 523 // dequeue(), enqueue(), or process_pending_events() (all of which require
kamg@2511 524 // the holding of the Service_lock), and will be enqueued at that time.
jprovino@4165 525 static void add_pending_event(const JvmtiDeferredEvent&) NOT_JVMTI_RETURN;
kamg@2511 526 };
kamg@2511 527
duke@435 528 // Utility macro that checks for NULL pointers:
duke@435 529 #define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }
stefank@2314 530
stefank@2314 531 #endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP

mercurial