Bug 186692

Summary: Properly zero unused property storage offsets
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ews-watchlist, fpizlo, ggaren, mark.lam, msaboff, rniwa, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=187362
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews113 for mac-sierra
none
Patch
none
Archive of layout-test-results from ews116 for mac-sierra
none
Archive of layout-test-results from ews204 for win-future
none
Patch
none
Patch
none
Archive of layout-test-results from ews113 for mac-sierra
none
Archive of layout-test-results from ews107 for mac-sierra-wk2
none
Patch
none
Archive of layout-test-results from ews114 for mac-sierra
none
Patch
none
Patch
none
Patch none

Description Keith Miller 2018-06-15 13:57:23 PDT
Properly zero unused property storage offsets
Comment 1 Keith Miller 2018-06-15 14:04:31 PDT
Created attachment 342843 [details]
Patch
Comment 2 EWS Watchlist 2018-06-15 14:06:06 PDT
Attachment 342843 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:166:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:166:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1184:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 EWS Watchlist 2018-06-15 15:07:39 PDT
Comment on attachment 342843 [details]
Patch

Attachment 342843 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/8202573

Number of test failures exceeded the failure limit.
Comment 4 EWS Watchlist 2018-06-15 15:07:41 PDT
Created attachment 342851 [details]
Archive of layout-test-results from ews113 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 5 Keith Miller 2018-06-15 15:55:56 PDT
Created attachment 342854 [details]
Patch
Comment 6 EWS Watchlist 2018-06-15 15:58:43 PDT
Attachment 342854 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1184:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Geoffrey Garen 2018-06-15 16:17:55 PDT
Comment on attachment 342854 [details]
Patch

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

Test case please.

r=me with test case and fix for test time regression if needed.

> Source/JavaScriptCore/ChangeLog:12
> +        or creating a RegExp matches array we never cleared the unused

array, we never clear

> Source/JavaScriptCore/runtime/ObjectInitializationScope.cpp:94
> +    for (int64_t i = 0; i < static_cast<int64_t>(structure->outOfLineCapacity()); i++) {
> +        // We rely on properties past the last offset be zero for concurrent GC.
> +        if (i + firstOutOfLineOffset > structure->lastOffset())
> +            ASSERT(!butterfly->propertyStorage()[-i - 1].get());
> +        else if (isScribbledValue(butterfly->propertyStorage()[-i - 1].get())) {
> +            dataLogLn("Found scribbled property at i = ", -i - 1);
> +            ASSERT_NOT_REACHED();
> +        }
> +    }

If this increases debug test time too much, you need to find a way to do this assertion conditionally.
Comment 8 EWS Watchlist 2018-06-15 17:29:26 PDT
Comment on attachment 342854 [details]
Patch

Attachment 342854 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/8204362

Number of test failures exceeded the failure limit.
Comment 9 EWS Watchlist 2018-06-15 17:29:27 PDT
Created attachment 342859 [details]
Archive of layout-test-results from ews116 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 10 EWS Watchlist 2018-06-15 18:28:59 PDT
Comment on attachment 342854 [details]
Patch

Attachment 342854 [details] did not pass win-ews (win):
Output: http://webkit-queues.webkit.org/results/8204839

New failing tests:
http/tests/preload/onload_event.html
Comment 11 EWS Watchlist 2018-06-15 18:29:09 PDT
Created attachment 342865 [details]
Archive of layout-test-results from ews204 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews204  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 12 Keith Miller 2018-06-15 18:29:20 PDT
rdar://problem/39489288
Comment 13 Saam Barati 2018-06-15 19:10:15 PDT
Comment on attachment 342854 [details]
Patch

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

> Source/JavaScriptCore/runtime/RegExpMatchesArray.h:-52
> -    unsigned i = (createUninitialized ? initialLength : 0);

Why this change?
Comment 14 Keith Miller 2018-06-15 19:17:14 PDT
Comment on attachment 342854 [details]
Patch

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

>> Source/JavaScriptCore/runtime/RegExpMatchesArray.h:-52
>> -    unsigned i = (createUninitialized ? initialLength : 0);
> 
> Why this change?

createUninitialized was always false. We only ever pass a custom structure.
Comment 15 Keith Miller 2018-06-15 20:22:58 PDT
Created attachment 342872 [details]
Patch
Comment 16 EWS Watchlist 2018-06-15 20:24:13 PDT
Attachment 342872 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1184:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 17 Keith Miller 2018-06-15 20:24:30 PDT
Created attachment 342873 [details]
Patch
Comment 18 EWS Watchlist 2018-06-15 20:27:13 PDT
Attachment 342873 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1184:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 19 EWS Watchlist 2018-06-15 21:52:23 PDT
Comment on attachment 342873 [details]
Patch

Attachment 342873 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/8207177

Number of test failures exceeded the failure limit.
Comment 20 EWS Watchlist 2018-06-15 21:52:24 PDT
Created attachment 342875 [details]
Archive of layout-test-results from ews113 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 21 EWS Watchlist 2018-06-15 22:28:59 PDT
Comment on attachment 342873 [details]
Patch

Attachment 342873 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/8207436

New failing tests:
css3/filters/backdrop/add-remove-add-backdrop-filter.html
Comment 22 EWS Watchlist 2018-06-15 22:29:01 PDT
Created attachment 342876 [details]
Archive of layout-test-results from ews107 for mac-sierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-sierra-wk2  Platform: Mac OS X 10.12.6
Comment 23 Mark Lam 2018-06-16 11:11:40 PDT
Comment on attachment 342873 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:13
> +        proprety storage. This patch fixes that issue and gets most users

typo: /proprety/property/

> Source/JavaScriptCore/runtime/Butterfly.h:166
> +    static Butterfly* tryCreateUninitialized(VM&, ObjectInitializationScope*, JSObject* intendedOwner, size_t preCapacity, size_t propertyCapacity, bool hasIndexingHeader, size_t indexingPayloadSizeInBytes, GCDeferralContext* = nullptr);
> +    static Butterfly* createUninitialized(VM&, ObjectInitializationScope*, JSObject* intendedOwner, size_t preCapacity, size_t propertyCapacity, bool hasIndexingHeader, size_t indexingPayloadSizeInBytes);

I see that operationAllocateSimplePropertyStorageWithInitialCapacity, operationAllocateSimplePropertyStorage, and tryCreateUninitializedRegExpMatchesArray are the only 2 clients that calls these without a ObjectInitializationScope.  I suggest that you:
1. Change all clients to instantiate and pass a ObjectInitializationScope anyway.
2. Pass a ObjectInitializationScope& instead of a ObjectInitializationScope*.
3. Remove the VM& argument.  You can get the VM& from the ObjectInitializationScope&.  ObjectInitializationScope was designed to work this way.

That will keep the interface simpler, and removes the question of whether ObjectInitializationScope is needed or not (preventing someone from making the wrong choice in the future when adding new code).

> Source/JavaScriptCore/runtime/ButterflyInlines.h:89
> +    if (initializationScope)
> +        initializationScope->notifyAllocated(intendedOwner, wasCreatedUnitializated);

Remove the initializationScope condition (after changing this function to take a ObjectInitializationScope& instead of ObjectInitializationScope*).

> Source/JavaScriptCore/runtime/ButterflyInlines.h:102
> +    if (initializationScope)
> +        initializationScope->notifyAllocated(intendedOwner, wasCreatedUnitializated);

Remove the initializationScope condition (after changing this function to take a ObjectInitializationScope& instead of ObjectInitializationScope*).

> Source/JavaScriptCore/runtime/JSObject.cpp:1185
> +        

Please remove whitespace.
Comment 24 Keith Miller 2018-06-16 12:26:03 PDT
Comment on attachment 342873 [details]
Patch

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

>> Source/JavaScriptCore/ChangeLog:13
>> +        proprety storage. This patch fixes that issue and gets most users
> 
> typo: /proprety/property/

fixed.

>> Source/JavaScriptCore/runtime/Butterfly.h:166
>> +    static Butterfly* createUninitialized(VM&, ObjectInitializationScope*, JSObject* intendedOwner, size_t preCapacity, size_t propertyCapacity, bool hasIndexingHeader, size_t indexingPayloadSizeInBytes);
> 
> I see that operationAllocateSimplePropertyStorageWithInitialCapacity, operationAllocateSimplePropertyStorage, and tryCreateUninitializedRegExpMatchesArray are the only 2 clients that calls these without a ObjectInitializationScope.  I suggest that you:
> 1. Change all clients to instantiate and pass a ObjectInitializationScope anyway.
> 2. Pass a ObjectInitializationScope& instead of a ObjectInitializationScope*.
> 3. Remove the VM& argument.  You can get the VM& from the ObjectInitializationScope&.  ObjectInitializationScope was designed to work this way.
> 
> That will keep the interface simpler, and removes the question of whether ObjectInitializationScope is needed or not (preventing someone from making the wrong choice in the future when adding new code).

