Tidying optimisation stuff.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7938 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-10-31 11:05:23 +00:00
parent 392ad35b90
commit f926a998e8
19 changed files with 165 additions and 139 deletions

View file

@ -3,7 +3,32 @@
* Headers/gnustep/base/NSGString.h:
* Headers/gnustep/base/NSGCString.h:
* Source/NSGString.m:
* Source/NSGCString.m: Removed classes - no loinger used.
* Source/NSGCString.m: Removed classes - no longer used.
* Headers/gnustep/base/NSObjCRuntime.h:
* Headers/gnustep/base/fast.x:
* Source/GSString.m:
* Source/Makefile.postamble:
* Source/NSArchiver.m:
* Source/NSCTemplateValue.m:
* Source/NSConcreteValue.m:
* Source/NSCountedSet.m:
* Source/NSDate.m:
* Source/NSDictionary.m:
* Source/NSDistantObject.m:
* Source/NSGSet.m:
* Source/NSNumber.m:
* Source/NSObject.m:
* Source/NSScanner.m:
* Source/NSSerializer.m:
* Source/NSSet.m:
* Source/NSUnarchiver.m:
Changed calls to 'fastClass()' to use 'GSObjCClassOfObject()' and
added that to NSObjCRuntime.h. Removed central class and
implementation caching from NSObject.m and fast.x since it was not
being effectively used. New intention to do removal of fast.x and
add similar functionality to NSObjCRuntime.h - intention being to
combine functionality of fast access to the runtime, and hiding both
GNU and Apple runtime behind a single interface.
2000-10-30 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -1,5 +1,5 @@
/* Interface to ObjC runtime for GNUStep
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Date: 1995
@ -38,21 +38,22 @@
@class NSString;
GS_EXPORT NSString *NSStringFromSelector(SEL aSelector);
GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
GS_EXPORT Class NSClassFromString(NSString *aClassName);
GS_EXPORT NSString *NSStringFromClass(Class aClass);
GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, unsigned int *sizep, unsigned int *alignp);
GS_EXPORT NSString *NSStringFromSelector(SEL aSelector);
GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
GS_EXPORT Class NSClassFromString(NSString *aClassName);
GS_EXPORT NSString *NSStringFromClass(Class aClass);
GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr,
unsigned int *sizep, unsigned int *alignp);
/* Logging */
/* OpenStep spec states that log messages go to stderr, but just in case
someone wants them to go somewhere else, they can implement a function
like this */
typedef void NSLog_printf_handler (NSString* message);
GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
GS_EXPORT void NSLog (NSString* format, ...);
GS_EXPORT void NSLogv (NSString* format, va_list args);
GS_EXPORT void NSLog (NSString* format, ...);
GS_EXPORT void NSLogv (NSString* format, va_list args);
#ifndef YES
#define YES 1
@ -64,12 +65,23 @@ GS_EXPORT void NSLogv (NSString* format, va_list args);
#define nil 0
#endif nil
#ifndef NO_GNUSTEP
GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data);
GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
#endif
#define FOUNDATION_EXPORT
#define FOUNDATION_STATIC_INLINE static inline
#ifndef NO_GNUSTEP
GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data);
GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
/*
* GSObjCClassOfInstance() return the class of an instance.
* The argument to this function must NOT be nil.
*/
FOUNDATION_STATIC_INLINE Class
GSObjCClassOfObject(id obj)
{
return obj->class_pointer;
}
#endif
#endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */

View file

