diff options
Diffstat (limited to 'WebCore/bridge/objc')
-rw-r--r-- | WebCore/bridge/objc/objc_instance.mm | 21 | ||||
-rw-r--r-- | WebCore/bridge/objc/objc_runtime.h | 3 |
2 files changed, 19 insertions, 5 deletions
diff --git a/WebCore/bridge/objc/objc_instance.mm b/WebCore/bridge/objc/objc_instance.mm index f7550e4..9f2e3bb 100644 --- a/WebCore/bridge/objc/objc_instance.mm +++ b/WebCore/bridge/objc/objc_instance.mm @@ -28,9 +28,10 @@ #import "FoundationExtras.h" #import "WebScriptObject.h" -#include <runtime/Error.h> -#include <runtime/JSLock.h> -#include <wtf/Assertions.h> +#import <objc/objc-auto.h> +#import <runtime/Error.h> +#import <runtime/JSLock.h> +#import <wtf/Assertions.h> #ifdef NDEBUG #define OBJC_LOG(formatAndArgs...) ((void)0) @@ -123,10 +124,22 @@ ObjcInstance::~ObjcInstance() [pool drain]; } +static NSAutoreleasePool* allocateAutoReleasePool() +{ +#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 + // If GC is enabled an autorelease pool is unnecessary, and the + // pool cannot be protected from GC so may be collected leading + // to a crash when we try to drain the release pool. + if (objc_collectingEnabled()) + return nil; +#endif + return [[NSAutoreleasePool alloc] init]; +} + void ObjcInstance::virtualBegin() { if (!_pool) - _pool = [[NSAutoreleasePool alloc] init]; + _pool = allocateAutoReleasePool(); _beginCount++; } diff --git a/WebCore/bridge/objc/objc_runtime.h b/WebCore/bridge/objc/objc_runtime.h index 7c772a6..63f3254 100644 --- a/WebCore/bridge/objc/objc_runtime.h +++ b/WebCore/bridge/objc/objc_runtime.h @@ -104,10 +104,11 @@ public: static PassRefPtr<Structure> createStructure(JSValue prototype) { - return Structure::create(prototype, TypeInfo(ObjectType)); + return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags)); } private: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags; virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); |