12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #include "precompiled.hpp"
28 #include "memory/allocation.hpp"
29 #include "oops/markWord.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/lockStack.inline.hpp"
33 #include "runtime/objectMonitor.inline.hpp"
34 #include "runtime/safepoint.hpp"
35 #include "runtime/stackWatermark.hpp"
36 #include "runtime/stackWatermarkSet.inline.hpp"
37 #include "runtime/thread.hpp"
38 #include "utilities/copy.hpp"
39 #include "utilities/debug.hpp"
40 #include "utilities/globalDefinitions.hpp"
41 #include "utilities/growableArray.hpp"
42 #include "utilities/ostream.hpp"
43
44 #include <type_traits>
45
46 const int LockStack::lock_stack_offset = in_bytes(JavaThread::lock_stack_offset());
47 const int LockStack::lock_stack_top_offset = in_bytes(JavaThread::lock_stack_top_offset());
48 const int LockStack::lock_stack_base_offset = in_bytes(JavaThread::lock_stack_base_offset());
49
50 LockStack::LockStack(JavaThread* jt) :
51 _top(lock_stack_base_offset), _base() {
52 // Make sure the layout of the object is compatible with the emitted code's assumptions.
53 STATIC_ASSERT(sizeof(_bad_oop_sentinel) == oopSize);
54 STATIC_ASSERT(sizeof(_base[0]) == oopSize);
55 STATIC_ASSERT(std::is_standard_layout<LockStack>::value);
56 STATIC_ASSERT(offsetof(LockStack, _bad_oop_sentinel) == offsetof(LockStack, _base) - oopSize);
57 #ifdef ASSERT
58 for (int i = 0; i < CAPACITY; i++) {
59 _base[i] = nullptr;
60 }
61 #endif
62 }
97 }
98 }
99 for (int i = top; i < CAPACITY; i++) {
100 assert(_base[i] == nullptr, "only zapped entries after top: i: %d, top: %d, entry: " PTR_FORMAT, i, top, p2i(_base[i]));
101 }
102 }
103 }
104 #endif
105
106 void LockStack::print_on(outputStream* st) {
107 for (int i = to_index(_top); (--i) >= 0;) {
108 st->print("LockStack[%d]: ", i);
109 oop o = _base[i];
110 if (oopDesc::is_oop(o)) {
111 o->print_on(st);
112 } else {
113 st->print_cr("not an oop: " PTR_FORMAT, p2i(o));
114 }
115 }
116 }
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #include "precompiled.hpp"
28 #include "memory/allocation.hpp"
29 #include "oops/markWord.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/javaThread.inline.hpp"
33 #include "runtime/lockStack.inline.hpp"
34 #include "runtime/objectMonitor.inline.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "runtime/stackWatermark.hpp"
37 #include "runtime/stackWatermarkSet.inline.hpp"
38 #include "runtime/synchronizer.inline.hpp"
39 #include "runtime/thread.hpp"
40 #include "utilities/copy.hpp"
41 #include "utilities/debug.hpp"
42 #include "utilities/globalDefinitions.hpp"
43 #include "utilities/growableArray.hpp"
44 #include "utilities/ostream.hpp"
45 #include "utilities/sizes.hpp"
46
47 #include <type_traits>
48
49 const int LockStack::lock_stack_offset = in_bytes(JavaThread::lock_stack_offset());
50 const int LockStack::lock_stack_top_offset = in_bytes(JavaThread::lock_stack_top_offset());
51 const int LockStack::lock_stack_base_offset = in_bytes(JavaThread::lock_stack_base_offset());
52
53 LockStack::LockStack(JavaThread* jt) :
54 _top(lock_stack_base_offset), _base() {
55 // Make sure the layout of the object is compatible with the emitted code's assumptions.
56 STATIC_ASSERT(sizeof(_bad_oop_sentinel) == oopSize);
57 STATIC_ASSERT(sizeof(_base[0]) == oopSize);
58 STATIC_ASSERT(std::is_standard_layout<LockStack>::value);
59 STATIC_ASSERT(offsetof(LockStack, _bad_oop_sentinel) == offsetof(LockStack, _base) - oopSize);
60 #ifdef ASSERT
61 for (int i = 0; i < CAPACITY; i++) {
62 _base[i] = nullptr;
63 }
64 #endif
65 }
100 }
101 }
102 for (int i = top; i < CAPACITY; i++) {
103 assert(_base[i] == nullptr, "only zapped entries after top: i: %d, top: %d, entry: " PTR_FORMAT, i, top, p2i(_base[i]));
104 }
105 }
106 }
107 #endif
108
109 void LockStack::print_on(outputStream* st) {
110 for (int i = to_index(_top); (--i) >= 0;) {
111 st->print("LockStack[%d]: ", i);
112 oop o = _base[i];
113 if (oopDesc::is_oop(o)) {
114 o->print_on(st);
115 } else {
116 st->print_cr("not an oop: " PTR_FORMAT, p2i(o));
117 }
118 }
119 }
120
121 OMCache::OMCache(JavaThread* jt) : _entries() {
122 STATIC_ASSERT(std::is_standard_layout<OMCache>::value);
123 STATIC_ASSERT(std::is_standard_layout<OMCache::OMCacheEntry>::value);
124 STATIC_ASSERT(offsetof(OMCache, _null_sentinel) == offsetof(OMCache, _entries) +
125 offsetof(OMCache::OMCacheEntry, _oop) +
126 OMCache::CAPACITY * in_bytes(oop_to_oop_difference()));
127 }
|