[vmkit-commits] [vmkit] r183665 - Restore MONITOREXIT behavior to conform to the Java specifications, i.e., MONITOREXIT throws an exception if given a null reference.

Koutheir Attouchi koutheir at gmail.com
Mon Jun 10 08:09:02 PDT 2013


Author: koutheir
Date: Mon Jun 10 10:09:02 2013
New Revision: 183665

URL: http://llvm.org/viewvc/llvm-project?rev=183665&view=rev
Log:
Restore MONITOREXIT behavior to conform to the Java specifications, i.e., MONITOREXIT throws an exception if given a null reference.

Modified:
    vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp

Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp?rev=183665&r1=183664&r2=183665&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp Mon Jun 10 10:09:02 2013
@@ -695,13 +695,7 @@ void JavaJIT::monitorEnter(Value* obj) {
 }
 
 void JavaJIT::monitorExit(Value* obj) {
-	/*
-		obj should not be null if we are here.
-		If obj was null when monitorEnter() was run, then monitorEnter() should have
-		thrown an exception. If it was not null then, and it is null now, it must have
-		been reset by the GC (it became a stale reference) between monitorEnter() and
-		monitorExit(). In this case, just get out of the synchronize block silently.
-	*/
+	// obj should not be null if we are here.
     BasicBlock* nonNullObjBlock = createBasicBlock("monitorExit_nonNullObj");
     BasicBlock* EndBlock = createBasicBlock("monitorExit_End");
 

Modified: vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=183665&r1=183664&r2=183665&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp Mon Jun 10 10:09:02 2013
@@ -2566,11 +2566,9 @@ void JavaJIT::compileOpcodes(Reader& rea
       }
 
       case MONITOREXIT : {
-        // NOTE: monitorExit() should NOT throw an exception if object is null.
-        // See monitorExit() implementation.
-        //bool thisReference = isThisReference(currentStackIndex - 1);
+        bool thisReference = isThisReference(currentStackIndex - 1);
         Value* obj = pop();
-        // if (!thisReference) JITVerifyNull(obj);
+        if (!thisReference) JITVerifyNull(obj);
         monitorExit(obj);
         break;
       }





More information about the vmkit-commits mailing list