From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8146 invoked by alias); 9 Oct 2010 10:39:45 -0000 Received: (qmail 8137 invoked by uid 22791); 9 Oct 2010 10:39:45 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,HS_INDEX_PARAM,TW_BJ,TW_SV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Oct 2010 10:39:40 +0000 From: "nicola at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libobjc/45953] New: Registering untyped selector mutates existing selector X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libobjc X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: nicola at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 09 Oct 2010 10:39:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg00780.txt.bz2 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 @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