gnustep-dev
[Top][All Lists]
Advanced

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

Re: CoreBase toll-free bridging


From: Luboš Doležel
Subject: Re: CoreBase toll-free bridging
Date: Mon, 11 Mar 2013 09:39:56 +0100
User-agent: Roundcube Webmail/0.5

On Mon, 11 Mar 2013 08:13:45 +0000, David Chisnall wrote:
I'd certainly be interested in improving the NSString structure.  I
put out a request for this a while ago, but got no feedback.

Great, so let's do it now :-)

There are a few problems, the most significant is that GNUstep
periodically does isa comparisons to determine if something is a
constant string.  Check the code for comparisons against
NXConstantStringClass.  These would need fixing, and we'd also have a
transition period where we had two constant string classes.

Sure. This is what CFString's struct looks like now (I replaced internal types with what everyone understands):

stuct __CFString
{
    void* isa; // for ObjC support
int16_t typeID; // CF type ID - we need to make CFString's typeID constant forever (now it could randomly change)
    struct
    {
        int16_t ro:1; // always set to 1 for constant strings
        int16_t reserved:7;
int16_t info:8; // probably only "hasnull" (0x10) for constant strings
    };
    void* data;
    uint32_t length;
    uintptr_t hashCode;
};

Is this layout something you'd accept as the next constant NSString?

Note that, to support CF code in GNUstep, clang exposes a builtin
function in C code for creating constant string objects.


Which one exactly? CFSTR() in corebase expands to a regular function call.

Adding a hash field to NSConstantString is something I would
definitely support.  For efficiency, there is a load of stuff in
GNUstep that replaces NSConstantString instances with GSString
instances at load time because caching the hash significantly improves
performance when the hashes are stored in collections.

We don't have to make the hash computation part of the ABI, we can
simply reserve a flag to indicate 'hash calculated.'  The hash method
would then check this flag and return the hash field if it is set, or
compute it if it isn't.

Fine! So I guess we would kill two birds with one stone - remove some speed hacks and make it bridging-ready.

--
Luboš Doležel



reply via email to

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