@ -36,61 +36,15 @@
* This file is all to do with improving performance by avoiding the
* Objective-C messaging overhead in time-critical code.
*
* The motiviation behind it is to keep all the information needed to
* do that in one place (using a single mechanism), so that optimization
* attempts can be kept track of.
* THIS STUFF IS GOING AWAY!
*
* The optimisations are of three sorts -
*
* 1. inline functions
* There are many operations that can be speeded up by using inline
* code to examine objects rather than sending messages to them to
* ask them about themselves. Often, the objc runtime provides
* functions to do this, but these sometimes perform unnecessary
* checks. Here we attempt to provide some basics.
*
* 2. class comparison
* It is often necessary to check the class of objects - instead of
* using [+class] method, we can cache certain classes in a global
* structure (The [NSObject +initialize] method does the caching)
* and refer to the structure elements directly.
*
* 3. direct method despatch
* A common techique is to obtain the method implementation for a
* specific message sent to a particular class of object, and call
* the implementation directly to avoid repeated lookup within the
* objc runtime.
* While there is no huge speed advantage to caching the method
* implementations, it does make it easy to search the source for
* code that is using this technique and referring to a cached
* method implementation.
* The intention is to provide similar functionality in NSObjCRuntime.h
* There will be GNUstep specific (mostly inline) functions added to
* the header to provide direct access to runtime functinality and the
* internals of objects. Hopefully a simple configuration option will
* let us build for either the GNU or the Apple runtime.
*/
/*
* Structure to cache class information.
* By convention, the name of the structure element is the name of the
* class with an underscore prepended.
*/
typedef struct {
Class _NSArray;
Class _NSMutableArray;
Class _NSDictionary;
Class _NSMutableDictionary;
Class _NSDataMalloc;
Class _NSMutableDataMalloc;
} fastCls;
GS_EXPORT fastCls _fastCls; /* Populated by _fastBuildCache() */
/*
* The '_fastBuildCache()' function is called to populate the cache
* structures. This is (at present) called in [NSObject +initialize]
* but you may call it explicitly later to repopulate the cache after
* changes have been made to the runtime by loading of categories or
* by classes posing as other classes.
*/
GS_EXPORT void _fastBuildCache();
/*
* The '_fastMallocBuffer()' function is called to get a chunk of
* memory that will automatically be released when the current
@ -100,9 +54,6 @@ GS_EXPORT void *_fastMallocBuffer(unsigned size);
/*
* Fast access to class info - DON'T pass nil to these!
* These should really do different things conditional upon the objc
* runtime in use, but we will probably only ever want to support the
* latest GNU runtime, so I haven't bothered about that.
*/
static INLINE BOOL

View file

