It is a value type.

But I think MS assumes that the function calls will be inlined anyway,
and the no copy ends up on the stack.

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.) 

> -----Original Message-----
> From: Unmoderated discussion of advanced .NET topics. 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Shawn A. Van Ness
> Sent: Montag, 17. Mai 2004 07:29
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] Large structures
> 
> > This seems like a big waste of time
> 
> Arlie, are you concerned more about the time (ie, the memcpy 
> operation) or excess growth of the stack (eg, in recursive 
> scenarios)?  Or both?
> 
> I don't have the managed dx sdk handy -- is their Matrix 
> really a valuetype?
> In System.Drawing.Drawing2D, it's a class.  Somewhat ironic, 
> considering that one's only 2x3 floats. :/
> 
> I'd be shocked to learn that the JIT we have today gives 
> special treatment to large valuetypes -- it'd be a pretty 
> obscure opt, if not for the DirectX calls you cite.  But I 
> agree it sounds like it would be feasible.
> (Especially in scenarios where the JIT also decides to inline 
> the function in question -- wouldn't even need to pass a 
> pointer, on x86 -- just emit opcodes which read the fields 
> from somewhere above the ebp, instead of below
> it.)
> 
> Cheers,
> -Shawn
> http://www.windojitsu.com/
> 
> 
> -----Original Message-----
> From: Arlie Davis [mailto:[EMAIL PROTECTED]
> Sent: Sunday, May 16, 2004 11:51
> Subject: Large structures
> 
> I have a few questions for the advanced CLR people here.  I 
> haven't been able to find any satisfactory answers elsewhere.
> 
> Consider value types / structures in CLR, and passing them as 
> arguments to methods.  Does the MS CLR *always* copy the 
> entire structure onto the stack?
> Or does it ever simply pass a pointer to the structure?
> 
> I like value types.  However, structures of any significant 
> size are just impractical, if they must always be copied.  
> For example, in managed DirectX, nearly all of the matrix 
> manipulation methods take "Matrix foo" as an argument, never 
> "ref Matrix foo".  These matrices are 4x4 floats, which means 
> that 64 bytes must be copied for every single matrix that is 
> passed into a method.
> 
> This seems like a big waste of time, compared to the same 
> thing in C++, where you would simply always pass a pointer to 
> the matrix.  Does the CLR actually pass an entire Matrix on 
> the stack?  Or just a pointer?
> 
> It seems like it would be within the specification / 
> requirements of the CLR to allow a CLR implementation to do 
> this, if it realizes that the method never alters the 
> structure, only examines its fields.
> 
> Any insight is appreciated.
> 
> -- arlie
> 
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com 
> Some .NET courses you may be interested in:
> 
> NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles 
> http://www.develop.com/courses/gaspdotnetls
> 
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com 
> Some .NET courses you may be interested in:
> 
> NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles 
> http://www.develop.com/courses/gaspdotnetls
> 
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
> 
> 

===================================
This list is hosted by DevelopMentor®  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to