Modified: trunk/Source/WebCore/ChangeLog (149176 => 149177)
--- trunk/Source/WebCore/ChangeLog 2013-04-26 13:02:53 UTC (rev 149176)
+++ trunk/Source/WebCore/ChangeLog 2013-04-26 13:03:23 UTC (rev 149177)
@@ -1,3 +1,26 @@
+2013-04-26 Christophe Dumez <ch.du...@sisa.samsung.com>
+
+ Optimize function and interface object length computation in bindings generator
+ https://bugs.webkit.org/show_bug.cgi?id=115247
+
+ Reviewed by Kentaro Hara.
+
+ Introduce new GetFunctionLength() function that efficiently compute the length
+ of a function (i.e. its number of mandatory parameters).
+
+ We now call GetFunctionLength() instead of GenerateFunctionParametersCheck()
+ whenever we care only interested in the function length and not the actual
+ _expression_ for checking the parameters. This is much more efficient as
+ GenerateFunctionParametersCheck() does a lot more processing than we need in
+ this case.
+
+ No new tests, no behavior change.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GetFunctionLength):
+ (GenerateImplementation):
+ (GenerateConstructorHelperMethods):
+
2013-04-26 Andreas Kling <akl...@apple.com>
Web Audio: Remove reduplicative addInput() in AnalyserNode.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (149176 => 149177)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-04-26 13:02:53 UTC (rev 149176)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-04-26 13:03:23 UTC (rev 149177)
@@ -1320,6 +1320,22 @@
return ($res, keys %usedArguments);
}
+# As per Web IDL specification, the length of a function Object is
+# its number of mandatory parameters.
+sub GetFunctionLength
+{
+ my $function = shift;
+
+ my $numMandatoryParams = 0;
+ foreach my $parameter (@{$function->parameters}) {
+ # Abort as soon as we find the first optional parameter as no mandatory
+ # parameter can follow an optional one.
+ last if $parameter->extendedAttributes->{"Optional"};
+ $numMandatoryParams++;
+ }
+ return $numMandatoryParams;
+}
+
sub GenerateFunctionParametersCheck
{
my $function = shift;
@@ -1622,8 +1638,8 @@
my $functionName = GetFunctionName($className, $function);
push(@hashValue1, $functionName);
- my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($function);
- push(@hashValue2, $numMandatoryParams);
+ my $functionLength = GetFunctionLength($function);
+ push(@hashValue2, $functionLength);
my @specials = ();
push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"};
@@ -1686,8 +1702,8 @@
my $functionName = GetFunctionName($className, $function);
push(@hashValue1, $functionName);
- my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($function);
- push(@hashValue2, $numMandatoryParams);
+ my $functionLength = GetFunctionLength($function);
+ push(@hashValue2, $functionLength);
my @specials = ();
push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"};
@@ -4161,19 +4177,19 @@
my $generatingNamedConstructor = shift;
my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
- my $leastNumMandatoryParams = $interface->extendedAttributes->{"ConstructorParameters"};
- if (!defined $leastNumMandatoryParams) {
+ my $leastConstructorLength = $interface->extendedAttributes->{"ConstructorParameters"};
+ if (!defined $leastConstructorLength) {
if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
- $leastNumMandatoryParams = 1;
+ $leastConstructorLength = 1;
} elsif ($interface->extendedAttributes->{"Constructor"}) {
my @constructors = @{$interface->constructors};
- $leastNumMandatoryParams = 255;
+ $leastConstructorLength = 255;
foreach my $constructor (@constructors) {
- my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($constructor);
- $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams);
+ my $constructorLength = GetFunctionLength($constructor);
+ $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
}
} else {
- $leastNumMandatoryParams = 0;
+ $leastConstructorLength = 0;
}
}
@@ -4214,7 +4230,7 @@
push(@$outputArray, " ASSERT(inherits(&s_info));\n");
push(@$outputArray, " putDirect(exec->vm(), exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n");
}
- push(@$outputArray, " putDirect(exec->vm(), exec->propertyNames().length, jsNumber(${leastNumMandatoryParams}), ReadOnly | DontDelete | DontEnum);\n") if defined $leastNumMandatoryParams;
+ push(@$outputArray, " putDirect(exec->vm(), exec->propertyNames().length, jsNumber(${leastConstructorLength}), ReadOnly | DontDelete | DontEnum);\n") if defined $leastConstructorLength;
push(@$outputArray, "}\n\n");
if (!$generatingNamedConstructor) {