author | coleenp |
Thu, 29 Aug 2013 18:56:29 -0400 | |
changeset 19696 | bd5a0131bde1 |
parent 17023 | aab2b408ebfe |
permissions | -rw-r--r-- |
13195 | 1 |
/* |
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17023
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
13195 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
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 |
#ifndef SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP |
|
26 |
#define SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "runtime/thread.hpp" |
|
30 |
#include "services/memRecorder.hpp" |
|
31 |
||
32 |
// Maximum MAX_GENERATIONS generation data can be tracked. |
|
33 |
#define MAX_GENERATIONS 512 |
|
34 |
||
17023
aab2b408ebfe
8012464: NMT: classes should not derive from _ValueObj, use VALUE_OBJ_CLASS_SPEC instead
zgu
parents:
16991
diff
changeset
|
35 |
class GenerationData VALUE_OBJ_CLASS_SPEC { |
15104
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
36 |
private: |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
37 |
int _number_of_classes; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
38 |
MemRecorder* _recorder_list; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
39 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
40 |
public: |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
41 |
GenerationData(): _number_of_classes(0), _recorder_list(NULL) { } |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
42 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
43 |
inline int number_of_classes() const { return _number_of_classes; } |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
44 |
inline void set_number_of_classes(long num) { _number_of_classes = num; } |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
45 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
46 |
inline MemRecorder* next_recorder() { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
47 |
if (_recorder_list == NULL) { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
48 |
return NULL; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
49 |
} else { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
50 |
MemRecorder* tmp = _recorder_list; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
51 |
_recorder_list = _recorder_list->next(); |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
52 |
return tmp; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
53 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
54 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
55 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
56 |
inline bool has_more_recorder() const { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
57 |
return (_recorder_list != NULL); |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
58 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
59 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
60 |
// add recorders to this generation |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
61 |
void add_recorders(MemRecorder* head) { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
62 |
if (head != NULL) { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
63 |
if (_recorder_list == NULL) { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
64 |
_recorder_list = head; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
65 |
} else { |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
66 |
MemRecorder* tmp = _recorder_list; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
67 |
for (; tmp->next() != NULL; tmp = tmp->next()); |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
68 |
tmp->set_next(head); |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
69 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
70 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
71 |
} |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
72 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
73 |
void reset(); |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
74 |
|
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
75 |
NOT_PRODUCT(MemRecorder* peek() const { return _recorder_list; }) |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
76 |
}; |
13195 | 77 |
|
78 |
class MemTrackWorker : public NamedThread { |
|
79 |
private: |
|
15104
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
80 |
// circular buffer. This buffer contains generation data to be merged into global |
13195 | 81 |
// snaphsot. |
15104
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
82 |
// Each slot holds a generation |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
83 |
GenerationData _gen[MAX_GENERATIONS]; |
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
84 |
int _head, _tail; // head and tail pointers to above circular buffer |
13195 | 85 |
|
15104
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
86 |
bool _has_error; |
13195 | 87 |
|
16991
aa4978a77e1f
8010151: nsk/regression/b6653214 fails "assert(snapshot != NULL) failed: Worker should not be started"
zgu
parents:
15452
diff
changeset
|
88 |
MemSnapshot* _snapshot; |
aa4978a77e1f
8010151: nsk/regression/b6653214 fails "assert(snapshot != NULL) failed: Worker should not be started"
zgu
parents:
15452
diff
changeset
|
89 |
|
13195 | 90 |
public: |
16991
aa4978a77e1f
8010151: nsk/regression/b6653214 fails "assert(snapshot != NULL) failed: Worker should not be started"
zgu
parents:
15452
diff
changeset
|
91 |
MemTrackWorker(MemSnapshot* snapshot); |
13195 | 92 |
~MemTrackWorker(); |
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17023
diff
changeset
|
93 |
_NOINLINE_ void* operator new(size_t size) throw(); |
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17023
diff
changeset
|
94 |
_NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw(); |
13195 | 95 |
|
96 |
void start(); |
|
97 |
void run(); |
|
98 |
||
99 |
inline bool has_error() const { return _has_error; } |
|
100 |
||
101 |
// task at synchronization point |
|
15104
f5d78994619f
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
13300
diff
changeset
|
102 |
void at_sync_point(MemRecorder* pending_recorders, int number_of_classes); |
13195 | 103 |
|
104 |
// for debugging purpose, they are not thread safe. |
|
105 |
NOT_PRODUCT(static int count_recorder(const MemRecorder* head);) |
|
106 |
NOT_PRODUCT(int count_pending_recorders() const;) |
|
107 |
||
108 |
NOT_PRODUCT(int _sync_point_count;) |
|
109 |
NOT_PRODUCT(int _merge_count;) |
|
110 |
NOT_PRODUCT(int _last_gen_in_use;) |
|
111 |
||
15452
3bfde2dea09d
8005012: Add WB APIs to better support NMT testing
ctornqvi
parents:
15104
diff
changeset
|
112 |
// how many generations are queued |
13195 | 113 |
inline int generations_in_use() const { |
13300 | 114 |
return (_tail >= _head ? (_tail - _head + 1) : (MAX_GENERATIONS - (_head - _tail) + 1)); |
13195 | 115 |
} |
116 |
}; |
|
117 |
||
118 |
#endif // SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP |