Bug 109902 - [JSC] MAYBE_MISSING_PARAMETER(..., DefaultIsNullString) macro is redundant
Summary: [JSC] MAYBE_MISSING_PARAMETER(..., DefaultIsNullString) macro is redundant
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-14 23:43 PST by Kentaro Hara
Modified: 2013-02-19 13:09 PST (History)
12 users (show)

See Also:


Attachments
Patch (60.77 KB, patch)
2013-02-14 23:45 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff
patch for landing (61.10 KB, patch)
2013-02-18 23:27 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kentaro Hara 2013-02-14 23:43:37 PST
c.f. corresponding V8 bug: https://bugs.webkit.org/show_bug.cgi?id=109899

Currently:

- MAYBE_MISSING_PARAMETER(exec, index, DefaultIsUndefined) returns exec->argument(index).
- MAYBE_MISSING_PARAMETER(exec, index, DefaultIsNullString) returns JSValue() if exec->argument(index) is missing (i.e. the length of the argument is less than index). It returns exec->argument(index) otherwise.

No one other than CodeGeneratorJS.pm uses MAYBE_MISSING_PARAMETER(exec, index, DefaultIsUndefined). Instead, we simply use exec->argument(index). We should remove the redundant usage in CodeGeneratorJS.pm too. The long-name macro has been making generated code less readable.

In addition, we can rename MAYBE_MISSING_PARAMETER() to MissingIsNullString().
Comment 1 Kentaro Hara 2013-02-14 23:45:12 PST
Created attachment 188494 [details]
Patch
Comment 2 Adam Barth 2013-02-15 09:11:23 PST
Comment on attachment 188494 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=188494&action=review

> Source/WebCore/bindings/js/JSDOMBinding.h:62
> +#define MissingIsNullString(exec, index) (((index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index)))

Same comment.  This should probably be an inline function.  If it can't be an inline function, we should keep the ALL_CAPS name.
Comment 3 Darin Adler 2013-02-15 09:34:55 PST
Comment on attachment 188494 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=188494&action=review

>> Source/WebCore/bindings/js/JSDOMBinding.h:62
>> +#define MissingIsNullString(exec, index) (((index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index)))
> 
> Same comment.  This should probably be an inline function.  If it can't be an inline function, we should keep the ALL_CAPS name.

Further, both the names MAYBE_MISSING_PARAMETER and MissingIsNullString are examples of the kind of confusing names we try to avoid. A function should be named after its return value. And even though it’s used to implement DefaultIsNullString, this does not return a string, so it’s really confusing to mention string in its name.

ARGUMENT_OR_NULL (or ArgumentOrNull if it can be an inline function) would be one possible name. Not great, but better than the two we used in the past.
Comment 4 Kentaro Hara 2013-02-18 23:27:22 PST
Created attachment 189002 [details]
patch for landing
Comment 5 Kentaro Hara 2013-02-18 23:28:07 PST
(In reply to comment #3)
> (From update of attachment 188494 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188494&action=review
> 
> >> Source/WebCore/bindings/js/JSDOMBinding.h:62
> >> +#define MissingIsNullString(exec, index) (((index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index)))
> > 
> > Same comment.  This should probably be an inline function.  If it can't be an inline function, we should keep the ALL_CAPS name.
> 
> Further, both the names MAYBE_MISSING_PARAMETER and MissingIsNullString are examples of the kind of confusing names we try to avoid. A function should be named after its return value. And even though it’s used to implement DefaultIsNullString, this does not return a string, so it’s really confusing to mention string in its name.
> 
> ARGUMENT_OR_NULL (or ArgumentOrNull if it can be an inline function) would be one possible name. Not great, but better than the two we used in the past.

Thanks, changed it to an inline function and renamed it to argumentOrNull().
Comment 6 WebKit Review Bot 2013-02-19 00:13:55 PST
Comment on attachment 189002 [details]
patch for landing

Clearing flags on attachment: 189002

Committed r143304: <http://trac.webkit.org/changeset/143304>
Comment 7 WebKit Review Bot 2013-02-19 00:13:59 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Julien Brianceau 2013-02-19 00:20:56 PST
This patch breaks our SH4 build slave: http://build.webkit.org/builders/Qt%20Linux%20SH4%20Release/builds/20416
Comment 9 Kentaro Hara 2013-02-19 00:21:33 PST
(In reply to comment #8)
> This patch breaks our SH4 build slave: http://build.webkit.org/builders/Qt%20Linux%20SH4%20Release/builds/20416

Sorry, looking.
Comment 10 Kentaro Hara 2013-02-19 00:25:50 PST
Fixed the build error in r143306.
Comment 11 Julien Brianceau 2013-02-19 01:03:02 PST
(In reply to comment #10)
> Fixed the build error in r143306.
Thanks a lot !
Comment 12 Ryosuke Niwa 2013-02-19 01:24:32 PST
Landed another build fix in r143309.
Comment 13 Csaba Osztrogonác 2013-02-19 02:07:06 PST
Comment on attachment 189002 [details]
patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=189002&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2758
> +            push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, $optional eq "DefaultIsNullString" ? "argumentOrNull(exec, $argsIndex)" : "exec->argument($argsIndex)") . ");\n");

It caused the following warning:
Use of uninitialized value $optional in string eq at /home/oszi/WebKit/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm line 2758.

Could you check and fix it, please?
Comment 14 Csaba Osztrogonác 2013-02-19 02:09:30 PST
(In reply to comment #13)
> (From update of attachment 189002 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=189002&action=review
> 
> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2758
> > +            push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, $optional eq "DefaultIsNullString" ? "argumentOrNull(exec, $argsIndex)" : "exec->argument($argsIndex)") . ");\n");
> 
> It caused the following warning:
> Use of uninitialized value $optional in string eq at /home/oszi/WebKit/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm line 2758.
> 
> Could you check and fix it, please?

See the Qt bot for details:
http://build.webkit.org/builders/Qt%20Linux%20Release/builds/57635/steps/compile-webkit/logs/stdio
Comment 15 Csaba Osztrogonác 2013-02-19 03:20:01 PST
(In reply to comment #14)
> (In reply to comment #13)
> > (From update of attachment 189002 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=189002&action=review
> > 
> > > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2758
> > > +            push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, $optional eq "DefaultIsNullString" ? "argumentOrNull(exec, $argsIndex)" : "exec->argument($argsIndex)") . ");\n");
> > 
> > It caused the following warning:
> > Use of uninitialized value $optional in string eq at /home/oszi/WebKit/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm line 2758.
> > 
> > Could you check and fix it, please?
> 
> See the Qt bot for details:
> http://build.webkit.org/builders/Qt%20Linux%20Release/builds/57635/steps/compile-webkit/logs/stdio

Fixed by https://trac.webkit.org/changeset/143308
Comment 16 Csaba Osztrogonác 2013-02-19 03:20:24 PST
Additionally it broke the bindings tests on all bot. Could you fix it?
Comment 17 Csaba Osztrogonác 2013-02-19 13:07:58 PST
(In reply to comment #16)
> Additionally it broke the bindings tests on all bot. Could you fix it?

ping for fix?
Comment 18 Kentaro Hara 2013-02-19 13:09:41 PST
(In reply to comment #17)
> (In reply to comment #16)
> > Additionally it broke the bindings tests on all bot. Could you fix it?
> 
> ping for fix?

Fixed in r143374. Sorry for late.