Mercurial > hg > graal-jvmci-8
comparison src/os/solaris/vm/osThread_solaris.hpp @ 10405:f2110083203d
8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author | sla |
---|---|
date | Mon, 10 Jun 2013 11:30:51 +0200 |
parents | 960a442eae91 |
children |
comparison
equal
deleted
inserted
replaced
10404:d0add7016434 | 10405:f2110083203d |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
70 // the thread context (get_thread_pc), to set the thread context | 70 // the thread context (get_thread_pc), to set the thread context |
71 // (set_thread_pc), and to implement java.lang.Thread.interrupt. | 71 // (set_thread_pc), and to implement java.lang.Thread.interrupt. |
72 // *************************************************************** | 72 // *************************************************************** |
73 | 73 |
74 public: | 74 public: |
75 | 75 os::SuspendResume sr; |
76 class InterruptArguments : StackObj { | |
77 private: | |
78 Thread* _thread; // the thread to signal was dispatched to | |
79 ucontext_t* _ucontext; // the machine context at the time of the signal | |
80 | |
81 public: | |
82 InterruptArguments(Thread* thread, ucontext_t* ucontext) { | |
83 _thread = thread; | |
84 _ucontext = ucontext; | |
85 } | |
86 | |
87 Thread* thread() const { return _thread; } | |
88 ucontext_t* ucontext() const { return _ucontext; } | |
89 }; | |
90 | |
91 // There are currently no asynchronous callbacks - and we'd better not | |
92 // support them in the future either, as they need to be deallocated from | |
93 // the interrupt handler, which is not safe; they also require locks to | |
94 // protect the callback queue. | |
95 | |
96 class Sync_Interrupt_Callback : private StackObj { | |
97 protected: | |
98 volatile bool _is_done; | |
99 Monitor* _sync; | |
100 Thread* _target; | |
101 public: | |
102 Sync_Interrupt_Callback(Monitor * sync) { | |
103 _is_done = false; _target = NULL; _sync = sync; | |
104 } | |
105 | |
106 bool is_done() const { return _is_done; } | |
107 Thread* target() const { return _target; } | |
108 | |
109 int interrupt(Thread * target, int timeout); | |
110 | |
111 // override to implement the callback. | |
112 virtual void execute(InterruptArguments *args) = 0; | |
113 | |
114 void leave_callback(); | |
115 }; | |
116 | 76 |
117 private: | 77 private: |
118 | 78 ucontext_t* _ucontext; |
119 Sync_Interrupt_Callback * volatile _current_callback; | |
120 enum { | |
121 callback_in_progress = 1 | |
122 }; | |
123 Mutex * _current_callback_lock; // only used on v8 | |
124 | 79 |
125 public: | 80 public: |
126 | 81 ucontext_t* ucontext() const { return _ucontext; } |
127 int set_interrupt_callback (Sync_Interrupt_Callback * cb); | 82 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } |
128 void remove_interrupt_callback(Sync_Interrupt_Callback * cb); | 83 static void SR_handler(Thread* thread, ucontext_t* uc); |
129 void do_interrupt_callbacks_at_interrupt(InterruptArguments *args); | |
130 | 84 |
131 // *************************************************************** | 85 // *************************************************************** |
132 // java.lang.Thread.interrupt state. | 86 // java.lang.Thread.interrupt state. |
133 // *************************************************************** | 87 // *************************************************************** |
134 | 88 |