Title: [140031] trunk/Source/_javascript_Core
- Revision
- 140031
- Author
- mhahnenb...@apple.com
- Date
- 2013-01-17 12:51:56 -0800 (Thu, 17 Jan 2013)
Log Message
Objective-C API: Clean up JSValue
https://bugs.webkit.org/show_bug.cgi?id=107156
Reviewed by Oliver Hunt.
JSContext m_protectCounts, protect, unprotect are all now unnecessary overhead, and should all be removed.
These exist to handle the context going away before the value does; the context needs to be able to unprotect
values early. Since the value is now keeping the context alive there is no longer any danger of this happening;
instead we should just protect/unprotect the value in JSValue's init/dealloc methods.
* API/JSContext.mm:
(-[JSContext dealloc]):
* API/JSContextInternal.h:
* API/JSValue.mm:
(-[JSValue initWithValue:inContext:]):
(-[JSValue dealloc]):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSContext.mm (140030 => 140031)
--- trunk/Source/_javascript_Core/API/JSContext.mm 2013-01-17 20:45:06 UTC (rev 140030)
+++ trunk/Source/_javascript_Core/API/JSContext.mm 2013-01-17 20:51:56 UTC (rev 140031)
@@ -42,7 +42,6 @@
JSVirtualMachine *m_virtualMachine;
JSGlobalContextRef m_context;
JSWrapperMap *m_wrapperMap;
- HashCountedSet<JSValueRef> m_protectCounts;
}
@synthesize exception;
@@ -156,12 +155,6 @@
- (void)dealloc
{
toJS(m_context)->lexicalGlobalObject()->m_apiData = 0;
-
- HashCountedSet<JSValueRef>::iterator iterator = m_protectCounts.begin();
- HashCountedSet<JSValueRef>::iterator end = m_protectCounts.end();
- for (; iterator != end; ++iterator)
- JSValueUnprotect(m_context, iterator->key);
-
[m_wrapperMap release];
JSGlobalContextRelease(m_context);
[m_virtualMachine release];
@@ -206,24 +199,6 @@
[self release];
}
-- (void)protect:(JSValueRef)value
-{
- // Lock access to m_protectCounts
- JSC::JSLockHolder lock(toJS(m_context));
-
- if (m_protectCounts.add(value).isNewEntry)
- JSValueProtect(m_context, value);
-}
-
-- (void)unprotect:(JSValueRef)value
-{
- // Lock access to m_protectCounts
- JSC::JSLockHolder lock(toJS(m_context));
-
- if (m_protectCounts.remove(value))
- JSValueUnprotect(m_context, value);
-}
-
- (JSValue *)wrapperForObject:(id)object
{
// Lock access to m_wrapperMap
Modified: trunk/Source/_javascript_Core/API/JSContextInternal.h (140030 => 140031)
--- trunk/Source/_javascript_Core/API/JSContextInternal.h 2013-01-17 20:45:06 UTC (rev 140030)
+++ trunk/Source/_javascript_Core/API/JSContextInternal.h 2013-01-17 20:51:56 UTC (rev 140031)
@@ -63,9 +63,6 @@
- (void)beginCallbackWithData:(CallbackData *)callbackData thisValue:(JSValueRef)thisValue argumentCount:(size_t)argumentCount arguments:(const JSValueRef *)arguments;
- (void)endCallbackWithData:(CallbackData *)callbackData;
-- (void)protect:(JSValueRef)value;
-- (void)unprotect:(JSValueRef)value;
-
- (JSValue *)wrapperForObject:(id)object;
@end
Modified: trunk/Source/_javascript_Core/API/JSValue.mm (140030 => 140031)
--- trunk/Source/_javascript_Core/API/JSValue.mm 2013-01-17 20:45:06 UTC (rev 140030)
+++ trunk/Source/_javascript_Core/API/JSValue.mm 2013-01-17 20:51:56 UTC (rev 140031)
@@ -1051,8 +1051,8 @@
ASSERT(value);
m_context = [context retain];
- [context protect:value];
m_value = value;
+ JSValueProtect(contextInternalContext(m_context), m_value);
return self;
}
@@ -1172,7 +1172,7 @@
{
JSContext *context = [self context];
if (context)
- [context unprotect:m_value];
+ JSValueUnprotect(contextInternalContext(context), m_value);
[m_context release];
m_context = nil;
[super dealloc];
Modified: trunk/Source/_javascript_Core/ChangeLog (140030 => 140031)
--- trunk/Source/_javascript_Core/ChangeLog 2013-01-17 20:45:06 UTC (rev 140030)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-01-17 20:51:56 UTC (rev 140031)
@@ -1,3 +1,22 @@
+2013-01-17 Mark Hahnenberg <mhahnenb...@apple.com>
+
+ Objective-C API: Clean up JSValue
+ https://bugs.webkit.org/show_bug.cgi?id=107156
+
+ Reviewed by Oliver Hunt.
+
+ JSContext m_protectCounts, protect, unprotect are all now unnecessary overhead, and should all be removed.
+ These exist to handle the context going away before the value does; the context needs to be able to unprotect
+ values early. Since the value is now keeping the context alive there is no longer any danger of this happening;
+ instead we should just protect/unprotect the value in JSValue's init/dealloc methods.
+
+ * API/JSContext.mm:
+ (-[JSContext dealloc]):
+ * API/JSContextInternal.h:
+ * API/JSValue.mm:
+ (-[JSValue initWithValue:inContext:]):
+ (-[JSValue dealloc]):
+
2013-01-17 Filip Pizlo <fpi...@apple.com>
DFG Node::ref() and Node::deref() should not return bool, and should have postfixRef variants
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes