Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Legacy ABI Compatibility #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ set(libobjc_HDRS
objc/objc-runtime.h
objc/objc-visibility.h
objc/objc.h
objc/runtime-deprecated.h
objc/runtime.h
objc/slot.h)

Expand Down Expand Up @@ -134,7 +133,6 @@ option(ENABLE_TRACING
option(OLDABI_COMPAT
"Enable compatibility with GCC and old GNUstep ABIs"
${OLD_ABI_COMPAT_DEFAULT})
option(LEGACY_COMPAT "Enable legacy compatibility features" OFF)
option(DEBUG_ARC_COMPAT
"Log warnings for classes that don't hit ARC fast paths" OFF)
option(ENABLE_OBJCXX "Enable support for Objective-C++" ON)
Expand All @@ -153,12 +151,6 @@ if (OLDABI_COMPAT)
add_definitions(-DOLDABI_COMPAT=1)
endif()

if (LEGACY_COMPAT)
list(APPEND libobjc_C_SRCS legacy_malloc.c)
else ()
add_definitions(-DNO_LEGACY)
endif ()

set(LIBOBJC_NAME "objc" CACHE STRING
"Name of the Objective-C runtime library (e.g. objc2 for libobjc2)")

Expand Down
7 changes: 2 additions & 5 deletions abi_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct objc_abi_version

enum
{
gcc_abi = 8,
gnustep_abi = 9,
gc_abi = 10
};
Expand All @@ -42,12 +41,10 @@ enum
*/
static struct objc_abi_version known_abis[] =
{
/* GCC ABI. */
{gcc_abi, gcc_abi, gnustep_abi, sizeof(struct objc_module_abi_8)},
/* Non-fragile ABI. */
{gnustep_abi, gcc_abi, gc_abi, sizeof(struct objc_module_abi_8)},
{gnustep_abi, gnustep_abi, gc_abi, sizeof(struct objc_module_abi_8)},
/* GC ABI. Adds a field describing the GC mode. */
{gc_abi, gcc_abi, gc_abi, sizeof(struct objc_module_abi_10)}
{gc_abi, gnustep_abi, gc_abi, sizeof(struct objc_module_abi_10)}
};

static int known_abi_count =
Expand Down
42 changes: 21 additions & 21 deletions category.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ struct objc_category
struct objc_property_list *class_properties;
};

struct objc_category_gcc
struct objc_category_gsv1
{
/**
* The name of this category.
*/
const char *name;
/**
* The name of the class to which this category should be applied.
*/
const char *class_name;
/**
* The list of instance methods to add to the class.
*/
struct objc_method_list_gcc *instance_methods;
/**
* The list of class methods to add to the class.
*/
struct objc_method_list_gcc *class_methods;
/**
* The list of protocols adopted by this category.
*/
struct objc_protocol_list *protocols;
/**
* The name of this category.
*/
const char *name;
/**
* The name of the class to which this category should be applied.
*/
const char *class_name;
/**
* The list of instance methods to add to the class.
*/
struct objc_method_list_gsv1 *instance_methods;
/**
* The list of class methods to add to the class.
*/
struct objc_method_list_gsv1 *class_methods;
/**
* The list of protocols adopted by this category.
*/
struct objc_protocol_list *protocols;
};
27 changes: 2 additions & 25 deletions class.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ struct objc_class_gsv1
/**
* Metadata describing the instance variables in this class.
*/
struct objc_ivar_list_gcc *ivars;
struct objc_ivar_list_gsv1 *ivars;
/**
* Metadata for for defining the mappings from selectors to IMPs. Linked
* list of method list structures, one per class and one per category.
*/
struct objc_method_list_gcc *methods;
struct objc_method_list_gsv1 *methods;
/**
* The dispatch table for this class. Intialized and maintained by the
* runtime.
Expand Down Expand Up @@ -274,29 +274,6 @@ struct objc_class_gsv1
uintptr_t weak_pointers;
};

/**
* Structure representing the GCC ABI class structure. This is only ever
* required so that we can take its size - struct objc_class begins with the
* same fields, and you can test the new abi flag to tell whether it is safe to
* access the subsequent fields.
*/
struct objc_class_gcc
{
Class isa;
Class super_class;
const char *name;
long version;
unsigned long info;
long instance_size;
struct objc_ivar_list_gcc *ivars;
struct objc_method_list *methods;
void *dtable;
Class subclass_list;
Class sibling_class;
struct objc_protocol_list *protocols;
void *gc_object_type;
};


