dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_alloc....


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_alloc....
Date: Fri, 28 Jul 2006 17:41:55 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      06/07/28 17:41:55

Modified files:
        .              : ChangeLog 
        engine         : jitc.c jitc_alloc.c jitc_call.c jitc_except.c 
                         jitc_pinvoke.c 

Log message:
        2006-07-28  Klaus Treichel  <address@hidden>
        
                * engine/jitc.c: Add constants for the 
System.MissingMethodException,
                System.DllNotFoundException and 
System.EntrypointNotFoundException thrown
                by the engine. Add support for errorhandling in pinvokes if the 
shared
                library could not be found or the entrypoint could not be 
located.
        
                * engine/jitc_alloc.c: Allocate objects containing no 
references to managed
                objects with ILGCAllocExplicitelyTyped so that the monitor for 
the object
                is not prematurely collected.
        
                * engine/jitc_call.c: Throw a System.MissingMethodException if 
the vtable
                pointer returned for a virtual or interface call is null.
        
                * engine/jitc_except.c: Add the System.MissingMethodException,
                System.DllNotFoundException and 
System.EntrypointNotFoundException in
                _ILJitThrowSystem.
        
                * engine/jitc_pinvoke.c: Throw the right exception if a shared 
library or
                the entrypoint for a pinvoke could not be found.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3345&r2=1.3346
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_alloc.c?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_call.c?cvsroot=dotgnu-pnet&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_except.c?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_pinvoke.c?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3345
retrieving revision 1.3346
diff -u -b -r1.3345 -r1.3346
--- ChangeLog   28 Jul 2006 17:12:20 -0000      1.3345
+++ ChangeLog   28 Jul 2006 17:41:54 -0000      1.3346
@@ -1,3 +1,24 @@
+2006-07-28  Klaus Treichel  <address@hidden>
+
+       * engine/jitc.c: Add constants for the System.MissingMethodException,
+       System.DllNotFoundException and System.EntrypointNotFoundException 
thrown
+       by the engine. Add support for errorhandling in pinvokes if the shared
+       library could not be found or the entrypoint could not be located.
+
+       * engine/jitc_alloc.c: Allocate objects containing no references to 
managed
+       objects with ILGCAllocExplicitelyTyped so that the monitor for the 
object
+       is not prematurely collected.
+
+       * engine/jitc_call.c: Throw a System.MissingMethodException if the 
vtable
+       pointer returned for a virtual or interface call is null.
+
+       * engine/jitc_except.c: Add the System.MissingMethodException,
+       System.DllNotFoundException and System.EntrypointNotFoundException in
+       _ILJitThrowSystem.
+
+       * engine/jitc_pinvoke.c: Throw the right exception if a shared library 
or
+       the entrypoint for a pinvoke could not be found.
+
 2006-07-28  Kaushik Srenevasan  <address@hidden>
 
        * cscc/csharp/cs_decls.tc: Disallow explicit parameterless constructors

Index: engine/jitc.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- engine/jitc.c       22 Jul 2006 08:48:32 -0000      1.43
+++ engine/jitc.c       28 Jul 2006 17:41:54 -0000      1.44
@@ -351,6 +351,19 @@
 #define _IL_JIT_IMPL_INTERNALMASK      0x3
 #define _IL_JIT_IMPL_PINVOKE           0x4
 
+/* Error codes stored in fnInfo.func in case a library or method was not */
+/* found */
+#define _IL_JIT_PINVOKE_DLLNOTFOUND                    ((void *)0x01)
+#define _IL_JIT_PINVOKE_ENTRYPOINTNOTFOUND     ((void *)0x02)
+#define _IL_JIT_PINVOKE_ERRORMASK                      ((void *)0x03)
+
+#ifdef IL_NATIVE_INT64
+#define _ILJitPinvokeError(fnInfo)     ((((ILInt64)(fnInfo).func) & 
~((ILInt64)_IL_JIT_PINVOKE_ERRORMASK)) == 0)
+#endif
+#ifdef IL_NATIVE_INT32
+#define _ILJitPinvokeError(fnInfo)     ((((ILInt32)(fnInfo).func) & 
~((ILInt32)_IL_JIT_PINVOKE_ERRORMASK)) == 0)
+#endif
+       
 /*
  * Define the structure of a JIT coder's instance block.
  */
