Bug 165982

Summary: WebAssembly: Implement the WebAssembly.instantiate API
Product: WebKit Reporter: Saam Barati <saam>
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, fpizlo, ggaren, gskachkov, jfbastien, keith_miller, mark.lam, msaboff, oliver, ticaiolima, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 169187    
Attachments:
Description Flags
WIP
none
WIP
none
WIP
none
patch keith_miller: review+

Description Saam Barati 2016-12-16 18:31:19 PST
...
Comment 1 Radar WebKit Bug Importer 2016-12-20 14:19:01 PST
<rdar://problem/29760110>
Comment 2 Saam Barati 2017-03-03 18:47:51 PST
Created attachment 303376 [details]
WIP
Comment 3 Saam Barati 2017-03-05 12:01:35 PST
Created attachment 303461 [details]
WIP

Need to write tests still. I think the API is done.
Comment 4 Saam Barati 2017-03-05 12:23:40 PST
Created attachment 303462 [details]
WIP

Now with tests. I need to write a changelog still.
Comment 5 Saam Barati 2017-03-05 14:01:56 PST
Created attachment 303464 [details]
patch
Comment 6 WebKit Commit Bot 2017-03-05 14:04:12 PST
Attachment 303464 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp:73:  Missing space inside { }.  [whitespace/braces] [5]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Keith Miller 2017-03-06 13:59:54 PST
Comment on attachment 303464 [details]
patch

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

r=me with some comments.

> Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp:117
> +            throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("import must be an object"), defaultSourceAppender, runtimeTypeForValue(importModuleValue)));
> +            return nullptr;

you could make a lambda like

auto throw = [&] (Error* error) {
    throwException(exec, throwScope, error);
    return nullptr;
};

then do:

if (!importModuleValue.isObject())
    return throw(createTypeError(exec, ASCIILiteral("import must be an object"), defaultSourceAppender, runtimeTypeForValue(importModuleValue)));
Comment 8 Keith Miller 2017-03-06 14:04:33 PST
Comment on attachment 303464 [details]
patch

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

> Source/JavaScriptCore/wasm/JSWebAssembly.cpp:102
> +        module = WebAssemblyModuleConstructor::createModule(exec, firstArgument, exec->lexicalGlobalObject()->WebAssemblyModuleStructure());

I think we should pass the mode here if we are given a memory import.
Comment 9 Saam Barati 2017-03-06 14:24:20 PST
(In reply to comment #8)
> Comment on attachment 303464 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=303464&action=review
> 
> > Source/JavaScriptCore/wasm/JSWebAssembly.cpp:102
> > +        module = WebAssemblyModuleConstructor::createModule(exec, firstArgument, exec->lexicalGlobalObject()->WebAssemblyModuleStructure());
> 
> I think we should pass the mode here if we are given a memory import.

We should do this in a follow up since it's non trivial. I filed:
https://bugs.webkit.org/show_bug.cgi?id=169218
Comment 10 Saam Barati 2017-03-06 14:24:59 PST
Comment on attachment 303464 [details]
patch

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

>> Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp:117
>> +            return nullptr;
> 
> you could make a lambda like
> 
> auto throw = [&] (Error* error) {
>     throwException(exec, throwScope, error);
>     return nullptr;
> };
> 
> then do:
> 
> if (!importModuleValue.isObject())
>     return throw(createTypeError(exec, ASCIILiteral("import must be an object"), defaultSourceAppender, runtimeTypeForValue(importModuleValue)));

Sounds good. Will do.
Comment 11 Saam Barati 2017-03-06 23:39:42 PST
landed in:
https://trac.webkit.org/changeset/213506