summaryrefslogtreecommitdiffstats
path: root/WebCore/bridge/objc
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-11-05 09:23:40 +0000
committerSteve Block <steveblock@google.com>2009-11-10 22:41:12 +0000
commitcac0f67c402d107cdb10971b95719e2ff9c7c76b (patch)
treed182c7f87211c6f201a5f038e332336493ebdbe7 /WebCore/bridge/objc
parent4b2ef0f288e7c6c4602f621b7a0e9feed304b70e (diff)
downloadexternal_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.zip
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.gz
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.bz2
Merge webkit.org at r50258 : Initial merge by git.
Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0
Diffstat (limited to 'WebCore/bridge/objc')
-rw-r--r--WebCore/bridge/objc/objc_instance.mm21
-rw-r--r--WebCore/bridge/objc/objc_runtime.h3
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&);