Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

objc4-222, released with OS X v10.2

  • Loading branch information...
commit 8f8c63d46b86c0f449d04aeec1004c5bca58cea4 1 parent 68b8b3c
@bavarious authored
Showing with 2,030 additions and 1,700 deletions.
  1. +372 −0 APPLE_LICENSE
  2. +406 −26 Makefile
  3. 0  Makefile.postamble
  4. +0 −5 Makefile.preamble
  5. +0 −24 PB.project
  6. +144 −0 objc-exports
  7. +0 −65 runtime/Makefile
  8. +0 −27 runtime/Makefile.postamble
  9. +0 −31 runtime/Makefile.preamble
  10. +0 −47 runtime/Messengers.subproj/Makefile
  11. +0 −100 runtime/Messengers.subproj/Makefile.postamble
  12. +0 −123 runtime/Messengers.subproj/Makefile.preamble
  13. +0 −31 runtime/Messengers.subproj/PB.project
  14. +125 −167 runtime/Messengers.subproj/objc-msg-i386.s
  15. +178 −278 runtime/Messengers.subproj/objc-msg-ppc.s
  16. +0 −2  runtime/Object.h
  17. +0 −9 runtime/Object.m
  18. +1 −1  runtime/OldClasses.subproj/List.h
  19. +0 −49 runtime/OldClasses.subproj/Makefile
  20. +0 −7 runtime/OldClasses.subproj/Makefile.preamble
  21. +0 −27 runtime/OldClasses.subproj/PB.project
  22. +0 −68 runtime/PB.project
  23. +2 −2 runtime/error.h
  24. +2 −2 runtime/hashtable2.h
  25. +0 −4 runtime/hashtable2.m
  26. +4 −0 runtime/objc-api.h
  27. +66 −16 runtime/objc-class.h
  28. +634 −469 runtime/objc-class.m
  29. +1 −16 runtime/objc-config.h
  30. +3 −3 runtime/objc-errors.m
  31. +33 −42 runtime/objc-private.h
  32. +0 −12 runtime/objc-runtime.h
  33. +57 −45 runtime/objc-runtime.m
  34. +2 −2 runtime/objc-sel.m
