You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/02 22:20:59 UTC
svn commit: r470524 - in /incubator/harmony/enhanced/drlvm/trunk/vm:
interpreter/src/ vmcore/include/ vmcore/src/class_support/ vmcore/src/jit/
vmcore/src/jvmti/
Author: gshimansky
Date: Thu Nov 2 13:20:58 2006
New Revision: 470524
URL: http://svn.apache.org/viewvc?view=rev&rev=470524
Log:
Applied HARMONY-1988 [DRLVM] [JVMTI] NativeMethodBind event implementation.
Tests passed on Gentoo linux
Modified:
incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Thu Nov 2 13:20:58 2006
@@ -3624,13 +3624,17 @@
return (GenericFunctionPointer) method->get_code_addr();
}
- GenericFunctionPointer f = interp_find_native(method);
+ NativeCodePtr f = (NativeCodePtr)interp_find_native(method);
+
+ hythread_suspend_enable();
+ jvmti_process_native_method_bind_event( (jmethodID) method, f, &f);
+ hythread_suspend_disable();
// TODO: check if we need synchronization here
if( f ) {
- method->set_code_addr((NativeCodePtr) f);
+ method->set_code_addr(f);
method->set_state( Method::ST_Linked );
}
- return f;
+ return (GenericFunctionPointer)f;
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Thu Nov 2 13:20:58 2006
@@ -113,6 +113,8 @@
VMEXPORT void jvmti_send_thread_start_end_event(int is_start);
void jvmti_send_vm_death_event();
bool jvmti_jit_breakpoint_handler(Registers *regs);
+VMEXPORT void jvmti_process_native_method_bind_event(jmethodID method,
+ NativeCodePtr address, NativeCodePtr* new_address_ptr);
#ifdef __cplusplus
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Thu Nov 2 13:20:58 2006
@@ -690,9 +690,13 @@
// found method
not_found = false;
+ // Calling callback for NativeMethodBind event
+ NativeCodePtr native_addr = methods[index].fnPtr;
+ jvmti_process_native_method_bind_event( (jmethodID) class_method, native_addr, &native_addr);
+
// lock class
klass->m_lock->_lock();
- class_method->set_code_addr( methods[index].fnPtr );
+ class_method->set_code_addr( native_addr );
class_method->set_registered( true );
klass->m_lock->_unlock();
break;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp Thu Nov 2 13:20:58 2006
@@ -653,8 +653,10 @@
if (!func)
return JIT_FAILURE;
- Class* cl = method->get_class();
+ // Calling callback for NativeMethodBind event
+ jvmti_process_native_method_bind_event( (jmethodID) method, (NativeCodePtr)func, (NativeCodePtr*)&func);
+ Class* cl = method->get_class();
NativeStubOverride nso = nso_find_method_override(VM_Global_State::loader_env,
cl->name, method->get_name(),
method->get_descriptor());
@@ -663,7 +665,6 @@
if (!stub)
return JIT_FAILURE;
-
cl->m_lock->_lock();
method->set_code_addr(stub);
cl->m_lock->_unlock();
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp Thu Nov 2 13:20:58 2006
@@ -61,7 +61,7 @@
1, // can_generate_compiled_method_load_events
1, // can_generate_monitor_events
1, // can_generate_vm_object_alloc_events
- 0, // can_generate_native_method_bind_events
+ 1, // can_generate_native_method_bind_events
0, // can_generate_garbage_collection_events
0 // can_generate_object_free_events
};
@@ -98,7 +98,7 @@
1, // can_generate_compiled_method_load_events
1, // can_generate_monitor_events
1, // can_generate_vm_object_alloc_events
- 0, // can_generate_native_method_bind_events
+ 1, // can_generate_native_method_bind_events
0, // can_generate_garbage_collection_events
0 // can_generate_object_free_events
};
@@ -137,7 +137,7 @@
1, // can_generate_compiled_method_load_events
0, // can_generate_monitor_events
1, // can_generate_vm_object_alloc_events
- 0, // can_generate_native_method_bind_events
+ 1, // can_generate_native_method_bind_events
0, // can_generate_garbage_collection_events
0 // can_generate_object_free_events
};
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Thu Nov 2 13:20:58 2006
@@ -40,7 +40,6 @@
#include "jvmti_break_intf.h"
#include "stack_iterator.h"
#include "m2n.h"
-#include "suspend_checker.h"
/*
* Set Event Callbacks
@@ -834,6 +833,8 @@
VMEXPORT void
jvmti_process_frame_pop_event(jvmtiEnv *jvmti_env, jmethodID method, jboolean was_popped_by_exception)
{
+ assert(hythread_is_suspend_enabled());
+
DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
if (!ti->isEnabled() ) return;
@@ -854,6 +855,40 @@
ti_env->event_table.FramePop(jvmti_env, jni_env, thread, method,
was_popped_by_exception);
+}
+
+VMEXPORT void
+jvmti_process_native_method_bind_event(jmethodID method, NativeCodePtr address, NativeCodePtr* new_address_ptr)
+{
+ SuspendEnabledChecker sec;
+
+ DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
+ if( !ti->isEnabled() )
+ return;
+
+ //Checking current phase
+ jvmtiPhase phase = ti->getPhase();
+ if( phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE && phase != JVMTI_PHASE_PRIMORDIAL)
+ return;
+
+ TRACE2("jvmti.event.bind", "Native method bind event is called for method:"
+ << (method ? class_get_name(method_get_class((Method*)method)) : "(nil)") << "."
+ << (method ? method_get_name((Method*)method) : "(nil)")
+ << (method ? method_get_descriptor((Method*)method) : "" ) );
+
+ jthread thread = getCurrentThread();
+ JNIEnv *jni_env = p_TLS_vmthread->jni_env;
+
+ for( TIEnv *ti_env = ti->getEnvironments(); ti_env; ti_env = ti_env->next ) {
+ //Must possess capability
+ jvmtiCapabilities capa;
+ if( JVMTI_ERROR_NONE != ((jvmtiEnv *)ti_env)->GetCapabilities(&capa) )
+ return;
+ if( !capa.can_generate_native_method_bind_events )
+ return;
+ if (NULL != ti_env->event_table.NativeMethodBind)
+ ti_env->event_table.NativeMethodBind((jvmtiEnv *)ti_env, jni_env, thread, method, address, new_address_ptr);
+ }
}
VMEXPORT void
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?view=diff&rev=470524&r1=470523&r2=470524
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Thu Nov 2 13:20:58 2006
@@ -42,7 +42,12 @@
jthread getCurrentThread() {
tmn_suspend_disable();
ObjectHandle hThread = oh_allocate_local_handle();
- hThread->object = (Java_java_lang_Thread *)jthread_get_java_thread(hythread_self())->object;
+ jthread thread = jthread_get_java_thread(hythread_self());
+ if(thread) {
+ hThread->object = (Java_java_lang_Thread *)thread->object;
+ } else {
+ hThread->object = NULL;
+ }
tmn_suspend_enable();
return (jthread) hThread;
}