Title: [185377] trunk/Source/WebCore
Revision
185377
Author
[email protected]
Date
2015-06-09 14:18:23 -0700 (Tue, 09 Jun 2015)

Log Message

Follow-up fix for:
_javascript_ bindings are unnecessarily checking for impossible empty JSValue arguments
https://bugs.webkit.org/show_bug.cgi?id=145811

Reviewed by Antti Koivisto.

There was one unusual case in the bindings generator that was depending on this.

* bindings/js/JSDOMBinding.h:
(WebCore::argumentOrNull): Deleted.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck): Stop using argumentOrNull.
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp: Updated.
* bindings/scripts/test/JS/JSTestObj.cpp: Updated.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185376 => 185377)


--- trunk/Source/WebCore/ChangeLog	2015-06-09 20:23:45 UTC (rev 185376)
+++ trunk/Source/WebCore/ChangeLog	2015-06-09 21:18:23 UTC (rev 185377)
@@ -1,10 +1,27 @@
 2015-06-09  Darin Adler  <[email protected]>
 
+        Follow-up fix for:
         _javascript_ bindings are unnecessarily checking for impossible empty JSValue arguments
         https://bugs.webkit.org/show_bug.cgi?id=145811
 
         Reviewed by Antti Koivisto.
 
+        There was one unusual case in the bindings generator that was depending on this.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::argumentOrNull): Deleted.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck): Stop using argumentOrNull.
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: Updated.
+        * bindings/scripts/test/JS/JSTestObj.cpp: Updated.
+
+2015-06-09  Darin Adler  <[email protected]>
+
+        _javascript_ bindings are unnecessarily checking for impossible empty JSValue arguments
+        https://bugs.webkit.org/show_bug.cgi?id=145811
+
+        Reviewed by Antti Koivisto.
+
         At some point, someone who didn't understand JSValue very well added checks for
         isEmpty (and the function isEmpty itself) in _javascript_ bindings. But the engine
         never would pass an empty JSValue to a binding; that's used only inside the

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (185376 => 185377)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2015-06-09 20:23:45 UTC (rev 185376)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2015-06-09 21:18:23 UTC (rev 185377)
@@ -238,11 +238,6 @@
     return createWrapper<WrapperClass>(globalObject, domObject);
 }
 
-inline JSC::JSValue argumentOrNull(JSC::ExecState* exec, unsigned index)
-{
-    return index >= exec->argumentCount() ? JSC::JSValue() : exec->argument(index);
-}
-
 void addImpureProperty(const AtomicString&);
 
 const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (185376 => 185377)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-06-09 20:23:45 UTC (rev 185376)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-06-09 21:18:23 UTC (rev 185377)
@@ -3335,7 +3335,16 @@
                 push(@$outputArray, "    if ($name.isNull())\n");
                 push(@$outputArray, "        return JSValue::encode(jsNull());\n");
             } else {
-                push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, $optional && $defaultAttribute && $defaultAttribute eq "NullString" ? "argumentOrNull(exec, $argsIndex)" : "exec->argument($argsIndex)", $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
+                my $outer;
+                my $inner;
+                if ($optional && $defaultAttribute && $defaultAttribute eq "NullString") {
+                    $outer = "exec->argumentCount() <= $argsIndex ? String() : ";
+                    $inner = "exec->uncheckedArgument($argsIndex)";
+                } else {
+                    $outer = "";
+                    $inner = "exec->argument($argsIndex)";
+                }
+                push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name = $outer" . JSValueToNative($parameter, $inner, $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
             }
 
             # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (185376 => 185377)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2015-06-09 20:23:45 UTC (rev 185376)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2015-06-09 21:18:23 UTC (rev 185377)
@@ -134,7 +134,7 @@
     String str2 = exec->argument(1).toString(exec)->value(exec);
     if (UNLIKELY(exec->hadException()))
         return JSValue::encode(jsUndefined());
-    String str3 = argumentOrNull(exec, 2).toString(exec)->value(exec);
+    String str3 = exec->argumentCount() <= 2 ? String() : exec->uncheckedArgument(2).toString(exec)->value(exec);
     if (UNLIKELY(exec->hadException()))
         return JSValue::encode(jsUndefined());
     RefPtr<TestNamedConstructor> object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), str1, str2, str3, ec);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (185376 => 185377)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-06-09 20:23:45 UTC (rev 185376)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-06-09 21:18:23 UTC (rev 185377)
@@ -3578,7 +3578,7 @@
         return throwThisTypeError(*exec, "TestObj", "methodWithOptionalStringIsNullString");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->impl();
-    String str = argumentOrNull(exec, 0).toString(exec)->value(exec);
+    String str = exec->argumentCount() <= 0 ? String() : exec->uncheckedArgument(0).toString(exec)->value(exec);
     if (UNLIKELY(exec->hadException()))
         return JSValue::encode(jsUndefined());
     impl.methodWithOptionalStringIsNullString(str);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to