Hi,
Using mono_runtime_invoke () is simpler indeed but it's much slower than
using managed only implementation. Using the attached test I got 19265 for
CEE_CALL while 34672 for mono_runtime_invoke (). So I think it's worth to
generate managed wrappers unless they cause some serious problems.
Is it OK to use MONO_WRAPPER_MANAGED_TO_NATIVE for the generated
managed-to-managed wrappers to be consistent with other icalls?
Kornél
----- Original Message -----
From: "Zoltan Varga" <[EMAIL PROTECTED]>
To: "Kornél Pál" <[EMAIL PROTECTED]>
Cc: <mono-devel-list@lists.ximian.com>
Sent: Sunday, July 16, 2006 1:40 AM
Subject: Re: [Mono-dev] [PATCH] Redirect certain string constructors to
CreateString
Hi,
I would prefer the wrapper approach. Another (simpler) approach
would be to simply
call the CreateString methods from the unmanaged ctors using
mono_runtime_invoke ().
Zoltan
On 7/15/06, Kornél Pál <[EMAIL PROTECTED]> wrote:
Hi,
Could you please let me know which solution do you prefer? (redirecting
.ctor to CreateString or using a wrapper that calls CreateString)
According to my test using a wrapper makes the code slower. I tried to use
CEE_JMP as well but in that case .ctor is lost from the stack trace as
well
so I think there is no use to create a wrapper using CEE_JMP.
Thanks for your help.
Kornél
----- Original Message -----
From: "Kornél Pál" <[EMAIL PROTECTED]>
To: "Zoltan Varga" <[EMAIL PROTECTED]>
Cc: <mono-devel-list@lists.ximian.com>
Sent: Thursday, July 13, 2006 2:48 PM
Subject: Re: [Mono-dev] [PATCH] Redirect certain string constructors to
CreateString
> Hi,
>
> I reallized that simply redirecting the method may not be a good
> solution
> because the .ctor method is lost from the stack trace this way. And I
> think
> other problems may occur altough I never experienced such problems.
>
> I attached an extended version of the previous patch that creates a
> wrapper.
>
> In addition now CreateString () methods are properly implemented and
> I've
> patched ASCIIEncoding and Latin1Encoding classes so that their GetString
> ()
> methods no longer recurse to CreateString () methods.
>
> If these modifications are approved I'll commit this patch and later it
> will
> be easier to extend CreateString () to use faster method implementations
> for
> internal encoding classes. (I changed my mind.:)
>
> Kornél
>
> ----- Original Message -----
> From: "Kornél Pál" <[EMAIL PROTECTED]>
> To: "Zoltan Varga" <[EMAIL PROTECTED]>
> Cc: <mono-devel-list@lists.ximian.com>
> Sent: Wednesday, July 12, 2006 5:27 PM
> Subject: Re: [Mono-dev] [PATCH] Redirect certain string constructors to
> CreateString
>
>
>> Hi,
>>
>> CreateString methods are not yet complete. The attached CreateString
>> methods were forged for testing only.
>>
>> Encoding.GetString() methods are currently using new String (char [])
>> so
>> the performance gain were probably insignificant and
>> Latin1Encoding.GetString () methods currently use new String (sbyte*,
>> int,
>> int) that would result in infinite recursion.
>>
>> I'm going to check-in the modifications made to the runtime after I
>> finish
>> the work on Encoding classes. (And when those modifications will be
>> approved as well.)
>>
>> Thanks for the approval and your help in implementing the code.
>>
>> Kornél
>>
>> ----- Original Message -----
>> From: "Zoltan Varga" <[EMAIL PROTECTED]>
>> To: "Kornél Pál" <[EMAIL PROTECTED]>
>> Cc: <mono-devel-list@lists.ximian.com>
>> Sent: Wednesday, July 12, 2006 4:30 PM
>> Subject: Re: [Mono-dev] [PATCH] Redirect certain string constructors to
>> CreateString
>>
>>
>> Hi,
>>
>> This looks ok to check-in, except the Console.WriteLine in CreateString
>> ().
>>
>> Zoltan
>>
>> On 7/12/06, Kornél Pál <[EMAIL PROTECTED]> wrote:
>>> Attached a modified version. Using a function instead of (-1) is a
>>> good
>>> idea
>>> not because g_assert_not_reached () can be used but because (-1) will
>>> not
>>> be
>>> monopolized to string constructors (altought it's very unlikely to
>>> need
>>> any
>>> other kind of redirection).
>>>
>>> And I added two more g_asserts to ensure that CreateString methods are
>>> implemented using managed code.
>>>
>>> If you have any other comments please let me know.
>>>
>>> Kornél
>>>
>>> ----- Original Message -----
>>> From: "Zoltan Varga" <[EMAIL PROTECTED]>
>>> To: "Kornél Pál" <[EMAIL PROTECTED]>
>>> Sent: Wednesday, July 12, 2006 12:43 PM
>>> Subject: Re: [Mono-dev] [PATCH] Redirect certain string constructors
>>> to
>>> CreateString
>>>
>>>
>>> Hi,
>>>
>>> This approach seems workable. It would be better to have a dummy
>>> string
>>> ctor (eg ves_icall_System_String_ctor_CreateString with a body of
>>> g_assert_not_reached ()) instead of the ICALL_... constant. Probably
>>> only
>>> mono_marshal_lock () is needed.
>>>
>>> On 7/11/06, Kornél Pál <[EMAIL PROTECTED]> wrote:
>>> > The previous one did not cache the results. Now this is fixed.
>>> >
>>> > BTW is mono_loader_lock () and mono_marshal_lock () necessary as
>>> > well?
>>> >
>>> > Kornél
>>> >
>>> > ----- Original Message -----
>>> > From: "Kornél Pál" <[EMAIL PROTECTED]>
>>> > To: <mono-devel-list@lists.ximian.com>
>>> > Sent: Tuesday, July 11, 2006 9:20 AM
>>> > Subject: [PATCH] Redirect certain string constructors to
>>> > CreateString
>>> >
>>> >
>>> > > Hi,
>>> > >
>>> > > The attached patch implements what I was planning to do.
>>> > >
>>> > > Note that if the patch is approved I'm not going to commit is yet
>>> > > because
>>> > > the encoding classes should be updated first.
>>> > >
>>> > > This patch contains String.cs modifications as well that should
>>> > > compile
>>> > > with
>>> > > the current encoding classes as well.
>>> > >
>>> > > I think this is a good solution and works for me but comments are
>>> > > welcome.
>>> > >
>>> > > Please review and approve the patch.
>>> > >
>>> > > Kornél
>>> > >
>>> >
>>> >
>>> > _______________________________________________
>>> > Mono-devel-list mailing list
>>> > Mono-devel-list@lists.ximian.com
>>> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>> >
>>> >
>>> >
>>> >
>>>
>>>
>>>
>>
>
using System;
using System.Text;
namespace CreateStringTest
{
class CreateStringTest
{
unsafe static void Main(string[] args)
{
Encoding encoding = Encoding.GetEncoding(28591);
byte[] bytes = encoding.GetBytes(new string('x', 4096));
int byteCount = bytes.Length;
string s;
DateTime date;
date = DateTime.Now;
fixed (byte* bytePtr = bytes)
for (int i = 0; i < 1000000; i++)
s = new string((sbyte*) bytePtr, 0,
byteCount, encoding);
Console.WriteLine((long)DateTime.Now.Subtract(date).TotalMilliseconds);
}
}
}
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list