[cfe-dev] Objective-C: methods, ivars, and cleanup
Devang Patel
dpatel at apple.com
Wed Mar 26 10:19:12 PDT 2008
On Mar 26, 2008, at 10:15 AM, David Chisnall wrote:
>
> On 26 Mar 2008, at 16:40, Devang Patel wrote:
>
>>
>> On Mar 26, 2008, at 8:09 AM, David Chisnall wrote:
>>
>>>> In this method you do a field lookup by iterating over all ObjectTy
>>>> ivars. Would not it be more efficient to keep a map just like
>>>> normal C
>>>> struct fields ?
>>>
>>> You'd need to generate the map at some point, possibly the first
>>> time it's called?
>>
>> The map is collected for C structure while determining its layout
>> (in ConvertType()).
>>
>>> Since it works as-is, I'd rather do this later if profiling
>>> indicates this is a bottleneck.
>>
>> A class is defined once but its fields are referenced multiple
>> times, so it makes sense to avoid lookups during field access.
>> That's what we do for C structures. Let's not diverge here.
>
> I have added a map from decls to field numbers which is filled in
> when the LLVM type of the object is generated. This isn't quite
> ideal, since subclasses have the same ivars at the same locations
> and this is not taken into account, but is simpler (and might be
> faster) than calculating the offset every lookup.
>
>>> + assert(!verifyFunction(*CurFn));
>>
>> nit-pick, add a message here.
>
> That code was copied-and-pasted from the GenerateCode method used
> for generating functions. For completeness I've added a message in
> to where I originally copied it from as well.
Great!. I'll apply this later today (or go ahead if you've commit
access).
-
Devang
More information about the cfe-dev
mailing list