View
372 APPLE_LICENSE
@@ -0,0 +1,372 @@
+APPLE PUBLIC SOURCE LICENSE
+Version 1.1 - April 19,1999
+
+Please read this License carefully before downloading this software.
+By downloading and using this software, you are agreeing to be bound
+by the terms of this License. If you do not or cannot agree to the
+terms of this License, please do not download or use the software.
+
+1. General; Definitions. This License applies to any program or other
+work which Apple Computer, Inc. ("Apple") publicly announces as
+subject to this Apple Public Source License and which contains a
+notice placed by Apple identifying such program or work as "Original
+Code" and stating that it is subject to the terms of this Apple Public
+Source License version 1.1 (or subsequent version thereof), as it may
+be revised from time to time by Apple ("License"). As used in this
+License:
+
+1.1 "Affected Original Code" means only those specific portions of
+Original Code that allegedly infringe upon any party's intellectual
+property rights or are otherwise the subject of a claim of
+infringement.
+
+1.2 "Applicable Patent Rights" mean: (a) in the case where Apple is
+the grantor of rights, (i) claims of patents that are now or hereafter
+acquired, owned by or assigned to Apple and (ii) that cover subject
+matter contained in the Original Code, but only to the extent
+necessary to use, reproduce and/or distribute the Original Code
+without infringement; and (b) in the case where You are the grantor of
+rights, (i) claims of patents that are now or hereafter acquired,
+owned by or assigned to You and (ii) that cover subject matter in Your
+Modifications, taken alone or in combination with Original Code.
+
+1.3 "Covered Code" means the Original Code, Modifications, the
+combination of Original Code and any Modifications, and/or any
+respective portions thereof.
+
+1.4 "Deploy" means to use, sublicense or distribute Covered Code other
+than for Your internal research and development (R&D), and includes
+without limitation, any and all internal use or distribution of
+Covered Code within Your business or organization except for R&D use,
+as well as direct or indirect sublicensing or distribution of Covered
+Code by You to any third party in any form or manner.
+
+1.5 "Larger Work" means a work which combines Covered Code or portions
+thereof with code not governed by the terms of this License.
+
+1.6 "Modifications" mean any addition to, deletion from, and/or change
+to, the substance and/or structure of Covered Code. When code is
+released as a series of files, a Modification is: (a) any addition to
+or deletion from the contents of a file containing Covered Code;
+and/or (b) any new file or other representation of computer program
+statements that contains any part of Covered Code.
+
+1.7 "Original Code" means (a) the Source Code of a program or other
+work as originally made available by Apple under this License,
+including the Source Code of any updates or upgrades to such programs
+or works made available by Apple under this License, and that has been
+expressly identified by Apple as such in the header file(s) of such
+work; and (b) the object code compiled from such Source Code and
+originally made available by Apple under this License.
+
+1.8 "Source Code" means the human readable form of a program or other
+work that is suitable for making modifications to it, including all
+modules it contains, plus any associated interface definition files,
+scripts used to control compilation and installation of an executable
+(object code).
+
+1.9 "You" or "Your" means an individual or a legal entity exercising
+rights under this License. For legal entities, "You" or "Your"
+includes any entity which controls, is controlled by, or is under
+common control with, You, where "control" means (a) the power, direct
+or indirect, to cause the direction or management of such entity,
+whether by contract or otherwise, or (b) ownership of fifty percent
+(50%) or more of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Permitted Uses; Conditions & Restrictions. Subject to the terms
+and conditions of this License, Apple hereby grants You, effective on
+the date You accept this License and download the Original Code, a
+world-wide, royalty-free, non- exclusive license, to the extent of
+Apple's Applicable Patent Rights and copyrights covering the Original
+Code, to do the following:
+
+2.1 You may use, copy, modify and distribute Original Code, with or
+without Modifications, solely for Your internal research and
+development, provided that You must in each instance:
+
+(a) retain and reproduce in all copies of Original Code the copyright
+and other proprietary notices and disclaimers of Apple as they appear
+in the Original Code, and keep intact all notices in the Original Code
+that refer to this License;
+
+(b) include a copy of this License with every copy of Source Code of
+Covered Code and documentation You distribute, and You may not offer
+or impose any terms on such Source Code that alter or restrict this
+License or the recipients' rights hereunder, except as permitted under
+Section 6; and
+
+(c) completely and accurately document all Modifications that you have
+made and the date of each such Modification, designate the version of
+the Original Code you used, prominently include a file carrying such
+information with the Modifications, and duplicate the notice in
+Exhibit A in each file of the Source Code of all such Modifications.
+
+2.2 You may Deploy Covered Code, provided that You must in each
+ instance:
+
+(a) satisfy all the conditions of Section 2.1 with respect to the
+Source Code of the Covered Code;
+
+(b) make all Your Deployed Modifications publicly available in Source
+Code form via electronic distribution (e.g. download from a web site)
+under the terms of this License and subject to the license grants set
+forth in Section 3 below, and any additional terms You may choose to
+offer under Section 6. You must continue to make the Source Code of
+Your Deployed Modifications available for as long as you Deploy the
+Covered Code or twelve (12) months from the date of initial
+Deployment, whichever is longer;
+
+(c) if You Deploy Covered Code containing Modifications made by You,
+inform others of how to obtain those Modifications by filling out and
+submitting the information found at
+http://www.apple.com/publicsource/modifications.html, if available;
+and
+
+(d) if You Deploy Covered Code in object code, executable form only,
+include a prominent notice, in the code itself as well as in related
+documentation, stating that Source Code of the Covered Code is
+available under the terms of this License with information on how and
+where to obtain such Source Code.
+
+3. Your Grants. In consideration of, and as a condition to, the
+licenses granted to You under this License:
+
+(a) You hereby grant to Apple and all third parties a non-exclusive,
+royalty-free license, under Your Applicable Patent Rights and other
+intellectual property rights owned or controlled by You, to use,
+reproduce, modify, distribute and Deploy Your Modifications of the
+same scope and extent as Apple's licenses under Sections 2.1 and 2.2;
+and
+
+(b) You hereby grant to Apple and its subsidiaries a non-exclusive,
+worldwide, royalty-free, perpetual and irrevocable license, under Your
+Applicable Patent Rights and other intellectual property rights owned
+or controlled by You, to use, reproduce, execute, compile, display,
+perform, modify or have modified (for Apple and/or its subsidiaries),
+sublicense and distribute Your Modifications, in any form, through
+multiple tiers of distribution.
+
+4. Larger Works. You may create a Larger Work by combining Covered
+Code with other code not governed by the terms of this License and
+distribute the Larger Work as a single product. In each such
+instance, You must make sure the requirements of this License are
+fulfilled for the Covered Code or any portion thereof.
+
+5. Limitations on Patent License. Except as expressly stated in
+Section 2, no other patent rights, express or implied, are granted by
+Apple herein. Modifications and/or Larger Works may require
+additional patent licenses from Apple which Apple may grant in its
+sole discretion.
+
+6. Additional Terms. You may choose to offer, and to charge a fee
+for, warranty, support, indemnity or liability obligations and/or
+other rights consistent with the scope of the license granted herein
+("Additional Terms") to one or more recipients of Covered
+Code. However, You may do so only on Your own behalf and as Your sole
+responsibility, and not on behalf of Apple. You must obtain the
+recipient's agreement that any such Additional Terms are offered by
+You alone, and You hereby agree to indemnify, defend and hold Apple
+harmless for any liability incurred by or claims asserted against
+Apple by reason of any such Additional Terms.
+
+7. Versions of the License. Apple may publish revised and/or new
+versions of this License from time to time. Each version will be
+given a distinguishing version number. Once Original Code has been
+published under a particular version of this License, You may continue
+to use it under the terms of that version. You may also choose to use
+such Original Code under the terms of any subsequent version of this
+License published by Apple. No one other than Apple has the right to
+modify the terms applicable to Covered Code created under this
+License.
+
+8. NO WARRANTY OR SUPPORT. The Original Code may contain in whole or
+in part pre-release, untested, or not fully tested works. The
+Original Code may contain errors that could cause failures or loss of
+data, and may be incomplete or contain inaccuracies. You expressly
+acknowledge and agree that use of the Original Code, or any portion
+thereof, is at Your sole and entire risk. THE ORIGINAL CODE IS
+PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND
+AND APPLE AND APPLE'S LICENSOR(S) (FOR THE PURPOSES OF SECTIONS 8 AND
+9, APPLE AND APPLE'S LICENSOR(S) ARE COLLECTIVELY REFERRED TO AS
+"APPLE") EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR CONDITIONS, EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+AND/OR CONDITIONS OF MERCHANTABILITY OR SATISFACTORY QUALITY AND
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+RIGHTS. APPLE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE
+ORIGINAL CODE WILL MEET YOUR REQUIREMENTS, OR THAT THE OPERATION OF
+THE ORIGINAL CODE WILL BE UNINTERRUPTED OR ERROR- FREE, OR THAT
+DEFECTS IN THE ORIGINAL CODE WILL BE CORRECTED. NO ORAL OR WRITTEN
+INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED
+REPRESENTATIVE SHALL CREATE A WARRANTY OR IN ANY WAY INCREASE THE
+SCOPE OF THIS WARRANTY. You acknowledge that the Original Code is not
+intended for use in the operation of nuclear facilities, aircraft
+navigation, communication systems, or air traffic control machines in
+which case the failure of the Original Code could lead to death,
+personal injury, or severe physical or environmental damage.
+
+9. Liability.
+
+9.1 Infringement. If any portion of, or functionality implemented by,
+the Original Code becomes the subject of a claim of infringement,
+Apple may, at its option: (a) attempt to procure the rights necessary
+for Apple and You to continue using the Affected Original Code; (b)
+modify the Affected Original Code so that it is no longer infringing;
+or (c) suspend Your rights to use, reproduce, modify, sublicense and
+distribute the Affected Original Code until a final determination of
+the claim is made by a court or governmental administrative agency of
+competent jurisdiction and Apple lifts the suspension as set forth
+below. Such suspension of rights will be effective immediately upon
+Apple's posting of a notice to such effect on the Apple web site that
+is used for implementation of this License. Upon such final
+determination being made, if Apple is legally able, without the
+payment of a fee or royalty, to resume use, reproduction,
+modification, sublicensing and distribution of the Affected Original
+Code, Apple will lift the suspension of rights to the Affected
+Original Code by posting a notice to such effect on the Apple web site
+that is used for implementation of this License. If Apple suspends
+Your rights to Affected Original Code, nothing in this License shall
+be construed to restrict You, at Your option and subject to applicable
+law, from replacing the Affected Original Code with non-infringing
+code or independently negotiating for necessary rights from such third
+party.
+
+9.2 LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES SHALL APPLE BE
+LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF OR RELATING TO THIS LICENSE OR YOUR USE OR INABILITY TO
+USE THE ORIGINAL CODE, OR ANY PORTION THEREOF, WHETHER UNDER A THEORY
+OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY
+OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF
+ANY REMEDY. In no event shall Apple's total liability to You for all
+damages under this License exceed the amount of fifty dollars
+($50.00).
+
+10. Trademarks. This License does not grant any rights to use the
+trademarks or trade names "Apple", "Apple Computer", "Mac OS X", "Mac
+OS X Server" or any other trademarks or trade names belonging to Apple
+(collectively "Apple Marks") and no Apple Marks may be used to endorse
+or promote products derived from the Original Code other than as
+permitted by and in strict compliance at all times with Apple's third
+party trademark usage guidelines which are posted at
+http://www.apple.com/legal/guidelinesfor3rdparties.html.
+
+11. Ownership. Apple retains all rights, title and interest in and to
+the Original Code and any Modifications made by or on behalf of Apple
+("Apple Modifications"), and such Apple Modifications will not be
+automatically subject to this License. Apple may, at its sole
+discretion, choose to license such Apple Modifications under this
+License, or on different terms from those contained in this License or
+may choose not to license them at all. Apple's development, use,
+reproduction, modification, sublicensing and distribution of Covered
+Code will not be subject to this License.
+
+12. Termination.
+
+12.1 Termination. This License and the rights granted hereunder will
+ terminate:
+
+(a) automatically without notice from Apple if You fail to comply with
+any term(s) of this License and fail to cure such breach within 30
+days of becoming aware of such breach; (b) immediately in the event of
+the circumstances described in Section 13.5(b); or (c) automatically
+without notice from Apple if You, at any time during the term of this
+License, commence an action for patent infringement against Apple.
+
+12.2 Effect of Termination. Upon termination, You agree to
+immediately stop any further use, reproduction, modification,
+sublicensing and distribution of the Covered Code and to destroy all
+copies of the Covered Code that are in your possession or control.
+All sublicenses to the Covered Code which have been properly granted
+prior to termination shall survive any termination of this License.
+Provisions which, by their nature, should remain in effect beyond the
+termination of this License shall survive, including but not limited
+to Sections 3, 5, 8, 9, 10, 11, 12.2 and 13. Neither party will be
+liable to the other for compensation, indemnity or damages of any sort
+solely as a result of terminating this License in accordance with its
+terms, and termination of this License will be without prejudice to
+any other right or remedy of either party.
+
+13. Miscellaneous.
+
+13.1 Government End Users. The Covered Code is a "commercial item" as
+defined in FAR 2.101. Government software and technical data rights
+in the Covered Code include only those rights customarily provided to
+the public as defined in this License. This customary commercial
+license in technical data and software is provided in accordance with
+FAR 12.211 (Technical Data) and 12.212 (Computer Software) and, for
+Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
+Commercial Items) and 227.7202-3 (Rights in Commercial Computer
+Software or Computer Software Documentation). Accordingly, all U.S.
+Government End Users acquire Covered Code with only those rights set
+forth herein.
+
+13.2 Relationship of Parties. This License will not be construed as
+creating an agency, partnership, joint venture or any other form of
+legal association between You and Apple, and You will not represent to
+the contrary, whether expressly, by implication, appearance or
+otherwise.
+
+13.3 Independent Development. Nothing in this License will impair
+Apple's right to acquire, license, develop, have others develop for
+it, market and/or distribute technology or products that perform the
+same or similar functions as, or otherwise compete with,
+Modifications, Larger Works, technology or products that You may
+develop, produce, market or distribute.
+
+13.4 Waiver; Construction. Failure by Apple to enforce any provision
+of this License will not be deemed a waiver of future enforcement of
+that or any other provision. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+will not apply to this License.
+
+13.5 Severability. (a) If for any reason a court of competent
+jurisdiction finds any provision of this License, or portion thereof,
+to be unenforceable, that provision of the License will be enforced to
+the maximum extent permissible so as to effect the economic benefits
+and intent of the parties, and the remainder of this License will
+continue in full force and effect. (b) Notwithstanding the foregoing,
+if applicable law prohibits or restricts You from fully and/or
+specifically complying with Sections 2 and/or 3 or prevents the
+enforceability of either of those Sections, this License will
+immediately terminate and You must immediately discontinue any use of
+the Covered Code and destroy all copies of it that are in your
+possession or control.
+
+13.6 Dispute Resolution. Any litigation or other dispute resolution
+between You and Apple relating to this License shall take place in the
+Northern District of California, and You and Apple hereby consent to
+the personal jurisdiction of, and venue in, the state and federal
+courts within that District with respect to this License. The
+application of the United Nations Convention on Contracts for the
+International Sale of Goods is expressly excluded.
+
+13.7 Entire Agreement; Governing Law. This License constitutes the
+entire agreement between the parties with respect to the subject
+matter hereof. This License shall be governed by the laws of the
+United States and the State of California, except that body of
+California law concerning conflicts of law.
+
+Where You are located in the province of Quebec, Canada, the following
+clause applies: The parties hereby confirm that they have requested
+that this License and all related documents be drafted in English. Les
+parties ont exige que le present contrat et tous les documents
+connexes soient rediges en anglais.
+
+EXHIBIT A.
+
+"Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
+Reserved. This file contains Original Code and/or Modifications of
+Original Code as defined in and that are subject to the Apple Public
+Source License Version 1.1 (the "License"). You may not use this file
+except in compliance with the License. Please obtain a copy of the
+License at http://www.apple.com/publicsource and read it before using
+this file.
+
+The Original Code and all software distributed under the License are
+distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
+License for the specific language governing rights and limitations
+under the License."
View
432 Makefile
@@ -1,44 +1,424 @@
+# use LDFLAGS not LFLAGS
+# seg-addr-table, sect-order
#
-# Generated by the Apple Project Builder.
+# Simple makefile for building objc4 on Darwin
#
-# NOTE: Do NOT change this file -- Project Builder maintains it.
+# These make variables (or environment variables) are used
+# if defined:
+# SRCROOT path location of root of source hierarchy;
+# defaults to ".", but must be set to a
+# destination path for installsrc target.
+# OBJROOT path location where .o files will be put;
+# defaults to SRCROOT.
+# SYMROOT path location where build products will be
+# put; defaults to SRCROOT.
+# DSTROOT path location where installed products will
+# be put; defaults to / .
+# OBJROOT and SYMROOT should not be directories shared with other
+# built projects.
+# PLATFORM name of platform being built on
+# USER name of user building the project
+# ARCHS list of archs for which to build
+# RC_ARCHS more archs for which to build (build system)
+# OTHER_CFLAGS other flags to be passed to compiler
+# RC_CFLAGS more flags to be passed to compiler (build system)
+# OTHER_LDFLAGS other flags to be passed to the link stage
#
-# Put all of your customizations in files called Makefile.preamble
-# and Makefile.postamble (both optional), and Makefile will include them.
+
+# Default targets
+default: build
+all: build
+
+.SUFFIXES:
+.PHONY: default all build optimized debug profile installsrc installhdrs install clean prebuild build-optimized build-debug build-profile prebuild-optimized prevuild-debug prebuild-profile compile-optimized compile-debug compile-profile link-optimized link-debug link-profile postbuild
+
+CURRENT_PROJECT_VERSION = 218
+
+VERSION_NAME = A
+
+# First figure out the platform if not specified, so we can use it in the
+# rest of this file. Currently defined values: Darwin
+ifeq "$(PLATFORM)" ""
+PLATFORM := $(shell uname)
+endif
+
+ifndef SRCROOT
+SRCROOT = .
+endif
+
+ifndef OBJROOT
+OBJROOT = $(SRCROOT)
+endif
+
+ifndef SYMROOT
+SYMROOT = $(SRCROOT)
+endif
+
+ifndef DSTROOT
+DSTROOT = /
+endif
+
+ifeq "$(PLATFORM)" "Darwin"
+CC = /usr/bin/cc
+else
+CC = /usr/bin/gcc
+endif
+
+ECHO = @/bin/echo
+MKDIRS = /bin/mkdir -p
+CD = cd
+COPY = /bin/cp
+COPY_RECUR = /bin/cp -r
+REMOVE = /bin/rm
+REMOVE_RECUR = /bin/rm -rf
+SYMLINK = /bin/ln -s
+CHMOD = /bin/chmod
+CHOWN = /usr/sbin/chown
+TAR = /usr/bin/tar
+STRIP = /usr/bin/strip
+NMEDIT = /usr/bin/nmedit
+
+ifeq "$(PLATFORM)" "Darwin"
+WARNING_FLAGS = -Wmost -Wno-precomp -Wno-four-char-constants
+endif
+
+ARCH_LIST=
+ifeq "$(PLATFORM)" "Darwin"
+
+ifneq "$(ARCHS)" ""
+ARCH_LIST += $(ARCHS)
+else
+ifneq "$(RC_ARCHS)" ""
+ARCH_LIST += $(RC_ARCHS)
+else
+ARCH_LIST += ppc
+endif
+endif
+
+ARCH_FLAGS = $(foreach A, $(ARCH_LIST), $(addprefix -arch , $(A)))
+
+endif
+
+
+
+ifeq "$(USER)" ""
+USER = unknown
+endif
+
+CFLAGS = -g -fno-common -pipe $(PLATFORM_CFLAGS) $(WARNING_FLAGS) -I$(SYMROOT) -I. -I$(SYMROOT)/ProjectHeaders
+LDFLAGS = -framework CoreFoundation
+
+LIBRARY_EXT = .dylib
+
+PUBLIC_HEADER_INSTALLDIR = usr/include/objc
+OTHER_HEADER_INSTALLDIR = usr/local/include/objc
+INSTALLDIR = usr/lib
+
+ifeq "$(PLATFORM)" "Darwin"
+CFLAGS += $(ARCH_FLAGS)
+LDFLAGS += $(ARCH_FLAGS) -dynamiclib -dynamic -compatibility_version 1 -current_version $(CURRENT_PROJECT_VERSION)
+endif
+
+CFLAGS += $(OTHER_CFLAGS) $(RC_CFLAGS)
+LDFLAGS += $(OTHER_LDFLAGS)
+
+ifndef OPTIMIZATION_CFLAGS
+OPTIMIZATION_CFLAGS = -Os
+endif
+ifndef DEBUG_CFLAGS
+DEBUG_CFLAGS = -DDEBUG
+endif
+ifndef PROFILE_CFLAGS
+PROFILE_CFLAGS = -DPROFILE -pg -Os
+endif
+
+CFLAGS_OPTIMIZED = $(CFLAGS) $(OPTIMIZATION_CFLAGS)
+CFLAGS_DEBUG = $(CFLAGS) $(DEBUG_CFLAGS)
+CFLAGS_PROFILE = $(CFLAGS) $(PROFILE_CFLAGS)
+
+LDFLAGS_OPTIMIZED = $(LDFLAGS)
+LDFLAGS_DEBUG = $(LDFLAGS) -g
+LDFLAGS_PROFILE = $(LDFLAGS) -g -pg
+
+SUBDIRS = . runtime runtime/OldClasses.subproj runtime/Messengers.subproj
+
+# files to compile
+SOURCES=
+# files to not compile
+OTHER_SOURCES=
+# headers to install in /usr/include/objc
+PUBLIC_HEADERS=
+# headers that don't get installed
+PRIVATE_HEADERS=
+# headers to install in /usr/local/include/objc
+OTHER_HEADERS=
+
+# runtime
+SOURCES += $(addprefix runtime/, \
+ Object.m Protocol.m hashtable2.m maptable.m objc-class.m objc-errors.m \
+ objc-file.m objc-load.m objc-moninit.c objc-runtime.m objc-sel.m \
+ )
+PUBLIC_HEADERS += $(addprefix runtime/, \
+ objc-class.h objc-api.h objc-load.h objc-runtime.h objc.h Object.h \
+ Protocol.h error.h hashtable2.h \
+ )
+PRIVATE_HEADERS += runtime/objc-private.h runtime/objc-config.h
+OTHER_HEADERS += runtime/maptable.h
+
+# OldClasses
+SOURCES += runtime/OldClasses.subproj/List.m
+PUBLIC_HEADERS += runtime/OldClasses.subproj/List.h
+
+# Messengers
+SOURCES += runtime/Messengers.subproj/objc-msg.s
+OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-ppc.s runtime/Messengers.subproj/objc-msg-i386.s
+
+# project root
+OTHER_SOURCES += Makefile APPLE_LICENSE objc-exports
+
+OBJECTS = $(addprefix $(OBJROOT)/, $(addsuffix .o, $(basename $(SOURCES) ) ) )
+OBJECTS_OPTIMIZED = $(OBJECTS:.o=.opt.o)
+OBJECTS_DEBUG = $(OBJECTS:.o=.debug.o)
+OBJECTS_PROFILE = $(OBJECTS:.o=.profile.o)
+
+# For simplicity, each object target depends on all objc headers. Most of
+# them come close to requiring this anyway, and rebuild from scratch is fast.
+DEPEND_HEADERS = $(addprefix $(SRCROOT)/, \
+ $(PUBLIC_HEADERS) $(PRIVATE_HEADERS) $(OTHER_HEADERS) )
+
+$(OBJROOT)/%.opt.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+
+$(OBJROOT)/%.debug.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+
+$(OBJROOT)/%.profile.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+
+$(OBJROOT)/%.opt.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+
+$(OBJROOT)/%.debug.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+
+$(OBJROOT)/%.profile.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+
+$(OBJROOT)/%.opt.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+
+$(OBJROOT)/%.debug.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+
+$(OBJROOT)/%.profile.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
+ $(SILENT) $(ECHO) " ... $<"
+ $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+
+# Additional dependency: objc-msg.s depends on objc-msg-ppc.s and
+# objc-msg-i386.s, which it includes.
+$(OBJROOT)/runtime/Messengers.subproj/objc-msg.opt.o \
+$(OBJROOT)/runtime/Messengers.subproj/objc-msg.debug.o \
+$(OBJROOT)/runtime/Messengers.subproj/objc-msg.profile.o : \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-ppc.s \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-i386.s
+
+
+# These are the main targets:
+# build builds the library to OBJROOT and SYMROOT
+# installsrc copies the sources to SRCROOT
+# installhdrs install only the headers to DSTROOT
+# install build, then install the headers and library to DSTROOT
+# clean removes build products in OBJROOT and SYMROOT
#
+# optimized same as 'build' but builds optimized library only
+# debug same as 'build' but builds debug library only
+# profile same as 'build' but builds profile library only
+
+# Default build doesn't currently build the debug library.
+build: prebuild build-optimized build-profile postbuild
+
+optimized: prebuild build-optimized postbuild
+debug: prebuild build-debug postbuild
+profile: prebuild build-profile postbuild
+
+installsrc:
+ $(SILENT) $(ECHO) "Installing source from . to $(SRCROOT)..."
+ifeq "$(SRCROOT)" "."
+ $(SILENT) $(ECHO) "SRCROOT must be defined to be the destination directory; it cannot be '.'"
+ exit 1
+endif
+ $(SILENT) $(TAR) -cf $(SRCROOT)/objc4.sources.tar $(SOURCES) $(PUBLIC_HEADERS) $(PRIVATE_HEADERS) $(OTHER_HEADERS) $(OTHER_SOURCES)
+ $(SILENT) $(CD) $(SRCROOT) && $(TAR) -xf $(SRCROOT)/objc4.sources.tar
+ $(SILENT) $(REMOVE) -f $(SRCROOT)/objc4.sources.tar
+
+installhdrs:
+ $(SILENT) $(ECHO) "Installing headers from $(SRCROOT) to $(DSTROOT)/$(HEADER_INSTALLDIR)..."
+
+ $(SILENT) $(MKDIRS) $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)
+ -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
+ $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PUBLIC_HEADERS) ) \
+ $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)
+# duplicate hashtable2.h to hashtable.h
+ $(SILENT) $(COPY) $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/hashtable2.h \
+ $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/hashtable.h
+ $(SILENT) $(CHMOD) -w $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
+ $(SILENT) $(CHMOD) a+r $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
+
+ $(SILENT) $(MKDIRS) $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)
+ -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
+ $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(OTHER_HEADERS) ) \
+ $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)
+ $(SILENT) $(CHMOD) -w $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
+ $(SILENT) $(CHMOD) a+r $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
+
+
+ $(SILENT) $(RM) -f $(DSTROOT)$(PUBLIC_HEADER_DIR)$(PUBLIC_HEADER_DIR_SUFFIX)/hashtable.h
+
+
+install: build installhdrs
+ $(SILENT) $(ECHO) "Installing products from $(SYMROOT) to $(DSTROOT)..."
+
+ $(SILENT) $(MKDIRS) $(DSTROOT)/$(INSTALLDIR)
+ -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(INSTALLDIR)
+
+ $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
+
+# optimized
+ $(SILENT) $(COPY) $(SYMROOT)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
+ -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
+ $(SYMLINK) libobjc.$(VERSION_NAME)$(LIBRARY_EXT) libobjc$(LIBRARY_EXT)
+
+# debug (allowed not to exist)
+ -$(SILENT) $(COPY) $(SYMROOT)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
+ -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
+ -$(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
+ -$(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
+ test -e libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) && \
+ $(SYMLINK) libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) libobjc_debug$(LIBRARY_EXT) && \
+ $(SYMLINK) libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) libobjc.$(VERSION_NAME)_debug$(LIBRARY_EXT)
+
+
+# profile (allowed not to exist)
+ -$(SILENT) $(COPY) $(SYMROOT)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
+ -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
+ -$(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
+ -$(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
+ test -e libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) && \
+ $(SYMLINK) libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) libobjc_profile$(LIBRARY_EXT) && \
+ $(SYMLINK) libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) libobjc.$(VERSION_NAME)_profile$(LIBRARY_EXT)
+
+
+clean:
+ $(SILENT) $(ECHO) "Deleting build products..."
+ $(foreach A, $(ARCH_LIST), \
+ $(SILENT) $(REMOVE) -f $(OBJROOT)/libobjc_debug.$A.o $(OBJROOT)/libobjc_profile.$A.o $(OBJROOT)/libobjc.$A.o ; )
+
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.optimized.o
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.debug.o
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.profile.o
+
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
+ $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
+
+ $(SILENT) $(REMOVE) -f $(OBJECTS_OPTIMIZED)
+ $(SILENT) $(REMOVE) -f $(OBJECTS_DEBUG)
+ $(SILENT) $(REMOVE) -f $(OBJECTS_PROFILE)
+
+ $(SILENT) $(REMOVE) -rf $(SYMROOT)/ProjectHeaders
+
+prebuild:
+ $(SILENT) $(ECHO) "Prebuild-setup..."
+
+# Install headers into $(SYMROOT)/ProjectHeaders so #includes can find them
+# even if they're not installed in /usr.
+ $(SILENT) $(MKDIRS) $(SYMROOT)
+ $(SILENT) $(REMOVE_RECUR) $(SYMROOT)/ProjectHeaders
+ $(SILENT) $(MKDIRS) $(SYMROOT)/ProjectHeaders
+ $(SILENT) $(ECHO) "Copying headers from $(SRCROOT) to $(SYMROOT)/ProjectHeaders..."
+ $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PRIVATE_HEADERS) ) $(SYMROOT)/ProjectHeaders
+ $(SILENT) $(MKDIRS) $(SYMROOT)/ProjectHeaders/objc
+ $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PUBLIC_HEADERS) ) $(SYMROOT)/ProjectHeaders/objc
+ $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(OTHER_HEADERS) ) $(SYMROOT)/ProjectHeaders/objc
+
+
+
+build-optimized: prebuild-optimized compile-optimized link-optimized
+build-debug: prebuild-debug compile-debug link-debug
+build-profile: prebuild-profile compile-profile link-profile
+
+
+prebuild-optimized:
+ $(SILENT) $(ECHO) "Building (optimized) ..."
+ $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
+
+prebuild-debug:
+ $(SILENT) $(ECHO) "Building (debug) ..."
+ $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
+
+prebuild-profile:
+ $(SILENT) $(ECHO) "Building (profile) ..."
+ $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
+
-NAME = objc4
+compile-optimized: $(OBJECTS_OPTIMIZED)
+compile-debug: $(OBJECTS_DEBUG)
+compile-profile: $(OBJECTS_PROFILE)
-PROJECTVERSION = 2.8
-PROJECT_TYPE = Aggregate
-LIBRARIES = runtime
+# link lib-suffix, LDFLAGS, OBJECTS
+# libsuffix should be "" or _debug or _profile
+ifeq "$(PLATFORM)" "Darwin"
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble
+define link
+ $(foreach A, $(ARCH_LIST), \
+ $(SILENT) $(LD) -arch $A -r -o $(OBJROOT)/libobjc$1.$A.o $3 ; )
+ $(foreach A, $(ARCH_LIST), \
+ -$(SILENT) $(NMEDIT) -s $(SRCROOT)/objc-exports \
+ $(OBJROOT)/libobjc$1.$A.o ; )
+ $(SILENT) $(CC) $2 \
+ -Wl,-init,__objcInit \
+ -install_name /$(INSTALLDIR)/libobjc$1.$(VERSION_NAME)$(LIBRARY_EXT) \
+ -o $(SYMROOT)/libobjc$1.$(VERSION_NAME)$(LIBRARY_EXT) \
+ $(foreach A, $(ARCH_LIST), $(OBJROOT)/libobjc$1.$A.o )
+endef
-MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
-CODE_GEN_STYLE = DYNAMIC
-MAKEFILE = aggregate.make
-LIBS =
-DEBUG_LIBS = $(LIBS)
-PROF_LIBS = $(LIBS)
+else
+# PLATFORM != Darwin
+define link
+ $(SILENT) $(ECHO) "Don't know how to link for platform '$(PLATFORM)'"
+endef
+endif
+link-optimized:
+ $(SILENT) $(ECHO) "Linking (optimized)..."
+ $(call link,,$(LDFLAGS_OPTIMIZED),$(OBJECTS_OPTIMIZED) )
+ $(SILENT) $(STRIP) -x $(SYMROOT)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
-NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
-WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc
-PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc
-NEXTSTEP_JAVA_COMPILER = /usr/bin/javac
-WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe
-PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac
+link-debug:
+ $(SILENT) $(ECHO) "Linking (debug)..."
+ $(call link,_debug,$(LDFLAGS_DEBUG),$(OBJECTS_DEBUG) )
-include $(MAKEFILEDIR)/platform.make
+link-profile:
+ $(SILENT) $(ECHO) "Linking (profile)..."
+ $(call link,_profile,$(LDFLAGS_PROFILE),$(OBJECTS_PROFILE))
--include Makefile.preamble
-include $(MAKEFILEDIR)/$(MAKEFILE)
+postbuild:
+ $(SILENT) $(ECHO) "Done!"
--include Makefile.postamble
--include Makefile.dependencies
View
0  Makefile.postamble
No changes.
View
5 Makefile.preamble
@@ -1,5 +0,0 @@
-
-ifeq "$(PLATFORM_OS)" "macos"
- BEFORE_INSTALL += profile
-endif
-
View
24 PB.project
@@ -1,24 +0,0 @@
-{
- DYNAMIC_CODE_GEN = YES;
- FILESTABLE = {
- CLASSES = ();
- H_FILES = ();
- OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble);
- SUBPROJECTS = (runtime);
- };
- LANGUAGE = English;
- LOCALIZABLE_FILES = {};
- MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
- NEXTSTEP_BUILDTOOL = /bin/gnumake;
- NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
- NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
- PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make;
- PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac";
- PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc";
- PROJECTNAME = objc4;
- PROJECTTYPE = Aggregate;
- PROJECTVERSION = 2.8;
- WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make;
- WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe";
- WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc";
-}
View
144 objc-exports
@@ -0,0 +1,144 @@
+# Functions and variables explicitly exported from ObjC.
+# GrP 2002-2-4
+# Note that some commonly used functions are *not* listed in the
+# ObjC headers (e.g. objc_flush_caches())
+# List.h
+.objc_class_name_List
+# objc-class.h
+_object_setInstanceVariable
+_object_getInstanceVariable
+_class_createInstance
+_class_createInstanceFromZone
+_class_setVersion
+_class_getVersion
+_class_getInstanceVariable
+_class_getInstanceMethod
+_class_getClassMethod
+_class_addMethods
+_class_removeMethods
+_class_poseAs
+_method_getNumberOfArguments
+_method_getSizeOfArguments
+_method_getArgumentInfo
+_class_nextMethodList
+# objc-load.h
+_objc_loadModules
+_objc_loadModule
+_objc_unloadModules
+# objc-runtime.h
+# fixme does anybody use objc_msgSendFew* ?
+_objc_getClass
+_objc_getMetaClass
+_objc_msgSend
+_objc_msgSend_stret
+_objc_msgSendSuper
+_objc_msgSendSuper_stret
+_objc_msgSendv
+_objc_msgSendv_stret
+_objc_getClassList
+_objc_getClasses
+_objc_lookUpClass
+_objc_addClass
+_objc_setClassHandler
+_objc_setMultithreaded
+__alloc
+__copy
+__realloc
+__dealloc
+__zoneAlloc
+__zoneRealloc
+__zoneCopy
+__error
+# objc.h
+_sel_isMapped
+_sel_getName
+_sel_getUid
+_sel_registerName
+_object_getClassName
+_object_getIndexedIvars
+# Object.h
+.objc_class_name_Object
+_object_dispose
+_object_copy
+_object_copyFromZone
+_object_realloc
+_object_reallocFromZone
+# Protocol.h
+.objc_class_name_Protocol
+# error.h
+# everything inside is declared but no longer defined?!
+# hashtable2.h
+_NXCreateHashTableFromZone
+_NXCreateHashTable
+_NXFreeHashTable
+_NXEmptyHashTable
+_NXResetHashTable
+_NXCompareHashTables
+_NXCopyHashTable
+_NXCountHashTable
+_NXHashMember
+_NXHashGet
+_NXHashInsert
+_NXHashInsertIfAbsent
+_NXHashRemove
+_NXInitHashState
+_NXNextHashState
+_NXPtrHash
+_NXStrHash
+_NXPtrIsEqual
+_NXStrIsEqual
+_NXNoEffectFree
+_NXReallyFree
+_NXPtrPrototype
+_NXStrPrototype
+_NXPtrStructKeyPrototype
+_NXStrStructKeyPrototype
+_NXUniqueString
+_NXUniqueStringWithLength
+_NXUniqueStringNoCopy
+_NXCopyStringBuffer
+_NXCopyStringBufferFromZone
+# maptable.h
+_NXCreateMapTableFromZone
+_NXCreateMapTable
+_NXFreeMapTable
+_NXResetMapTable
+_NXCompareMapTables
+_NXCountMapTable
+_NXMapMember
+_NXMapGet
+_NXMapInsert
+_NXMapRemove
+_NXInitMapState
+_NXNextMapState
+_NXPtrValueMapPrototype
+_NXStrValueMapPrototype
+_NXObjectMapPrototype
+#
+# Functions that aren't in the headers but are used or are useful.
+#
+# sudo find / -xdev -type f -perm -0111 \! -name "libobjc*dylib" -print -exec nm -u {} \; > /tmp/all-used-symbols
+# (repeat with any other disks you want checked, appending to the same file)
+# nm /usr/lib/libobjc.dylib | awk '$2 ~ /^[ADST]$/' | colrm 1 11 | sort -u > /tmp/objc-exports
+# (note that you need an unstripped, un-nmedited libobjc.dylib)
+# grep -f /tmp/objc-exports /tmp/all-used-symbols | sort -u > /tmp/used-objc-symbols
+# grep -v -f /tmp/used-objc-symbols /tmp/objc-exports | sort -u > /tmp/unused-objc-symbols
+#
+__class_printDuplicateCacheEntries
+__class_printMethodCaches
+__class_printMethodCacheStatistics
+__objc_create_zone
+__objc_error
+__objc_flush_caches
+__objc_msgForward
+__objcInit
+_class_lookupMethod
+_class_respondsToMethod
+_instrumentObjcMessageSends
+_objc_getOrigClass
+# magic, or garbage?
+__dummy
+_do_not_remove_this_dummy_function
+# used by debugging tools like heap
+__objc_debug_class_hash
+
View
65 runtime/Makefile
@@ -1,65 +0,0 @@
-#
-# Generated by the Apple Project Builder.
-#
-# NOTE: Do NOT change this file -- Project Builder maintains it.
-#
-# Put all of your customizations in files called Makefile.preamble
-# and Makefile.postamble (both optional), and Makefile will include them.
-#
-
-NAME = runtime
-
-PROJECTVERSION = 2.8
-PROJECT_TYPE = Library
-
-HFILES = error.h hashtable2.h maptable.h objc-api.h objc-class.h\
- objc-config.h objc-load.h objc-private.h objc-runtime.h\
- objc.h Object.h Protocol.h
-
-MFILES = hashtable2.m maptable.m objc-class.m objc-errors.m\
- objc-file.m objc-load.m objc-runtime.m objc-sel.m Object.m\
- Protocol.m
-
-CFILES = objc-moninit.c
-
-SUBPROJECTS = Messengers.subproj OldClasses.subproj
-
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble
-
-
-MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
-CURRENTLY_ACTIVE_VERSION = YES
-DEPLOY_WITH_VERSION_NAME = A
-CODE_GEN_STYLE = DYNAMIC
-MAKEFILE = library.make
-NEXTSTEP_INSTALLDIR = /usr/lib
-WINDOWS_INSTALLDIR = /.
-PDO_UNIX_INSTALLDIR = $(LOCAL_DEVELOPER_DIR)/Libraries
-LIBS =
-DEBUG_LIBS = $(LIBS)
-PROF_LIBS = $(LIBS)
-
-
-PUBLIC_HEADERS = objc-class.h objc-api.h objc-load.h objc-runtime.h\
- objc.h Object.h Protocol.h error.h hashtable2.h
-
-PROJECT_HEADERS = objc-runtime.h objc-class.h
-
-
-
-NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
-WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc
-PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc
-NEXTSTEP_JAVA_COMPILER = /usr/bin/javac
-WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe
-PDO_UNIX_JAVA_COMPILER = $(NEXTDEV_BIN)/javac
-
-include $(MAKEFILEDIR)/platform.make
-
--include Makefile.preamble
-
-include $(MAKEFILEDIR)/$(MAKEFILE)
-
--include Makefile.postamble
-
--include Makefile.dependencies
View
27 runtime/Makefile.postamble
@@ -1,27 +0,0 @@
-###############################################################################
-# Makefile.postamble
-# Copyright 1997,2000 Apple Computer, Inc.
-###############################################################################
-
-ifeq "$(PLATFORM_OS)" "macos"
-
-PROFILE_PRODUCT = $(PRODUCT_DIR)/$(LIBRARY_PREFIX)$(NAME)$(PROFILE_SUFFIX)$(LIBRARY_EXT)
-VERSIONED_PROFILE_PRODUCT = $(PRODUCT_DIR)/$(LIBRARY_PREFIX)$(NAME)$(PROFILE_SUFFIX).$(VERSION_NAME)$(LIBRARY_EXT)
-PRODUCTS += $(PROFILE_PRODUCT) $(VERSIONED_PROFILE_PRODUCT)
-STRIPPED_PRODUCTS += $(VERSIONED_PROFILE_PRODUCT)
-DYLIB_INSTALL_NAME = $(LIBRARY_PREFIX)$(NAME)$(BUILD_TYPE_SUFFIX).$(VERSION_NAME)$(LIBRARY_EXT)
-PRODUCT = $(PRODUCT_DIR)/$(DYLIB_INSTALL_NAME)
-
-endif
-
-create-profile-lib-compat-link:
- $(SYMLINK) $(notdir $(VERSIONED_PROFILE_PRODUCT)) $(DSTROOT)$(INSTALLDIR)/libobjc.A_profile.dylib
-
-link-hashtable:
- $(RM) -f $(DSTROOT)$(PUBLIC_HEADER_DIR)$(PUBLIC_HEADER_DIR_SUFFIX)/hashtable.h
- $(CP) $(DSTROOT)$(PUBLIC_HEADER_DIR)$(PUBLIC_HEADER_DIR_SUFFIX)/hashtable2.h $(DSTROOT)$(PUBLIC_HEADER_DIR)$(PUBLIC_HEADER_DIR_SUFFIX)/hashtable.h
- true
-
-# from AFTER_POSTINSTALL
-postprocess:
-
View
31 runtime/Makefile.preamble
@@ -1,31 +0,0 @@
-###############################################################################
-# Makefile.preamble
-# Copyright 1997,2000 Apple Computer, Inc.
-###############################################################################
-
-
-NAME = objc
-OTHER_CFLAGS += -Wno-unused
-OTHER_LIBTOOL_FLAGS += -Wl,-init,__objcInit
-FRAMEWORKS += -framework CoreFoundation
-HEADER_PATHS += -I$(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders
-AFTER_INSTALL += create-profile-lib-compat-link
-
-OTHER_CFLAGS += -DNSBUILDINGOBJC -I$(SYMROOT)
-OTHER_LDFLAGS =
-
-AFTER_INSTALLHDRS += link-hashtable
-AFTER_POSTINSTALL += postprocess
-
-PUBLIC_HEADER_DIR = /usr/include
-PRIVATE_HEADER_DIR = /usr/local/include
-
-# If, in a subproject, you want to append to the parent's PUBLIC_HEADER_DIR#
-# (say, to add a subdirectory like "/sys"), you can use:
-PUBLIC_HEADER_DIR_SUFFIX = /objc
-PRIVATE_HEADER_DIR_SUFFIX = /objc
-
-OTHER_PUBLIC_HEADERS =
-OTHER_PRIVATE_HEADERS = maptable.h
-OTHER_PROJECT_HEADERS = $(PUBLIC_HEADERS) $(OTHER_PRIVATE_HEADERS) objc-private.h objc-config.h
-
View
47 runtime/Messengers.subproj/Makefile
@@ -1,47 +0,0 @@
-#
-# Generated by the Apple Project Builder.
-#
-# NOTE: Do NOT change this file -- Project Builder maintains it.
-#
-# Put all of your customizations in files called Makefile.preamble
-# and Makefile.postamble (both optional), and Makefile will include them.
-#
-
-NAME = Messengers
-
-PROJECTVERSION = 2.8
-PROJECT_TYPE = Component
-
-OTHERLINKED = objc-msg.s
-
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\
- objc-msg-i386.s objc-msg-ppc.s
-
-OTHERLINKEDOFILES = objc-msg.o
-
-MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
-CODE_GEN_STYLE = DYNAMIC
-MAKEFILE = subproj.make
-LIBS =
-DEBUG_LIBS = $(LIBS)
-PROF_LIBS = $(LIBS)
-
-
-
-
-NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
-WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc
-PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc
-NEXTSTEP_JAVA_COMPILER = /usr/bin/javac
-WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe
-PDO_UNIX_JAVA_COMPILER = $(NEXTDEV_BIN)/javac
-
-include $(MAKEFILEDIR)/platform.make
-
--include Makefile.preamble
-
-include $(MAKEFILEDIR)/$(MAKEFILE)
-
--include Makefile.postamble
-
--include Makefile.dependencies
View
100 runtime/Messengers.subproj/Makefile.postamble
@@ -1,100 +0,0 @@
-###############################################################################
-# Makefile.postamble
-# Copyright 1997, Apple Computer, Inc.
-#
-# Use this makefile, which is imported after all other makefiles, to
-# override attributes for a project's Makefile environment. This allows you
-# to take advantage of the environment set up by the other Makefiles.
-# You can also define custom rules at the end of this file.
-#
-###############################################################################
-#
-# These variables are exported by the standard makefiles and can be
-# used in any customizations you make. They are *outputs* of
-# the Makefiles and should be used, not set.
-#
-# PRODUCTS: products to install. All of these products will be placed in
-# the directory $(DSTROOT)$(INSTALLDIR)
-# GLOBAL_RESOURCE_DIR: The directory to which resources are copied.
-# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied.
-# OFILE_DIR: Directory into which .o object files are generated.
-# DERIVED_SRC_DIR: Directory used for all other derived files
-#
-# ALL_CFLAGS: flags to pass when compiling .c files
-# ALL_MFLAGS: flags to pass when compiling .m files
-# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files
-# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files
-# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files
-# ALL_LDFLAGS: flags to pass when linking object files
-# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files
-# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files
-# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files
-# ALL_YFLAGS: flags to pass when processing .y (yacc) files
-# ALL_LFLAGS: flags to pass when processing .l (lex) files
-#
-# NAME: name of application, bundle, subproject, palette, etc.
-# LANGUAGE: langage in which the project is written (default "English")
-# LOCAL_RESOURCES: localized resources (e.g. nib's, images) of project
-# GLOBAL_RESOURCES: non-localized resources of project
-#
-# SRCROOT: base directory in which to place the new source files
-# SRCPATH: relative path from SRCROOT to present subdirectory
-#
-# INSTALLDIR: Directory the product will be installed into by 'install' target
-# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget
-# to prefix this with DSTROOT when you use it.
-# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget
-# to prefix this with DSTROOT when you use it.
-#
-# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows)
-#
-###############################################################################
-
-# Some compiler flags can be overridden here for certain build situations.
-#
-# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost)
-# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults
-# to -g)
-# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG)
-# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults
-# to -O)
-# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults
-# to -pg -DPROFILE)
-# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to
-# the include path (defaults to -I.)
-# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags
-# passed to ld/libtool (defaults to nothing)
-
-
-# Library and Framework projects only:
-# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked
-# against the framework will run against the correct version even if
-# the current version of the framework changes. You may override this
-# to "" as an alternative to using the DYLD_LIBRARY_PATH during your
-# development cycle, but be sure to restore it before installing.
-
-
-# Ownership and permissions of files installed by 'install' target
-
-#INSTALL_AS_USER = root
- # User/group ownership
-#INSTALL_AS_GROUP = wheel
- # (probably want to set both of these)
-#INSTALL_PERMISSIONS =
- # If set, 'install' chmod's executable to this
-
-
-# Options to strip. Note: -S strips debugging symbols (executables can be stripped
-# down further with -x or, if they load no bundles, with no options at all).
-
-#STRIPFLAGS = -S
-
-
-#########################################################################
-# Put rules to extend the behavior of the standard Makefiles here. Include them in
-# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble.
-#
-# You should avoid redefining things like "install" or "app", as they are
-# owned by the top-level Makefile API and no context has been set up for where
-# derived files should go.
-#
View
123 runtime/Messengers.subproj/Makefile.preamble
@@ -1,123 +0,0 @@
-###############################################################################
-# Makefile.preamble
-# Copyright 1997, Apple Computer, Inc.
-#
-# Use this makefile for configuring the standard application makefiles
-# associated with ProjectBuilder. It is included before the main makefile.
-# In Makefile.preamble you set attributes for a project, so they are available
-# to the project's makefiles. In contrast, you typically write additional rules or
-# override built-in behavior in the Makefile.postamble.
-#
-# Each directory in a project tree (main project plus subprojects) should
-# have its own Makefile.preamble and Makefile.postamble.
-###############################################################################
-#
-# Before the main makefile is included for this project, you may set:
-#
-# MAKEFILEDIR: Directory in which to find $(MAKEFILE)
-# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make)
-
-# Compiler/linker flags added to the defaults: The OTHER_* variables will be
-# inherited by all nested sub-projects, but the LOCAL_ versions of the same
-# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's
-# Build Attributes inspector if at all possible. To override the default flags
-# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The
-# variables below are *inputs* to the build process and distinct from the override
-# settings done (less often) in the Makefile.postamble.
-#
-# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler
-# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m,
-# .cc, .cxx, .C, and .M files. There is no need to respecify the
-# flags in OTHER_MFLAGS, etc.
-# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files
-# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files
-# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files
-# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when
-# precompiling header files
-# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool
-# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap
-# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen
-# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc
-# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex
-
-# These variables provide hooks enabling you to add behavior at almost every
-# stage of the make:
-#
-# BEFORE_PREBUILD: targets to build before installing headers for a subproject
-# AFTER_PREBUILD: targets to build after installing headers for a subproject
-# BEFORE_BUILD_RECURSION: targets to make before building subprojects
-# BEFORE_BUILD: targets to make before a build, but after subprojects
-# AFTER_BUILD: targets to make after a build
-#
-# BEFORE_INSTALL: targets to build before installing the product
-# AFTER_INSTALL: targets to build after installing the product
-# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject
-# AFTER_POSTINSTALL: targts to build after postinstalling every subproject
-#
-# BEFORE_INSTALLHDRS: targets to build before installing headers for a
-# subproject
-# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject
-# BEFORE_INSTALLSRC: targets to build before installing source for a subproject
-# AFTER_INSTALLSRC: targets to build after installing source for a subproject
-#
-# BEFORE_DEPEND: targets to build before building dependencies for a
-# subproject
-# AFTER_DEPEND: targets to build after building dependencies for a
-# subproject
-#
-# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is
-# updated every time the project is built. If NO, the dependency
-# file is only built when the depend target is invoked.
-
-# Framework-related variables:
-# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates
-# where to put the framework's DLL. This variable defaults to
-# $(INSTALLDIR)/../Executables
-
-# Library-related variables:
-# PUBLIC_HEADER_DIR: Determines where public exported header files
-# should be installed. Do not include $(DSTROOT) in this value --
-# it is prefixed automatically.
-# PRIVATE_HEADER_DIR: Determines where private exported header files
-# should be installed. Do not include $(DSTROOT) in this value --
-# it is prefixed automatically.
-# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines
-# whether the libraries produced are statically linked when they
-# are used or if they are dynamically loadable. <<default?>>
-# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates
-# where to put the library's DLL. This variable defaults to
-# $(INSTALLDIR)/../Executables
-#
-# INSTALL_AS_USER: owner of the intalled products (default root)
-# INSTALL_AS_GROUP: group of the installed products (default wheel)
-# INSTALL_PERMISSION: permissions of the installed product (default o+rX)
-#
-# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be
-# passed on the command line to recursive invocations of make. Note that
-# the values in OTHER_*FLAGS are inherited by subprojects automatically --
-# you do not have to (and shouldn't) add OTHER_*FLAGS to
-# OTHER_RECURSIVE_VARIABLES.
-
-# Additional headers to export beyond those in the PB.project:
-# OTHER_PUBLIC_HEADERS
-# OTHER_PROJECT_HEADERS
-# OTHER_PRIVATE_HEADERS
-
-# Additional files for the project's product: <<path relative to proj?>>
-# OTHER_RESOURCES: (non-localized) resources for this project
-# OTHER_OFILES: relocatables to be linked into this project
-# OTHER_LIBS: more libraries to link against
-# OTHER_PRODUCT_DEPENDS: other dependencies of this project
-# OTHER_SOURCEFILES: other source files maintained by .pre/postamble
-# OTHER_GARBAGE: additional files to be removed by `make clean'
-
-# Set this to YES if you don't want a final libtool call for a library/framework.
-# BUILD_OFILES_LIST_ONLY
-
-# To include a version string, project source must exist in a directory named
-# $(NAME).%d[.%d][.%d] and the following line must be uncommented.
-# OTHER_GENERATED_OFILES = $(VERS_OFILE)
-
-# This definition will suppress stripping of debug symbols when an executable
-# is installed. By default it is YES.
-# STRIP_ON_INSTALL = NO
View
31 runtime/Messengers.subproj/PB.project
@@ -1,31 +0,0 @@
-{
- DYNAMIC_CODE_GEN = YES;
- FILESTABLE = {
- CLASSES = ();
- H_FILES = ();
- OTHER_LINKED = ("objc-msg.s");
- OTHER_SOURCES = (
- Makefile.preamble,
- Makefile,
- Makefile.postamble,
- "objc-msg-i386.s",
- "objc-msg-ppc.s"
- );
- SUBPROJECTS = ();
- };
- LANGUAGE = English;
- LOCALIZABLE_FILES = {};
- MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
- NEXTSTEP_BUILDTOOL = /bin/gnumake;
- NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
- NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
- PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make;
- PDO_UNIX_JAVA_COMPILER = "$(NEXTDEV_BIN)/javac";
- PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc";
- PROJECTNAME = Messengers;
- PROJECTTYPE = Component;
- PROJECTVERSION = 2.8;
- WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make;
- WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe";
- WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc";
-}
View
292 runtime/Messengers.subproj/objc-msg-i386.s
@@ -39,7 +39,6 @@
kEight = 8
#endif
-#if defined(OBJC_COLLECTING_CACHE)
// _objc_entryPoints and _objc_exitPoints are used by objc
// to get the critical regions for which method caches
// cannot be garbage collected.
@@ -47,6 +46,8 @@
.data
.globl _objc_entryPoints
_objc_entryPoints:
+ .long __cache_getImp
+ .long __cache_getMethod
.long _objc_msgSend
.long _objc_msgSend_stret
.long _objc_msgSendSuper
@@ -55,12 +56,13 @@ _objc_entryPoints:
.globl _objc_exitPoints
_objc_exitPoints:
+ .long LGetImpExit
+ .long LGetMethodExit
.long LMsgSendExit
.long LMsgSendStretExit
.long LMsgSendSuperExit
.long LMsgSendSuperStretExit
.long 0
-#endif
/********************************************************************
@@ -271,18 +273,20 @@ $0:
/////////////////////////////////////////////////////////////////////
//
//
-// CacheLookup WORD_RETURN | STRUCT_RETURN, MSG_SEND | MSG_SENDSUPER, cacheMissLabel
+// CacheLookup WORD_RETURN | STRUCT_RETURN, MSG_SEND | MSG_SENDSUPER | CACHE_GET, cacheMissLabel
//
// Locate the implementation for a selector in a class method cache.
//
// Takes: WORD_RETURN (first parameter is at sp+4)
// STRUCT_RETURN (struct address is at sp+4, first parameter at sp+8)
-// MSG_SEND (first parameter is receiver)
+// MSG_SEND (first parameter is receiver)
// MSG_SENDSUPER (first parameter is address of objc_super structure)
+// CACHE_GET (first parameter is class; return method triplet)
//
// cacheMissLabel = label to branch to iff method is not cached
//
-// On exit: (found) imp in eax register
+// On exit: (found) MSG_SEND and MSG_SENDSUPER: return imp in eax
+// (found) CACHE_GET: return method triplet in eax
// (not found) jumps to cacheMissLabel
//
/////////////////////////////////////////////////////////////////////
@@ -295,8 +299,9 @@ STRUCT_RETURN = 1
// Values to specify to method lookup macros whether the first argument
// is an object/class reference or a 'objc_super' structure.
-MSG_SEND = 0
-MSG_SENDSUPER = 1
+MSG_SEND = 0 // first argument is receiver, search the isa
+MSG_SENDSUPER = 1 // first argument is objc_super, search the class
+CACHE_GET = 2 // first argument is class, search that class
.macro CacheLookup
@@ -306,19 +311,23 @@ MSG_SENDSUPER = 1
.if $1 == MSG_SEND // MSG_SEND
movl isa(%eax), %eax // class = self->isa
movl selector(%esp), %ecx // get selector
-.else // MSG_SENDSUPER
+.elseif $1 == MSG_SENDSUPER // MSG_SENDSUPER
movl super(%esp), %eax // get objc_super address
movl class(%eax), %eax // class = caller->class
movl selector(%esp), %ecx // get selector
+.else // CACHE_GET
+ movl selector(%esp), %ecx // get selector - class already in eax
.endif
.else // Struct return
.if $1 == MSG_SEND // MSG_SEND (stret)
movl isa(%eax), %eax // class = self->isa
movl (selector_stret)(%esp), %ecx // get selector
-.else // MSG_SENDSUPER (stret)
+.elseif $1 == MSG_SENDSUPER // MSG_SENDSUPER (stret)
movl super_stret(%esp), %eax // get objc_super address
movl class(%eax), %eax // class = caller->class
movl (selector_stret)(%esp), %ecx // get selector
+.else // CACHE_GET
+ !! This should not happen.
.endif
.endif
@@ -334,9 +343,14 @@ MSG_SENDSUPER = 1
leal buckets(%eax), %edi // buckets = &cache->buckets
movl mask(%eax), %esi // mask = cache->mask
movl %ecx, %edx // index = selector
+#ifdef NO_MACRO_CONSTS
+ shrl $kTwo, %edx // index = selector >> 2
+#else
+ shrl $2, %edx // index = selector >> 2
+#endif
// search the receiver's cache
-LMsgSendProbeCache_$0_$1:
+LMsgSendProbeCache_$0_$1_$2:
#if defined(OBJC_INSTRUMENTED)
inc %ebx // probeCount += 1
#endif
@@ -344,19 +358,19 @@ LMsgSendProbeCache_$0_$1:
movl (%edi, %edx, 4), %eax // method = buckets[index]
testl %eax, %eax // check for end of bucket
- je LMsgSendCacheMiss_$0_$1 // go to cache miss code
+ je LMsgSendCacheMiss_$0_$1_$2 // go to cache miss code
cmpl method_name(%eax), %ecx // check for method name match
- je LMsgSendCacheHit_$0_$1 // go handle cache hit
+ je LMsgSendCacheHit_$0_$1_$2 // go handle cache hit
inc %edx // bump index ...
- jmp LMsgSendProbeCache_$0_$1// ... and loop
+ jmp LMsgSendProbeCache_$0_$1_$2 // ... and loop
// not found in cache: restore state and go to callers handler
-LMsgSendCacheMiss_$0_$1:
+LMsgSendCacheMiss_$0_$1_$2:
#if defined(OBJC_INSTRUMENTED)
popl %edx // retrieve cache pointer
movl mask(%edx), %esi // mask = cache->mask
testl %esi, %esi // a mask of zero is only for the...
- je LMsgSendMissInstrumentDone_$0 // ... emptyCache, do not record anything
+ je LMsgSendMissInstrumentDone_$0_$1_$2 // ... emptyCache, do not record anything
// locate and update the CacheInstrumentation structure
inc %esi // entryCount = mask + 1
@@ -376,15 +390,15 @@ LMsgSendCacheMiss_$0_$1:
movl %edi, missProbes(%esi) // cacheData->missProbes += probeCount
movl maxMissProbes(%esi), %edi// if (cacheData->maxMissProbes < probeCount)
cmpl %ebx, %edi //
- jge LMsgSendMaxMissProbeOK_$0 //
+ jge LMsgSendMaxMissProbeOK_$0_$1_$2 //
movl %ebx, maxMissProbes(%esi)// cacheData->maxMissProbes = probeCount
-LMsgSendMaxMissProbeOK_$0:
+LMsgSendMaxMissProbeOK_$0_$1_$2:
// update cache miss probe histogram
cmpl $CACHE_HISTOGRAM_SIZE, %ebx // pin probeCount to max index
- jl LMsgSendMissHistoIndexSet_$0
+ jl LMsgSendMissHistoIndexSet_$0_$1_$2
movl $(CACHE_HISTOGRAM_SIZE-1), %ebx
-LMsgSendMissHistoIndexSet_$0:
+LMsgSendMissHistoIndexSet_$0_$1_$2:
LEA_STATIC_DATA %esi, _CacheMissHistogram, EXTERNAL_SYMBOL
#ifdef NO_MACRO_CONSTS
shll $kTwo, %ebx // convert probeCount to histogram index
@@ -395,7 +409,7 @@ LMsgSendMissHistoIndexSet_$0:
movl 0(%esi), %edi // get current tally
inc %edi //
movl %edi, 0(%esi) // tally += 1
-LMsgSendMissInstrumentDone_$0:
+LMsgSendMissInstrumentDone_$0_$1_$2:
popl %ebx // restore non-volatile register
#endif
@@ -403,9 +417,9 @@ LMsgSendMissInstrumentDone_$0:
.if $1 == MSG_SEND // MSG_SEND
popl %esi // restore callers register
popl %edi // restore callers register
- movl self(%esp), %eax // get messaged object
+ movl self(%esp), %eax // get messaged object
movl isa(%eax), %eax // get objects class
-.else // MSG_SENDSUPER
+.elseif $1 == MSG_SENDSUPER // MSG_SENDSUPER
// replace "super" arg with "receiver"
movl super+8(%esp), %edi // get super structure
movl receiver(%edi), %esi // get messaged object
@@ -413,6 +427,9 @@ LMsgSendMissInstrumentDone_$0:
movl class(%edi), %eax // get messaged class
popl %esi // restore callers register
popl %edi // restore callers register
+.else // CACHE_GET
+ popl %esi // restore callers register
+ popl %edi // restore callers register
.endif
.else // Struct return
.if $1 == MSG_SEND // MSG_SEND (stret)
@@ -420,7 +437,7 @@ LMsgSendMissInstrumentDone_$0:
popl %edi // restore callers register
movl self_stret(%esp), %eax // get messaged object
movl isa(%eax), %eax // get objects class
-.else // MSG_SENDSUPER (stret)
+.elseif $1 == MSG_SENDSUPER // MSG_SENDSUPER (stret)
// replace "super" arg with "receiver"
movl super_stret+8(%esp), %edi// get super structure
movl receiver(%edi), %esi // get messaged object
@@ -428,6 +445,8 @@ LMsgSendMissInstrumentDone_$0:
movl class(%edi), %eax // get messaged class
popl %esi // restore callers register
popl %edi // restore callers register
+.else // CACHE_GET
+ !! This should not happen.
.endif
.endif
@@ -435,12 +454,12 @@ LMsgSendMissInstrumentDone_$0:
// eax points to matching cache entry
.align 4, 0x90
-LMsgSendCacheHit_$0_$1:
+LMsgSendCacheHit_$0_$1_$2:
#if defined(OBJC_INSTRUMENTED)
popl %edx // retrieve cache pointer
movl mask(%edx), %esi // mask = cache->mask
testl %esi, %esi // a mask of zero is only for the...
- je LMsgSendHitInstrumentDone_$0_$1 // ... emptyCache, do not record anything
+ je LMsgSendHitInstrumentDone_$0_$1_$2 // ... emptyCache, do not record anything
// locate and update the CacheInstrumentation structure
inc %esi // entryCount = mask + 1
@@ -460,15 +479,15 @@ LMsgSendCacheHit_$0_$1:
movl %edi, hitProbes(%esi) // cacheData->hitProbes += probeCount
movl maxHitProbes(%esi), %edi// if (cacheData->maxHitProbes < probeCount)
cmpl %ebx, %edi
- jge LMsgSendMaxHitProbeOK_$0_$1
+ jge LMsgSendMaxHitProbeOK_$0_$1_$2
movl %ebx, maxHitProbes(%esi)// cacheData->maxHitProbes = probeCount
-LMsgSendMaxHitProbeOK_$0_$1:
+LMsgSendMaxHitProbeOK_$0_$1_$2:
// update cache hit probe histogram
cmpl $CACHE_HISTOGRAM_SIZE, %ebx // pin probeCount to max index
- jl LMsgSendHitHistoIndexSet_$0_$1
+ jl LMsgSendHitHistoIndexSet_$0_$1_$2
movl $(CACHE_HISTOGRAM_SIZE-1), %ebx
-LMsgSendHitHistoIndexSet_$0_$1:
+LMsgSendHitHistoIndexSet_$0_$1_$2:
LEA_STATIC_DATA %esi, _CacheHitHistogram, EXTERNAL_SYMBOL
#ifdef NO_MACRO_CONSTS
shll $kTwo, %ebx // convert probeCount to histogram index
@@ -479,12 +498,16 @@ LMsgSendHitHistoIndexSet_$0_$1:
movl 0(%esi), %edi // get current tally
inc %edi //
movl %edi, 0(%esi) // tally += 1
-LMsgSendHitInstrumentDone_$0_$1:
+LMsgSendHitInstrumentDone_$0_$1_$2:
popl %ebx // restore non-volatile register
#endif
// load implementation address, restore state, and we're done
+.if $1 == CACHE_GET
+ // method triplet is already in eax
+.else
movl method_imp(%eax), %eax // imp = method->method_imp
+.endif
.if $0 == WORD_RETURN // Regular word return
.if $1 == MSG_SENDSUPER // MSG_SENDSUPER
@@ -555,6 +578,73 @@ HAVE_CALL_EXTERN_lookupMethodAndLoadCache = 1
PICIFY(func) ; \
jmp %edx ;
+
+
+
+/********************************************************************
+ * Method _cache_getMethod(Class cls, SEL sel)
+ *
+ * If found, returns method triplet pointer.
+ * If not found, returns NULL.
+ *
+ * NOTE: _cache_getMethod never returns any cache entry whose implementation
+ * is _objc_msgForward. It returns NULL instead. This prevents thread-
+ * safety and memory management bugs in _class_lookupMethodAndLoadCache.
+ * See _class_lookupMethodAndLoadCache for details.
+ ********************************************************************/
+
+ ENTRY __cache_getMethod
+
+// load the class into eax
+ movl self(%esp), %eax
+
+// do lookup
+ CacheLookup WORD_RETURN, CACHE_GET, LGetMethodMiss
+
+// cache hit, method triplet in %eax
+// check for _objc_msgForward
+ LEA_STATIC_DATA %ecx, __objc_msgForward, LOCAL_SYMBOL // eats edx
+ cmpl method_imp(%eax), %ecx
+ je LGetMethodMiss // if (imp==_objc_msgForward) return nil
+ ret // else return method triplet address
+
+LGetMethodMiss:
+// cache miss, return nil
+ xorl %eax, %eax // zero %eax
+ ret
+
+LGetMethodExit:
+ END_ENTRY __cache_getMethod
+
+
+/********************************************************************
+ * IMP _cache_getImp(Class cls, SEL sel)
+ *
+ * If found, returns method implementation.
+ * If not found, returns NULL.
+ ********************************************************************/
+
+ ENTRY __cache_getImp
+
+// load the class into eax
+ movl self(%esp), %eax
+
+// do lookup
+ CacheLookup WORD_RETURN, CACHE_GET, LGetImpMiss
+
+// cache hit, method triplet in %eax
+ movl method_imp(%eax), %eax // return method imp
+ ret
+
+LGetImpMiss:
+// cache miss, return nil
+ xorl %eax, %eax // zero %eax
+ ret
+
+LGetImpExit:
+ END_ENTRY __cache_getImp
+
+
/********************************************************************
*
* id objc_msgSend(id self, SEL _cmd,...);
@@ -570,14 +660,7 @@ HAVE_CALL_EXTERN_lookupMethodAndLoadCache = 1
testl %eax, %eax
je LMsgSendNilSelf
-#if !defined(OBJC_COLLECTING_CACHE)
-// check whether context is multithreaded
- EXTERN_TO_REG(__objc_multithread_mask,%ecx)
- testl %ecx, %ecx
- je LMsgSendMT
-#endif
-
-// single threaded and receiver is non-nil: search the cache
+// receiver is non-nil: search the cache
CacheLookup WORD_RETURN, MSG_SEND, LMsgSendCacheMiss
movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
jmp *%eax // goto *imp
@@ -588,32 +671,6 @@ LMsgSendCacheMiss:
movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
jmp *%eax // goto *imp
-#if !defined(OBJC_COLLECTING_CACHE)
-// multithreaded: hold _messageLock while accessing cache
-LMsgSendMT:
- movl $1, %ecx // acquire _messageLock
- LEA_STATIC_DATA %eax, _messageLock, EXTERNAL_SYMBOL
-LMsgSendLockSpin:
- xchgl %ecx, (%eax)
- cmpl $0, %ecx
- jne LMsgSendLockSpin
- movl self(%esp), %eax // restore eax
-
- CacheLookup WORD_RETURN, MSG_SEND, LMsgSendMTCacheMiss
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
- jmp *%eax // goto *imp
-
-// cache miss: go search the method lists
-LMsgSendMTCacheMiss:
- MethodTableLookup WORD_RETURN, MSG_SEND
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
- jmp *%eax // goto *imp
-#endif
-
// message sent to nil object: call optional handler and return nil
LMsgSendNilSelf:
EXTERN_TO_REG(__objc_msgNil,%eax)
@@ -643,14 +700,7 @@ LMsgSendExit:
movl super(%esp), %eax
-#if !defined(OBJC_COLLECTING_CACHE)
-// check whether context is multithreaded
- EXTERN_TO_REG_AGAIN(__objc_multithread_mask,%ecx)
- testl %ecx, %ecx
- je LMsgSendSuperMT
-#endif
-
-// single threaded and receiver is non-nil: search the cache
+// receiver is non-nil: search the cache
CacheLookup WORD_RETURN, MSG_SENDSUPER, LMsgSendSuperCacheMiss
movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
jmp *%eax // goto *imp
@@ -661,32 +711,6 @@ LMsgSendSuperCacheMiss:
movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
jmp *%eax // goto *imp
-#if !defined(OBJC_COLLECTING_CACHE)
-LMsgSendSuperMT:
-// multithreaded: hold _messageLock while accessing cache
- movl $1, %ecx // acquire _messageLock
- LEA_STATIC_DATA %eax, _messageLock, EXTERNAL_SYMBOL
-LMsgSendSuperLockSpin:
- xchgl %ecx, (%eax)
- cmpl $0, %ecx
- jne LMsgSendSuperLockSpin
- movl super(%esp), %eax // restore eax
-
- CacheLookup WORD_RETURN, MSG_SENDSUPER, LMsgSendSuperMTCacheMiss
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
- jmp *%eax // goto *imp
-
-// cache miss: go search the method lists
-LMsgSendSuperMTCacheMiss:
- MethodTableLookup WORD_RETURN, MSG_SENDSUPER
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSend, %edx // flag word-return for _objc_msgForward
- jmp *%eax // goto *imp
-#endif
-
LMsgSendSuperExit:
END_ENTRY _objc_msgSendSuper
@@ -757,14 +781,7 @@ LMsgSendvArgsOK:
testl %eax, %eax
je LMsgSendStretNilSelf
-#if !defined(OBJC_COLLECTING_CACHE)
-// check whether context is multithreaded
- EXTERN_TO_REG_AGAIN(__objc_multithread_mask,%ecx)
- testl %ecx, %ecx
- je LMsgSendStretMT
-#endif
-
-// single threaded and receiver is non-nil: search the cache
+// receiver is non-nil: search the cache
CacheLookup STRUCT_RETURN, MSG_SEND, LMsgSendStretCacheMiss
movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
jmp *%eax // goto *imp
@@ -775,32 +792,6 @@ LMsgSendStretCacheMiss:
movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
jmp *%eax // goto *imp
-#if !defined(OBJC_COLLECTING_CACHE)
-// multithreaded: hold _messageLock while accessing cache
-LMsgSendStretMT:
- movl $1, %ecx // acquire _messageLock
- LEA_STATIC_DATA %eax, _messageLock, EXTERNAL_SYMBOL
-LMsgSendStretLockSpin:
- xchgl %ecx, (%eax)
- cmpl $0, %ecx
- jne LMsgSendStretLockSpin
- movl self_stret(%esp), %eax // restore eax
-
- CacheLookup STRUCT_RETURN, MSG_SEND, LMsgSendStretMTCacheMiss
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
- jmp *%eax // goto *imp
-
-// cache miss: go search the method lists
-LMsgSendStretMTCacheMiss:
- MethodTableLookup STRUCT_RETURN, MSG_SEND
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
- jmp *%eax // goto *imp
-#endif
-
// message sent to nil object: call optional handler and return nil
LMsgSendStretNilSelf:
EXTERN_TO_REG_AGAIN(__objc_msgNil,%eax)
@@ -840,14 +831,7 @@ LMsgSendStretExit:
movl super_stret(%esp), %eax
-#if !defined(OBJC_COLLECTING_CACHE)
-// check whether context is multithreaded
- EXTERN_TO_REG_AGAIN(__objc_multithread_mask,%ecx)
- testl %ecx, %ecx
- je LMsgSendSuperStretMT
-#endif
-
-// single threaded and receiver is non-nil: search the cache
+// receiver is non-nil: search the cache
CacheLookup STRUCT_RETURN, MSG_SENDSUPER, LMsgSendSuperStretCacheMiss
movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
jmp *%eax // goto *imp
@@ -858,32 +842,6 @@ LMsgSendSuperStretCacheMiss:
movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
jmp *%eax // goto *imp
-#if !defined(OBJC_COLLECTING_CACHE)
-LMsgSendStretSuperMT:
-// multithreaded: hold _messageLock while accessing cache
- movl $1, %ecx // acquire _messageLock
- LEA_STATIC_DATA %eax, _messageLock, EXTERNAL_SYMBOL
-LMsgSendSuperStretLockSpin:
- xchgl %ecx, (%eax)
- cmpl $0, %ecx
- jne LMsgSendSuperStretLockSpin
- movl super_stret(%esp), %eax // restore eax
-
- CacheLookup STRUCT_RETURN, MSG_SENDSUPER, LMsgSendSuperStretMTCacheMiss
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
- jmp *%eax // goto *imp
-
-// cache miss: go search the method lists
-LMsgSendSuperStretMTCacheMiss:
- MethodTableLookup MSG_SENDSUPER
- LEA_STATIC_DATA %ecx, _messageLock, EXTERNAL_SYMBOL
- movl $0, (%ecx) // unlock
- movl $kFwdMsgSendStret, %edx // flag struct-return for _objc_msgForward
- jmp *%eax // goto *imp
-#endif
-
LMsgSendSuperStretExit:
END_ENTRY _objc_msgSendSuper_stret
@@ -1043,7 +1001,7 @@ L__objc_msgForwardStret$pic_base:
#endif
pushl %ecx
pushl (self_stret+16)(%esp)
- call _objc_msgSend_stret
+ call _objc_msgSend
movl %ebp,%esp
popl %ebp
ret
View
456 runtime/Messengers.subproj/objc-msg-ppc.s
@@ -49,7 +49,6 @@
* Created from m98k.
********************************************************************/
-#if defined(OBJC_COLLECTING_CACHE)
; _objc_entryPoints and _objc_exitPoints are used by method dispatch
; caching code to figure out whether any threads are actively
; in the cache for dispatching. The labels surround the asm code
@@ -57,6 +56,8 @@
.data
.globl _objc_entryPoints
_objc_entryPoints:
+ .long __cache_getImp
+ .long __cache_getMethod
.long _objc_msgSend
.long _objc_msgSend_stret
.long _objc_msgSendSuper
@@ -69,6 +70,8 @@ _objc_entryPoints:
.globl _objc_exitPoints
_objc_exitPoints:
+ .long LGetImpExit
+ .long LGetMethodExit
.long LMsgSendExit
.long LMsgSendStretExit
.long LMsgSendSuperExit
@@ -78,7 +81,6 @@ _objc_exitPoints:
.long LMsgSendSuperFewExit
.long LMsgSendSuperFewStretExit
.long 0
-#endif
/********************************************************************
*
@@ -157,7 +159,7 @@ EXTERNAL_SYMBOL = 1
#if defined(__DYNAMIC__)
mflr r0
- bl 1f
+ bcl 20,31,1f ; 31 is cr7[so]
1: mflr $0
mtlr r0
.if $2 == EXTERNAL_SYMBOL
@@ -194,7 +196,7 @@ EXTERNAL_SYMBOL = 1
.macro LEA_STATIC_DATA
#if defined(__DYNAMIC__)
mflr r0
- bl 1f
+ bcl 20,31,1f ; 31 is cr7[so]
1: mflr $0
mtlr r0
.if $2 == EXTERNAL_SYMBOL
@@ -291,7 +293,7 @@ $0:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
-; CacheLookup WORD_RETURN | STRUCT_RETURN, MSG_SEND | MSG_SENDSUPER, cacheMissLabel, FEW_ARGS | MANY_ARGS
+; CacheLookup WORD_RETURN | STRUCT_RETURN, MSG_SEND | MSG_SENDSUPER | CACHE_GET, cacheMissLabel, FEW_ARGS | MANY_ARGS
;
; Locate the implementation for a selector in a class method cache.
;
@@ -299,13 +301,20 @@ $0:
; STRUCT_RETURN (r3 is structure return address, r4 is first parameter)
; MSG_SEND (first parameter is receiver)
; MSG_SENDSUPER (first parameter is address of objc_super structure)
+; CACHE_GET (first parameter is class; return method triplet)
;
; cacheMissLabel = label to branch to iff method is not cached
;
; Eats: r0, r11, r12
-; On exit: (found) imp in ctr register
+; On exit: (found) MSG_SEND and MSG_SENDSUPER: return imp in r12 and ctr
+; (found) CACHE_GET: return method triplet in r12
; (not found) jumps to cacheMissLabel
-;
+;
+; For MSG_SEND and MSG_SENDSUPER, the messenger jumps to the imp
+; in ctr. The same imp in r12 is used by the method itself for its
+; relative addressing. This saves the usual "jump to next line and
+; fetch link register" construct inside the method.
+;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Values to specify to method lookup macros whether the return type of
@@ -317,6 +326,7 @@ STRUCT_RETURN = 1
; the method is an integer or structure.
MSG_SEND = 0
MSG_SENDSUPER = 1
+CACHE_GET = 2
; Values to specify to method lookup macros whether this is a "few args" call or not
; (number of args < 5 , including self and _cmd)
@@ -332,30 +342,29 @@ MANY_ARGS = 1
li r7,0 ; no probes so far!
#endif
- stw r8,44(r1) ; save r8
.if $3 == MANY_ARGS
stw r9,48(r1) ; save r9 and r10
stw r10,52(r1) ;
.endif
-; locate the cache
-; Locking idea:
-;LGetMask_$0_$1_$2
-
.if $0 == WORD_RETURN ; WORD_RETURN
.if $1 == MSG_SEND ; MSG_SEND
lwz r12,isa(r3) ; class = receiver->isa
-.else ; MSG_SENDSUPER
+.elseif $1 == MSG_SENDSUPER ; MSG_SENDSUPER
lwz r12,class(r3) ; class = super->class
+.else ; CACHE_GET
+ mr r12,r3 ; class = class
.endif
.else
; STRUCT_RETURN
.if $1 == MSG_SEND ; MSG_SEND
lwz r12,isa(r4) ; class = receiver->isa
-.else ; MSG_SENDSUPER
+.elseif $1 == MSG_SENDSUPER ; MSG_SENDSUPER
lwz r12,class(r4) ; class = super->class
+.else ; CACHE_GET
+ mr r12,r4 ; class = class
.endif
.endif
@@ -365,21 +374,14 @@ MANY_ARGS = 1
#if defined(OBJC_INSTRUMENTED)
mr r6,r12 ; save cache pointer
#endif
- lwz r11,mask(r12) ; mask = cache->mask
-
-; Locking idea
-; lea r0,mask(r12) ; XXX eliminate this by moving the mask to first position
-; lwarx r11,r0 ; mask = reserve(cache->mask)
-; bgt LGetMask_$0_$1_$2 ; if (mask > 0) goto LGetMask // someone already using it
-; neg r11 ; mask = -mask
-; stcwx. r11,r0 ; cache->mask = mask // store positive to mark in use
-; bf LGetMask_$0_$1_$2 ; go to the class and get a possibly new one again
+ lwz r11,mask(r12) ; mask = cache->mask
addi r9,r12,buckets ; buckets = cache->buckets
+ slwi r11,r11,2 ; r11 = mask << 2
.if $0 == WORD_RETURN ; WORD_RETURN
- and r12,r4,r11 ; index = selector & mask
+ and r12,r4,r11 ; bytes = sel & (mask<<2)
.else ; STRUCT_RETURN
- and r12,r5,r11 ; index = selector & mask
+ and r12,r5,r11 ; bytes = sel & (mask<<2)
.endif
#if defined(OBJC_INSTRUMENTED)
@@ -391,17 +393,17 @@ LMiss_$0_$1_$2:
addi r9,r9,1 ;
slwi r9,r9,2 ; tableSize = entryCount * sizeof(entry)
addi r9,r9,buckets ; offset = buckets + tableSize
- add r8,r6,r9 ; cacheData = &cache->buckets[mask+1]
- lwz r9,missCount(r8) ; cacheData->missCount += 1
+ add r11,r6,r9 ; cacheData = &cache->buckets[mask+1]
+ lwz r9,missCount(r11) ; cacheData->missCount += 1
addi r9,r9,1 ;
- stw r9,missCount(r8) ;
- lwz r9,missProbes(r8) ; cacheData->missProbes += probeCount
+ stw r9,missCount(r11) ;
+ lwz r9,missProbes(r11) ; cacheData->missProbes += probeCount
add r9,r9,r7 ;
- stw r9,missProbes(r8) ;
- lwz r9,maxMissProbes(r8) ; if (probeCount > cacheData->maxMissProbes)
+ stw r9,missProbes(r11) ;
+ lwz r9,maxMissProbes(r11) ; if (probeCount > cacheData->maxMissProbes)
cmplw r7,r9 ; maxMissProbes = probeCount
ble .+8 ;
- stw r7,maxMissProbes(r8) ;
+ stw r7,maxMissProbes(r11) ;
lwz r6,36(r1) ; restore r6
lwz r7,40(r1) ; restore r7
@@ -414,8 +416,9 @@ LLoop_$0_$1_$2:
#if defined(OBJC_INSTRUMENTED)
addi r7,r7,1 ; probeCount += 1
#endif
- slwi r0,r12,2 ; convert word index into byte count
- lwzx r10,r9,r0 ; method = cache->buckets[index]
+
+ lwzx r10,r9,r12 ; method = buckets[bytes/4]
+ addi r12,r12,4 ; bytes += 4
cmplwi r10,0 ; if (method == NULL)
#if defined(OBJC_INSTRUMENTED)
beq LMiss_$0_$1_$2
@@ -423,28 +426,25 @@ LLoop_$0_$1_$2:
beq $2 ; goto cacheMissLabel
#endif
- addi r12,r12,1 ; index += 1
- lwz r8,method_name(r10) ; name = method->method_name
- and r12,r12,r11 ; index &= mask
- lwz r10,method_imp(r10) ; imp = method->method_imp
+ lwz r0,method_name(r10) ; name = method->method_name
+ and r12,r12,r11 ; bytes &= (mask<<2)
.if $0 == WORD_RETURN ; WORD_RETURN
- cmplw r8,r4 ; if (name != selector)
+ cmplw r0,r4 ; if (name != selector)
.else ; STRUCT_RETURN
- cmplw r8,r5 ; if (name != selector)
+ cmplw r0,r5 ; if (name != selector)
.endif
bne LLoop_$0_$1_$2 ; goto loop
-; Locking idea
-; clear lock
-; lwz r12,isa(r3) ; XXX or r4 or class(r3/4) - use macro
-; lwz r12,cache(r12)
-; neg r11 ; mask = -mask
-; stwz r11,mask(r12) ; cache->mask = mask // store negative to mark free
-
-
-; cache hit, r10 == method implementation address
+; cache hit, r10 == method triplet address
+.if $1 == CACHE_GET
+ ; return method triplet in r12
+ mr r12,r10
+.else
+ ; return method imp in ctr and r12
+ lwz r10,method_imp(r10) ; imp = method->method_imp
mr r12,r10 ; copy implementation to r12
mtctr r10 ; ctr = imp
+.endif
#if defined(OBJC_INSTRUMENTED)
; r6 = cache, r7 = probeCount
@@ -452,23 +452,22 @@ LLoop_$0_$1_$2:
addi r9,r9,1 ;
slwi r9,r9,2 ; tableSize = entryCount * sizeof(entry)
addi r9,r9,buckets ; offset = buckets + tableSize
- add r8,r6,r9 ; cacheData = &cache->buckets[mask+1]
- lwz r9,hitCount(r8) ; cache->hitCount += 1
+ add r11,r6,r9 ; cacheData = &cache->buckets[mask+1]
+ lwz r9,hitCount(r11) ; cache->hitCount += 1
addi r9,r9,1 ;
- stw r9,hitCount(r8) ;
- lwz r9,hitProbes(r8) ; cache->hitProbes += probeCount
+ stw r9,hitCount(r11) ;
+ lwz r9,hitProbes(r11) ; cache->hitProbes += probeCount
add r9,r9,r7 ;
- stw r9,hitProbes(r8) ;
- lwz r9,maxHitProbes(r8) ; if (probeCount > cache->maxMissProbes)
+ stw r9,hitProbes(r11) ;
+ lwz r9,maxHitProbes(r11) ; if (probeCount > cache->maxMissProbes)
cmplw r7,r9 ;maxMissProbes = probeCount
ble .+8 ;
- stw r7,maxHitProbes(r8) ;
+ stw r7,maxHitProbes(r11) ;
lwz r6,36(r1) ; restore r6
lwz r7,40(r1) ; restore r7
#endif
- lwz r8,44(r1) ; restore r8
.if $3 == MANY_ARGS
lwz r9,48(r1) ; restore r9 and r10
lwz r10,52(r1) ;
@@ -476,19 +475,56 @@ LLoop_$0_$1_$2:
.endmacro
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; CacheLookup cache locking - 2001-11-12
+; The collecting cache mechanism precludes the need for a cache lock
+; in objc_msgSend. The cost of the collecting cache is small: a few
+; K of memory for uncollected caches, and less than 1 ms per collection.
+; A large app will only run collection a few times.
+; Using the code below to lock the cache almost doubles messaging time,
+; costing several seconds of CPU across several minutes of operation.
+; The code below probably could be improved, but almost all of the
+; locking slowdown is in the sync and isync.
+;
+; 40 million message test times (G4 1x667):
+; no lock 4.390u 0.030s 0:04.59 96.2% 0+0k 0+1io 0pf+0w
+; with lock 9.120u 0.010s 0:09.83 92.8% 0+0k 0+0io 0pf+0w
+;
+;; LockCache mask_dest, cache
+;.macro LockCache
+; ; LOCKED mask is NEGATIVE
+; lwarx $0, mask, $1 ; mask = reserve(cache->mask)
+; cmpwi $0, 0 ;
+; blt .-8 ; try again if mask < 0
+; neg r0, $0 ;
+; stwcx. r0, mask, $1 ; cache->mask = -mask ($0 keeps +mask)
+; bne .-20 ; try again if lost reserve
+; isync ; flush prefetched instructions after locking
+;.endmacro
+;
+;; UnlockCache (mask<<2), cache
+;.macro UnlockCache
+; sync ; finish previous instructions before unlocking
+; srwi r0, $0, 2 ; r0 = (mask<<2) >> 2
+; stw r0, mask($1) ; cache->mask = +mask
+;.endmacro
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
; MethodTableLookup WORD_RETURN | STRUCT_RETURN, MSG_SEND | MSG_SENDSUPER, FEW_ARGS | MANY_ARGS
;
-; Takes: WORD_RETURN (r3 is first parameter)
+; Takes: WORD_RETURN (r3 is first parameter)
; STRUCT_RETURN (r3 is structure return address, r4 is first parameter)
; MSG_SEND (first parameter is receiver)
; MSG_SENDSUPER (first parameter is address of objc_super structure)
;
; Eats: r0, r11, r12
-; On exit: restores registers r8 and possibly, r9 and r10, saved by CacheLookup
+; On exit: if MANY_ARGS, restores r9,r10 saved by CacheLookup
; imp in ctr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -500,7 +536,8 @@ HAVE_CALL_EXTERN_lookupMethodAndLoadCache = 0
stw r5, 32(r1) ;
stw r6, 36(r1) ;
stw r7, 40(r1) ;
- ; r8 and possibly, r9 and r10, were saved by CacheLookup
+ stw r8, 44(r1) ;
+ ; if MANY_ARGS, r9 and r10 were saved by CacheLookup
mflr r0 ; save lr
stw r0,8(r1) ;
@@ -585,10 +622,10 @@ HAVE_CALL_EXTERN_lookupMethodAndLoadCache = 1
lwz r5, 32(r1) ;
lwz r6, 36(r1) ;
lwz r7, 40(r1) ;
+ lwz r8, 44(r1) ;
- lwz r8, 44(r1) ; restore leftovers from CacheLookup...
.if $2 == MANY_ARGS
- lwz r9, 48(r1) ;
+ lwz r9, 48(r1) ; restore saves from CacheLookup
lwz r10,52(r1) ;
.endif
@@ -683,6 +720,77 @@ HAVE_CALL_EXTERN_mcount = 1
#endif
.endmacro
+
+/********************************************************************
+ * Method _cache_getMethod(Class cls, SEL sel)
+ *
+ * On entry: r3 = class whose cache is to be searched
+ * r4 = selector to search for
+ *
+ * If found, returns method triplet pointer.
+ * If not found, returns NULL.
+ *
+ * NOTE: _cache_getMethod never returns any cache entry whose implementation
+ * is _objc_msgForward. It returns NULL instead. This prevents thread-
+ * safety and memory management bugs in _class_lookupMethodAndLoadCache.
+ * See _class_lookupMethodAndLoadCache for details.
+ ********************************************************************/
+
+ ENTRY __cache_getMethod
+; do profiling if enabled
+ CALL_MCOUNT
+
+; do lookup
+ CacheLookup WORD_RETURN, CACHE_GET, LGetMethodMiss, MANY_ARGS
+
+; cache hit, method triplet in r12
+; check for _objc_msgForward
+ lwz r11, method_imp(r12) ; get the imp
+ LEA_STATIC_DATA r10, __objc_msgForward, LOCAL_SYMBOL
+ cmplw r11, r10
+ beq LGetMethodMiss ; if (imp==_objc_msgForward) return nil
+ mr r3, r12 ; else return method triplet address
+ blr
+
+LGetMethodMiss:
+; cache miss, return nil
+ li r3, 0 ; return nil
+ blr
+
+LGetMethodExit:
+ END_ENTRY __cache_getMethod
+
+
+/********************************************************************
+ * IMP _cache_getImp(Class cls, SEL sel)
+ *
+ * On entry: r3 = class whose cache is to be searched
+ * r4 = selector to search for
+ *
+ * If found, returns method implementation.
+ * If not found, returns NULL.
+ ********************************************************************/