Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

objc4-371, released with OS X v10.5

  • Loading branch information...
commit 01372de0e3354a12f8855bb21a4f880901472c64 1 parent 2b649a8
@bavarious authored
Showing with 56,905 additions and 25,813 deletions.
  1. +89 −32 Makefile
  2. +222 −100 libobjc.order
  3. +451 −0 markgc.c
  4. +0 −187 objc-exports
  5. +12 −15 runtime/{objc-moninit.c → Accessors.subproj/objc-accessors-arch.s}
  6. +157 −0 runtime/Accessors.subproj/objc-accessors-i386.s
  7. +24 −0 runtime/Accessors.subproj/objc-accessors-ppc.s
  8. +24 −0 runtime/Accessors.subproj/objc-accessors-ppc64.s
  9. +166 −0 runtime/Accessors.subproj/objc-accessors-table.h
  10. +24 −0 runtime/Accessors.subproj/objc-accessors-x86_64.s
  11. +51 −0 runtime/Accessors.subproj/objc-accessors.h
  12. +231 −0 runtime/Accessors.subproj/objc-accessors.m
  13. +60 −4 runtime/Auto.subproj/objc-auto-i386.s
  14. +2 −4 runtime/Auto.subproj/objc-auto-ppc.s
  15. +24 −0 runtime/Auto.subproj/objc-auto-ppc64.s
  16. +78 −0 runtime/Auto.subproj/objc-auto-x86_64.s
  17. +15 −12 runtime/Auto.subproj/objc-auto.s
  18. +256 −220 runtime/Messengers.subproj/objc-msg-i386.s
  19. +150 −108 runtime/Messengers.subproj/objc-msg-ppc.s
  20. +1,434 −0 runtime/Messengers.subproj/objc-msg-ppc64.s
  21. +3 −5 runtime/Messengers.subproj/objc-msg-stub-i386.s
  22. +2 −4 runtime/Messengers.subproj/objc-msg-stub-ppc.s
  23. +57 −0 runtime/Messengers.subproj/objc-msg-stub-ppc64.s
  24. +38 −0 runtime/Messengers.subproj/objc-msg-stub-x86_64.s
  25. +5 −4 runtime/Messengers.subproj/objc-msg-stub.s
  26. +1,279 −0 runtime/Messengers.subproj/objc-msg-x86_64.s
  27. +6 −5 runtime/Messengers.subproj/objc-msg.s
  28. +18 −11 runtime/Object.h
  29. +59 −591 runtime/Object.m
  30. +44 −36 runtime/OldClasses.subproj/List.h
  31. +7 −4 runtime/OldClasses.subproj/List.m
  32. +11 −19 runtime/Protocol.h
  33. +45 −138 runtime/Protocol.m
  34. +9 −4 runtime/error.h
  35. +10 −9 runtime/hashtable2.h
  36. +26 −45 runtime/hashtable2.m
  37. +24 −0 runtime/lookupa.h
  38. +244 −0 runtime/lookupa.m
  39. +8 −7 runtime/maptable.h
  40. +79 −33 runtime/maptable.m
  41. +173 −0 runtime/message.h
  42. +33 −10 runtime/objc-api.h
  43. +73 −16 runtime/objc-auto.h
  44. +588 −764 runtime/objc-auto.m
  45. +1,806 −0 runtime/objc-cache.m
  46. +2,211 −0 runtime/objc-class-old.m
  47. +2 −257 runtime/objc-class.h
  48. +551 −3,465 runtime/objc-class.m
  49. +6 −9 runtime/objc-config.h
  50. +158 −71 runtime/objc-errors.m
  51. +32 −12 runtime/objc-exception.h
  52. +928 −22 runtime/objc-exception.m
  53. +223 −88 runtime/objc-file.m
  54. +32 −0 runtime/objc-initialize.h
  55. +356 −0 runtime/objc-initialize.m
  56. +797 −0 runtime/objc-layout.m
  57. +7 −16 runtime/objc-load.h
  58. +7 −15 runtime/objc-load.m
  59. +37 −0 runtime/objc-loadmethod.h
  60. +353 −0 runtime/objc-loadmethod.m
  61. +148 −0 runtime/objc-lockdebug.m
  62. +569 −191 runtime/objc-private.h
  63. +1 −7 runtime/objc-rtp-sym.s
  64. +8 −11 runtime/objc-rtp.h
  65. +122 −47 runtime/objc-rtp.m
  66. +159 −0 runtime/objc-runtime-new.h
  67. +3,953 −0 runtime/objc-runtime-new.m
  68. +2,834 −0 runtime/objc-runtime-old.m
  69. +2 −200 runtime/objc-runtime.h
  70. +780 −2,480 runtime/objc-runtime.m
  71. +1 −3 runtime/objc-sel-set.h
  72. +1 −3 runtime/objc-sel-set.m
  73. +32,770 −16,423 runtime/objc-sel-table.h
  74. +21 −18 runtime/objc-sel.m
  75. +2 −9 runtime/objc-sync.h
  76. +159 −56 runtime/objc-sync.m
  77. +403 −0 runtime/objc-typeencoding.m
  78. +28 −23 runtime/objc.h
  79. +17 −0 runtime/phash.h
  80. +573 −0 runtime/phash.m
  81. +483 −0 runtime/runtime.h
  82. +54 −0 runtime/standard.h
