From cac0f67c402d107cdb10971b95719e2ff9c7c76b Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 5 Nov 2009 09:23:40 +0000 Subject: Merge webkit.org at r50258 : Initial merge by git. Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0 --- WebCore/bridge/objc/objc_instance.mm | 21 +++++++++++++++++---- WebCore/bridge/objc/objc_runtime.h | 3 ++- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'WebCore/bridge/objc') 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 -#include -#include +#import +#import +#import +#import #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 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&); -- cgit v1.1