NOHANDLES(ICALL(STRING_6, ".ctor(sbyte*)", ves_icall_System_String_ctor_RedirectToCreateString))
NOHANDLES(ICALL(STRING_7, ".ctor(sbyte*,int,int)", ves_icall_System_String_ctor_RedirectToCreateString))
NOHANDLES(ICALL(STRING_8, ".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_RedirectToCreateString))
-HANDLES(STRING_9, "FastAllocateString", ves_icall_System_String_InternalAllocateStr, MonoString, 1, (gint32))
+HANDLES(STRING_9, "FastAllocateString", ves_icall_System_String_FastAllocateString, MonoString, 1, (gint32))
HANDLES(STRING_10, "InternalIntern", ves_icall_System_String_InternalIntern, MonoString, 1, (MonoString))
HANDLES(STRING_11, "InternalIsInterned", ves_icall_System_String_InternalIsInterned, MonoString, 1, (MonoString))
NOHANDLES(ICALL(STRING_6, ".ctor(sbyte*)", ves_icall_System_String_ctor_RedirectToCreateString))
NOHANDLES(ICALL(STRING_7, ".ctor(sbyte*,int,int)", ves_icall_System_String_ctor_RedirectToCreateString))
NOHANDLES(ICALL(STRING_8, ".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_RedirectToCreateString))
-HANDLES(STRING_9, "FastAllocateString", ves_icall_System_String_InternalAllocateStr, MonoString, 1, (gint32))
+HANDLES(STRING_9, "FastAllocateString", ves_icall_System_String_FastAllocateString, MonoString, 1, (gint32))
HANDLES(STRING_10, "InternalIntern", ves_icall_System_String_InternalIntern, MonoString, 1, (MonoString))
HANDLES(STRING_11, "InternalIsInterned", ves_icall_System_String_InternalIsInterned, MonoString, 1, (MonoString))
mono_mb_patch_branch (mb, pos_leave);
/* end catch */
} else if (atype == ATYPE_STRING) {
- int pos;
-
/*
* a string allocator method takes the args: (vtable, len)
*
*
* condition:
*
- * bytes <= INT32_MAX - (SGEN_ALLOC_ALIGN - 1)
+ * bytes <= SIZE_MAX - (SGEN_ALLOC_ALIGN - 1)
*
* therefore:
*
* offsetof (MonoString, chars) + ((len + 1) * 2) <= INT32_MAX - (SGEN_ALLOC_ALIGN - 1)
- * len <= (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - offsetof (MonoString, chars)) / 2 - 1
+ * len <= (SIZE_MAX - (SGEN_ALLOC_ALIGN - 1) - offsetof (MonoString, chars)) / 2 - 1
+ *
+ * On 64-bit platforms SIZE_MAX is so big that the 32-bit string length can
+ * never reach the maximum size.
*/
+#if TARGET_SIZEOF_VOID_P == 4
+ int pos;
+
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_icon (mb, (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - MONO_STRUCT_OFFSET (MonoString, chars)) / 2 - 1);
pos = mono_mb_emit_short_branch (mb, MONO_CEE_BLE_UN_S);
mono_mb_emit_byte (mb, CEE_MONO_NOT_TAKEN);
mono_mb_emit_exception (mb, "OutOfMemoryException", NULL);
mono_mb_patch_short_branch (mb, pos);
+#endif
mono_mb_emit_ldarg (mb, 1);
+ mono_mb_emit_byte (mb, CEE_CONV_I);
mono_mb_emit_icon (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_SHL);
//WE manually fold the above + 2 here
}
MonoStringHandle
-ves_icall_System_String_InternalAllocateStr (gint32 length, MonoError *error)
+ves_icall_System_String_FastAllocateString (gint32 length, MonoError *error)
{
return mono_string_new_size_handle (mono_domain_get (), length, error);
}
{
if (method->klass == mono_defaults.string_class) {
/* managed string allocation support */
- if (strcmp (method->name, "InternalAllocateStr") == 0 && !(cfg->opt & MONO_OPT_SHARED)) {
+ if (strcmp (method->name, "FastAllocateString") == 0 && !(cfg->opt & MONO_OPT_SHARED)) {
MonoInst *iargs [2];
MonoVTable *vtable = mono_class_vtable_checked (cfg->domain, method->klass, cfg->error);
MonoMethod *managed_alloc = NULL;
<!-- domain.c: mono_defaults.string_class -->
<type fullname="System.String" preserve="fields">
<!-- method-to-ir.c: mini_redirect_call -->
- <method name="InternalAllocateStr" />
+ <method name="FastAllocateString" />
<!-- method-to-it.c: mini_emit_initobj -->
<method name="memset" />
<!-- mini-generic-sharing.c: class_type_info