Bug 214403

Summary: [JSC] Use unvalidatedGet instead of get to access UnlinkedCodeBlock from CodeBlock destructor
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Yusuke Suzuki 2020-07-16 03:48:14 PDT
[JSC] Touch UnlinkedCodeBlock from CodeBlock destructor by using unvalidatedGet
Comment 1 Yusuke Suzuki 2020-07-16 03:50:41 PDT
Created attachment 404433 [details]
Patch
Comment 2 Yusuke Suzuki 2020-07-16 03:50:43 PDT
<rdar://problem/65527229>
Comment 3 Mark Lam 2020-07-16 10:18:54 PDT
Comment on attachment 404433 [details]
Patch

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

r=me if EWS bots are green.  The mac-wk1 bot was red but I told it to re-run the test.  If the failure is real, please fix before landing.  Thanks.

> Source/JavaScriptCore/ChangeLog:3
> +        [JSC] Touch UnlinkedCodeBlock from CodeBlock destructor by using unvalidatedGet

I suggest renaming this title to "Use unvalidatedGet instead of get to access UnlinkedCodeBlock from CodeBlock destructor".  The current title reads to me like an imperative to add some code to access the UnlinkedCodeBlock, whereas what you meant is that when we access it, we need to use unvalidatedGet.

> Source/JavaScriptCore/bytecode/CodeBlock.cpp:820
> +    // We use unvalidatedGet because validation rejects get() access when we are destroying cells.

I suggest rephrasing as "because get() has a validation assertion that rejects access".  Mentioning the "assertion" here also sets the context for the next point.

> Source/JavaScriptCore/bytecode/CodeBlock.cpp:821
> +    // This is right assertion since destruction order of cells is not defined, so member cells would get destroyed already.

I suggest rephrasing as "This assertion is correct since destruction order of cells is not guaranteed, and member cells could already be destroyed."

> JSTests/stress/codeblock-destructor-access-unlinkedcodeblock.js:2
> +//@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=1")
> +//@ slow!

Please skip for memoryLimited.  I'm using memoryLimited here as a proxy for slow machines here.  The armv7 and mips bots are showing that this tests times out there.  I'm guessing this might also be the case for other embedded / memory limited devices.
Comment 4 Yusuke Suzuki 2020-07-16 12:35:22 PDT
Comment on attachment 404433 [details]
Patch

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

>> Source/JavaScriptCore/ChangeLog:3
>> +        [JSC] Touch UnlinkedCodeBlock from CodeBlock destructor by using unvalidatedGet
> 
> I suggest renaming this title to "Use unvalidatedGet instead of get to access UnlinkedCodeBlock from CodeBlock destructor".  The current title reads to me like an imperative to add some code to access the UnlinkedCodeBlock, whereas what you meant is that when we access it, we need to use unvalidatedGet.

Changed.

>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:820
>> +    // We use unvalidatedGet because validation rejects get() access when we are destroying cells.
> 
> I suggest rephrasing as "because get() has a validation assertion that rejects access".  Mentioning the "assertion" here also sets the context for the next point.

Changed.

>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:821
>> +    // This is right assertion since destruction order of cells is not defined, so member cells would get destroyed already.
> 
> I suggest rephrasing as "This assertion is correct since destruction order of cells is not guaranteed, and member cells could already be destroyed."

Changed.

>> JSTests/stress/codeblock-destructor-access-unlinkedcodeblock.js:2
>> +//@ slow!
> 
> Please skip for memoryLimited.  I'm using memoryLimited here as a proxy for slow machines here.  The armv7 and mips bots are showing that this tests times out there.  I'm guessing this might also be the case for other embedded / memory limited devices.

OK, added.
Comment 5 Yusuke Suzuki 2020-07-16 12:39:54 PDT
Created attachment 404474 [details]
Patch
Comment 6 Yusuke Suzuki 2020-07-16 12:42:18 PDT
Committed r264473: <https://trac.webkit.org/changeset/264473>