comparison src/share/vm/services/lowMemoryDetector.hpp @ 2195:bf8517f4e4d0

6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread" Summary: Defer posting events from the compiler thread: use service thread Reviewed-by: coleenp, dholmes, never, dcubed
author kamg
date Wed, 02 Feb 2011 14:38:01 -0500
parents f95d63e2154a
children d2a62e0f25eb
comparison
equal deleted inserted replaced
2194:face83fc8882 2195:bf8517f4e4d0
1 /* 1 /*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2011, 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.
56 // For Code cache, detection will be performed in the allocation 56 // For Code cache, detection will be performed in the allocation
57 // and deallocation. 57 // and deallocation.
58 // 58 //
59 // May need to deal with hysteresis effect. 59 // May need to deal with hysteresis effect.
60 // 60 //
61 61 // Memory detection code runs in the Service thread (serviceThread.hpp).
62 class LowMemoryDetectorThread; 62
63 class OopClosure; 63 class OopClosure;
64 class MemoryPool; 64 class MemoryPool;
65 65
66 class ThresholdSupport : public CHeapObj { 66 class ThresholdSupport : public CHeapObj {
67 private: 67 private:
209 void print(); 209 void print();
210 #endif // PRODUCT 210 #endif // PRODUCT
211 }; 211 };
212 212
213 class LowMemoryDetector : public AllStatic { 213 class LowMemoryDetector : public AllStatic {
214 friend class LowMemoryDetectorDisabler; 214 friend class LowMemoryDetectorDisabler;
215 friend class ServiceThread;
215 private: 216 private:
216 // true if any collected heap has low memory detection enabled 217 // true if any collected heap has low memory detection enabled
217 static volatile bool _enabled_for_collected_pools; 218 static volatile bool _enabled_for_collected_pools;
218 // > 0 if temporary disabed 219 // > 0 if temporary disabed
219 static volatile jint _disabled_count; 220 static volatile jint _disabled_count;
220 221
221 static LowMemoryDetectorThread* _detector_thread;
222 static void low_memory_detector_thread_entry(JavaThread* thread, TRAPS);
223 static void check_memory_usage(); 222 static void check_memory_usage();
224 static bool has_pending_requests(); 223 static bool has_pending_requests();
225 static bool temporary_disabled() { return _disabled_count > 0; } 224 static bool temporary_disabled() { return _disabled_count > 0; }
226 static void disable() { Atomic::inc(&_disabled_count); } 225 static void disable() { Atomic::inc(&_disabled_count); }
227 static void enable() { Atomic::dec(&_disabled_count); } 226 static void enable() { Atomic::dec(&_disabled_count); }
227 static void process_sensor_changes(TRAPS);
228 228
229 public: 229 public:
230 static void initialize();
231 static void detect_low_memory(); 230 static void detect_low_memory();
232 static void detect_low_memory(MemoryPool* pool); 231 static void detect_low_memory(MemoryPool* pool);
233 static void detect_after_gc_memory(MemoryPool* pool); 232 static void detect_after_gc_memory(MemoryPool* pool);
234 233
235 static bool is_enabled(MemoryPool* pool) { 234 static bool is_enabled(MemoryPool* pool) {
273 detect_low_memory(pool); 272 detect_low_memory(pool);
274 } 273 }
275 } 274 }
276 } 275 }
277 } 276 }
278
279 }; 277 };
280 278
281 class LowMemoryDetectorDisabler: public StackObj { 279 class LowMemoryDetectorDisabler: public StackObj {
282 public: 280 public:
283 LowMemoryDetectorDisabler() 281 LowMemoryDetectorDisabler()