public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libobjc/45953] New: Registering untyped selector mutates existing selector
@ 2010-10-09 10:39 nicola at gcc dot gnu.org
  2010-12-19 18:35 ` [Bug libobjc/45953] " nicola at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2010-10-09 10:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45953

           Summary: Registering untyped selector mutates existing selector
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libobjc
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nicola@gcc.gnu.org


Created attachment 22005
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22005
Patch to improve the efficiency of registering selectors with the same name

This bug originates from GNUstep,

https://savannah.gnu.org/bugs/?25869

It is a small inefficiency in the runtime.  Here is the original report from
Truls Becken.  I also attach his patch.

-------------------------------------

A test case is shown below, where four -test messages all use the same typed
selector. An interleaved -valueForKey: message registers an untyped selector
with the same name. At that moment, the typed selector is modified to use the
same string pointer as the new untyped selector.

One would think that this should be the other way around. The newer selector
should use the same string as the existing one, not modify one that is already
registered.

This is using libobjc from the GNUstep Subversion repository at r28049. GNUstep
Base is from the same svn revision.

$ cat GNUmakefile
include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = test

${TOOL_NAME}_OBJC_FILES = main.m

include $(GNUSTEP_MAKEFILES)/tool.make

$ cat main.m
#import <Foundation/Foundation.h>

@interface Foo : NSObject {}
- (void) test;
@end

@implementation Foo
- (void) test
{
NSLog(@"%d %d %s %s", _cmd, sel_get_name(_cmd),
sel_get_name(_cmd), sel_get_type(_cmd));
}
@end

int main (int argc, const char **argv)
{
[NSAutoreleasePool new];

id foo = [Foo new];

[foo test];
[foo test];
[foo valueForKey: @"test"];
[foo test];
[foo test];

return 0;
}

$ make
This is gnustep-make 2.0.8. Type 'make print-gnustep-make-help' for help.
Making all for tool test...
Compiling file main.m ...
Linking tool test ...

$ obj/test
2009-03-14 22:22:10.401 test[23586] 134520200 134519897 test v8@0:4
2009-03-14 22:22:10.406 test[23586] 134520200 134519897 test v8@0:4
2009-03-14 22:22:10.410 test[23586] 144773752 145449736 test (null)
2009-03-14 22:22:10.413 test[23586] 134520200 145449736 test v8@0:4
2009-03-14 22:22:10.416 test[23586] 134520200 145449736 test v8@0:4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libobjc/45953] Registering untyped selector mutates existing selector
  2010-10-09 10:39 [Bug libobjc/45953] New: Registering untyped selector mutates existing selector nicola at gcc dot gnu.org
@ 2010-12-19 18:35 ` nicola at gcc dot gnu.org
  2010-12-21 13:44 ` nicola at gcc dot gnu.org
  2010-12-21 13:47 ` nicola at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2010-12-19 18:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45953

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.12.19 18:35:08
     Ever Confirmed|0                           |1

--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2010-12-19 18:35:08 UTC ---
Yes, it's confirmed.

Thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libobjc/45953] Registering untyped selector mutates existing selector
  2010-10-09 10:39 [Bug libobjc/45953] New: Registering untyped selector mutates existing selector nicola at gcc dot gnu.org
  2010-12-19 18:35 ` [Bug libobjc/45953] " nicola at gcc dot gnu.org
@ 2010-12-21 13:44 ` nicola at gcc dot gnu.org
  2010-12-21 13:47 ` nicola at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2010-12-21 13:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45953

--- Comment #2 from Nicola Pero <nicola at gcc dot gnu.org> 2010-12-21 13:44:09 UTC ---
Author: nicola
Date: Tue Dec 21 13:44:04 2010
New Revision: 168115

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168115
Log:
In libobjc/:
2010-12-21  Nicola Pero  <nicola.pero@meta-innovation.com>

    PR libobjc/45953
    * selector.c (__sel_register_typed_name): When registering a new
    selector with the same name as an existing one, reuse the existing
    name string.  Also updated types, casts and comments in the whole
    function.

In gcc/testsuite/:
2010-12-21  Nicola Pero  <nicola.pero@meta-innovation.com>

    PR libobjc/45953
    * objc.dg/libobjc-selector-1.m: New test.


Added:
    trunk/gcc/testsuite/objc.dg/libobjc-selector-1.m
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libobjc/ChangeLog
    trunk/libobjc/selector.c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libobjc/45953] Registering untyped selector mutates existing selector
  2010-10-09 10:39 [Bug libobjc/45953] New: Registering untyped selector mutates existing selector nicola at gcc dot gnu.org
  2010-12-19 18:35 ` [Bug libobjc/45953] " nicola at gcc dot gnu.org
  2010-12-21 13:44 ` nicola at gcc dot gnu.org
@ 2010-12-21 13:47 ` nicola at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2010-12-21 13:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45953

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.6.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0

--- Comment #3 from Nicola Pero <nicola at gcc dot gnu.org> 2010-12-21 13:47:23 UTC ---
Fixed in trunk, with testcase.

Thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-21 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-09 10:39 [Bug libobjc/45953] New: Registering untyped selector mutates existing selector nicola at gcc dot gnu.org
2010-12-19 18:35 ` [Bug libobjc/45953] " nicola at gcc dot gnu.org
2010-12-21 13:44 ` nicola at gcc dot gnu.org
2010-12-21 13:47 ` nicola at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).