@@ -471,7 +484,9 @@
 #define _IL_JIT_OUT_OF_MEMORY          1
 #define _IL_JIT_INVALID_CAST           2
 #define _IL_JIT_INDEX_OUT_OF_RANGE     3
-#define _IL_JIT_METHOD_INVOKATION      4
+#define _IL_JIT_MISSING_METHOD                 4
+#define _IL_JIT_DLL_NOT_FOUND                  5
+#define _IL_JIT_ENTRYPOINT_NOT_FOUND   6
 
 /*
  * Emit the code to throw a system exception.
@@ -3057,10 +3072,8 @@
                                        }
                                        moduleHandle = LocateExternalModule
                                                                        
(ILExecThreadGetProcess(thread), name, pinv);
-                                       if(!moduleHandle)
+                                       if(moduleHandle)
                                        {
-                                               return 0;
-                                       }
 
                                        /* Get the name of the function within 
the module */
                                        name = ILPInvoke_Alias(pinv);
@@ -3072,10 +3085,14 @@
                                        /* Look up the method within the module 
*/
                                        fnInfo.func = 
ILDynLibraryGetSymbol(moduleHandle, name);
 
-                                       /* Bail out if we did not find the 
underlying native method */
                                        if(!(fnInfo.func))
                                        {
-                                               return 0;
+                                                       fnInfo.func = 
_IL_JIT_PINVOKE_ENTRYPOINTNOTFOUND;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               fnInfo.func = 
_IL_JIT_PINVOKE_DLLNOTFOUND;
                                        }
 
                                        /* Flag the method pinvoke. */

Index: engine/jitc_alloc.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc_alloc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- engine/jitc_alloc.c 3 Jun 2006 11:00:40 -0000       1.4
+++ engine/jitc_alloc.c 28 Jul 2006 17:41:54 -0000      1.5
@@ -63,7 +63,20 @@
        ILObject *obj;
 
        /* Allocate memory from the heap */
+#ifdef IL_CONFIG_USE_THIN_LOCKS
        ptr = ILGCAllocAtomic(size + IL_OBJECT_HEADER_SIZE);
+#else
+       /* We need this because we have to make sure the ILLockWord in the 
ObjectHeader is scanned by the GC. */
+       /* TODO: Move descriptor creation to layout.c */
+       if(classPrivate->gcTypeDescriptor == IL_MAX_NATIVE_UINT)
+       {
+               ILNativeUInt bitmap = IL_OBJECT_HEADER_PTR_MAP;
+
+               classPrivate->gcTypeDescriptor = 
ILGCCreateTypeDescriptor(&bitmap, IL_OBJECT_HEADER_SIZE / sizeof(ILNativeInt)); 
               
+       }
+
+       ptr = ILGCAllocExplicitlyTyped(size + IL_OBJECT_HEADER_SIZE, 
classPrivate->gcTypeDescriptor);
+#endif
 
        if(!ptr)
        {

Index: engine/jitc_call.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc_call.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- engine/jitc_call.c  28 Jun 2006 19:20:02 -0000      1.21
+++ engine/jitc_call.c  28 Jul 2006 17:41:54 -0000      1.22
@@ -53,6 +53,8 @@
        ILJitValue interfaceClass;
        ILJitValue methodIndex;
        ILJitValue args[3];
+       ILJitValue jitFunction;
+       jit_label_t label = jit_label_undefined;
 
        _ILJitCheckNull(jitCoder, object);
        classPrivate = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, 
object);
@@ -65,11 +67,17 @@
        args[0] = classPrivate;
        args[1] = interfaceClass;
        args[2] = methodIndex;
