Hi, i just realised that the choice of allocation is required at the alloc-site level rather than at the class level so the only option is the last one- wrapping the new operator? could u please elaborate on that?? Thanks archana
On Tue, 24 Aug 2004, Jan Kotas wrote: > New/newobj is a primitive operation that is hardwired into many parts of > the system. It is not just another function. Simplification of the > solution to your problem will likely come from tagging the existing > New/newobj to use your allocator instead of implementing the entire > parallel New/newobj world. > > Here are more details about the attribute and method ideas that I have > mentioned below: > > - If all instances of certain classes are supposed to be allocated by > your allocator, you can use custom attribute to mark them as such. Or > you can use custom attribute to say that all instances of given class in > an assembly should be allocated using your allocator. The JIT would > consult the custom attribute every time it jitted a newobj instruction > and call the appropriate internal implementation of new. > > - Instead of introducing a new "new" operator, you can introduce a > helper function to wrap existing calls to "new" operator like: > mycustomallocator(new Object()). Then the JIT can look for newobj > immediately followed by call to your helper function and convert these > sequences to use the custom allocator. There is a problem that > mycustomallocator would always return object, and you would need to cast > in the pattern as well. You can overcome it if you use generics: static > T mycustomallocator<T>(T o) > > > -Jan > > -----Original Message----- > From: Discussion of the Rotor Shared Source CLI implementation > [mailto:[EMAIL PROTECTED] On Behalf Of Archana > Sent: Tuesday, August 24, 2004 4:26 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET-ROTOR] adding a new alloc function > > Hi, > Thanks for such a prompt response. the solution sounds kind of > complicated. > well,actually i just want a function that can allocate memory, like > new that i can call in a C# program. > Isnt there any other way to do it. say as pointed > out by you in the first option- if i want to have a method instead of > another instruction, what would the changes involve. it might be a lot > simpler than this? > > Regards > archana > > On Mon, 23 Aug 2004, Jan Kotas wrote: > > > If you want to expose this feature in C# and seemingly integrate into > > IL, then it involves: > > > > - Carefully design the whole thing: Do you really need a new > > instruction? Won't be attribute or method enough? If it needs to be a > > new instruction, should it be a standalone instruction or prefix? Etc. > > > > - Add support for the new instruction in the CLR: google for "adding > > instruction in Rotor" to find tutorial on how to do that. > > > > - Modify the C# compiler to accept the new keyword. Look for the > > dataflow for the existing new operator (NK_NEW, TID_NEW, CEE_NEWOBJ, > > EXF_NEWOBJCALL and bindNew) and modify the codepaths appropriately > > depending on what your instruction does exactly. > > > > -Jan > > > > -----Original Message----- > > From: Discussion of the Rotor Shared Source CLI implementation > > [mailto:[EMAIL PROTECTED] On Behalf Of Archana > > Sent: Monday, August 23, 2004 9:49 PM > > To: [EMAIL PROTECTED] > > Subject: [DOTNET-ROTOR] adding a new alloc function > > > > Hi, > > incase one needs to add a new alloc function apart from getting > memory > > using the operator new, what are the changes involved in doing so. > what > > all files in Rotor need to change etc.. > > eg: x=new object(), x = new1 object(); > > Thanks, > > archana > > > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > ASP.NET courses you may be interested in: > > Guerrilla ASP.NET > 15 March 2004, in Boston, MA > 17 May 2004 in Torrance, CA > 7 June 2004, London, UK > > 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 > ASP.NET courses you may be interested in: > > Guerrilla ASP.NET > 15 March 2004, in Boston, MA > 17 May 2004 in Torrance, CA > 7 June 2004, London, UK > > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at http://discuss.develop.com > -- Regards, Archana =================================== This list is hosted by DevelopMentorŪ http://www.develop.com ASP.NET courses you may be interested in: Guerrilla ASP.NET 15 March 2004, in Boston, MA 17 May 2004 in Torrance, CA 7 June 2004, London, UK http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com