Bug 180724 - Fill out some Poisoned APIs, fix some bugs, and add some tests.
Summary: Fill out some Poisoned APIs, fix some bugs, and add some tests.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-12-12 15:36 PST by Mark Lam
Modified: 2017-12-13 11:23 PST (History)
8 users (show)

See Also:


Attachments
proposed patch. (39.86 KB, patch)
2017-12-12 15:41 PST, Mark Lam
jfbastien: review+
Details | Formatted Diff | Diff
patch for landing + speculative build fixes. (40.07 KB, patch)
2017-12-12 16:05 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing + speculative build fixes 2. (42.89 KB, patch)
2017-12-12 17:24 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test to see if EWS toolchains support C++14. (42.96 KB, patch)
2017-12-12 17:45 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test for EWS. (43.03 KB, patch)
2017-12-12 17:49 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test for EWS. (43.16 KB, patch)
2017-12-12 18:02 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test for EWS. (43.30 KB, patch)
2017-12-12 18:09 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test for EWS. (40.12 KB, patch)
2017-12-12 20:25 PST, Mark Lam
no flags Details | Formatted Diff | Diff
test for EWS. (40.11 KB, patch)
2017-12-12 20:37 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.48 KB, patch)
2017-12-12 22:29 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.48 KB, patch)
2017-12-12 22:54 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.55 KB, patch)
2017-12-12 23:19 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.52 KB, patch)
2017-12-13 00:20 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.68 KB, patch)
2017-12-13 01:00 PST, Mark Lam
no flags Details | Formatted Diff | Diff
patch for landing. (41.49 KB, patch)
2017-12-13 10:28 PST, Mark Lam
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 Lam 2017-12-12 15:36:11 PST
Also rename Int32Poisoned to ConstExprPoisoned.  The key it takes is actually a uint32_t.  So, Int32 is really a misnomer.  In addition, the key needs to be a constexpr.  So, ConstExprPoisoned is a better name for it.
Comment 1 Radar WebKit Bug Importer 2017-12-12 15:37:13 PST
<rdar://problem/36006884>
Comment 2 Mark Lam 2017-12-12 15:41:01 PST
Created attachment 329169 [details]
proposed patch.
Comment 3 JF Bastien 2017-12-12 15:50:18 PST
Comment on attachment 329169 [details]
proposed patch.

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

r=me

> Source/WTF/wtf/Poisoned.h:55
> +struct isValidReference : std::integral_constant<bool, !isFunctionPointer<T>::value && !isVoidPointer<T>::value> { };

What's a "valid reference"? What makes it "valid"?

> Source/WTF/wtf/Poisoned.h:194
> +constexpr uintptr_t makePoison(uint32_t key)

inline?
Comment 4 Mark Lam 2017-12-12 15:55:11 PST
Comment on attachment 329169 [details]
proposed patch.

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

>> Source/WTF/wtf/Poisoned.h:55
>> +struct isValidReference : std::integral_constant<bool, !isFunctionPointer<T>::value && !isVoidPointer<T>::value> { };
> 
> What's a "valid reference"? What makes it "valid"?

I'll rename this to isConvertibleToReference, which is what I really meant.

>> Source/WTF/wtf/Poisoned.h:194
>> +constexpr uintptr_t makePoison(uint32_t key)
> 
> inline?

Thanks.  Fixed.
Comment 5 Mark Lam 2017-12-12 16:05:30 PST
Created attachment 329172 [details]
patch for landing + speculative build fixes.
Comment 6 Mark Lam 2017-12-12 17:24:15 PST
Created attachment 329182 [details]
patch for landing + speculative build fixes 2.

