15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "oops/verifyOopClosure.hpp"
32 #include "runtime/interfaceSupport.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/thread.inline.hpp"
36 #include "runtime/vmThread.hpp"
37 #include "runtime/vm_operations.hpp"
38 #include "services/runtimeService.hpp"
39 #include "trace/tracing.hpp"
40 #include "utilities/dtrace.hpp"
41 #include "utilities/events.hpp"
42 #include "utilities/xmlstream.hpp"
43
44 // Dummy VM operation to act as first element in our circular double-linked list
45 class VM_Dummy: public VM_Operation {
46 VMOp_Type type() const { return VMOp_Dummy; }
47 void doit() {};
48 };
49
50 VMOperationQueue::VMOperationQueue() {
51 // The queue is a circular doubled-linked list, which always contains
52 // one element (i.e., one element means empty).
53 for(int i = 0; i < nof_priorities; i++) {
54 _queue_length[i] = 0;
335 while(!VMThread::is_terminated()) {
336 _terminate_lock->wait(Mutex::_no_safepoint_check_flag);
337 }
338 }
339 }
340
341 void VMThread::evaluate_operation(VM_Operation* op) {
342 ResourceMark rm;
343
344 {
345 PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
346 HOTSPOT_VMOPS_BEGIN(
347 (char *) op->name(), strlen(op->name()),
348 op->evaluation_mode());
349
350 EventExecuteVMOperation event;
351
352 op->evaluate();
353
354 if (event.should_commit()) {
355 bool is_concurrent = op->evaluate_concurrently();
356 event.set_operation(op->type());
357 event.set_safepoint(op->evaluate_at_safepoint());
358 event.set_blocking(!is_concurrent);
359 // Only write caller thread information for non-concurrent vm operations.
360 // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
361 // This is because the caller thread could have exited already.
362 event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
363 event.commit();
364 }
365
366 HOTSPOT_VMOPS_END(
367 (char *) op->name(), strlen(op->name()),
368 op->evaluation_mode());
369 }
370
371 // Last access of info in _cur_vm_operation!
372 bool c_heap_allocated = op->is_cheap_allocated();
373
374 // Mark as completed
375 if (!op->evaluate_concurrently()) {
376 op->calling_thread()->increment_vm_operation_completed_count();
377 }
378 // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,
379 // since if it is stack allocated the calling thread might have deallocated
380 if (c_heap_allocated) {
381 delete _cur_vm_operation;
382 }
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "oops/verifyOopClosure.hpp"
32 #include "runtime/interfaceSupport.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "runtime/thread.inline.hpp"
37 #include "runtime/vmThread.hpp"
38 #include "runtime/vm_operations.hpp"
39 #include "services/runtimeService.hpp"
40 #include "trace/tracing.hpp"
41 #include "utilities/dtrace.hpp"
42 #include "utilities/events.hpp"
43 #include "utilities/xmlstream.hpp"
44
45 // Dummy VM operation to act as first element in our circular double-linked list
46 class VM_Dummy: public VM_Operation {
47 VMOp_Type type() const { return VMOp_Dummy; }
48 void doit() {};
49 };
50
51 VMOperationQueue::VMOperationQueue() {
52 // The queue is a circular doubled-linked list, which always contains
53 // one element (i.e., one element means empty).
54 for(int i = 0; i < nof_priorities; i++) {
55 _queue_length[i] = 0;
336 while(!VMThread::is_terminated()) {
337 _terminate_lock->wait(Mutex::_no_safepoint_check_flag);
338 }
339 }
340 }
341
342 void VMThread::evaluate_operation(VM_Operation* op) {
343 ResourceMark rm;
344
345 {
346 PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
347 HOTSPOT_VMOPS_BEGIN(
348 (char *) op->name(), strlen(op->name()),
349 op->evaluation_mode());
350
351 EventExecuteVMOperation event;
352
353 op->evaluate();
354
355 if (event.should_commit()) {
356 const bool is_concurrent = op->evaluate_concurrently();
357 const bool evaluate_at_safepoint = op->evaluate_at_safepoint();
358 event.set_operation(op->type());
359 event.set_safepoint(evaluate_at_safepoint);
360 event.set_blocking(!is_concurrent);
361 // Only write caller thread information for non-concurrent vm operations.
362 // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
363 // This is because the caller thread could have exited already.
364 event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
365 event.set_safepointId(evaluate_at_safepoint ? SafepointSynchronize::safepoint_counter() : 0);
366 event.commit();
367 }
368
369 HOTSPOT_VMOPS_END(
370 (char *) op->name(), strlen(op->name()),
371 op->evaluation_mode());
372 }
373
374 // Last access of info in _cur_vm_operation!
375 bool c_heap_allocated = op->is_cheap_allocated();
376
377 // Mark as completed
378 if (!op->evaluate_concurrently()) {
379 op->calling_thread()->increment_vm_operation_completed_count();
380 }
381 // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,
382 // since if it is stack allocated the calling thread might have deallocated
383 if (c_heap_allocated) {
384 delete _cur_vm_operation;
385 }
|