author | brutisso |
Fri, 09 Oct 2015 20:31:56 +0200 | |
changeset 33152 | 6ad7fe735042 |
parent 33146 | 77349b58b4c0 |
child 33229 | 51173444fdd5 |
permissions | -rw-r--r-- |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
1 |
/* |
30764 | 2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
4 |
* |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
8 |
* |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
13 |
* accompanied this code). |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
14 |
* |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
18 |
* |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
21 |
* questions. |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
22 |
* |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
23 |
*/ |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
24 |
|
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/shared/gcId.hpp" |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
27 |
#include "runtime/safepoint.hpp" |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
28 |
#include "runtime/thread.inline.hpp" |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
29 |
|
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
30 |
uint GCId::_next_id = 0; |
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
31 |
|
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
32 |
NamedThread* currentNamedthread() { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
33 |
assert(Thread::current()->is_Named_thread(), "This thread must be NamedThread"); |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
34 |
return (NamedThread*)Thread::current(); |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
35 |
} |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
36 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
37 |
const uint GCId::create() { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
38 |
return _next_id++; |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
39 |
} |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
40 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
41 |
const uint GCId::current() { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
42 |
assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id."); |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
43 |
return current_raw(); |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
44 |
} |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
45 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
46 |
const uint GCId::current_raw() { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
47 |
return currentNamedthread()->gc_id(); |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
48 |
} |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
49 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
50 |
GCIdMark::GCIdMark() : _gc_id(GCId::create()) { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
51 |
currentNamedthread()->set_gc_id(_gc_id); |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
52 |
} |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
53 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
54 |
GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
55 |
currentNamedthread()->set_gc_id(_gc_id); |
25350
6423a57e5451
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
56 |
} |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
57 |
|
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
58 |
GCIdMark::~GCIdMark() { |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
59 |
currentNamedthread()->set_gc_id(GCId::undefined()); |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
60 |
} |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
30764
diff
changeset
|
61 |
|
33146
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
62 |
GCIdMarkAndRestore::GCIdMarkAndRestore() : _gc_id(GCId::create()) { |
33152
6ad7fe735042
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents:
33146
diff
changeset
|
63 |
_previous_gc_id = GCId::current(); // will assert that the GC Id is not undefined |
6ad7fe735042
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents:
33146
diff
changeset
|
64 |
currentNamedthread()->set_gc_id(_gc_id); |
6ad7fe735042
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents:
33146
diff
changeset
|
65 |
} |
6ad7fe735042
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents:
33146
diff
changeset
|
66 |
|
6ad7fe735042
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents:
33146
diff
changeset
|
67 |
GCIdMarkAndRestore::GCIdMarkAndRestore(uint gc_id) : _gc_id(gc_id) { |
33146
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
68 |
_previous_gc_id = GCId::current(); // will assert that the GC Id is not undefinied |
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
69 |
currentNamedthread()->set_gc_id(_gc_id); |
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
70 |
} |
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
71 |
|
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
72 |
GCIdMarkAndRestore::~GCIdMarkAndRestore() { |
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
73 |
currentNamedthread()->set_gc_id(_previous_gc_id); |
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
74 |
} |