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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185377
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-06-09 Darin Adler <darin@apple.com>
+
+ 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 <darin@apple.com>
JavaScript bindings are unnecessarily checking for impossible empty JSValue arguments
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);
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.
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);
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);