Fri Feb 12 18:36:02 CET 2010 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Fri, 12 Feb 2010 17:37:06 +0000 (17:37 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Fri, 12 Feb 2010 17:37:06 +0000 (17:37 -0000)
* icall.c, icall-def.h: new icall to check for sufficient
stack space.

svn path=/trunk/mono/; revision=151637

mono/metadata/ChangeLog
mono/metadata/icall-def.h
mono/metadata/icall.c

index bf1aa19a09457a62e350277045359f9b10e4d9eb..da30388c6e66aad2fc9b49892889c0813ec93e41 100644 (file)
@@ -1,3 +1,9 @@
+
+Fri Feb 12 18:36:02 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * icall.c, icall-def.h: new icall to check for sufficient
+       stack space.
+
 2010-02-12  Mark Probst  <mark.probst@gmail.com>
 
        * reflection.c (ensure_complete_type): Check that reflection_info
index d3d7e30df2f388341ee8f7618e1759afcff61120..73b9020644727ef60db37eae25609129734f39dd 100644 (file)
@@ -642,6 +642,7 @@ ICALL(RUNH_2, "GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices
 ICALL(RUNH_3, "InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray)
 ICALL(RUNH_4, "RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor)
 ICALL(RUNH_5, "RunModuleConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor)
+ICALL(RUNH_5h, "SufficientExecutionStack", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack)
 ICALL(RUNH_6, "get_OffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData)
 
 ICALL_TYPE(GCH, "System.Runtime.InteropServices.GCHandle", GCH_1)
index 945f59029ab1675210a2d48cd4f01272f05846bc..dbc24af1c9979fd9a9fbb31cb99a1f289b3cfc6d 100644 (file)
@@ -977,6 +977,29 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (M
        }
 }
 
+static MonoBoolean
+ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void)
+{
+       guint8 *stack_addr;
+       guint8 *current;
+       size_t stack_size;
+       /* later make this configurable and per-arch */
+       int min_size = 4096 * 4 * sizeof (void*);
+       mono_thread_get_stack_bounds (&stack_addr, &stack_size);
+       /* if we have no info we are optimistic and assume there is enough room */
+       if (!stack_addr)
+               return TRUE;
+       current = (guint8 *)&stack_addr;
+       if (current > stack_addr) {
+               if ((current - stack_addr) < min_size)
+                       return FALSE;
+       } else {
+               if (current - (stack_addr - stack_size) < min_size)
+                       return FALSE;
+       }
+       return TRUE;
+}
+
 static MonoObject *
 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
 {