-       return jit_insn_call_native(jitCoder->jitFunction,
+       jitFunction = jit_insn_call_native(jitCoder->jitFunction,
                                                                
"_ILRuntimeLookupInterfaceMethod",
                                                                
_ILRuntimeLookupInterfaceMethod,
                                                                
_ILJitSignature_ILRuntimeLookupInterfaceMethod,
                                                                args, 3, 0);
+
+       jit_insn_branch_if(jitCoder->jitFunction, jitFunction, &label);
+       _ILJitThrowSystem(jitCoder, _IL_JIT_MISSING_METHOD);
+       jit_insn_label(jitCoder->jitFunction, &label);
+
+       return jitFunction;
 }
 
 /*
@@ -82,6 +90,8 @@
        ILJitValue classPrivate;
        ILJitValue vtable;
        ILJitValue vtableIndex;
+       ILJitValue jitFunction;
+       jit_label_t label = jit_label_undefined;
 
        _ILJitCheckNull(jitCoder, object);
        classPrivate = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, 
object);
@@ -91,8 +101,14 @@
        vtableIndex = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                 _IL_JIT_TYPE_INT32,
                                                                                
                 (jit_nint)index);
-       return jit_insn_load_elem(jitCoder->jitFunction,
+       jitFunction = jit_insn_load_elem(jitCoder->jitFunction,
                                                          vtable, vtableIndex, 
_IL_JIT_TYPE_VPTR);
+
+       jit_insn_branch_if(jitCoder->jitFunction, jitFunction, &label);
+       _ILJitThrowSystem(jitCoder, _IL_JIT_MISSING_METHOD);
+       jit_insn_label(jitCoder->jitFunction, &label);
+
+       return jitFunction;
 }
 
 /*

Index: engine/jitc_except.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc_except.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- engine/jitc_except.c        25 Jun 2006 11:56:32 -0000      1.8
+++ engine/jitc_except.c        28 Jul 2006 17:41:54 -0000      1.9
@@ -58,7 +58,10 @@
                "Ok",
                "System.OutOfMemoryException",
                "System.InvalidCastException",
-               "System.IndexOutOfRangeException"
+               "System.IndexOutOfRangeException",
+               "System.MissingMethodException",
+               "System.DllNotFoundException",
+               "System.EntryPointNotFoundException"
        };
        #define numExceptions   (sizeof(exceptionClasses) / sizeof(const char 
*))
        ILExecThread *_thread = ILExecThreadCurrent();

Index: engine/jitc_pinvoke.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc_pinvoke.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- engine/jitc_pinvoke.c       22 Jul 2006 08:48:32 -0000      1.2
+++ engine/jitc_pinvoke.c       28 Jul 2006 17:41:54 -0000      1.3
@@ -52,10 +52,10 @@
 static int _ILJitCompilePinvoke(jit_function_t func)
 {
        ILMethod *method = (ILMethod *)jit_function_get_meta(func, 
IL_JIT_META_METHOD);
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
        ILClass *info = ILMethod_Owner(method);
        ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
        ILJITCoder *jitCoder = (ILJITCoder*)(classPrivate->process->coder);
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
        char *methodName = _ILJitFunctionGetMethodName(func);
 #endif
        ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo *)(method->userData);
@@ -86,6 +86,24 @@
                /* The pinvoke record could not be found. */
                return JIT_RESULT_COMPILE_ERROR;
        }
+
+       /* Setup the needed stuff in the jitCoder. */
+       jitCoder->jitFunction = func;
+
+       /* Check if the method to invoke was found on this system. */
+       if(_ILJitPinvokeError(jitMethodInfo->fnInfo))
+       {
+               if(jitMethodInfo->fnInfo.func == _IL_JIT_PINVOKE_DLLNOTFOUND)
+               {
+                       _ILJitThrowSystem(jitCoder, _IL_JIT_DLL_NOT_FOUND);
+               }
+               else if(jitMethodInfo->fnInfo.func == 
_IL_JIT_PINVOKE_ENTRYPOINTNOTFOUND)
+               {
+                       _ILJitThrowSystem(jitCoder, 
_IL_JIT_ENTRYPOINT_NOT_FOUND);
+               }
+               return JIT_RESULT_OK;
+       }
+
        /* determine which calling convention to use. */
        switch(pinv->member.attributes & IL_META_PINVOKE_CALL_CONV_MASK)
        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]