Mercurial > hg > graal-compiler
comparison src/share/vm/memory/gcLocker.inline.hpp @ 4867:1a2723f7ad8e
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
Reviewed-by: kvn, iveresov, dholmes
author | never |
---|---|
date | Sun, 29 Jan 2012 16:46:04 -0800 |
parents | f95d63e2154a |
children | ad3b47344802 |
comparison
equal
deleted
inserted
replaced
4826:072384a61312 | 4867:1a2723f7ad8e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2012, 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. |
26 #define SHARE_VM_MEMORY_GCLOCKER_INLINE_HPP | 26 #define SHARE_VM_MEMORY_GCLOCKER_INLINE_HPP |
27 | 27 |
28 #include "memory/gcLocker.hpp" | 28 #include "memory/gcLocker.hpp" |
29 | 29 |
30 inline bool GC_locker::is_active() { | 30 inline bool GC_locker::is_active() { |
31 assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); | |
32 verify_critical_count(); | |
31 return _lock_count > 0 || _jni_lock_count > 0; | 33 return _lock_count > 0 || _jni_lock_count > 0; |
32 } | |
33 | |
34 inline bool GC_locker::check_active_before_gc() { | |
35 if (is_active()) { | |
36 set_needs_gc(); | |
37 } | |
38 return is_active(); | |
39 } | 34 } |
40 | 35 |
41 inline void GC_locker::lock() { | 36 inline void GC_locker::lock() { |
42 // cast away volatile | 37 // cast away volatile |
43 Atomic::inc(&_lock_count); | 38 Atomic::inc(&_lock_count); |
54 if (CheckUnhandledOops) { Thread::current()->_gc_locked_out_count--; }) | 49 if (CheckUnhandledOops) { Thread::current()->_gc_locked_out_count--; }) |
55 } | 50 } |
56 | 51 |
57 inline void GC_locker::lock_critical(JavaThread* thread) { | 52 inline void GC_locker::lock_critical(JavaThread* thread) { |
58 if (!thread->in_critical()) { | 53 if (!thread->in_critical()) { |
59 if (!needs_gc()) { | 54 if (needs_gc()) { |
60 jni_lock(); | 55 // jni_lock call calls enter_critical under the lock so that the |
61 } else { | 56 // global lock count and per thread count are in agreement. |
62 jni_lock_slow(); | 57 jni_lock(thread); |
58 return; | |
63 } | 59 } |
60 increment_debug_jni_lock_count(); | |
64 } | 61 } |
65 thread->enter_critical(); | 62 thread->enter_critical(); |
66 } | 63 } |
67 | 64 |
68 inline void GC_locker::unlock_critical(JavaThread* thread) { | 65 inline void GC_locker::unlock_critical(JavaThread* thread) { |
66 if (thread->in_last_critical()) { | |
67 if (needs_gc()) { | |
68 // jni_unlock call calls exit_critical under the lock so that | |
69 // the global lock count and per thread count are in agreement. | |
70 jni_unlock(thread); | |
71 return; | |
72 } | |
73 decrement_debug_jni_lock_count(); | |
74 } | |
69 thread->exit_critical(); | 75 thread->exit_critical(); |
70 if (!thread->in_critical()) { | |
71 if (!needs_gc()) { | |
72 jni_unlock(); | |
73 } else { | |
74 jni_unlock_slow(); | |
75 } | |
76 } | |
77 } | 76 } |
78 | 77 |
79 #endif // SHARE_VM_MEMORY_GCLOCKER_INLINE_HPP | 78 #endif // SHARE_VM_MEMORY_GCLOCKER_INLINE_HPP |