gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GSIMap


From: David Chisnall
Subject: Re: GSIMap
Date: Wed, 1 Jun 2011 23:48:08 +0100

On 1 Jun 2011, at 23:20, Richard Frith-Macdonald wrote:

> 
> On 1 Jun 2011, at 19:30, David Chisnall wrote:
> 
>> Hi,
>> 
>> I'm trying to make NSHashTable / NSMapTable use the correct read / write 
>> barrier functions in GC mode, but I don't really understand the GSIMap code. 
>>  Does it define macros for reading / writing pointers anywhere?  In GC mode, 
>> we need to call the relevant read and write barrier functions for assigning 
>> pointer values, depending in the pointer functions:
> 
> NSHashTable and NSMapTable use both NSPointerFunctions and the old callbacks 
> (Apple added new classes for these objects, while retaining backward 
> compatibility with the old API)... see NSConcretePointerFunctions.[hm] for 
> the new functions  and the CallBacks files for the old ones.
> 
> If you look at the actual hash/map table code (eg NSConcreteHashTable.m) you 
> will see the defines which tell GSIMAP which versions to use.
> eg.
> #define GSI_MAP_RETAIN_KEY(M, X)\
> (M->legacy ? M->cb.old.retain(M, X.ptr) \
> : pointerFunctionsAcquire(&M->cb.pf, &X.ptr, X.ptr))

I am not sure this helps.  The GSIMap code seems to do things like:

GSI_MAP_RETAIN_KEY(map, node->key)
node->key = key;

This is actually wrong in retain / release mode (-retain is not guaranteed to 
return self), but in GC mode, these two lines need to somehow become:

objc_assign_strongCast(key, &(node->key));

there also doesn't seem to be any macro for reading the keys.  For example, 
when ever you read node->key or node->value as a weak pointer, lines like:

GSI_MAP_EQUAL(map, node->key, key)

Need to be expanded to something like:

[objc_read_weak(&(node->key) isEqual: key]

David

-- Sent from my STANTEC-ZEBRA


reply via email to

[Prev in Thread] Current Thread [Next in Thread]