From 570925ad0ef6f8f8e6068d6115da8428813ed900 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 11 Jan 2008 10:49:11 -0700 Subject: [PATCH] handle locking for synchronized native methods --- src/compile.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/compile.cpp b/src/compile.cpp index 2b98a738a5..c797880356 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -3949,6 +3949,14 @@ invokeNative2(MyThread* t, object method) &byteArrayBody(t, methodName(t, method), 0)); } + if (methodFlags(t, method) & ACC_SYNCHRONIZED) { + if (methodFlags(t, method) & ACC_STATIC) { + acquire(t, methodClass(t, method)); + } else { + acquire(t, *reinterpret_cast(args[0])); + } + } + { ENTER(t, Thread::IdleState); result = t->m->system->call @@ -3960,6 +3968,14 @@ invokeNative2(MyThread* t, object method) returnType); } + if (methodFlags(t, method) & ACC_SYNCHRONIZED) { + if (methodFlags(t, method) & ACC_STATIC) { + release(t, methodClass(t, method)); + } else { + release(t, *reinterpret_cast(args[0])); + } + } + if (DebugNatives) { fprintf(stderr, "return from native method %s.%s\n", &byteArrayBody(t, className(t, methodClass(t, method)), 0),