Title: [164136] trunk/Source/_javascript_Core
Revision
164136
Author
mhahnenb...@apple.com
Date
2014-02-14 14:44:52 -0800 (Fri, 14 Feb 2014)

Log Message

ASSERT(isValidAllocation(bytes)) when ObjC API creates custom errors
https://bugs.webkit.org/show_bug.cgi?id=128840

Reviewed by Joseph Pecoraro.

We need to add APIEntryShims around places where we allocate errors in JSC.
Also converted some of the createTypeError call sites to use ASCIILiteral.

* API/JSValue.mm:
(valueToArray):
(valueToDictionary):
* API/ObjCCallbackFunction.mm:
(JSC::objCCallbackFunctionCallAsConstructor):
(JSC::ObjCCallbackFunctionImpl::call):
* API/tests/testapi.mm:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSValue.mm (164135 => 164136)


--- trunk/Source/_javascript_Core/API/JSValue.mm	2014-02-14 22:30:18 UTC (rev 164135)
+++ trunk/Source/_javascript_Core/API/JSValue.mm	2014-02-14 22:44:52 UTC (rev 164136)
@@ -780,8 +780,9 @@
     if (JSValueIsObject(context, value))
         return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableArray array], ContainerArray});
 
+    JSC::APIEntryShim shim(toJS(context));
     if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value)))
-        *exception = toRef(JSC::createTypeError(toJS(context), "Cannot convert primitive to NSArray"));
+        *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSArray")));
     return nil;
 }
 
@@ -796,8 +797,9 @@
     if (JSValueIsObject(context, value))
         return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableDictionary dictionary], ContainerDictionary});
 
+    JSC::APIEntryShim shim(toJS(context));
     if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value)))
-        *exception = toRef(JSC::createTypeError(toJS(context), "Cannot convert primitive to NSDictionary"));
+        *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSDictionary")));
     return nil;
 }
 

Modified: trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm (164135 => 164136)


--- trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm	2014-02-14 22:30:18 UTC (rev 164135)
+++ trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm	2014-02-14 22:44:52 UTC (rev 164136)
@@ -129,7 +129,7 @@
             return;
         }
 
-        *exception = toRef(JSC::createTypeError(toJS(contextRef), "Argument does not match Objective-C Class"));
+        *exception = toRef(JSC::createTypeError(toJS(contextRef), ASCIILiteral("Argument does not match Objective-C Class")));
     }
 
     Class m_class;
@@ -496,7 +496,7 @@
         return 0;
 
     if (!JSValueIsObject(contextRef, result)) {
-        *exception = toRef(JSC::createTypeError(toJS(contextRef), "Objective-C blocks called as constructors must return an object."));
+        *exception = toRef(JSC::createTypeError(toJS(contextRef), ASCIILiteral("Objective-C blocks called as constructors must return an object.")));
         return 0;
     }
     return (JSObjectRef)result;
@@ -562,7 +562,7 @@
         RELEASE_ASSERT(!thisObject);
         target = [m_instanceClass alloc];
         if (!target || ![target isKindOfClass:m_instanceClass]) {
-            *exception = toRef(JSC::createTypeError(toJS(contextRef), "self type check failed for Objective-C instance method"));
+            *exception = toRef(JSC::createTypeError(toJS(contextRef), ASCIILiteral("self type check failed for Objective-C instance method")));
             return JSValueMakeUndefined(contextRef);
         }
         [m_invocation setTarget:target];
@@ -572,7 +572,7 @@
     case CallbackInstanceMethod: {
         target = tryUnwrapObjcObject(contextRef, thisObject);
         if (!target || ![target isKindOfClass:m_instanceClass]) {
-            *exception = toRef(JSC::createTypeError(toJS(contextRef), "self type check failed for Objective-C instance method"));
+            *exception = toRef(JSC::createTypeError(toJS(contextRef), ASCIILiteral("self type check failed for Objective-C instance method")));
             return JSValueMakeUndefined(contextRef);
         }
         [m_invocation setTarget:target];

Modified: trunk/Source/_javascript_Core/API/tests/testapi.mm (164135 => 164136)


--- trunk/Source/_javascript_Core/API/tests/testapi.mm	2014-02-14 22:30:18 UTC (rev 164135)
+++ trunk/Source/_javascript_Core/API/tests/testapi.mm	2014-02-14 22:44:52 UTC (rev 164136)
@@ -1272,6 +1272,12 @@
         checkResult(@"makeObject() instanceof UnexportedObject", [result isBoolean] && [result toBool]);
     }
 
+    @autoreleasepool {
+        JSContext *context = [[JSContext alloc] init];
+        [[JSValue valueWithInt32:42 inContext:context] toDictionary];
+        [[JSValue valueWithInt32:42 inContext:context] toArray];
+    }
+
     currentThisInsideBlockGetterTest();
     runDateTests();
     runJSExportTests();

Modified: trunk/Source/_javascript_Core/ChangeLog (164135 => 164136)


--- trunk/Source/_javascript_Core/ChangeLog	2014-02-14 22:30:18 UTC (rev 164135)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-02-14 22:44:52 UTC (rev 164136)
@@ -1,5 +1,23 @@
 2014-02-14  Mark Hahnenberg  <mhahnenb...@apple.com>
 
+        ASSERT(isValidAllocation(bytes)) when ObjC API creates custom errors
+        https://bugs.webkit.org/show_bug.cgi?id=128840
+
+        Reviewed by Joseph Pecoraro.
+
+        We need to add APIEntryShims around places where we allocate errors in JSC.
+        Also converted some of the createTypeError call sites to use ASCIILiteral.
+
+        * API/JSValue.mm:
+        (valueToArray):
+        (valueToDictionary):
+        * API/ObjCCallbackFunction.mm:
+        (JSC::objCCallbackFunctionCallAsConstructor):
+        (JSC::ObjCCallbackFunctionImpl::call):
+        * API/tests/testapi.mm:
+
+2014-02-14  Mark Hahnenberg  <mhahnenb...@apple.com>
+
         Baseline JIT should have a fast path to bypass the write barrier on op_enter
         https://bugs.webkit.org/show_bug.cgi?id=128832
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to