comparison src/share/vm/services/attachListener.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents f95d63e2154a
children 1d1603768966
comparison
equal deleted inserted replaced
2176:27e4ea99855d 2177:3582bf76420e
41 // Implementation of "properties" command. 41 // Implementation of "properties" command.
42 // 42 //
43 // Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize 43 // Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize
44 // the system properties into a byte array. 44 // the system properties into a byte array.
45 45
46 static klassOop load_and_initialize_klass(symbolHandle sh, TRAPS) { 46 static klassOop load_and_initialize_klass(Symbol* sh, TRAPS) {
47 klassOop k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL); 47 klassOop k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL);
48 instanceKlassHandle ik (THREAD, k); 48 instanceKlassHandle ik (THREAD, k);
49 if (ik->should_be_initialized()) { 49 if (ik->should_be_initialized()) {
50 ik->initialize(CHECK_NULL); 50 ik->initialize(CHECK_NULL);
51 } 51 }
52 return ik(); 52 return ik();
53 } 53 }
54 54
55 static jint get_properties(AttachOperation* op, outputStream* out, symbolHandle serializePropertiesMethod) { 55 static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) {
56 Thread* THREAD = Thread::current(); 56 Thread* THREAD = Thread::current();
57 HandleMark hm; 57 HandleMark hm;
58 58
59 // load sun.misc.VMSupport 59 // load sun.misc.VMSupport
60 symbolHandle klass = vmSymbolHandles::sun_misc_VMSupport(); 60 Symbol* klass = vmSymbols::sun_misc_VMSupport();
61 klassOop k = load_and_initialize_klass(klass, THREAD); 61 klassOop k = load_and_initialize_klass(klass, THREAD);
62 if (HAS_PENDING_EXCEPTION) { 62 if (HAS_PENDING_EXCEPTION) {
63 java_lang_Throwable::print(PENDING_EXCEPTION, out); 63 java_lang_Throwable::print(PENDING_EXCEPTION, out);
64 CLEAR_PENDING_EXCEPTION; 64 CLEAR_PENDING_EXCEPTION;
65 return JNI_ERR; 65 return JNI_ERR;
69 // invoke the serializePropertiesToByteArray method 69 // invoke the serializePropertiesToByteArray method
70 JavaValue result(T_OBJECT); 70 JavaValue result(T_OBJECT);
71 JavaCallArguments args; 71 JavaCallArguments args;
72 72
73 73
74 symbolHandle signature = vmSymbolHandles::serializePropertiesToByteArray_signature(); 74 Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
75 JavaCalls::call_static(&result, 75 JavaCalls::call_static(&result,
76 ik, 76 ik,
77 serializePropertiesMethod, 77 serializePropertiesMethod,
78 signature, 78 signature,
79 &args, 79 &args,
97 return JNI_OK; 97 return JNI_OK;
98 } 98 }
99 99
100 // Implementation of "properties" command. 100 // Implementation of "properties" command.
101 static jint get_system_properties(AttachOperation* op, outputStream* out) { 101 static jint get_system_properties(AttachOperation* op, outputStream* out) {
102 return get_properties(op, out, vmSymbolHandles::serializePropertiesToByteArray_name()); 102 return get_properties(op, out, vmSymbols::serializePropertiesToByteArray_name());
103 } 103 }
104 104
105 // Implementation of "agent_properties" command. 105 // Implementation of "agent_properties" command.
106 static jint get_agent_properties(AttachOperation* op, outputStream* out) { 106 static jint get_agent_properties(AttachOperation* op, outputStream* out) {
107 return get_properties(op, out, vmSymbolHandles::serializeAgentPropertiesToByteArray_name()); 107 return get_properties(op, out, vmSymbols::serializeAgentPropertiesToByteArray_name());
108 } 108 }
109 109
110 // Implementation of "datadump" command. 110 // Implementation of "datadump" command.
111 // 111 //
112 // Raises a SIGBREAK signal so that VM dump threads, does deadlock detection, 112 // Raises a SIGBREAK signal so that VM dump threads, does deadlock detection,
428 } 428 }
429 429
430 // Starts the Attach Listener thread 430 // Starts the Attach Listener thread
431 void AttachListener::init() { 431 void AttachListener::init() {
432 EXCEPTION_MARK; 432 EXCEPTION_MARK;
433 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK); 433 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
434 instanceKlassHandle klass (THREAD, k); 434 instanceKlassHandle klass (THREAD, k);
435 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); 435 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
436 436
437 const char thread_name[] = "Attach Listener"; 437 const char thread_name[] = "Attach Listener";
438 Handle string = java_lang_String::create_from_str(thread_name, CHECK); 438 Handle string = java_lang_String::create_from_str(thread_name, CHECK);
440 // Initialize thread_oop to put it into the system threadGroup 440 // Initialize thread_oop to put it into the system threadGroup
441 Handle thread_group (THREAD, Universe::system_thread_group()); 441 Handle thread_group (THREAD, Universe::system_thread_group());
442 JavaValue result(T_VOID); 442 JavaValue result(T_VOID);
443 JavaCalls::call_special(&result, thread_oop, 443 JavaCalls::call_special(&result, thread_oop,
444 klass, 444 klass,
445 vmSymbolHandles::object_initializer_name(), 445 vmSymbols::object_initializer_name(),
446 vmSymbolHandles::threadgroup_string_void_signature(), 446 vmSymbols::threadgroup_string_void_signature(),
447 thread_group, 447 thread_group,
448 string, 448 string,
449 CHECK); 449 CHECK);
450 450
451 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); 451 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass());
452 JavaCalls::call_special(&result, 452 JavaCalls::call_special(&result,
453 thread_group, 453 thread_group,
454 group, 454 group,
455 vmSymbolHandles::add_method_name(), 455 vmSymbols::add_method_name(),
456 vmSymbolHandles::thread_void_signature(), 456 vmSymbols::thread_void_signature(),
457 thread_oop, // ARG 1 457 thread_oop, // ARG 1
458 CHECK); 458 CHECK);
459 459
460 { MutexLocker mu(Threads_lock); 460 { MutexLocker mu(Threads_lock);
461 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); 461 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry);