harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r572313 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c
Date Mon, 03 Sep 2007 13:18:56 GMT
Author: dlydick
Date: Mon Sep  3 06:18:55 2007
New Revision: 572313

URL: http://svn.apache.org/viewvc?rev=572313&view=rev
Log:
Added more object lock functions, namely
objectutil_is_somehow_locked(), objectutil_is_lock_owner(),
and objectutil_locked_by_thread().  These are mainly for
use by ATHROW opcode.

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c?rev=572313&r1=572312&r2=572313&view=diff
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/objectutil.c Mon Sep  3 06:18:55 2007
@@ -188,6 +188,169 @@
 
 
 /*!
+ * @brief Test if @c @b synchronize() has successfully locked an
+ * object's monitor lock on @e any thread (not any one in particular).
+ *
+ * Test does @e not consider which thread is the owner of
+ * this object's monitor lock.  Use @link #objutil_is_lock_owner
+   objutil_is_lock_owner@endlink to determine if this thread
+ * is the owner of the object's monitor lock.
+ *
+ *
+ * @param  objhashthis  Object table hash of @c @b this object.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this object's monitor lock
+ *          has been locked by this thread, otherwise
+ *          @link #rfalse rfalse@endlink.
+ *
+ * @throws JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+ *         @link #JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+           if the object hash is the null object@endlink,
+ *         typically due to bad input parameter.
+ *
+ */
+
+rboolean objectutil_is_somehow_locked(jvm_object_hash objhashthis)
+{
+    ARCH_FUNCTION_NAME(objectutil_is_somwhow_locked);
+
+    /* Requested object must be in use and not null */
+    if ((OBJECT_STATUS_INUSE & OBJECT(objhashthis).status)     &&
+       ((!(OBJECT_STATUS_NULL & OBJECT(objhashthis).status))))
+    {
+       /* If object has been locked */
+       return((OBJECT_STATUS_MLOCK & OBJECT(objhashthis).status)
+              ? rtrue
+              : rfalse);
+    }
+
+    /* This thread cannot possibly own the object's monitor lock */
+    thread_throw_exception(CURRENT_THREAD,
+                           THREAD_STATUS_THREW_EXCEPTION,
+                           JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION);
+/*NOTREACHED*/
+    return(rfalse); /* Satisfy compiler */
+
+} /* END of objectutil_is_somehow_locked() */
+
+
+/*!
+ * @brief Test if @c @b synchronize() has successfully locked
+ * an object's monitor lock on a certain thread.
+ *
+ * Result does @e not indicate whether or not this thread is the
+ * one which owns this object.  @link #objutil_is_lock_owner
+   objutil_is_lock_owner@endlink must be called to determine
+ * if this thread is the owner of this object's monitor lock.
+ *
+ *
+ * @param  objhashthis  Object table hash of @c @b this object.
+ *
+ * @param  thridx       Thread table index of a thread requesting
+ *                      ownership of this object's monitor lock.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this object's monitor lock
+ *          has been locked by this thread, otherwise
+ *          @link #rfalse rfalse@endlink.
+ *
+ * @throws JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+ *         @link #JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+           if the object hash is the null object@endlink,
+ *         typically due to bad input parameter.
+ *
+ */
+
+rboolean objectutil_is_lock_owner(jvm_object_hash  objhashthis,
+                                  jvm_thread_index thridx)
+{
+    ARCH_FUNCTION_NAME(objectutil_is_lock_owner);
+
+    /* Requested object must be in use and not null */
+    if ((OBJECT_STATUS_INUSE & OBJECT(objhashthis).status)     &&
+       ((!(OBJECT_STATUS_NULL & OBJECT(objhashthis).status))))
+    {
+       /* If object has been locked */
+       if (((OBJECT_STATUS_MLOCK & OBJECT(objhashthis).status)) &&
+
+       /* and if I am the owner of the lock */
+           (OBJECT(objhashthis).mlock_thridx == thridx))
+       {
+           /* Then synchronization status is known to be true */
+           return(rtrue);
+       }
+       else
+       {
+           /* otherwise it is either not locked or I am not the owner */
+           return(rfalse);
+       }
+    }
+
+    /* This thread cannot possibly own the object's monitor lock */
+    thread_throw_exception(CURRENT_THREAD,
+                           THREAD_STATUS_THREW_EXCEPTION,
+                           JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION);
+/*NOTREACHED*/
+    return(rfalse); /* Satisfy compiler */
+
+} /* END of objectutil_is_lock_owner() */
+
+
+/*!
+ * @brief Test which thread has locked an object's monitor lock.
+ *
+ * In order to query a particular thread, use
+ * @link #objutil_is_lock_owner objutil_is_lock_owner@endlink instead.
+ *
+ *
+ * @param  objhashthis  Object table hash of @c @b this object.
+ *
+ *
+ * @returns Thread table index of the thread which
+ *          owns this object's monitor lock or 
+ *          @link #rnull rnull@endlink if not locked.
+ *
+ * @throws JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+ *         @link #JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION
+           if the object hash is the null object@endlink,
+ *         typically due to bad input parameter.
+ *
+ */
+
+jvm_thread_index objectutil_locked_by_thread(jvm_object_hash
+                                                            objhashthis)
+{
+    ARCH_FUNCTION_NAME(objectutil_locked_by_thread);
+
+    /* Requested object must be in use and not null */
+    if ((OBJECT_STATUS_INUSE & OBJECT(objhashthis).status)     &&
+       ((!(OBJECT_STATUS_NULL & OBJECT(objhashthis).status))))
+    {
+       /* If this object has been locked */
+       if ((OBJECT_STATUS_MLOCK & OBJECT(objhashthis).status))
+       {
+           /* then report which thread locked it */
+           return(OBJECT(objhashthis).mlock_thridx);
+       }
+       else
+       {
+           /* Thread is  not locked */
+           return(jvm_thread_index_null);
+       }
+    }
+
+    /* This thread cannot possibly own the object's monitor lock */
+    thread_throw_exception(CURRENT_THREAD,
+                           THREAD_STATUS_THREW_EXCEPTION,
+                           JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION);
+/*NOTREACHED*/
+    return(rfalse); /* Satisfy compiler */
+
+} /* END of objectutil_locked_by_thread() */
+
+
+/*!
  * @brief Release @c @b synchronize from an object monitor lock.
  *
  *



Mime
View raw message