/**
* An enumerated type describing all of the valid flags that may be used in the
Expand Down
6 changes: 3 additions & 3 deletions ivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static inline objc_ivar_ownership ivarGetOwnership(Ivar ivar)
/**
* Legacy ivar structure, inherited from the GCC ABI.
*/
struct objc_ivar_gcc
struct objc_ivar_gsv1
{
/**
* Name of this instance variable.
Expand Down Expand Up @@ -189,7 +189,7 @@ static inline struct objc_ivar *ivar_at_index(struct objc_ivar_list *l, int i)
/**
* Legacy version of the ivar list
*/
struct objc_ivar_list_gcc
struct objc_ivar_list_gsv1
{
/**
* The number of instance variables in this list.
Expand All @@ -199,6 +199,6 @@ struct objc_ivar_list_gcc
* An array of instance variable metadata structures. Note that this array
* has count elements.
*/
struct objc_ivar_gcc ivar_list[];
struct objc_ivar_gsv1 ivar_list[];
};

39 changes: 10 additions & 29 deletions legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static objc_ivar_ownership ownershipForIvar(struct objc_class_gsv1 *cls, int idx

static struct objc_ivar_list *upgradeIvarList(struct objc_class_gsv1 *cls)
{
struct objc_ivar_list_gcc *l = cls->ivars;
struct objc_ivar_list_gsv1 *l = cls->ivars;
if (l == NULL)
{
return NULL;
Expand Down Expand Up @@ -136,7 +136,7 @@ static struct objc_ivar_list *upgradeIvarList(struct objc_class_gsv1 *cls)
return n;
}

static struct objc_method_list *upgradeMethodList(struct objc_method_list_gcc *old)
static struct objc_method_list *upgradeMethodList(struct objc_method_list_gsv1 *old)
{
if (old == NULL)
{
Expand Down Expand Up @@ -368,10 +368,11 @@ PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass)
}
return cls;
}
PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *old)

PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gsv1 *old)
{
struct objc_category *cat = calloc(1, sizeof(struct objc_category));
memcpy(cat, old, sizeof(struct objc_category_gcc));
memcpy(cat, old, sizeof(struct objc_category_gsv1));
cat->instance_methods = upgradeMethodList(old->instance_methods);
cat->class_methods = upgradeMethodList(old->class_methods);
if (cat->instance_methods != NULL)
Expand All @@ -390,7 +391,7 @@ PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *ol
}

static struct objc_protocol_method_description_list*
upgrade_protocol_method_list_gcc(struct objc_protocol_method_description_list_gcc *l)
upgrade_protocol_method_list_gsv1(struct objc_protocol_method_description_list_gsv1 *l)
{
if ((l == NULL) || (l->count == 0))
{
Expand All @@ -409,26 +410,6 @@ upgrade_protocol_method_list_gcc(struct objc_protocol_method_description_list_gc
return n;
}

PRIVATE struct objc_protocol *objc_upgrade_protocol_gcc(struct objc_protocol_gcc *p)
{
// If the protocol has already been upgraded, the don't try to upgrade it twice.
if (p->isa == (id)&_OBJC_CLASS_ProtocolGCC)
{
return objc_getProtocol(p->name);
}
p->isa = (id)&_OBJC_CLASS_ProtocolGCC;
Protocol *proto =
(Protocol*)class_createInstance(&_OBJC_CLASS_Protocol, 0);
proto->name = p->name;
// Aliasing of this between the new and old structures means that when this
// returns these will all be updated.
proto->protocol_list = p->protocol_list;
proto->instance_methods = upgrade_protocol_method_list_gcc(p->instance_methods);
proto->class_methods = upgrade_protocol_method_list_gcc(p->class_methods);
assert(proto->isa);
return proto;
}

PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gsv1 *p)
{
// If the protocol has already been upgraded, the don't try to upgrade it twice.
Expand All @@ -438,19 +419,19 @@ PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gs
}
Protocol *n =
(Protocol*)class_createInstance(&_OBJC_CLASS_Protocol, 0);
n->instance_methods = upgrade_protocol_method_list_gcc(p->instance_methods);
n->instance_methods = upgrade_protocol_method_list_gsv1(p->instance_methods);
// Aliasing of this between the new and old structures means that when this
// returns these will all be updated.
n->name = p->name;
n->protocol_list = p->protocol_list;
n->class_methods = upgrade_protocol_method_list_gcc(p->class_methods);
n->class_methods = upgrade_protocol_method_list_gsv1(p->class_methods);
n->properties = upgradePropertyList(p->properties);
n->optional_properties = upgradePropertyList(p->optional_properties);
n->isa = (id)&_OBJC_CLASS_Protocol;
// We do in-place upgrading of these, because they might be referenced
// directly
p->instance_methods = (struct objc_protocol_method_description_list_gcc*)n->instance_methods;
p->class_methods = (struct objc_protocol_method_description_list_gcc*)n->class_methods;
p->instance_methods = (struct objc_protocol_method_description_list_gsv1*)n->instance_methods;
p->class_methods = (struct objc_protocol_method_description_list_gsv1*)n->class_methods;
p->properties = (struct objc_property_list_gsv1*)n->properties;
p->optional_properties = (struct objc_property_list_gsv1*)n->optional_properties;
p->isa = (id)&_OBJC_CLASS_ProtocolGSv1;
Expand Down
6 changes: 1 addition & 5 deletions legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#include "protocol.h"

PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass);
PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *);

PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gsv1 *old);
PRIVATE struct objc_class_gsv1* objc_legacy_class_for_class(Class);

PRIVATE struct objc_protocol *objc_upgrade_protocol_gcc(struct objc_protocol_gcc*);
PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gsv1*);

43 changes: 0 additions & 43 deletions legacy_malloc.c

This file was deleted.

8 changes: 4 additions & 4 deletions method.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct objc_method
};
// end: objc_method

struct objc_method_gcc
struct objc_method_gsv1
{
/**
* Selector used to send messages to this method. The type encoding of
Expand Down Expand Up @@ -87,18 +87,18 @@ static inline struct objc_method *method_at_index(struct objc_method_list *l, in
/**
* Legacy version of the method list.
*/
struct objc_method_list_gcc
struct objc_method_list_gsv1
{
/**
* The next group of methods in the list.
*/
struct objc_method_list_gcc *next;
struct objc_method_list_gsv1 *next;
/**
* The number of methods in this list.
*/
int count;
/**
* An array of methods. Note that the actual size of this is count.
*/
struct objc_method_gcc methods[];
struct objc_method_gsv1 methods[];
};
Loading
Loading