I don't see how that would work. The DFG/FTL operations don't actually initialize the object while the ObjectInitializationScope would be alive. Are you proposing that there should be a new method to drop the initialization scope?

>> Source/JavaScriptCore/runtime/JSObject.cpp:1185
>> +        
> 
> Please remove whitespace.

Fixed.
Comment 25 Filip Pizlo 2018-06-18 11:34:42 PDT
Comment on attachment 342873 [details]
Patch

I would rip out the part of this patch that adds more uses of ObjectInitializationScope.  In RegExpMatchesArray, we already use GCDeferralContext, which may not interact great with the DisallowGC that ObjectInitializationScope does.
Comment 26 Keith Miller 2018-06-18 12:04:07 PDT
Created attachment 342959 [details]
Patch
Comment 27 EWS Watchlist 2018-06-18 12:05:54 PDT
Attachment 342959 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1181:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 28 EWS Watchlist 2018-06-18 13:24:26 PDT
Comment on attachment 342959 [details]
Patch

Attachment 342959 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/8235221

Number of test failures exceeded the failure limit.
Comment 29 EWS Watchlist 2018-06-18 13:24:27 PDT
Created attachment 342967 [details]
Archive of layout-test-results from ews114 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 30 Keith Miller 2018-06-18 14:46:25 PDT
Created attachment 342972 [details]
Patch
Comment 31 EWS Watchlist 2018-06-18 14:49:16 PDT
Attachment 342972 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1181:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 32 Keith Miller 2018-06-18 15:37:49 PDT
Created attachment 342981 [details]
Patch
Comment 33 EWS Watchlist 2018-06-18 15:40:30 PDT
Attachment 342981 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:168:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1181:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 34 Keith Miller 2018-06-18 15:51:56 PDT
Created attachment 342983 [details]
Patch
Comment 35 EWS Watchlist 2018-06-18 15:53:50 PDT
Attachment 342983 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Butterfly.h:167:  The parameter name "vm" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Butterfly.h:167:  The parameter name "indexingHeader" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/JSObject.cpp:1181:  Declaration has space between type name and * in propertyCapacity * sizeof  [whitespace/declaration] [3]
Total errors found: 3 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 36 WebKit Commit Bot 2018-06-18 16:53:34 PDT
Comment on attachment 342983 [details]
Patch

Clearing flags on attachment: 342983

Committed r232951: <https://trac.webkit.org/changeset/232951>
Comment 37 WebKit Commit Bot 2018-06-18 16:53:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 38 Saam Barati 2018-06-18 18:19:10 PDT
Comment on attachment 342983 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSArray.cpp:55
> +    ASSERT_UNUSED(globalObject, globalObject->isOriginalArrayStructure(structure) || structure == globalObject->regExpMatchesArrayStructure() || structure == globalObject->regExpMatchesArrayWithGroupsStructure());

This is crashing for me on a debug build
Comment 39 Saam Barati 2018-06-18 18:22:53 PDT
(In reply to Saam Barati from comment #38)
> Comment on attachment 342983 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=342983&action=review
> 
> > Source/JavaScriptCore/runtime/JSArray.cpp:55
> > +    ASSERT_UNUSED(globalObject, globalObject->isOriginalArrayStructure(structure) || structure == globalObject->regExpMatchesArrayStructure() || structure == globalObject->regExpMatchesArrayWithGroupsStructure());
> 
> This is crashing for me on a debug build

repro test case:

```
class A extends Array { }
new A;
```
Comment 40 Keith Miller 2018-06-18 18:25:01 PDT
Comment on attachment 342983 [details]
Patch

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

>>> Source/JavaScriptCore/runtime/JSArray.cpp:55
>>> +    ASSERT_UNUSED(globalObject, globalObject->isOriginalArrayStructure(structure) || structure == globalObject->regExpMatchesArrayStructure() || structure == globalObject->regExpMatchesArrayWithGroupsStructure());
>> 
>> This is crashing for me on a debug build
> 
> repro test case:
> 
> ```
> class A extends Array { }
> new A;
> ```

Yeah, I can see how this would break for that... I should just get rid of that assert. It doesn't do very much.