site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com
The traditional way to pic-ify such data structures is to store relative offsets instead of absolute pointers. Notable performance hit and serious addition of complexity: Replace *foo by *(something->getBaseAddress() + fooOffset) in about a zillion places.
-- Greg Parker gparker@apple.com Runtime Wrangler _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Sep 22, 2009, at 5:50 PM, Jay Reynolds Freeman wrote: On Sep 22, 2009, at 5:42 PM, Greg Parker wrote: You are thinking relocatable binary files, I believe. Think "linked lists" and "structs with pointers to other structs", instead -- that is what is in this big memory-mapped block. The trick to save performance is to store an offset relative to the location where the offset is stored. Then `*foo` becomes `foo+*foo`. And you can save space by using 4-byte offsets if you know the complete data structure spans less than 4GB (though for you that appears not to be the case). Snow Leopard's Objective-C runtime uses both of those for the selector table in the dyld shared cache. Usually the shared cache loads at the same address everywhere, but this makes it work without modification otherwise. This email sent to site_archiver@lists.apple.com