Bug 220918

Summary: [WASM-References] Change default value for externref's tables from null to undefined
Product: WebKit Reporter: Dmitry <dbezhetskov>
Component: WebAssemblyAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Dmitry 2021-01-25 05:56:09 PST
[WASM-References] Change default value for externref's tables from null to undefined
Comment 1 Dmitry 2021-01-25 06:00:24 PST
Created attachment 418283 [details]
Patch
Comment 2 Yusuke Suzuki 2021-01-25 12:33:30 PST
Comment on attachment 418283 [details]
Patch

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

r=me with comments.

> Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp:126
> +            : callFrame->argument(1);

Use `uncheckedArgument(1)` since we already checked.

> Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp:99
> +            defaultValue = callFrame->argument(1);

Use `callFrame->uncheckedArgument(1);` since we already checked `callFrame->argumentCount() < 2`

> Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp:137
>      JSValue value = callFrame->argument(1);
> -    if (Options::useWebAssemblyReferences() && value.isUndefined())
> -        value = jsNull();
> +    if (Options::useWebAssemblyReferences() && callFrame->argumentCount() < 2)
> +        value = defaultValueForTable(table->table()->type());

This needs to be done after

    if (index >= table->length())
        return throwVMRangeError(globalObject, throwScope, "WebAssembly.Table.prototype.set expects an integer less than the length of the table"_s);


part. Can you move it, and add test for this?
Comment 3 Dmitry 2021-01-26 07:17:06 PST
Created attachment 418416 [details]
Patch
Comment 4 Yusuke Suzuki 2021-01-26 12:52:25 PST
Comment on attachment 418416 [details]
Patch

r=me
Comment 5 Yusuke Suzuki 2021-01-26 12:52:55 PST
Comment on attachment 418416 [details]
Patch

EWS is getting stuck.
Comment 6 EWS 2021-01-26 13:45:25 PST
Committed r271903: <https://trac.webkit.org/changeset/271903>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 418416 [details].
Comment 7 Radar WebKit Bug Importer 2021-01-26 13:46:27 PST
<rdar://problem/73631096>