The build failures on the EWS bots are weird: it fails to specialize the PoisonedImpl template correctly for the Poisoned variant, but does it correctly for the ConstExprPoisoned variant.  I cannot reproduce this build failure locally, but the build failure error messages seem to imply that the EWS toolchain is confused with what the type of the poison key should be used in its inferrence.  I'm now uploading a patch that takes the linkage of the key out of the file where it's used to see if can kick the EWS toolchain into not inferring the wrong type.  Let's see if this makes a difference.
Comment 7 Mark Lam 2017-12-12 17:45:13 PST
Created attachment 329185 [details]
test to see if EWS toolchains support C++14.
Comment 8 Mark Lam 2017-12-12 17:49:16 PST
Created attachment 329187 [details]
test for EWS.
Comment 9 Mark Lam 2017-12-12 18:02:06 PST
Created attachment 329188 [details]
test for EWS.
Comment 10 Mark Lam 2017-12-12 18:09:44 PST
Created attachment 329189 [details]
test for EWS.
Comment 11 Mark Lam 2017-12-12 20:25:45 PST
Created attachment 329195 [details]
test for EWS.
Comment 12 Mark Lam 2017-12-12 20:37:38 PST
Created attachment 329197 [details]
test for EWS.
Comment 13 Mark Lam 2017-12-12 21:13:04 PST
I've managed to reproduce this build error on godbolt.org.  This is what godbolt.org says:

gcc 6.3 - Build fails
gcc 7.1 - Build fails
gcc 7.2 - Build passes

clang 3.9.1 - Build fails
clang 4.0.0 - Build passes

In all cases, I was using -std=c++14.

Hence, the issue is with the compilers and not my code.

That said, let me see if there's a way I can work around this compiler bug.
Comment 14 JF Bastien 2017-12-12 21:39:27 PST
Do you have a small repro from godbolt?
Comment 15 Mark Lam 2017-12-12 22:29:57 PST
Created attachment 329205 [details]
patch for landing.

I'm going to go with disabling the use of the Poisoned template methods that take a PoisonedImpl<K2, k, T2> argument in the tests that uses these methods with the uintptr_t& key type.  The compiler bug does not manifest when the methods are used with a constexpr uintptr_t key type.  In practice, we're likely to only assigned values which are poisoned with different keys when using the ConstExprPoisoned variant.  Hence, this compiler bug will not be an issue.

To make sure we don't break any builds, we only need to #if out the use of these methods in the API tests.  Since we don't use these methods for the Poisoned variant in real code, there's nothing more to do there.

I'll land this patch if the EWS bots are happy with it.
Comment 16 Mark Lam 2017-12-12 22:50:51 PST
Surprise surprise.  It looks like the old buggy compilers don't like assignment of Poisoned<keyA, DerivedClassPtr> to Poisoned<keyA, BaseClassPtr> either.  The only think it seems to support is assignment of Poisoned<keyA, SameClassPtr> to Poisoned<keyA, SameClassPtr>.  Again, this does not affect the ConstExprPoisoned variant.

I'll exclude these additional cases from the tests as well.
Comment 17 Mark Lam 2017-12-12 22:54:53 PST
Created attachment 329206 [details]
patch for landing.
Comment 18 Mark Lam 2017-12-12 23:19:16 PST
Created attachment 329207 [details]
patch for landing.
Comment 19 Mark Lam 2017-12-13 00:20:04 PST
Created attachment 329212 [details]
patch for landing.

Looks like the EWS thinks it's using at least clang 4, but is still failing to build.  Let's try filtering ENABLE_MIXED_POISON on clang 5 instead.
Comment 20 Mark Lam 2017-12-13 01:00:34 PST
Created attachment 329213 [details]
patch for landing.

Looks like Apple's versioning of clang is different than the open source one.  Here's a patch based with a speculative fix based on that versioning difference.
Comment 21 Mark Lam 2017-12-13 10:28:17 PST
Created attachment 329229 [details]
patch for landing.
Comment 22 EWS Watchlist 2017-12-13 10:29:48 PST
Attachment 329229 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/Poisoned.h:48:  Missing space after ,  [whitespace/comma] [3]
Total errors found: 1 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 23 Mark Lam 2017-12-13 11:21:01 PST
The bots are green.  I'm going to land this.
Comment 24 Mark Lam 2017-12-13 11:23:29 PST
Thanks for the review.  Landed in r225857: <http://trac.webkit.org/r225857>.