View
121 Makefile
@@ -28,8 +28,11 @@
default: build
all: build
+test:
+ make -C test
+
.SUFFIXES:
-.PHONY: default all build optimized debug profile installsrc installhdrs install clean prebuild build-optimized build-debug build-profile prebuild-optimized prebuild-debug prebuild-profile compile-optimized compile-debug compile-profile link-optimized link-debug link-profile postbuild
+.PHONY: default all test build optimized debug profile installsrc installhdrs install clean prebuild build-optimized build-debug build-profile prebuild-optimized prebuild-debug prebuild-profile compile-optimized compile-debug compile-profile link-optimized link-debug link-profile postbuild
CURRENT_PROJECT_VERSION = 227
@@ -79,7 +82,7 @@ NMEDIT = /usr/bin/nmedit
LIPO = /usr/bin/lipo
ifeq "$(PLATFORM)" "Darwin"
-WARNING_FLAGS = -Wmost -Wno-four-char-constants
+WARNING_FLAGS = -Wall -Wno-four-char-constants -Wshorten-64-to-32 -Wno-deprecated-declarations
endif
ARCH_LIST=
@@ -104,7 +107,7 @@ ifeq "$(ORDERFILE)" ""
ORDERFILE = $(SRCROOT)/libobjc.order
endif
ifneq "$(ORDERFILE)" ""
-ORDER = -sectorder __TEXT __text $(ORDERFILE)
+ORDER = -Wl,-order_file,$(ORDERFILE)
else
ORDER =
endif
@@ -113,7 +116,7 @@ ifeq "$(USER)" ""
USER = unknown
endif
-CFLAGS = -g -fno-common -fobjc-exceptions -fdollars-in-identifiers -pipe $(PLATFORM_CFLAGS) $(WARNING_FLAGS) -I$(SYMROOT) -I. -I$(SYMROOT)/ProjectHeaders
+CFLAGS = -g -fno-common -fdollars-in-identifiers -pipe $(PLATFORM_CFLAGS) $(WARNING_FLAGS) -I$(SYMROOT) -I. -I$(SYMROOT)/ProjectHeaders
LDFLAGS =
LIBRARY_EXT = .dylib
@@ -126,18 +129,23 @@ ifeq "$(PLATFORM)" "Darwin"
LDFLAGS += -dynamiclib -dynamic -compatibility_version 1 -current_version $(CURRENT_PROJECT_VERSION)
endif
+ifeq "$(PLATFORM)" "Darwin"
+# GC flags
+LDFLAGS += -lauto
+#CFLAGS += -fobjc-gc -Wassign-intercept
+endif
CFLAGS += $(OTHER_CFLAGS) $(RC_CFLAGS)
LDFLAGS += $(OTHER_LDFLAGS)
ifndef OPTIMIZATION_CFLAGS
-OPTIMIZATION_CFLAGS = -Os
+OPTIMIZATION_CFLAGS = -Os -DNDEBUG
endif
ifndef DEBUG_CFLAGS
DEBUG_CFLAGS = -DDEBUG
endif
ifndef PROFILE_CFLAGS
-PROFILE_CFLAGS = -DPROFILE -pg -Os
+PROFILE_CFLAGS = -DPROFILE -pg -Os -DNDEBUG
endif
CFLAGS_OPTIMIZED = $(OPTIMIZATION_CFLAGS) $(CFLAGS)
@@ -148,7 +156,7 @@ LDFLAGS_OPTIMIZED = $(LDFLAGS) -g
LDFLAGS_DEBUG = $(LDFLAGS) -g
LDFLAGS_PROFILE = $(LDFLAGS) -g -pg
-SUBDIRS = . runtime runtime/OldClasses.subproj runtime/Messengers.subproj runtime/Auto.subproj
+SUBDIRS = . runtime runtime/OldClasses.subproj runtime/Messengers.subproj runtime/Accessors.subproj runtime/Auto.subproj
# files to compile
SOURCES=
@@ -165,16 +173,25 @@ 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 \
+ Object.m Protocol.m hashtable2.m maptable.m objc-class.m \
+ objc-errors.m objc-cache.m objc-initialize.m \
+ objc-file.m objc-load.m objc-runtime.m objc-sel.m \
objc-sync.m objc-exception.m objc-auto.m objc-sel-set.m objc-rtp.m \
+ objc-layout.m objc-loadmethod.m objc-class-old.m objc-runtime-old.m \
+ objc-runtime-new.m objc-typeencoding.m objc-lockdebug.m \
+ phash.m lookupa.m \
)
PUBLIC_HEADERS += $(addprefix runtime/, \
- objc-class.h objc-api.h objc-load.h objc-runtime.h objc.h Object.h \
- objc-sync.h objc-exception.h objc-auto.h \
+ objc.h runtime.h message.h \
+ objc-class.h objc-api.h objc-load.h objc-runtime.h Object.h \
+ objc-sync.h objc-exception.h objc-auto.h \
Protocol.h error.h hashtable2.h \
)
-PRIVATE_HEADERS += runtime/objc-private.h runtime/objc-config.h runtime/objc-sel-table.h runtime/objc-sel-set.h runtime/objc-rtp.h
+PRIVATE_HEADERS += $(addprefix runtime/, \
+ objc-private.h objc-config.h objc-sel-table.h objc-sel-set.h \
+ objc-rtp.h objc-initialize.h objc-loadmethod.h objc-runtime-new.h \
+ phash.h lookupa.h standard.h \
+ )
OTHER_HEADERS += runtime/maptable.h runtime/objc-auto.h
# OldClasses
@@ -183,11 +200,17 @@ 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
+OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-ppc.s runtime/Messengers.subproj/objc-msg-ppc64.s runtime/Messengers.subproj/objc-msg-i386.s runtime/Messengers.subproj/objc-msg-x86_64.s
+
+# Property Accessors
+SOURCES += runtime/Accessors.subproj/objc-accessors.m runtime/Accessors.subproj/objc-accessors-arch.s
+PRIVATE_HEADERS += runtime/Accessors.subproj/objc-accessors.h runtime/Accessors.subproj/objc-accessors-table.h
+OTHER_SOURCES += runtime/Accessors.subproj/objc-accessors-ppc.s runtime/Accessors.subproj/objc-accessors-ppc64.s
+OTHER_SOURCES += runtime/Accessors.subproj/objc-accessors-i386.s runtime/Accessors.subproj/objc-accessors-x86_64.s
# Auto support
SOURCES += runtime/Auto.subproj/objc-auto.s
-OTHER_SOURCES += runtime/Auto.subproj/objc-auto-ppc.s runtime/Auto.subproj/objc-auto-i386.s
+OTHER_SOURCES += runtime/Auto.subproj/objc-auto-ppc.s runtime/Auto.subproj/objc-auto-ppc64.s runtime/Auto.subproj/objc-auto-i386.s runtime/Auto.subproj/objc-auto-x86_64.s
# RTP symbols for gdb
# See also $(OBJROOT)/runtime/objc-rtp-sym.ppc.o rule below.
@@ -197,10 +220,15 @@ OTHER_SOURCES += runtime/objc-rtp-sym.s
# This code is built into a second module so dyld's function interposing
# can manipulate the calls.
MODULE_SOURCES += runtime/Messengers.subproj/objc-msg-stub.s
-OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-stub-ppc.s runtime/Messengers.subproj/objc-msg-stub-i386.s
+OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-stub-ppc.s runtime/Messengers.subproj/objc-msg-stub-ppc64.s runtime/Messengers.subproj/objc-msg-stub-i386.s runtime/Messengers.subproj/objc-msg-stub-x86_64.s
# project root
-OTHER_SOURCES += Makefile APPLE_LICENSE objc-exports libobjc.order
+OTHER_SOURCES += Makefile APPLE_LICENSE libobjc.order
+
+# The GC Mark tool that marks our .o files as if they had been compiled with write-barriers
+OTHER_SOURCES += markgc.c
+MARKGC = $(OBJROOT)/markgc
+
OBJECTS = $(addprefix $(OBJROOT)/, $(addsuffix .o, $(basename $(SOURCES) ) ) )
OBJECTS_OPTIMIZED = $(OBJECTS:.o=.opt.o)
@@ -217,41 +245,44 @@ MODULE_OBJECTS_PROFILE = $(MODULE_OBJECTS:.o=.profile.o)
DEPEND_HEADERS = $(addprefix $(SRCROOT)/, \
$(PUBLIC_HEADERS) $(PRIVATE_HEADERS) $(OTHER_HEADERS) )
-$(OBJROOT)/%.opt.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+$(OBJROOT)/%.opt.o : $(SRCROOT)/%.m $(DEPEND_HEADERS) $(MARKGC)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+ $(SILENT) $(MARKGC) -p "$@"
-$(OBJROOT)/%.debug.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+$(OBJROOT)/%.debug.o : $(SRCROOT)/%.m $(DEPEND_HEADERS) $(MARKGC)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+ $(SILENT) $(MARKGC) -p "$@"
-$(OBJROOT)/%.profile.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
+$(OBJROOT)/%.profile.o : $(SRCROOT)/%.m $(DEPEND_HEADERS) $(MARKGC)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+ $(SILENT) $(MARKGC) -p "$@"
$(OBJROOT)/%.opt.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
$(OBJROOT)/%.debug.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_DEBUG) "$<" -c -o "$@"
$(OBJROOT)/%.profile.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_PROFILE) "$<" -c -o "$@"
$(OBJROOT)/%.opt.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
$(OBJROOT)/%.debug.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_DEBUG) "$<" -c -o "$@"
$(OBJROOT)/%.profile.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
$(SILENT) $(ECHO) " ... $<"
- $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
+ $(SILENT) $(CC) $(ARCH_FLAGS) $(CFLAGS_PROFILE) "$<" -c -o "$@"
# Additional dependency: objc-msg.s depends on objc-msg-ppc.s and
# objc-msg-i386.s, which it includes.
@@ -259,7 +290,9 @@ $(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
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-ppc64.s \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-i386.s \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-x86_64.s
# Additional dependency: objc-msg-sutb.s depends on objc-msg-stub-ppc.s and
# objc-msg-stub-i386.s, which it includes.
@@ -267,7 +300,9 @@ $(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.opt.o \
$(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.debug.o \
$(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.profile.o : \
$(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-ppc.s \
- $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-i386.s
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-ppc64.s \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-i386.s \
+ $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-x86_64.s
# Additional dependency: objc-auto.s depends on objc-auto-ppc.s and
# objc-auto-i386.s, which it includes.
@@ -275,7 +310,9 @@ $(OBJROOT)/runtime/Auto.subproj/objc-auto.opt.o \
$(OBJROOT)/runtime/Auto.subproj/objc-auto.debug.o \
$(OBJROOT)/runtime/Auto.subproj/objc-auto.profile.o : \
$(SRCROOT)/runtime/Auto.subproj/objc-auto-ppc.s \
- $(SRCROOT)/runtime/Auto.subproj/objc-auto-i386.s
+ $(SRCROOT)/runtime/Auto.subproj/objc-auto-ppc64.s \
+ $(SRCROOT)/runtime/Auto.subproj/objc-auto-i386.s \
+ $(SRCROOT)/runtime/Auto.subproj/objc-auto-x86_64.s
# Additional rules: objc-rtp-sym.s needs to be built with a per-arch seg1addr,
# and need to be stripped here because stripping the dylib does not remove
@@ -286,11 +323,29 @@ $(OBJROOT)/runtime/objc-rtp-sym.ppc.o: $(SRCROOT)/runtime/objc-rtp-sym.s
$(SILENT) $(STRIP) -S "$@.temp"
$(SILENT) $(LD) -arch ppc -seg1addr 0xfffec000 "$@.temp" -r -o "$@"
+$(OBJROOT)/runtime/objc-rtp-sym.ppc64.o: $(SRCROOT)/runtime/objc-rtp-sym.s
+ $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) -arch ppc64 "$<" -c -o "$@.temp"
+ $(SILENT) $(STRIP) -S "$@.temp"
+ $(SILENT) $(LD) -arch ppc64 -seg1addr 0xfffffffffffec000 "$@.temp" -r -o "$@"
+
$(OBJROOT)/runtime/objc-rtp-sym.i386.o: $(SRCROOT)/runtime/objc-rtp-sym.s
$(SILENT) $(CC) $(CFLAGS_OPTIMIZED) -arch i386 "$<" -c -o "$@.temp"
$(SILENT) $(STRIP) -S "$@.temp"
$(SILENT) $(LD) -arch i386 -seg1addr 0xfffe8000 "$@.temp" -r -o "$@"
+$(OBJROOT)/runtime/objc-rtp-sym.x86_64.o: $(SRCROOT)/runtime/objc-rtp-sym.s
+ $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) -arch x86_64 "$<" -c -o "$@.temp"
+ $(SILENT) $(STRIP) -S "$@.temp"
+ $(SILENT) $(LD) -arch x86_64 -seg1addr 0xfffffffffffec000 "$@.temp" -r -o "$@"
+
+# Additional rule: markgc tool to pretend we compiled with GC write-barriers
+$(MARKGC): $(SRCROOT)/markgc.c
+ $(SILENT) $(ECHO) "Building markgc tool ..."
+ $(SILENT) $(CC) -std=gnu99 "$<" -o "$@"
+
+# Additional linkage: LP64 targets require libstdc++
+LIBS_ppc64 = -lstdc++
+LIBS_x86_64 = -lstdc++
# These are the main targets:
# build builds the library to OBJROOT and SYMROOT
@@ -411,6 +466,8 @@ clean:
$(SILENT) $(REMOVE) -rf $(SYMROOT)/ProjectHeaders
+ $(SILENT) $(REMOVE) -f $(MARKGC)
+
prebuild:
$(SILENT) $(ECHO) "Prebuild-setup..."
@@ -462,7 +519,7 @@ define link
$3 ; \
$(SILENT) $(CC) $2 \
-arch $A \
- -Wl,-exported_symbols_list,$(SRCROOT)/objc-exports \
+ $(LIBS_$(A)) \
$(ORDER) \
-sectcreate __DATA __commpage $(OBJROOT)/runtime/objc-rtp-sym.$A.o \
-install_name /$(INSTALLDIR)/libobjc$1.$(VERSION_NAME)$(LIBRARY_EXT) \
View
322 libobjc.order
@@ -1,135 +1,257 @@
-__objc_notify_images
-___i686.get_pc_thunk.bx
+__objc_init
_map_images
+_sel_registerName
+___sel_registerName
+__objc_search_builtins
+_phash
+_lookup
+_exception_init
+__getImageSlide
+__getObjcImageInfo
_getsegbynamefromheader
-___i686.get_pc_thunk.cx
+__getObjcModules
+__malloc_internal
+__objc_internal_zone
_verify_gc_readiness
-_objc_msgSend
-__class_lookupMethodAndLoadCache
-_class_initialize
-_objc_getClass
-_look_up_class
+_gc_init
+_rtp_init
+__read_images
+__objc_init_class_hash
+_NXCreateHashTableFromZone
_NXHashGet
+_hashPrototype
+_isEqualPrototype
+_NXHashInsert
+__NXHashRehashToCapacity
+_freeBuckets
+_NXNoEffectFree
+_log2u
+__NXHashCapacity
+__class_hasLoadMethod
+__class_getLoadMethod_nocheck
_classHash
+__class_getName
+_resolve_categories_for_class
+_lookupNamedMethodInMethodList
_classIsEqual
+_objc_lookUpClass
+_look_up_class
+__objc_insertMethods
+__calloc_internal
+__class_clearInfo
__class_changeInfo
-__fetchInitializingClassList
-__cache_getMethod
-_fixupSelectorsInMethodList
-__malloc_internal
-__objc_internal_zone
+__class_setInfo
+__class_addProperties
+__memdup_internal
+_allocateExt
+_connect_class
+_class_is_connected
+_NXHashMember
+_really_connect_class
+_set_superclass
+_NXHashRemove
+_NXCountHashTable
+_NXFreeHashTable
+__getObjcClassRefs
+__getObjcSelectorRefs
_sel_lock
_sel_registerNameNoLock
-___sel_registerName
-__objc_search_builtins
-___objc_sel_set_get
-___objc_sel_set_findBuckets
+___objc_sel_set_create
___objc_sel_set_add
+___objc_sel_set_findBuckets
+___objc_sel_set_get
_sel_unlock
+_objc_getClass
+_NXCreateMapTableFromZone
+_NXCreateHashTable
+_NXPtrHash
+__getObjcProtocols
+__getObjcClassNames
+_map_method_descs
+_NXMapGet
+__mapStrHash
+_NXMapKeyCopyingInsert
+__strdup_internal
+_NXMapInsert
+__mapStrIsEqual
+__mapPtrHash
+__mapPtrIsEqual
+__NXMapRehash
+__free_internal
+_load_images
+_prepare_load_methods
+_schedule_class_load
+_add_class_to_loadable_list
+__class_getLoadMethod
+_call_load_methods
+__realloc_internal
+_add_category_to_loadable_list
+__category_getLoadMethod
+_object_getClass
+_protocol_copyMethodDescriptionList
+_class_getClassMethod
+__class_getMeta
+_look_up_method
+__class_getMethod
+_fixupSelectorsInMethodList
+_method_getTypeEncoding
+_method_getImplementation
+_method_getName
+_class_addMethod
+__class_addMethod
+_flush_caches
+__cache_flush
+__class_getCache
+_class_getInstanceMethod
+_class_replaceMethod
+_method_setImplementation
+_class_addProtocol
+_objc_exception_get_functions
+_objc_exception_set_functions
+_objc_setForwardHandler
+_objc_setEnumerationMutationHandler
+_objc_collecting_enabled
+_objc_getFutureClass
+_objc_setFutureClass
+_setOriginalClassForFutureClass
+_change_class_references
+_NXInitHashState
+_NXNextHashState
+__objc_headerStart
+_objc_msgSend
+__class_lookupMethodAndLoadCache
+__class_getFreedObjectClass
+__class_getNonexistentObjectClass
+__class_isInitialized
+__class_initialize
+__class_isMetaClass
+__class_getSuperclass
+__class_isInitializing
+__class_setInitializing
+__fetchInitializingClassList
+__objc_fetch_pthread_data
+__cache_getMethod
+__class_getMethodNoSuper
+_log_and_fill_cache
__cache_fill
+_objc_assign_global
+_class_setVersion
+__class_setInitialized
__cache_getImp
-__cache_create
__cache_malloc
-__calloc_internal
-_objc_assign_global
-_objc_collecting_enabled
+__class_setCache
+__class_setGrowCache
+_class_getInstanceSize
+__class_getInstanceSize
+_class_createInstanceFromZone
+__objc_warn_deprecated
__internal_class_createInstanceFromZone
_object_cxxConstructFromClass
+__class_hasCxxStructorsNoSuper
_object_getClassName
+_object_getIndexedIvars
+_objc_assign_strongCast
+__class_shouldGrowCache
+_class_createInstance
+__internal_class_createInstance
_objc_msgSendSuper
_objc_assign_ivar
-dyld_stub_binding_helper
__cache_collect_free
-_sel_registerName
+_class_getSuperclass
+__category_getClass
+__class_isLoadable
+_object_dispose
__internal_object_dispose
-_object_cxxDestruct
_object_cxxDestructFromClass
__objc_getFreedObjectClass
_objc_exception_try_enter
_objc_exception_try_exit
-__strdup_internal
-_class_respondsToMethod
+_class_getVersion
+_class_respondsToSelector
+__class_resolveMethod
__cache_addForwardEntry
-_objc_assign_strongCast
-_objc_msgSend_stret
_objc_msgSend_fpret
-_class_getInstanceMethod
-_objc_memmove_collectable
--[Protocol descriptionForInstanceMethod:]
-_class_nextMethodList
-_objc_getOrigClass
-_NXMapGet
-__mapStrHash
-__free_internal
-_NXUniqueString
-_NXCreateHashTable
-_NXCreateHashTableFromZone
-_hashPrototype
-_isEqualPrototype
-_NXHashInsert
-__NXHashRehashToCapacity
-_freeBuckets
-_NXNoEffectFree
-_NXStrHash
-_NXStrIsEqual
-_class_poseAs
-__objc_addOrigClass
-__mapStrIsEqual
-_NXMapInsert
-_objc_getClasses
-_NXHashRemove
-__mapPtrHash
-_NXInitHashState
-_NXNextHashState
-__objc_headerStart
-__getObjcClassRefs
-_sel_getName
-_object_setInstanceVariable
-_class_getInstanceVariable
-_objc_setMultithreaded
--[Object self]
-__objc_defaultClassHandler
-_class_lookupMethod
-__internal_object_copyFromZone
-__objc_msgForward
-_objc_msgSendv
-_objc_loadModule
-__getObjcModules
-__getObjcImageInfo
-__getImageSlide
-__NXHashCapacity
-_lookupNamedMethodInMethodList
-_log2
-_resolve_categories_for_class
-_connect_class
-_class_is_connected
-_NXHashMember
-_really_connect_class
-_NXCountHashTable
-_NXFreeHashTable
-__objc_fixup_selector_refs
-__getObjcMessageRefs
-__getObjcProtocols
-+[Protocol _fixup:numElements:]
--[Protocol conformsTo:]
-__objc_insertMethods
-__objc_flush_caches
-_flush_caches
-_objc_getClassList
-__realloc_internal
-__cache_flush
-__class_setInfo
-__class_clearInfo
-_map_method_descs
-_objc_msgSendSuper_stret
-_cache_region_calloc
-_objc_msgSendv_stret
_objc_sync_enter
_id2data
+_fetch_cache
+_class_getImageName
+__objc_getOrigClass
+_class_getName
_objc_sync_exit
-__mapPtrIsEqual
+_objc_finalizeOnMainThread
+__cache_free_block
+_class_conformsToProtocol
+_protocol_conformsToProtocol
++[Object initialize]
+_object_setInstanceVariable
+__class_getVariable
+_ivar_getOffset
+_gc_enforcer
+_flush_marked_caches
+_class_getMethodImplementation
+_objc_setProperty
+_objc_assign_weak
+_objc_read_weak
+_objc_allocateClassPair
+__objc_defaultClassHandler
+_objc_registerClassPair
+_NXHashInsertIfAbsent
+_method_getNumberOfArguments
+_encoding_getNumberOfArguments
+_SkipFirstType
+_method_copyArgumentType
+_encoding_copyArgumentType
+_encoding_getArgumentInfo
+_method_copyReturnType
+_encoding_copyReturnType
+_objc_getProperty
+_cache_region_calloc
+_class_copyProtocolList
+_class_isMetaClass
+_protocol_getMethodDescription
+_lookup_protocol_method
+_method_getDescription
+_sel_getName
__objc_pthread_destroyspecific
__destroyInitializingClassList
+__destroyLockList
+__destroySyncCache
+__destroyAltHandlerList
+_objc_msgSend_stret
+_objc_is_finalized
+_class_getInstanceVariable
+_objc_msgSendSuper_stret
+__objc_msgForward
+_objc_memmove_collectable
+_objc_atomicCompareAndSwapInstanceVariableBarrier
+_object_setClass
+_flush_cache
+_objc_atomicCompareAndSwapGlobalBarrier
+_ivar_getTypeEncoding
+_class_getProperty
+_property_list_nth
+_property_getAttributes
+_object_copyFromZone
+__internal_object_copyFromZone
+_class_copyIvarList
+_ivar_getName
__objcInit
+_objc_copyStruct
+_objc_sync_nil
+_objc_getClassList
+_objc_copyImageNames
+_objc_copyClassNamesForImage
+__objc_copyClassNamesForImage
+_objc_setMultithreaded
+_sel_getUid
+_class_poseAs
+__objc_addOrigClass
+_objc_exception_throw
_objc_exception_extract
_objc_exception_match
+_object_getIvar
+_object_setIvar
+_method_invoke
+_unmap_image
+_class_copyPropertyList
+_property_getName
View
451 markgc.c
@@ -0,0 +1,451 @@
+/*
+ * Copyright (c) 2007 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#import <stdio.h>
+#include <fcntl.h>
+#import <sys/stat.h>
+#import <mach-o/fat.h>
+#import <mach-o/arch.h>
+#import <mach-o/loader.h>
+
+typedef char bool;
+#define true 1
+#define false 0
+
+bool debug;
+bool verbose;
+bool quiet;
+bool rrOnly;
+bool patch = true;
+
+struct gcinfo {
+ bool hasObjC;
+ bool hasInfo;
+ uint32_t flags;
+ char *arch;
+} GCInfo[4];
+
+void dumpinfo(char *filename);
+
+int Errors = 0;
+char *FileBase;
+size_t FileSize;
+const char *FileName;
+
+int main(int argc, char *argv[]) {
+ //NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ int i;
+ //dumpinfo("/System/Library/Frameworks/AppKit.framework/AppKit");
+ if (argc == 1) {
+ printf("Usage: gcinfo [-v] [-r] [--] library_or_executable_image [image2 ...]\n");
+ printf(" prints Garbage Collection readiness of named images, ignoring those without ObjC segments\n");
+ printf(" 'GC' - compiled with write-barriers, presumably otherwise aware\n");
+ printf(" 'RR' - retain/release (presumed) aware for non-GC\n");
+ printf(" 'GC-only' - compiled with write-barriers and marked at compile time as not being retain/release savvy\n");
+ printf(" -v - provide archtectural details\n");
+ printf(" -r - only show libraries that are non-GC, e.g. RR only\n");
+ printf(" -- - read files & directories from stdin, e.g. find /Plug-ins | gcinfo --\n");
+ printf("\nAuthor: blaine@apple.com\n");
+ exit(0);
+ }
+ for (i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "-v")) {
+ verbose = true;
+ continue;
+ }
+ if (!strcmp(argv[i], "-d")) {
+ debug = true;
+ continue;
+ }
+ if (!strcmp(argv[i], "-q")) {
+ quiet = true;
+ continue;
+ }
+ if (!strcmp(argv[i], "-r")) {
+ quiet = true;
+ rrOnly = true;
+ continue;
+ }
+ if (!strcmp(argv[i], "-p")) {
+ patch = true;
+ continue;
+ }
+ if (!strcmp(argv[i], "--")) {
+ char buf[1024];
+ while (fgets(buf, 1024, stdin)) {
+ int len = strlen(buf);
+ buf[len-1] = 0;
+ dumpinfo(buf);
+ }
+ continue;
+ }
+ dumpinfo(argv[i]);
+ }
+ return Errors;
+}
+
+struct imageInfo {
+ uint32_t version;
+ uint32_t flags;
+};
+
+void patchFile(uint32_t value, size_t offset) {
+ int fd = open(FileName, 1);
+ off_t lresult = lseek(fd, offset, SEEK_SET);
+ if (lresult == -1) {
+ printf("couldn't seek to %x position on fd %d\n", offset, fd);
+ ++Errors;
+ return;
+ }
+ int wresult = write(fd, &value, 4);
+ if (wresult != 4) {
+ ++Errors;
+ printf("didn't write new value\n");
+ }
+ else {
+ printf("patched %s at offset %p\n", FileName, offset);
+ }
+ close(fd);
+}
+
+uint32_t iiflags(struct imageInfo *ii, uint32_t size, bool needsFlip) {
+ if (needsFlip) {
+ ii->flags = OSSwapInt32(ii->flags);
+ }
+ if (debug) printf("flags->%x, nitems %d\n", ii->flags, size/sizeof(struct imageInfo));
+ uint32_t flags = ii->flags;
+ if (patch && (flags&0x2)==0) {
+ //printf("will patch %s at offset %p\n", FileName, (char*)(&ii->flags) - FileBase);
+ uint32_t newvalue = flags | 0x2;
+ if (needsFlip) newvalue = OSSwapInt32(newvalue);
+ patchFile(newvalue, (char*)(&ii->flags) - FileBase);
+ }
+ for(int niis = 1; niis < size/sizeof(struct imageInfo); ++niis) {
+ if (needsFlip) ii[niis].flags = OSSwapInt32(ii[niis].flags);
+ if (ii[niis].flags != flags) {
+ // uh, oh.
+ printf("XXX ii[%d].flags %x != ii[0].flags %x\n", niis, ii[niis].flags, flags);
+ ++Errors;
+ }
+ }
+ return flags;
+}
+
+void printflags(uint32_t flags) {
+ if (flags & 0x1) printf(" F&C");
+ if (flags & 0x2) printf(" GC");
+ if (flags & 0x4) printf(" GC-only");
+ else printf(" RR");
+}
+
+/*
+void doimageinfo(struct imageInfo *ii, uint32_t size, bool needsFlip) {
+ uint32_t flags = iiflags(ii, size, needsFlip);
+ printflags(flags);
+}
+*/
+
+
+void dosect32(void *start, struct section *sect, bool needsFlip, struct gcinfo *gcip) {
+ if (debug) printf("section %s from segment %s\n", sect->sectname, sect->segname);
+ if (strcmp(sect->segname, "__OBJC")) return;
+ gcip->hasObjC = true;
+ if (strcmp(sect->sectname, "__image_info")) return;
+ gcip->hasInfo = true;
+ if (needsFlip) {
+ sect->offset = OSSwapInt32(sect->offset);
+ sect->size = OSSwapInt32(sect->size);
+ }
+ // these guys aren't inline - they point elsewhere
+ gcip->flags = iiflags(start + sect->offset, sect->size, needsFlip);
+}
+
+void dosect64(void *start, struct section_64 *sect, bool needsFlip, struct gcinfo *gcip) {
+ if (debug) printf("section %s from segment %s\n", sect->sectname, sect->segname);
+ if (strcmp(sect->segname, "__OBJC") && strcmp(sect->segname, "__DATA")) return;
+ if (strcmp(sect->sectname, "__image_info") && strncmp(sect->sectname, "__objc_imageinfo", 16)) return;
+ gcip->hasObjC = true;
+ gcip->hasInfo = true;
+ if (needsFlip) {
+ sect->offset = OSSwapInt32(sect->offset);
+ sect->size = OSSwapInt64(sect->size);
+ }
+ // these guys aren't inline - they point elsewhere
+ gcip->flags = iiflags(start + sect->offset, sect->size, needsFlip);
+}
+
+void doseg32(void *start, struct segment_command *seg, bool needsFlip, struct gcinfo *gcip) {
+ // lets do sections
+ if (needsFlip) {
+ seg->fileoff = OSSwapInt32(seg->fileoff);
+ seg->nsects = OSSwapInt32(seg->nsects);
+ }
+ if (debug) printf("segment name: %s, nsects %d\n", seg->segname, seg->nsects);
+ if (seg->segname[0]) {
+ if (strcmp("__OBJC", seg->segname)) return;
+ }
+ int nsects;
+ struct section *sect = (struct section *)(seg + 1);
+ for (int nsects = 0; nsects < seg->nsects; ++nsects) {
+ // sections directly follow
+
+ dosect32(start, sect + nsects, needsFlip, gcip);
+ }
+}
+void doseg64(void *start, struct segment_command_64 *seg, bool needsFlip, struct gcinfo *gcip) {
+ if (debug) printf("segment name: %s\n", seg->segname);
+ if (seg->segname[0] && strcmp("__OBJC", seg->segname) && strcmp("__DATA", seg->segname)) return;
+ gcip->hasObjC = true;
+ // lets do sections
+ if (needsFlip) {
+ seg->fileoff = OSSwapInt64(seg->fileoff);
+ seg->nsects = OSSwapInt32(seg->nsects);
+ }
+ int nsects;
+ struct section_64 *sect = (struct section_64 *)(seg + 1);
+ for (int nsects = 0; nsects < seg->nsects; ++nsects) {
+ // sections directly follow
+
+ dosect64(start, sect + nsects, needsFlip, gcip);
+ }
+}
+
+#if 0
+/*
+ * A variable length string in a load command is represented by an lc_str
+ * union. The strings are stored just after the load command structure and
+ * the offset is from the start of the load command structure. The size
+ * of the string is reflected in the cmdsize field of the load command.
+ * Once again any padded bytes to bring the cmdsize field to a multiple
+ * of 4 bytes must be zero.
+ */
+union lc_str {
+ uint32_t offset; /* offset to the string */
+#ifndef __LP64__
+ char *ptr; /* pointer to the string */
+#endif
+};
+
+struct dylib {
+ union lc_str name; /* library's path name */
+ uint32_t timestamp; /* library's build time stamp */
+ uint32_t current_version; /* library's current version number */
+ uint32_t compatibility_version; /* library's compatibility vers number*/
+};
+
+ * A dynamically linked shared library (filetype == MH_DYLIB in the mach header)
+ * contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library.
+ * An object that uses a dynamically linked shared library also contains a
+ * dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or
+ * LC_REEXPORT_DYLIB) for each library it uses.
+
+struct dylib_command {
+ uint32_t cmd; /* LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB,
+ LC_REEXPORT_DYLIB */
+ uint32_t cmdsize; /* includes pathname string */
+ struct dylib dylib; /* the library identification */
+};
+#endif
+
+void dodylib(void *start, struct dylib_command *dylibCmd, bool needsFlip) {
+ if (!verbose) return;
+ if (needsFlip) {
+ }
+ int count = dylibCmd->cmdsize - sizeof(struct dylib_command);
+ //printf("offset is %d, count is %d\n", dylibCmd->dylib.name.offset, count);
+ if (dylibCmd->dylib.name.offset > count) return;
+ //printf("-->%.*s<---", count, ((void *)dylibCmd)+dylibCmd->dylib.name.offset);
+ if (verbose) printf("load %s\n", ((void *)dylibCmd)+dylibCmd->dylib.name.offset);
+}
+
+struct load_command *doloadcommand(void *start, struct load_command *lc, bool needsFlip, bool is32, struct gcinfo *gcip) {
+ if (needsFlip) {
+ lc->cmd = OSSwapInt32(lc->cmd);
+ lc->cmdsize = OSSwapInt32(lc->cmdsize);
+ }
+
+ switch(lc->cmd) {
+ case LC_SEGMENT_64:
+ if (debug) printf("...segment64\n");
+ if (is32) printf("XXX we have a 64-bit segment in a 32-bit mach-o\n");
+ doseg64(start, (struct segment_command_64 *)lc, needsFlip, gcip);
+ break;
+ case LC_SEGMENT:
+ if (debug) printf("...segment32\n");
+ doseg32(start, (struct segment_command *)lc, needsFlip, gcip);
+ break;
+ case LC_SYMTAB: if (debug) printf("...dynamic symtab\n"); break;
+ case LC_DYSYMTAB: if (debug) printf("...symtab\n"); break;
+ case LC_LOAD_DYLIB:
+ dodylib(start, (struct dylib_command *)lc, needsFlip);
+ break;
+ case LC_SUB_UMBRELLA: if (debug) printf("...load subumbrella\n"); break;
+ default: if (debug) printf("cmd is %x\n", lc->cmd); break;
+ }
+
+ return (struct load_command *)((void *)lc + lc->cmdsize);
+}
+
+void doofile(void *start, uint32_t size, struct gcinfo *gcip) {
+ struct mach_header *mh = (struct mach_header *)start;
+ bool isFlipped = false;
+ if (mh->magic == MH_CIGAM || mh->magic == MH_CIGAM_64) {
+ if (debug) printf("(flipping)\n");
+ mh->magic = OSSwapInt32(mh->magic);
+ mh->cputype = OSSwapInt32(mh->cputype);
+ mh->cpusubtype = OSSwapInt32(mh->cpusubtype);
+ mh->filetype = OSSwapInt32(mh->filetype);
+ mh->ncmds = OSSwapInt32(mh->ncmds);
+ mh->sizeofcmds = OSSwapInt32(mh->sizeofcmds);
+ mh->flags = OSSwapInt32(mh->flags);
+ isFlipped = true;
+ }
+ if (rrOnly && mh->filetype != 6) return; // ignore executables
+ NXArchInfo *info = (NXArchInfo *)NXGetArchInfoFromCpuType(mh->cputype, mh->cpusubtype);
+ //printf("%s:", info->description);
+ gcip->arch = (char *)info->description;
+ //if (debug) printf("...description is %s\n", info->description);
+ bool is32 = (mh->cputype == 18 || mh->cputype == 7);
+ if (debug) printf("is 32? %d\n", is32);
+ if (debug) printf("filetype -> %d\n", mh->filetype);
+ if (debug) printf("ncmds -> %d\n", mh->ncmds);
+ struct load_command *lc = (is32 ? (struct load_command *)(mh + 1) : (struct load_command *)((struct mach_header_64 *)start + 1));
+ int ncmds;
+ for (ncmds = 0; ncmds < mh->ncmds; ++ncmds) {
+ lc = doloadcommand(start, lc, isFlipped, is32, gcip);
+ }
+ //printf("\n");
+}
+
+void initGCInfo() {
+ bzero((void *)GCInfo, sizeof(GCInfo));
+}
+
+void printGCInfo(char *filename) {
+ if (!GCInfo[0].hasObjC) return; // don't bother
+ // verify that flags are all the same
+ uint32_t flags = GCInfo[0].flags;
+ bool allSame = true;
+ for (int i = 1; i < 4 && GCInfo[i].arch; ++i) {
+ if (flags != GCInfo[i].flags) {
+ allSame = false;
+ }
+ }
+ if (rrOnly) {
+ if (allSame && (flags & 0x2))
+ return;
+ printf("*** not all GC in %s:\n", filename);
+ }
+ if (allSame && !verbose) {
+ printf("%s:", filename);
+ printflags(flags);
+ printf("\n");
+ }
+ else {
+ printf("%s:\n", filename);
+ for (int i = 0; i < 4 && GCInfo[i].arch; ++i) {
+ printf("%s:", GCInfo[i].arch);
+ printflags(GCInfo[i].flags);
+ printf("\n");
+ }
+ printf("\n");
+ }
+}
+
+void dofat(void *start) {
+ struct fat_header *fh = start;
+ bool needsFlip = false;
+ if (fh->magic == FAT_CIGAM) {
+ fh->nfat_arch = OSSwapInt32(fh->nfat_arch);
+ needsFlip = true;
+ }
+ if (debug) printf("%d architectures\n", fh->nfat_arch);
+ int narchs;
+ struct fat_arch *arch_ptr = (struct fat_arch *)(fh + 1);
+ for (narchs = 0; narchs < fh->nfat_arch; ++narchs) {
+ if (needsFlip) {
+ arch_ptr->offset = OSSwapInt32(arch_ptr->offset);
+ arch_ptr->size = OSSwapInt32(arch_ptr->size);
+ }
+ doofile(start+arch_ptr->offset, arch_ptr->size, &GCInfo[narchs]);
+ arch_ptr++;
+ }
+}
+
+bool openFile(const char *filename) {
+ FileName = filename;
+ // get size
+ struct stat statb;
+ int fd = open(filename, 0);
+ if (fd < 0) {
+ printf("couldn't open %s for reading\n", filename);
+ return false;
+ }
+ int osresult = fstat(fd, &statb);
+ if (osresult != 0) {
+ printf("couldn't get size of %s\n", filename);
+ close(fd);
+ return false;
+ }
+ FileSize = statb.st_size;
+ FileBase = malloc(FileSize);
+ if (!FileBase) {
+ printf("couldn't malloc %d bytes\n", FileSize);
+ close(fd);
+ return false;
+ }
+ off_t readsize = read(fd, FileBase, FileSize);
+ if (readsize != FileSize) {
+ printf("read %d bytes, wanted %d\n", readsize, FileSize);
+ close(fd);
+ return false;
+ }
+ close(fd);
+ return true;
+}
+
+void closeFile() {
+ free(FileBase);
+}
+
+void dumpinfo(char *filename) {
+ initGCInfo();
+ openFile(filename);
+ struct fat_header *fh = (struct fat_header *)FileBase;
+ if (fh->magic == FAT_MAGIC || fh->magic == FAT_CIGAM) {
+ dofat((void *)FileBase);
+ //printGCInfo(filename);
+ }
+ else if (fh->magic == MH_MAGIC || fh->magic == MH_CIGAM || fh->magic == MH_MAGIC_64 || fh->magic == MH_CIGAM_64) {
+ doofile((void *)FileBase, FileSize, &GCInfo[0]);
+ //printGCInfo(filename);
+ }
+ else if (!quiet) {
+ printf("don't understand %s!\n", filename);
+ }
+ closeFile();
+ }
+
View
187 objc-exports
@@ -1,187 +0,0 @@
-# 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-auto.h - actually, everything possible for now
-_objc_collect
-_objc_collect_generation
-_objc_numberAllocated
-_objc_isAuto
-_objc_collecting_enabled
-_objc_allocate_object
-_objc_assign_strongCast
-_objc_assign_global
-_objc_assign_ivar
-_objc_assign_strongCast_generic
-_objc_assign_global_generic
-_objc_assign_ivar_generic
-_objc_assign_strongCast_CF
-_objc_assign_ivar_address_CF
-_objc_collect_init
-_objc_is_finalized
-_objc_memmove_collectable
-_objc_collect_if_needed
-# objc-exception.h
-_objc_exception_throw
-_objc_exception_try_enter
-_objc_exception_try_exit
-_objc_exception_extract
-_objc_exception_match
-_objc_exception_get_functions
-_objc_exception_set_functions
-# objc-sync.h
-_objc_sync_enter
-_objc_sync_exit
-_objc_sync_wait
-_objc_sync_notify
-_objc_sync_notifyAll
-# objc-load.h
-_objc_loadModules
-_objc_loadModule
-_objc_unloadModules
-# objc-runtime.h
-_objc_getClass
-_objc_getMetaClass
-_objc_msgSend
-# non-nil entry points disabled for now
-# _objc_msgSendNonNil
-_objc_msgSend_fpret
-_objc_msgSend_stret
-# _objc_msgSendNonNil_stret
-_objc_msgSendSuper
-_objc_msgSendSuper_stret
-_objc_msgSendv
-_objc_msgSendv_fpret
-_objc_msgSendv_stret
-_objc_getClassList
-_objc_getClasses
-_objc_lookUpClass
-_objc_getRequiredClass
-_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
-__objc_resolve_categories_for_class
-__objc_setClassLoader
-__objc_setNilReceiver
-__objc_getNilReceiver
-__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
-# used by Foundation's NSAutoreleaseFreedObjectCheckEnabled
-__objc_getFreedObjectClass
View
27 runtime/objc-moninit.c → runtime/Accessors.subproj/objc-accessors-arch.s
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
+ * Copyright (c) 2006 Apple Inc. All Rights Reserved.
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
@@ -23,15 +21,14 @@
* @APPLE_LICENSE_HEADER_END@
*/
-#ifdef moninitobjc
-#undef moninitobjc
-
-unsigned long *
-moninitobjc(unsigned long moncount_addr)
-{
- extern void _objc_inform(const char *format, ...);
- _objc_inform ("moninitobjc is obsoleted, refer to documentation for how to do profiling\n");
- return (0);
-}
-
+#if defined (__i386__) || defined (i386)
+ #include "objc-accessors-i386.s"
+#elif defined (__ppc__) || defined(ppc)
+ #include "objc-accessors-ppc.s"
+#elif defined (__ppc64__) || defined(ppc64)
+ #include "objc-accessors-ppc64.s"
+#elif defined (__x86_64__)
+ #include "objc-accessors-x86_64.s"
+#else
+ #error Architecture not supported
#endif
View
157 runtime/Accessors.subproj/objc-accessors-i386.s
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2006 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+//////////////////////////////////////////////////////////////////////
+//
+// ENTRY functionName
+//
+// Assembly directives to begin an exported function.
+//
+// Takes: functionName - name of the exported function
+//////////////////////////////////////////////////////////////////////
+
+.macro ENTRY
+ .text
+ .globl $0
+$0:
+.endmacro
+
+//////////////////////////////////////////////////////////////////////
+//
+// END_ENTRY functionName
+//
+// Assembly directives to end an exported function. Just a placeholder,
+// a close-parenthesis for ENTRY, until it is needed for something.
+//
+// Takes: functionName - name of the exported function
+//////////////////////////////////////////////////////////////////////
+
+.macro END_ENTRY
+.endmacro
+
+//////////////////////////////////////////////////////////////////////
+//
+// OBJC_GET_PROPERTY_OFFSET offset
+//
+// Optimized id typed accessor methods.
+// Generates an accesssor for a specified compile time offset.
+//
+// Takes: offset - offset of an id typed instance variable
+//////////////////////////////////////////////////////////////////////
+
+.macro OBJC_GET_PROPERTY_OFFSET
+ .private_extern __objc_getProperty_offset_$0
+ ENTRY __objc_getProperty_offset_$0
+ movl 4(%esp), %eax
+ movl $0(%eax), %eax
+ ret
+ END_ENTRY __objc_getProperty_offset_$0
+.endmacro
+
+/*
+ * Thunk to retrieve PC.
+ * `call 1; 1: pop` sequence breaks any branch-prediction stack.
+ */
+L_get_pc_thunk.edx:
+ movl (%esp,1), %edx
+ ret
+
+.macro LAZY_PIC_FUNCTION_STUB
+.data
+.picsymbol_stub
+L$0$stub:
+ .indirect_symbol $0
+ call L_get_pc_thunk.edx
+L0$$0:
+ movl L$0$lz - L0$$0(%edx), %ecx
+ jmp *%ecx
+L$0$stub_binder:
+ lea L$0$lz - L0$$0(%edx),%eax
+ pushl %eax
+ jmp dyld_stub_binding_helper
+ nop
+.data
+.lazy_symbol_pointer
+L$0$lz:
+ .indirect_symbol $0
+ .long L$0$stub_binder
+.endmacro
+
+LAZY_PIC_FUNCTION_STUB _objc_assign_ivar_gc
+#define OBJC_ASSIGN_IVAR L_objc_assign_ivar_gc$stub // call objc_assign_ivar_gc() directly to avoid extra levels of testing/branching
+
+.macro OBJC_SET_PROPERTY_OFFSET
+ .private_extern __objc_setProperty_offset_$0
+ ENTRY __objc_setProperty_offset_$0
+ movl 4(%esp), %eax
+ movl %eax, 8(%esp) // pass self as the second parameter.
+ movl 12(%esp), %eax
+ movl %eax, 4(%esp) // pass value as the first parameter.
+ movl $$$0, 12(%esp) // pass the offset as the third parameter.
+ jmp OBJC_ASSIGN_IVAR // objc_assign_ivar_gc() is __private_extern__
+ END_ENTRY __objc_setProperty_offset_$0
+.endmacro
+
+/********************************************************************
+ * id _objc_getProperty_offset_N(id self, SEL _cmd);
+ ********************************************************************/
+
+ OBJC_GET_PROPERTY_OFFSET 0
+ OBJC_GET_PROPERTY_OFFSET 4
+ OBJC_GET_PROPERTY_OFFSET 8
+ OBJC_GET_PROPERTY_OFFSET 12
+ OBJC_GET_PROPERTY_OFFSET 16
+ OBJC_GET_PROPERTY_OFFSET 20
+ OBJC_GET_PROPERTY_OFFSET 24
+ OBJC_GET_PROPERTY_OFFSET 28
+ OBJC_GET_PROPERTY_OFFSET 32
+ OBJC_GET_PROPERTY_OFFSET 36
+ OBJC_GET_PROPERTY_OFFSET 40
+ OBJC_GET_PROPERTY_OFFSET 44
+ OBJC_GET_PROPERTY_OFFSET 48
+ OBJC_GET_PROPERTY_OFFSET 52
+ OBJC_GET_PROPERTY_OFFSET 56
+ OBJC_GET_PROPERTY_OFFSET 60
+ OBJC_GET_PROPERTY_OFFSET 64
+
+/********************************************************************
+ * id _objc_setProperty_offset_N(id self, SEL _cmd, id value);
+ ********************************************************************/
+
+ OBJC_SET_PROPERTY_OFFSET 0
+ OBJC_SET_PROPERTY_OFFSET 4
+ OBJC_SET_PROPERTY_OFFSET 8
+ OBJC_SET_PROPERTY_OFFSET 12
+ OBJC_SET_PROPERTY_OFFSET 16
+ OBJC_SET_PROPERTY_OFFSET 20
+ OBJC_SET_PROPERTY_OFFSET 24
+ OBJC_SET_PROPERTY_OFFSET 28
+ OBJC_SET_PROPERTY_OFFSET 32
+ OBJC_SET_PROPERTY_OFFSET 36
+ OBJC_SET_PROPERTY_OFFSET 40
+ OBJC_SET_PROPERTY_OFFSET 44
+ OBJC_SET_PROPERTY_OFFSET 48
+ OBJC_SET_PROPERTY_OFFSET 52
+ OBJC_SET_PROPERTY_OFFSET 56
+ OBJC_SET_PROPERTY_OFFSET 60
+ OBJC_SET_PROPERTY_OFFSET 64
View
24 runtime/Accessors.subproj/objc-accessors-ppc.s
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2006 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+ #warning ppc version needs to be implemented.
View
24 runtime/Accessors.subproj/objc-accessors-ppc64.s
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2006 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#warning ppc64 version needs to be implemented.
View
166 runtime/Accessors.subproj/objc-accessors-table.h
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2006 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/* Support for optimized accessor methods. Currently optimized accessor methods are provided for ivar offsets from 0 to 64. */
+
+#define ALWAYS_USE_C_ACCESSOR_METHODS 0
+
+// set of property getters for specific offsets.
+#define GETPROPERTY_OFFSET(offset) _objc_getProperty_offset_ ## offset
+#define DECLARE_GETPROPERTY_OFFSET(offset) extern id GETPROPERTY_OFFSET(offset)(id self, SEL _cmd)
+#define IMPLEMENT_GETPROPERTY_OFFSET(offset) static id GETPROPERTY_OFFSET(offset)(id self, SEL _cmd) { return *(id*)((char*)self + offset); }
+
+#if ALWAYS_USE_C_ACCESSOR_METHODS || defined(__ppc__) || defined(__ppc64__) || defined(__x86_64__)
+// C versions with hard-coded offsets. may be good enough in most cases.
+IMPLEMENT_GETPROPERTY_OFFSET(0)
+IMPLEMENT_GETPROPERTY_OFFSET(4)
+IMPLEMENT_GETPROPERTY_OFFSET(8)
+IMPLEMENT_GETPROPERTY_OFFSET(12)
+IMPLEMENT_GETPROPERTY_OFFSET(16)
+IMPLEMENT_GETPROPERTY_OFFSET(20)
+IMPLEMENT_GETPROPERTY_OFFSET(24)
+IMPLEMENT_GETPROPERTY_OFFSET(28)
+IMPLEMENT_GETPROPERTY_OFFSET(32)
+IMPLEMENT_GETPROPERTY_OFFSET(36)
+IMPLEMENT_GETPROPERTY_OFFSET(40)
+IMPLEMENT_GETPROPERTY_OFFSET(44)
+IMPLEMENT_GETPROPERTY_OFFSET(48)
+IMPLEMENT_GETPROPERTY_OFFSET(52)
+IMPLEMENT_GETPROPERTY_OFFSET(56)
+IMPLEMENT_GETPROPERTY_OFFSET(60)
+IMPLEMENT_GETPROPERTY_OFFSET(64)
+#else
+// forward delcarations to assembly versions. only on i386 right now.
+DECLARE_GETPROPERTY_OFFSET(0);
+DECLARE_GETPROPERTY_OFFSET(4);
+DECLARE_GETPROPERTY_OFFSET(8);
+DECLARE_GETPROPERTY_OFFSET(12);
+DECLARE_GETPROPERTY_OFFSET(16);
+DECLARE_GETPROPERTY_OFFSET(20);
+DECLARE_GETPROPERTY_OFFSET(24);
+DECLARE_GETPROPERTY_OFFSET(28);
+DECLARE_GETPROPERTY_OFFSET(32);
+DECLARE_GETPROPERTY_OFFSET(36);
+DECLARE_GETPROPERTY_OFFSET(40);
+DECLARE_GETPROPERTY_OFFSET(44);
+DECLARE_GETPROPERTY_OFFSET(48);
+DECLARE_GETPROPERTY_OFFSET(52);
+DECLARE_GETPROPERTY_OFFSET(56);
+DECLARE_GETPROPERTY_OFFSET(60);
+DECLARE_GETPROPERTY_OFFSET(64);
+#endif
+
+static void* _getProperty_offset_table[] = {
+ GETPROPERTY_OFFSET(0),
+ GETPROPERTY_OFFSET(4),
+ GETPROPERTY_OFFSET(8),
+ GETPROPERTY_OFFSET(12),
+ GETPROPERTY_OFFSET(16),
+ GETPROPERTY_OFFSET(20),
+ GETPROPERTY_OFFSET(24),
+ GETPROPERTY_OFFSET(28),
+ GETPROPERTY_OFFSET(32),
+ GETPROPERTY_OFFSET(36),
+ GETPROPERTY_OFFSET(40),
+ GETPROPERTY_OFFSET(44),
+ GETPROPERTY_OFFSET(48),
+ GETPROPERTY_OFFSET(52),
+ GETPROPERTY_OFFSET(56),
+ GETPROPERTY_OFFSET(60),
+ GETPROPERTY_OFFSET(64),
+};
+
+#undef GETPROPERTY_OFFSET
+#undef DECLARE_GETPROPERTY_OFFSET
+#undef IMPLEMENT_GETPROPERTY_OFFSET
+#define GETPROPERTY_IMP(offset) ((offset <= 64) ? (IMP)_getProperty_offset_table[offset >> 2] : NULL)
+
+// set of property setters for specific offsets.
+#define SETPROPERTY_OFFSET(offset) _objc_setProperty_offset_ ## offset
+#define DECLARE_SETPROPERTY_OFFSET(offset) extern id SETPROPERTY_OFFSET(offset)(id self, SEL _cmd, ...)
+#define IMPLEMENT_SETPROPERTY_OFFSET(offset) __private_extern__ void SETPROPERTY_OFFSET(offset)(id self, SEL _cmd, id value) { objc_assign_ivar_gc(value, self, offset); }
+
+#if ALWAYS_USE_C_ACCESSOR_METHODS || !defined(__i386__)
+// C versions with hard-coded offsets. may be good enough in most cases.
+IMPLEMENT_SETPROPERTY_OFFSET(0)
+IMPLEMENT_SETPROPERTY_OFFSET(4)
+IMPLEMENT_SETPROPERTY_OFFSET(8)
+IMPLEMENT_SETPROPERTY_OFFSET(12)
+IMPLEMENT_SETPROPERTY_OFFSET(16)
+IMPLEMENT_SETPROPERTY_OFFSET(20)
+IMPLEMENT_SETPROPERTY_OFFSET(24)
+IMPLEMENT_SETPROPERTY_OFFSET(28)
+IMPLEMENT_SETPROPERTY_OFFSET(32)
+IMPLEMENT_SETPROPERTY_OFFSET(36)
+IMPLEMENT_SETPROPERTY_OFFSET(40)
+IMPLEMENT_SETPROPERTY_OFFSET(44)
+IMPLEMENT_SETPROPERTY_OFFSET(48)
+IMPLEMENT_SETPROPERTY_OFFSET(52)
+IMPLEMENT_SETPROPERTY_OFFSET(56)
+IMPLEMENT_SETPROPERTY_OFFSET(60)
+IMPLEMENT_SETPROPERTY_OFFSET(64)
+#else
+// forward delcarations to assembly versions. only on i386 right now.
+DECLARE_SETPROPERTY_OFFSET(0);
+DECLARE_SETPROPERTY_OFFSET(4);
+DECLARE_SETPROPERTY_OFFSET(8);
+DECLARE_SETPROPERTY_OFFSET(12);
+DECLARE_SETPROPERTY_OFFSET(16);
+DECLARE_SETPROPERTY_OFFSET(20);
+DECLARE_SETPROPERTY_OFFSET(24);
+DECLARE_SETPROPERTY_OFFSET(28);
+DECLARE_SETPROPERTY_OFFSET(32);
+DECLARE_SETPROPERTY_OFFSET(36);
+DECLARE_SETPROPERTY_OFFSET(40);
+DECLARE_SETPROPERTY_OFFSET(44);
+DECLARE_SETPROPERTY_OFFSET(48);
+DECLARE_SETPROPERTY_OFFSET(52);
+DECLARE_SETPROPERTY_OFFSET(56);
+DECLARE_SETPROPERTY_OFFSET(60);
+DECLARE_SETPROPERTY_OFFSET(64);
+#endif
+
+static void* _setProperty_offset_table[] = {
+ SETPROPERTY_OFFSET(0),
+ SETPROPERTY_OFFSET(4),
+ SETPROPERTY_OFFSET(8),
+ SETPROPERTY_OFFSET(12),
+ SETPROPERTY_OFFSET(16),
+ SETPROPERTY_OFFSET(20),
+ SETPROPERTY_OFFSET(24),
+ SETPROPERTY_OFFSET(28),
+ SETPROPERTY_OFFSET(32),
+ SETPROPERTY_OFFSET(36),
+ SETPROPERTY_OFFSET(40),
+ SETPROPERTY_OFFSET(44),
+ SETPROPERTY_OFFSET(48),
+ SETPROPERTY_OFFSET(52),
+ SETPROPERTY_OFFSET(56),
+ SETPROPERTY_OFFSET(60),
+ SETPROPERTY_OFFSET(64),
+};
+
+#undef SETPROPERTY_OFFSET
+#undef DECLARE_SETPROPERTY_OFFSET
+#undef IMPLEMENT_SETPROPERTY_OFFSET
+#define SETPROPERTY_IMP(offset) ((offset <= 64) ? (IMP)_setProperty_offset_table[offset >> 2] : NULL)
View
24 runtime/Accessors.subproj/objc-accessors-x86_64.s
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2006 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#warning x86-64 version needs to be implemented.
View
51 runtime/Accessors.subproj/objc-accessors.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _OBJC_ACCESSORS_H_
+#define _OBJC_ACCESSORS_H_
+
+#import <objc/objc.h>
+#import <stddef.h>
+
+// Called under non-GC for retain or copy attributed properties
+void objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id newValue, BOOL atomic, BOOL shouldCopy);
+id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic);
+
+// Called under GC by compiler for copying structures containing objects or other strong pointers when
+// the destination memory is not known to be stack local memory.
+// Called to read instance variable structures (or other non-word sized entities) atomically
+void objc_copyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL hasStrong);
+
+// OBSOLETE
+
+@protocol NSCopying;
+
+// called for @property(copy)
+id <NSCopying> object_getProperty_bycopy(id object, SEL _cmd, ptrdiff_t offset);
+void object_setProperty_bycopy(id object, SEL _cmd, id <NSCopying> value, ptrdiff_t offset);
+
+// called for @property(retain)
+id object_getProperty_byref(id object, SEL _cmd, ptrdiff_t offset);
+void object_setProperty_byref(id object, SEL _cmd, id value, ptrdiff_t offset);
+
+#endif
View
231 runtime/Accessors.subproj/objc-accessors.m
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#import <string.h>
+#import <stddef.h>
+
+#import <libkern/OSAtomic.h>
+
+#import "objc-accessors.h"
+#import <objc/objc-auto.h>
+#import <objc/runtime.h>
+#import "../objc-private.h"
+
+#import "/usr/local/include/auto_zone.h"
+
+#import "objc-accessors-table.h"
+
+// stub interface declarations to make compiler happy.
+
+@interface __NSCopyable
+- (id)copyWithZone:(void *)zone;
+@end
+
+@interface __NSRetained
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+@end
+
+static /*inline*/ IMP optimized_getter_for_gc(id self, SEL name, ptrdiff_t offset) {
+ // replace this method with a faster version that does no message sends, and fewer tests.
+ IMP getter = GETPROPERTY_IMP(offset);
+ if (getter != NULL) {
+ // HACK ALERT: replaces the IMP in the cache!
+ Class cls = self->isa;
+ Method method = class_getInstanceMethod(cls, name);
+ if (method_getImplementation(method) != getter)
+ method_setImplementation(method, getter);
+ }
+ return getter;
+}
+
+static /*inline*/ IMP optimized_setter_for_gc(id self, SEL name, ptrdiff_t offset) {
+ // replace this method with a faster version that does no message sends.
+ IMP setter = SETPROPERTY_IMP(offset);
+ if (setter != NULL) {
+ // HACK ALERT: replaces the IMP in the cache!
+ Class cls = self->isa;
+ Method method = class_getInstanceMethod(cls, name);
+ if (method_getImplementation(method) != setter)
+ method_setImplementation(method, setter);
+ }
+ return setter;
+}
+
+// ATOMIC entry points
+
+typedef uintptr_t spin_lock_t;
+extern void _spin_lock(spin_lock_t *lockp);
+extern int _spin_lock_try(spin_lock_t *lockp);
+extern void _spin_unlock(spin_lock_t *lockp);
+
+/* need to consider cache line contention - space locks out XXX */
+
+#define GOODPOWER 7
+#define GOODMASK ((1<<GOODPOWER)-1)
+#define GOODHASH(x) (((long)x >> 5) & GOODMASK)
+static spin_lock_t PropertyLocks[1 << GOODPOWER] = { 0 };
+
+id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic) {
+ if (UseGC) {
+ // FIXME: we could optimize getters when a class is first initialized, then KVO won't get confused.
+ if (false) {
+ IMP getter = optimized_getter_for_gc(self, _cmd, offset);
+ if (getter) return getter(self, _cmd);
+ }
+ return *(id*) ((char*)self + offset);
+ }
+
+ // Retain release world
+ id *slot = (id*) ((char*)self + offset);
+ if (!atomic) return *slot;
+
+ // Atomic retain release world
+ spin_lock_t *slotlock = &PropertyLocks[GOODHASH(slot)];
+ _spin_lock(slotlock);
+ id value = [*slot retain];
+ _spin_unlock(slotlock);
+
+ // for performance, we (safely) issue the autorelease OUTSIDE of the spinlock.
+ return [value autorelease];
+}
+
+
+void objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id newValue, BOOL atomic, BOOL shouldCopy) {
+ if (UseGC) {
+ if (shouldCopy) {
+ newValue = [newValue copyWithZone:NULL];
+ }
+ else if (false) {
+ IMP setter = optimized_setter_for_gc(self, _cmd, offset);
+ if (setter) {
+ setter(self, _cmd, newValue);
+ return;
+ }
+ }
+ objc_assign_ivar_internal(newValue, self, offset);
+ return;
+ }
+
+ // Retain release world
+ id oldValue, *slot = (id*) ((char*)self + offset);
+
+ // atomic or not, if slot would be unchanged, do nothing.
+ if (!shouldCopy && *slot == newValue) return;
+
+ newValue = (shouldCopy ? [newValue copyWithZone:NULL] : [newValue retain]);
+
+ if (!atomic) {
+ oldValue = *slot;
+ *slot = newValue;
+ } else {
+ spin_lock_t *slotlock = &PropertyLocks[GOODHASH(slot)];
+ _spin_lock(slotlock);
+ oldValue = *slot;
+ *slot = newValue;
+ _spin_unlock(slotlock);
+ }
+
+ [oldValue release];
+}
+
+
+__private_extern__ auto_zone_t *gc_zone;
+
+// This entry point was designed wrong. When used as a getter, src needs to be locked so that
+// if simultaneously used for a setter then there would be contention on src.
+// So we need two locks - one of which will be contended.
+void objc_copyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL hasStrong) {
+ static spin_lock_t StructLocks[1 << GOODPOWER] = { 0 };
+ spin_lock_t *lockfirst = NULL;
+ spin_lock_t *locksecond = NULL;
+ if (atomic) {
+ lockfirst = &StructLocks[GOODHASH(src)];
+ locksecond = &StructLocks[GOODHASH(dest)];
+ // order the locks by address so that we don't deadlock
+ if (lockfirst > locksecond) {
+ lockfirst = locksecond;
+ locksecond = &StructLocks[GOODHASH(src)];
+ }
+ else if (lockfirst == locksecond) {
+ // lucky - we only need one lock
+ locksecond = NULL;
+ }
+ _spin_lock(lockfirst);
+ if (locksecond) _spin_lock(locksecond);
+ }
+ if (UseGC && hasStrong) {
+ auto_zone_write_barrier_memmove(gc_zone, dest, src, size);
+ }
+ else {
+ memmove(dest, src, size);
+ }
+ if (atomic) {
+ _spin_unlock(lockfirst);
+ if (locksecond) _spin_unlock(locksecond);
+ }
+}
+
+// PRE-ATOMIC entry points
+
+id <NSCopying> object_getProperty_bycopy(id self, SEL _cmd, ptrdiff_t offset) {
+ if (UseGC) {
+ IMP getter = optimized_getter_for_gc(self, _cmd, offset);
+ if (getter) return getter(self, _cmd);
+ }
+ id *slot = (id*) ((char*)self + offset);
+ return *slot;
+}
+
+void object_setProperty_bycopy(id self, SEL _cmd, id <NSCopying> value, ptrdiff_t offset) {
+ id *slot = (id*) ((char*)self + offset);
+ id oldValue = *slot;
+ objc_assign_ivar_internal([value copyWithZone:NULL], self, offset);
+ [oldValue release];
+}
+
+id object_getProperty_byref(id self, SEL _cmd, ptrdiff_t offset) {
+ if (UseGC) {
+ IMP getter = optimized_getter_for_gc(self, _cmd, offset);
+ if (getter) return getter(self, _cmd);
+ }
+ id *slot = (id*) ((char*)self + offset);
+ return *slot;
+}
+
+void object_setProperty_byref(id self, SEL _cmd, id value, ptrdiff_t offset) {
+ if (UseGC) {
+ IMP setter = optimized_setter_for_gc(self, _cmd, offset);
+ if (setter) {
+ setter(self, _cmd, value);
+ return;
+ }
+ }
+ id *slot = (id*) ((char*)self + offset);
+ id oldValue = *slot;
+ if (oldValue != value) {
+ objc_assign_ivar_internal([value retain], self, offset);
+ [oldValue release];
+ }
+}
View
64 runtime/Auto.subproj/objc-auto-i386.s
@@ -1,10 +1,8 @@
/*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004, 2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 2004 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 2.0 (the 'License'). You may not use this file except in
@@ -23,4 +21,62 @@
* @APPLE_LICENSE_HEADER_END@
*/
-#warning Intel version needs to be implemented.
+/*
+ This file defines the non-GC variants of objc_assign_* on a dedicated
+ page in the (__DATA,__data) section. At load time under GC, each
+ routine is overwritten with a jump to its GC variant. It is necessary
+ for these routines to exist on a dedicated page for vm_protect to
+ work properly in the GC case. The page exists in the data segment to
+ reduce the kernel's page table overhead.
+
+ Note: To avoid wasting more space than necessary at runtime, this file
+ must not contain anything other than the objc_assign_* routines.
+*/
+
+.data
+.align 12 // align to page boundary
+
+LNonGCAssigns$Begin:
+
+// id objc_assign_ivar(id value, id dest, ptrdiff_t offset);
+.globl _objc_assign_ivar
+_objc_assign_ivar:
+ pushl %ebp
+ movl %esp,%ebp
+ movl 0x08(%ebp),%eax // value
+ movl 0x0c(%ebp),%ecx // dest
+ movl 0x10(%ebp),%edx // offset
+ movl %eax,(%ecx,%edx) // return (*(dest + offset) = value);
+ leave
+ ret
+
+// id objc_assign_global(id value, id *dest);
+.globl _objc_assign_global
+_objc_assign_global:
+ pushl %ebp
+ movl %esp,%ebp
+ movl 0x08(%ebp),%eax // value
+ movl 0x0c(%ebp),%edx // dest
+ movl %eax,(%edx) // return (*dest = value);
+ leave
+ ret
+
+// As of OS X 10.5, objc_assign_strongCast_non_gc is identical to
+// objc_assign_global_non_gc.
+
+// id objc_assign_strongCast(id value, id *dest);
+.globl _objc_assign_strongCast
+_objc_assign_strongCast:
+ pushl %ebp
+ movl %esp,%ebp
+ movl 0x08(%ebp),%eax // value
+ movl 0x0c(%ebp),%edx // dest
+ movl %eax,(%edx) // return (*dest = value);
+ leave
+ ret
+
+LNonGCAssigns$End:
+
+// Claim the remainder of the page.
+.set L$set$assignsSize,LNonGCAssigns$End-LNonGCAssigns$Begin
+.space 4096-L$set$assignsSize
View
6 runtime/Auto.subproj/objc-auto-ppc.s
@@ -1,10 +1,8 @@
/*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004, 2006 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 2004 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 2.0 (the 'License'). You may not use this file except in
@@ -42,7 +40,7 @@
_$0: ; primary entry point
ba $1 ; branch to runtime page
- .globl _$0_non_gc ; non_gc entry point name
+ .private_extern _$0_non_gc ; non_gc entry point name
_$0_non_gc: ; non_gc entry point
.endmacro
View
24 runtime/Auto.subproj/objc-auto-ppc64.s
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2004 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#warning ppc64 version needs to be implemented.
View
78 runtime/Auto.subproj/objc-auto-x86_64.s
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ This file defines the non-GC variants of objc_assign_* on a dedicated
+ page in the (__DATA,__data) section. At load time under GC, each
+ routine is overwritten with a jump to its GC variant. It is necessary
+ for these routines to exist on a dedicated page for vm_protect to
+ work properly in the GC case. The page exists in the data segment to
+ reduce the kernel's page table overhead.
+
+ Note: To avoid wasting more space than necessary at runtime, this file
+ must not contain anything other than the objc_assign_* routines.
+*/
+
+.data
+.align 12 // align to page boundary
+
+LNonGCAssigns$Begin:
+
+// id objc_assign_ivar(id value, id dest, ptrdiff_t offset);
+.globl _objc_assign_ivar
+_objc_assign_ivar:
+ pushq %rbp
+ movq %rsp,%rbp
+ movq %rdi,(%rsi,%rdx) // *(dest + offset) = value);
+ movq %rdi,%rax // return value;
+ leave
+ ret
+
+// id objc_assign_global(id value, id *dest);
+.globl _objc_assign_global
+_objc_assign_global:
+ pushq %rbp
+ movq %rsp,%rbp
+ movq %rdi,(%rsi) // *(dest = value);
+ movq %rdi,%rax // return value;
+ leave
+ ret
+
+// As of OS X 10.5, objc_assign_strongCast_non_gc is identical to
+// objc_assign_global_non_gc.
+
+// id objc_assign_strongCast(id value, id *dest);
+.globl _objc_assign_strongCast
+_objc_assign_strongCast:
+ pushq %rbp
+ movq %rsp,%rbp
+ movq %rdi,(%rsi) // *(dest = value);
+ movq %rdi,%rax // return value;
+ leave
+ ret
+
+LNonGCAssigns$End:
+
+// Claim the remainder of the page.
+.set L$set$assignsSize,LNonGCAssigns$End-LNonGCAssigns$Begin
+.space 4096-L$set$assignsSize
View
27 runtime/Auto.subproj/objc-auto.s
@@ -1,23 +1,22 @@
/*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * 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.
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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
+ * 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.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
@@ -27,6 +26,10 @@
#include "objc-auto-i386.s"
#elif defined (__ppc__) || defined(ppc)
#include "objc-auto-ppc.s"
+#elif defined (__ppc64__) || defined(ppc64)
+ #include "objc-auto-ppc64.s"
+#elif defined (__x86_64__)
+ #include "objc-auto-x86_64.s"
#else
#error Architecture not supported
#endif
View
476 runtime/Messengers.subproj/objc-msg-i386.s
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
+ * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
@@ -30,18 +28,10 @@
********************************************************************
********************************************************************/
-// The assembler syntax for an immediate value is the same as the
-// syntax for a macro argument number (dollar sign followed by the
-// digits). Argument number wins in this ambiguity. Until the
-// assembler is fixed we have to find another way.
-#define NO_MACRO_CONSTS
-#ifdef NO_MACRO_CONSTS
- kOne = 1
- kTwo = 2
- kFour = 4
- kEight = 8
- kTwelve = 12
-#endif
+#undef OBJC_ASM
+#define OBJC_ASM
+#include "objc-rtp.h"
+
/********************************************************************
* Data used by the ObjC runtime.
@@ -52,7 +42,7 @@
// Substitute receiver for messages sent to nil (usually also nil)
// id _objc_nilReceiver
.align 4
-.globl __objc_nilReceiver
+.private_extern __objc_nilReceiver
__objc_nilReceiver:
.long 0
@@ -60,7 +50,7 @@ __objc_nilReceiver:
// to get the critical regions for which method caches
// cannot be garbage collected.
-.globl _objc_entryPoints
+.private_extern _objc_entryPoints
_objc_entryPoints:
.long __cache_getImp
.long __cache_getMethod
@@ -71,7 +61,7 @@ _objc_entryPoints:
.long _objc_msgSendSuper_stret
.long 0
-.globl _objc_exitPoints
+.private_extern _objc_exitPoints
_objc_exitPoints:
.long LGetImpExit
.long LGetMethodExit
@@ -83,20 +73,6 @@ _objc_exitPoints:
.long 0
-#if defined(__DYNAMIC__)
-
-/*
- * Thunk to retrieve PC.
- * `call 1; 1: pop` sequence breaks any branch-prediction stack.
- */
-
-.align 4, 0x90
-L_get_pc_thunk.edx:
- movl (%esp,1), %edx
- ret
-
-#endif
-
/*
* Handcrafted dyld stubs for each external call.
* They should be converted into a local branch after linking. aB.
@@ -114,15 +90,15 @@ L_get_pc_thunk.edx:
.picsymbol_stub ;\
L ## name ## $stub: ;\
.indirect_symbol name ;\
- call L_get_pc_thunk.edx ;\
+ call L0$ ## name ;\
L0$ ## name: ;\
+ popl %edx ;\
movl L ## name ## $lz-L0$ ## name(%edx),%ecx ;\
- jmp %ecx ;\
+ jmp *%ecx ;\
L ## name ## $stub_binder: ;\
lea L ## name ## $lz-L0$ ## name(%edx),%eax ;\
pushl %eax ;\
jmp dyld_stub_binding_helper ;\
- nop ;\
.data ;\
.lazy_symbol_pointer ;\
L ## name ## $lz: ;\
@@ -246,8 +222,8 @@ EXTERNAL_SYMBOL = 1
.macro LOAD_STATIC_WORD
#if defined(__DYNAMIC__)
- call L_get_pc_thunk.edx
-1:
+ call 1f
+1: popl %edx
.if $2 == EXTERNAL_SYMBOL
movl L$1-1b(%edx),$0
movl 0($0),$0
@@ -278,8 +254,8 @@ EXTERNAL_SYMBOL = 1
.macro LEA_STATIC_DATA
#if defined(__DYNAMIC__)
- call L_get_pc_thunk.edx
-1:
+ call 1f
+1: popl %edx
.if $2 == EXTERNAL_SYMBOL
movl L$1-1b(%edx),$0
.elseif $2 == LOCAL_SYMBOL
@@ -336,7 +312,7 @@ $0:
// Current stack contents: ret
pushl %ebp
movl %esp,%ebp
- subl $kEight,%esp
+ subl $$8,%esp
// Current stack contents: ret, ebp, pad, pad
CALL_EXTERN(mcount)
movl %ebp,%esp
@@ -357,6 +333,8 @@ $0:
// 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)
+// selector in %ecx
+// class to search in %edx
//
// cacheMissLabel = label to branch to iff method is not cached
//
@@ -381,33 +359,9 @@ CACHE_GET = 2 // first argument is class, search that class
.macro CacheLookup
// load variables and save caller registers.
-// Overlapped to prevent AGI
-.if $0 == WORD_RETURN // Regular word return
-.if $1 == MSG_SEND // MSG_SEND
- movl isa(%eax), %eax // class = self->isa
- movl selector(%esp), %ecx // get selector
-.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
-.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
pushl %edi // save scratch register
- movl cache(%eax), %eax // cache = class->cache
+ movl cache(%edx), %edi // cache = class->cache
pushl %esi // save scratch register
#if defined(OBJC_INSTRUMENTED)
@@ -415,19 +369,15 @@ CACHE_GET = 2 // first argument is class, search that class