Bug 183545

Summary: PerProcess<> should be safe by default
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: bmallocAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, ggaren, joepeck, lforschler, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
maybe this will work
none
the patch
ysuzuki: review+
patch for landing none

Description Filip Pizlo 2018-03-10 13:19:47 PST
Patch forthcoming.
Comment 1 Filip Pizlo 2018-03-10 13:20:25 PST
Created attachment 335519 [details]
maybe this will work
Comment 2 Filip Pizlo 2018-03-10 15:24:03 PST
Created attachment 335520 [details]
the patch
Comment 3 EWS Watchlist 2018-03-10 15:27:15 PST
Attachment 335520 [details] did not pass style-queue:


ERROR: Source/bmalloc/bmalloc/PerProcess.h:64:  The parameter name "size" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/bmalloc/bmalloc/PerProcess.cpp:26:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Yusuke Suzuki 2018-03-11 01:34:22 PST
Comment on attachment 335520 [details]
the patch

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

r=me with a micro nit.

> Source/bmalloc/bmalloc/PerProcess.cpp:49
> +static unsigned stringHash(const char* string)
> +{
> +    unsigned result = 5381;
> +    while (char c = *string++)
> +        result = result * 33 + c;
> +    return result;
> +}

Nits: you can make this `constexpr` function, move it to a header, and calculate hash value at compile time.
Comment 5 Filip Pizlo 2018-03-11 10:15:15 PDT
(In reply to Yusuke Suzuki from comment #4)
> Comment on attachment 335520 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=335520&action=review
> 
> r=me with a micro nit.
> 
> > Source/bmalloc/bmalloc/PerProcess.cpp:49
> > +static unsigned stringHash(const char* string)
> > +{
> > +    unsigned result = 5381;
> > +    while (char c = *string++)
> > +        result = result * 33 + c;
> > +    return result;
> > +}
> 
> Nits: you can make this `constexpr` function, move it to a header, and
> calculate hash value at compile time.

Really, the compiler will execute a constexpr loop?
Comment 6 Filip Pizlo 2018-03-11 10:18:50 PDT
Created attachment 335540 [details]
patch for landing

With Yusuke's suggested change.
Comment 7 EWS Watchlist 2018-03-11 10:20:44 PDT
Attachment 335540 [details] did not pass style-queue:


ERROR: Source/bmalloc/bmalloc/PerProcess.h:72:  The parameter name "size" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/bmalloc/bmalloc/PerProcess.cpp:26:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Yusuke Suzuki 2018-03-11 10:21:23 PDT
(In reply to Filip Pizlo from comment #5)
> > Nits: you can make this `constexpr` function, move it to a header, and
> > calculate hash value at compile time.
> 
> Really, the compiler will execute a constexpr loop?

Yeah, C++14 relaxed constexpr is super powerful. You can check our wtf/text/StringHasher.h's computeLiteralHash for example.
Comment 9 Filip Pizlo 2018-03-11 10:46:22 PDT
Landed in https://trac.webkit.org/changeset/229516/webkit
Comment 10 Radar WebKit Bug Importer 2018-03-12 17:24:43 PDT
<rdar://problem/38397867>
Comment 11 Joseph Pecoraro 2020-02-05 11:40:08 PST
*** Bug 182496 has been marked as a duplicate of this bug. ***