Bug 97754 - Clean up HasTrivialConstructor/Destructor
Summary: Clean up HasTrivialConstructor/Destructor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-26 20:25 PDT by Mark Hahnenberg
Modified: 2012-09-30 17:28 PDT (History)
3 users (show)

See Also:


Attachments
Patch (14.42 KB, patch)
2012-09-26 20:55 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (14.36 KB, patch)
2012-09-27 09:26 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (15.79 KB, patch)
2012-09-27 09:58 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (1.38 KB, patch)
2012-09-27 16:51 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hahnenberg 2012-09-26 20:25:00 PDT
As noted in bug 96980, TypeTraits.h could use a little cleaning up.
Comment 1 Mark Hahnenberg 2012-09-26 20:55:20 PDT
Created attachment 165921 [details]
Patch
Comment 2 Mark Hahnenberg 2012-09-27 09:26:36 PDT
Created attachment 166019 [details]
Patch
Comment 3 Mark Hahnenberg 2012-09-27 09:58:09 PDT
Created attachment 166024 [details]
Patch
Comment 4 Darin Adler 2012-09-27 10:20:54 PDT
Comment on attachment 166024 [details]
Patch

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

> Source/WTF/ChangeLog:3
> +        Cleanup HasTrivialConstructor/Destructor

The verb “clean up” is two words.

> Source/WTF/wtf/TypeTraits.h:244
>      // VC8 (VS2005) and later have built-in compiler support for HasTrivialConstructor / HasTrivialDestructor,

I don’t think it’s right to say they have built-in compiler support for HasTrivialConstructor / HasTrivialDestructor. The comment should say:

    // VC8 (VS2005) and later has __has_trivial_constructor and __has_trivial_destructor, but the implementation
    // incorrectly returns false for built-in types. Work around that by explicitly checking IsPod.

Also, if we wanted to cut down on copies of these templates, we could consider merging this case with the clang case. I see no harm in including the Visual Studio workaround even in the compilers that don’t need it.

> Source/WTF/wtf/TypeTraits.h:245
> +    // but for some unexplained reason it doesn't work on built-in types. We add the extra IsPod condition to 

I don’t think the phrase “for some unexplained reason” added anything to the old comment and adds nothing to the new either.

It would be nice if the comment said something more specific than “it doesn’t work on” like “it returns false for”.

> Source/WTF/wtf/TypeTraits.h:255
> +    // For platforms that don't support HasTrivialConstructor/HasTrivialDestructor at all, we want to at least provide 
> +    // some semblance of support.

I think the comment should be more specific. I would have written something more like this:

    // For compilers that don't support detection of trivial constructors and destructors in classes, use a template
    // that returns true for any POD type but false for all class types. This will give false negatives, which can
    // hurt performance, but avoids false positives, which can result in incorrect behavior.
Comment 5 Mark Hahnenberg 2012-09-27 11:30:30 PDT
Committed r129780: <http://trac.webkit.org/changeset/129780>
Comment 6 Darin Adler 2012-09-27 16:36:42 PDT
(In reply to comment #4)
> Also, if we wanted to cut down on copies of these templates, we could consider merging this case with the clang case. I see no harm in including the Visual Studio workaround even in the compilers that don’t need it.

Oops, my suggestion probably broke the VC10 case. It’s supposed to use std::tr1::has_trivial_constructor, right?
Comment 7 Mark Hahnenberg 2012-09-27 16:42:09 PDT
> Oops, my suggestion probably broke the VC10 case. It’s supposed to use std::tr1::has_trivial_constructor, right?

Argh, I believe so. Reopening...
Comment 8 Mark Hahnenberg 2012-09-27 16:51:03 PDT
Created attachment 166095 [details]
Patch
Comment 9 WebKit Review Bot 2012-09-30 17:28:34 PDT
Comment on attachment 166095 [details]
Patch

Clearing flags on attachment: 166095

Committed r129999: <http://trac.webkit.org/changeset/129999>
Comment 10 WebKit Review Bot 2012-09-30 17:28:38 PDT
All reviewed patches have been landed.  Closing bug.