src/share/vm/prims/jvmtiImpl.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6766644 Cdiff src/share/vm/prims/jvmtiImpl.cpp

src/share/vm/prims/jvmtiImpl.cpp

Print this page
rev 2029 : 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
Summary: Defer posting events from the compiler thread -- use service thread
Reviewed-by:
* * *

*** 1,7 **** /* ! * Copyright (c) 2003, 2010, 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. --- 1,7 ---- /* ! * Copyright (c) 2003, 2011, 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.
*** 908,912 **** --- 908,984 ---- tty->print(") "); } tty->print_cr("]"); #endif } + + #ifndef KERNEL + + void JvmtiDeferredEvent::post() { + switch(_type) { + case TYPE_COMPILED_METHOD_LOAD: + JvmtiExport::post_compiled_method_load(compiled_method_loaded()); + break; + default: + ShouldNotReachHere(); + } + } + + JvmtiDeferredEventQueue::QueueNode* JvmtiDeferredEventQueue::_free_list = NULL; + JvmtiDeferredEventQueue::QueueNode* JvmtiDeferredEventQueue::_queue = NULL; + + bool JvmtiDeferredEventQueue::has_events() { + return _queue != NULL; + } + + void JvmtiDeferredEventQueue::enqueue(const JvmtiDeferredEvent& event) { + assert(Service_lock->owned_by_self(), "Must own Service_lock"); + + QueueNode* node = _free_list; + if (node == NULL) { + node = new QueueNode(); + } else { + _free_list = node->next(); + } + + node->set_event(event); + node->set_next(_queue); + + _queue = node; + + Service_lock->notify_all(); + } + + JvmtiDeferredEvent JvmtiDeferredEventQueue::dequeue() { + assert(Service_lock->owned_by_self(), "Must own Service_lock"); + assert(_queue != NULL, "Nothing to dequeue"); + + if (_queue == NULL) { + // Just in case this happens in product; it shouldn't be let's not crash + return JvmtiDeferredEvent::null_event(); + } + + // Events need to be processed in FIFO order, so take the last event. + QueueNode* node = _queue->next(); + if (node == NULL) { + // Only one item in the queue + node = _queue; + _queue = NULL; + } else { + QueueNode* prev = _queue; + while (node->next() != NULL) { + prev = node; + node = node->next(); + } + prev->set_next(NULL); + } + + JvmtiDeferredEvent event = node->event(); + + // Stick the node on the freelist for reuse. + node->set_next(_free_list); + _free_list = node; + + return event; + } + + #endif // ndef KERNEL
src/share/vm/prims/jvmtiImpl.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File