@ -43,6 +43,7 @@
#include <Foundation/NSRange.h>
#include <Foundation/NSException.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSObjCRuntime.h>
#include <base/behavior.h>
/* memcpy(), strlen(), strcmp() are gcc builtin's */
@ -359,7 +360,7 @@ compare_c(ivars self, NSString *aString, unsigned mask, NSRange aRange)
if (fastIsInstance(aString) == NO)
return strCompCsNs((id)self, aString, mask, aRange);
c = fastClass(aString);
c = GSObjCClassOfObject(aString);
if (fastClassIsKindOfClass(c, GSUStringClass) == YES
|| (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1))
return strCompCsUs((id)self, aString, mask, aRange);
@ -381,7 +382,7 @@ compare_u(ivars self, NSString *aString, unsigned mask, NSRange aRange)
if (fastIsInstance(aString) == NO)
return strCompUsNs((id)self, aString, mask, aRange);
c = fastClass(aString);
c = GSObjCClassOfObject(aString);
if (fastClassIsKindOfClass(c, GSUStringClass)
|| (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1))
return strCompUsUs((id)self, aString, mask, aRange);
@ -1057,7 +1058,7 @@ rangeOfString_c(ivars self, NSString *aString, unsigned mask, NSRange aRange)
if (fastIsInstance(aString) == NO)
return strRangeCsNs((id)self, aString, mask, aRange);
c = fastClass(aString);
c = GSObjCClassOfObject(aString);
if (fastClassIsKindOfClass(c, GSUStringClass) == YES
|| (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1))
return strRangeCsUs((id)self, aString, mask, aRange);
@ -1079,7 +1080,7 @@ rangeOfString_u(ivars self, NSString *aString, unsigned mask, NSRange aRange)
if (fastIsInstance(aString) == NO)
return strRangeUsNs((id)self, aString, mask, aRange);
c = fastClass(aString);
c = GSObjCClassOfObject(aString);
if (fastClassIsKindOfClass(c, GSUStringClass) == YES
|| (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1))
return strRangeUsUs((id)self, aString, mask, aRange);
@ -1137,7 +1138,7 @@ transmute(ivars self, NSString *aString)
{
ivars other;
BOOL transmute;
Class c = fastClass(aString);
Class c = GSObjCClassOfObject(aString); // NB aString must not be nil
other = (ivars)aString;
transmute = YES;
@ -2202,6 +2203,12 @@ transmute(ivars self, NSString *aString)
unsigned length;
GS_RANGE_CHECK(aRange, _count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"replace characters with nil string"];
if (fastIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"replace characters with non-string"];
length = (aString == nil) ? 0 : [aString length];
offset = length - aRange.length;

View file

@ -244,6 +244,22 @@ $(GNUSTEP_OBJ_DIR)/NSString.o \
$(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \
: $(HEADER_DIR)/fast.x
#
# Files that include NSObjCRuntime.h will need a rebuild if it is changed.
#
$(GNUSTEP_OBJ_DIR)/GSString.o \
$(GNUSTEP_OBJ_DIR)/NSArchiver.o \
$(GNUSTEP_OBJ_DIR)/NSArray.o \
$(GNUSTEP_OBJ_DIR)/NSData.o \
$(GNUSTEP_OBJ_DIR)/NSGDictionary.o \
$(GNUSTEP_OBJ_DIR)/NSInvocation.o \
$(GNUSTEP_OBJ_DIR)/NSObjCRuntime.o \
$(GNUSTEP_OBJ_DIR)/NSObject.o \
$(GNUSTEP_OBJ_DIR)/NSSerializer.o \
$(GNUSTEP_OBJ_DIR)/NSString.o \
$(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \
: $(HEADER_DIR)/NSObjCRuntime.h
#
# Files that include GSeq.h will need a rebuild if it is changed.
#

View file

@ -60,6 +60,9 @@ static SEL xRefSel;
static SEL eObjSel;
static SEL eValSel;
@class NSMutableDataMalloc;
static Class NSMutableDataMallocClass;
+ (void) initialize
{
if (self == [NSArchiver class])
@ -69,6 +72,7 @@ static SEL eValSel;
xRefSel = @selector(serializeTypeTag:andCrossRef:);
eObjSel = @selector(encodeObject:);
eValSel = @selector(encodeValueOfObjCType:at:);
NSMutableDataMallocClass = [NSMutableDataMalloc class];
}
}
@ -76,7 +80,7 @@ static SEL eValSel;
{
NSMutableData *d;
d = [[_fastCls._NSMutableDataMalloc allocWithZone: fastZone(self)] init];
d = [[NSMutableDataMallocClass allocWithZone: fastZone(self)] init];
self = [self initForWritingWithMutableData: d];
RELEASE(d);
return self;
@ -162,7 +166,7 @@ static SEL eValSel;
id d;
NSZone *z = NSDefaultMallocZone();
d = [[_fastCls._NSMutableDataMalloc allocWithZone: z] initWithCapacity: 0];
d = [[NSMutableDataMallocClass allocWithZone: z] initWithCapacity: 0];
if (d == nil)
{
return nil;

View file

@ -27,6 +27,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSObjCRuntime.h>
#include <base/preface.h>
#include <base/fast.x>
@ -81,7 +82,8 @@
- (BOOL) isEqual: (id)other
{
if (other != nil && fastInstanceIsKindOfClass(other, fastClass(self)))
if (other != nil
&& fastInstanceIsKindOfClass(other, GSObjCClassOfObject(self)))
{
return [self isEqualToValue: other];
}
@ -92,7 +94,8 @@
{
typedef __typeof__(data) _dt;
if (aValue != nil && fastInstanceIsKindOfClass(aValue, fastClass(self)))
if (aValue != nil
&& fastInstanceIsKindOfClass(aValue, GSObjCClassOfObject(self)))
{
_dt val = [aValue TYPE_METHOD];
#if TYPE_ORDER == 0

View file

@ -28,6 +28,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSZone.h>
#include <Foundation/NSObjCRuntime.h>
#include <base/preface.h>
#include <base/fast.x>
@ -104,7 +105,7 @@
- (BOOL) isEqualToValue: (NSValue*)aValue
{
if (fastClass(aValue) != fastClass(self))
if (GSObjCClassOfObject(aValue) != GSObjCClassOfObject(self))
return NO;
if (strcmp(objctype, ((NSConcreteValue*)aValue)->objctype) != 0)
return NO;

View file

@ -33,6 +33,7 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSObjCRuntime.h>
@class NSSetNonCore;
@class NSMutableSetNonCore;
@ -110,7 +111,7 @@ static Class NSCountedSet_concrete_class;
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
Class c = fastClass(self);
Class c = GSObjCClassOfObject(self);
if (c == NSCountedSet_abstract_class)
{

View file

@ -33,6 +33,7 @@
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSScanner.h>
#include <Foundation/NSObjCRuntime.h>
#include <base/preface.h>
#include <base/behavior.h>
#include <base/fast.x>
@ -97,8 +98,13 @@ findInArray(NSArray *array, unsigned pos, NSString *str)
static inline NSTimeInterval
otherTime(NSDate* other)
{
Class c = fastClass(other);
Class c;
if (other == nil)
[NSException raise: NSInvalidArgumentException format: @"other time nil"];
if (fastIsInstance(other) == NO)
[NSException raise: NSInvalidArgumentException format: @"other time bad"];
c = GSObjCClassOfObject(other);
if (c == concreteClass || c == calendarClass)
return ((NSGDate*)other)->_seconds_since_ref;
else

View file

@ -35,6 +35,7 @@
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSObjCRuntime.h>
@interface NSDictionaryNonCore : NSDictionary
@end
@ -779,14 +780,14 @@ static NSString *indentStrings[] = {
for (i = 0; i < numKeys; i++)
{
if (fastClass(keys[i]) == lastClass)
if (GSObjCClassOfObject(keys[i]) == lastClass)
continue;
if ([keys[i] respondsToSelector: @selector(compare:)] == NO)
{
canCompare = NO;
break;
}
lastClass = fastClass(keys[i]);
lastClass = GSObjCClassOfObject(keys[i]);
}
if (canCompare == YES)
@ -830,7 +831,7 @@ static NSString *indentStrings[] = {
Class x;
NSComparisonResult r;
x = fastClass(a);
x = GSObjCClassOfObject(a);
if (x != lastClass)
{
lastClass = x;

View file

@ -30,6 +30,7 @@
#include <Foundation/NSPort.h>
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSException.h>
#include <Foundation/NSObjCRuntime.h>
static int debug_proxy = 0;
static Class placeHolder = 0;
@ -742,7 +743,7 @@ enum
- (IMP) methodForSelector: (SEL)aSelector
{
return get_imp(fastClass((id)self), aSelector);
return get_imp(GSObjCClassOfObject((id)self), aSelector);
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector

View file

@ -33,6 +33,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSObjCRuntime.h>
#define GSI_MAP_HAS_VALUE 0
#define GSI_MAP_KTYPES GSUNION_OBJ
@ -249,7 +250,7 @@ static Class mutableSetClass;
return NO;
// Loop for all members in otherSet
c = fastClass(otherSet);
c = GSObjCClassOfObject(otherSet);
if (c == setClass || c == mutableSetClass)
{
GSIMapNode node = ((NSGSet*)otherSet)->map.firstNode;
@ -319,7 +320,7 @@ static Class mutableSetClass;
}
else
{
Class c = fastClass(other);
Class c = GSObjCClassOfObject(other);
if (c == setClass || c == mutableSetClass)
{

View file

@ -36,6 +36,7 @@
#include <Foundation/NSThread.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSObjCRuntime.h>
@implementation NSNumber
@ -56,7 +57,9 @@ GSNumberInfoFromObject(NSNumber *o)
Class c;
GSNumberInfo *info;
c = fastClass(o);
if (o == nil)
return nil;
c = GSObjCClassOfObject(o);
info = (GSNumberInfo*)NSMapGet (numberMap, (void*)c);
if (info == 0)
{
@ -664,7 +667,7 @@ static Class doubleNumberClass;
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
{
[NSException raise: NSInternalInconsistencyException
format: @"descriptionWithLocale: for abstract NSNumber"];
@ -725,7 +728,7 @@ static Class doubleNumberClass;
/* All the rest of these methods must be implemented by a subclass */
- (BOOL) boolValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get boolValue from abstract NSNumber"];
else
@ -835,7 +838,7 @@ static Class doubleNumberClass;
- (signed char) charValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get charValue from abstract NSNumber"];
else
@ -945,7 +948,7 @@ static Class doubleNumberClass;
- (double) doubleValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get doubleValue from abstract NSNumber"];
else
@ -1055,7 +1058,7 @@ static Class doubleNumberClass;
- (float) floatValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get floatValue from abstract NSNumber"];
else
@ -1165,7 +1168,7 @@ static Class doubleNumberClass;
- (signed int) intValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get intValue from abstract NSNumber"];
else
@ -1275,7 +1278,7 @@ static Class doubleNumberClass;
- (signed long long) longLongValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get longLongValue from abstract NSNumber"];
else
@ -1385,7 +1388,7 @@ static Class doubleNumberClass;
- (signed long) longValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get longValue from abstract NSNumber"];
else
@ -1495,7 +1498,7 @@ static Class doubleNumberClass;
- (signed short) shortValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get shortValue from abstract NSNumber"];
else
@ -1610,7 +1613,7 @@ static Class doubleNumberClass;
- (unsigned char) unsignedCharValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get unsignedCharrValue from abstract NSNumber"];
else
@ -1720,7 +1723,7 @@ static Class doubleNumberClass;
- (unsigned int) unsignedIntValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get unsignedIntValue from abstract NSNumber"];
else
@ -1830,7 +1833,7 @@ static Class doubleNumberClass;
- (unsigned long long) unsignedLongLongValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get unsignedLongLongValue from abstract NSNumber"];
else
@ -1940,7 +1943,7 @@ static Class doubleNumberClass;
- (unsigned long) unsignedLongValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get unsignedLongValue from abstract NSNumber"];
else
@ -2050,7 +2053,7 @@ static Class doubleNumberClass;
- (unsigned short) unsignedShortValue
{
if (fastClass(self) == abstractClass)
if (GSObjCClassOfObject(self) == abstractClass)
[NSException raise: NSInternalInconsistencyException
format: @"get unsignedShortValue from abstract NSNumber"];
else

View file

@ -40,14 +40,13 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSObjCRuntime.h>
#include <limits.h>
#include <base/fast.x>
extern BOOL __objc_responds_to(id, SEL);
fastCls _fastCls; /* Structure to cache classes. */
@class _FastMallocBuffer;
static Class fastMallocClass;
static unsigned fastMallocOffset;
@ -57,20 +56,6 @@ static Class NXConstantStringClass;
@class NSDataMalloc;
@class NSMutableDataMalloc;
void _fastBuildCache()
{
/*
* Cache some classes for quick access later.
*/
_fastCls._NSArray = [NSArray class];
_fastCls._NSMutableArray = [NSMutableArray class];
_fastCls._NSDictionary = [NSDictionary class];
_fastCls._NSMutableDictionary = [NSMutableDictionary class];
_fastCls._NSDataMalloc = [NSDataMalloc class];
_fastCls._NSMutableDataMalloc = [NSMutableDataMalloc class];
}
/*
* Reference count and memory management
@ -424,7 +409,7 @@ NSDeallocateObject(NSObject *anObject)
inline NSZone *
fastZone(NSObject *object)
{
if (fastClass(object) == NXConstantStringClass)
if (GSObjCClassOfObject(object) == NXConstantStringClass)
return NSDefaultMallocZone();
return ((obj)object)[-1].zone;
}
@ -434,7 +419,7 @@ fastZone(NSObject *object)
inline NSZone *
fastZone(NSObject *object)
{
if (fastClass(object) == NXConstantStringClass)
if (GSObjCClassOfObject(object) == NXConstantStringClass)
return NSDefaultMallocZone();
return NSZoneFromPointer(&((obj)object)[-1]);
}
@ -495,7 +480,7 @@ NSDeallocateObject(NSObject *anObject)
inline NSZone *
fastZone(NSObject *object)
{
if (fastClass(object) == NXConstantStringClass)
if (GSObjCClassOfObject(object) == NXConstantStringClass)
return NSDefaultMallocZone();
return NSZoneFromPointer(object);
}
@ -622,7 +607,6 @@ static BOOL double_release_check_enabled = NO;
fastMallocOffset = 0;
#endif
NXConstantStringClass = [NXConstantString class];
_fastBuildCache();
GSBuildStrings();
[[NSNotificationCenter defaultCenter]
addObserver: self
@ -754,12 +738,12 @@ static BOOL deallocNotifications = NO;
- (IMP) methodForSelector: (SEL)aSelector
{
/*
* If 'self' is an instance, fastClass() will get the class,
* If 'self' is an instance, GSObjCClassOfObject() will get the class,
* and get_imp() will get the instance method.
* If 'self' is a class, fastClass() will get the meta-class,
* If 'self' is a class, GSObjCClassOfObject() will get the meta-class,
* and get_imp() will get the class method.
*/
return get_imp(fastClass(self), aSelector);
return get_imp(GSObjCClassOfObject(self), aSelector);
}
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector
@ -843,7 +827,6 @@ static BOOL deallocNotifications = NO;
* We may have replaced a class in the cache, or may have replaced one
* which had cached methods, so we must rebuild the cache.
*/
_fastBuildCache();
}
- (void) doesNotRecognizeSelector: (SEL)aSelector
@ -911,7 +894,7 @@ static BOOL deallocNotifications = NO;
* use get_imp() because NSDistantObject doesn't implement
* methodForSelector:
*/
proxyImp = get_imp(fastClass((id)proxyClass),
proxyImp = get_imp(GSObjCClassOfObject((id)proxyClass),
@selector(proxyWithLocal:connection:));
}
@ -1025,7 +1008,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
msg = get_imp(fastClass(self), aSelector);
msg = get_imp(GSObjCClassOfObject(self), aSelector);
if (!msg)
{
[NSException raise: NSGenericException
@ -1046,7 +1029,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
msg = get_imp(fastClass(self), aSelector);
msg = get_imp(GSObjCClassOfObject(self), aSelector);
if (!msg)
{
[NSException raise: NSGenericException
@ -1070,7 +1053,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
msg = get_imp(fastClass(self), aSelector);
msg = get_imp(GSObjCClassOfObject(self), aSelector);
if (!msg)
{
[NSException raise: NSGenericException
@ -1113,9 +1096,9 @@ static BOOL deallocNotifications = NO;
{
#if 0
if (fastIsInstance(self))
return (class_get_instance_method(fastClass(self), aSelector)!=METHOD_NULL);
return (class_get_instance_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL);
else
return (class_get_class_method(fastClass(self), aSelector)!=METHOD_NULL);
return (class_get_class_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL);
#else
return __objc_responds_to(self, aSelector);
#endif

View file

@ -27,6 +27,7 @@
#include <Foundation/NSScanner.h>
#include <Foundation/NSException.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSObjCRuntime.h>
#include <float.h>
#include <limits.h>
#include <math.h>
@ -126,7 +127,7 @@ typedef struct {
aString = @"";
}
c = fastClass(aString);
c = GSObjCClassOfObject(aString);
if (c == GSUString_class)
{
_isUnicode = YES;

View file

@ -34,6 +34,7 @@
#include <Foundation/NSSet.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSNotificationQueue.h>
#include <Foundation/NSObjCRuntime.h>
#include <base/NSGArray.h>
@ -133,8 +134,9 @@ static SEL setSel;
static void
initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u)
{
Class c = fastClass(d);
Class c;
c = GSObjCClassOfObject(d);
info->data = d;
info->appImp = (void (*)())get_imp(c, appSel);
info->datImp = (void* (*)())get_imp(c, datSel);
@ -160,8 +162,9 @@ endSerializerInfo(_NSSerializerInfo* info)
static void
serializeToInfo(id object, _NSSerializerInfo* info)
{
Class c = fastClass(object);
Class c;
c = GSObjCClassOfObject(object);
if (fastIsClass(c) == NO)
{
[NSException raise: NSInvalidArgumentException

View file

@ -31,6 +31,7 @@
#include <Foundation/NSUtilities.h>
#include <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSObjCRuntime.h>
@interface NSSetNonCore : NSSet
@end
@ -120,8 +121,9 @@ static Class NSMutableSet_concrete_class;
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
Class c = fastClass(self);
Class c;
c = GSObjCClassOfObject(self);
if (c == NSSet_abstract_class)
{
RELEASE(self);

View file

@ -27,6 +27,7 @@
#include <Foundation/NSZone.h>
#include <Foundation/NSException.h>
#include <Foundation/NSByteOrder.h>
#include <Foundation/NSObjCRuntime.h>
/*
* Setup for inline operation of arrays.
@ -294,6 +295,9 @@ mapClassName(NSUnarchiverObjectInfo *info)
@implementation NSUnarchiver
@class NSDataMalloc;
static Class NSDataMallocClass;
+ (void) initialize
{
if ([self class] == [NSUnarchiver class])
@ -302,6 +306,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
tagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:);
dValSel = @selector(decodeValueOfObjCType:at:);
clsDict = [[NSMutableDictionary alloc] initWithCapacity: 200];
NSDataMallocClass = [NSDataMalloc class];
}
}
@ -328,7 +333,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
+ (id) unarchiveObjectWithFile: (NSString*)path
{
NSData *d = [_fastCls._NSDataMalloc dataWithContentsOfFile: path];
NSData *d = [NSDataMallocClass dataWithContentsOfFile: path];
if (d != nil)
{
@ -1144,7 +1149,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
TEST_RELEASE(data);
data = RETAIN(anObject);
c = fastClass(data);
c = GSObjCClassOfObject(data);
if (src != self)
{
src = data;