• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online


  • Subject: Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online
  • From: Nat! <email@hidden>
  • Date: Wed, 31 Dec 2003 00:38:31 +0100

Am 30.12.2003 um 03:37 schrieb Glen Low:

If you liked the previous stuff, you'll love these :)

Hi Nat:

It seems you have the same sort of weird ideas as I. In a thread previous this month on MacOSXDev I was thinking about putting a ObjC object on the stack, and there you talk about the very thing:

I did wrote in a thread about stack objects previously:

http://cocoa.mamasam.com/MACOSXDEV/2003/12/2/79848.php

http://www.mulle-kybernetik.com/artikel/Optimization/opti-2.html
(How an Object is Created)

Yeah, technically it works. But it's not useful.


Questions:

1. Does that mean for a stack object I have to be very careful to avoid any alloc and (implicit) dealloc calls? How then do you handle the usual case of the subclass dealloc call being needed to release instance variables?

I don't handle this. I have given up on stack Foundation objects. :)

You can experiment with this (untested but oughta do the job)

@interface StackbasedObject : NSObject
{
}
@end

@implementation StackbasedObject

+ (id) alloc
{
StackbasedObject *p;
size_t size;

size = ((struct objc_class *) self)->instance_size;
p = alloca( size);
p->isa = self;
memset( &(p->isa + 1), 0, size - sizeof( Class));
return( p);
}

+ (id) allocWithZone:(NSZone *) zone
{
return( [self alloc]);
}

@end

Expect lotsa funny crashes :)

Can we somehow intercept the [super dealloc] not to free stack memory? -- perhaps with a custom zone?

Rather with C++...


I'm thinking along the same lines about cacheing IMP's, why is it an IMP needs a redundant(?) SEL to be passed to it?

Maybe someone else can answer this. AFAIK Obj-C wouldn't stop working if _cmd was not set. It's more of a (cheap) convenience. I don't understand what that has to do with caching though.

Ciao
Nat!

I act professionally, when I get paid for it. - Unknown
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online
      • From: Andrew Pinski <email@hidden>
  • Prev by Date: Fwd: WebServices Question (plus some additional details)
  • Next by Date: Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online
  • Previous by thread: Fwd: WebServices Question (plus some additional details)
  • Next by thread: Re: [ANN] Mulle kybernetiK - Optimizing Objective-C code - Articles #3.1 + #9 online
  • Index(es):
    • Date
    • Thread