Bug 165982 - WebAssembly: Implement the WebAssembly.instantiate API
Summary: WebAssembly: Implement the WebAssembly.instantiate API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks: 169187
  Show dependency treegraph
 
Reported: 2016-12-16 18:31 PST by Saam Barati
Modified: 2017-03-06 23:39 PST (History)
13 users (show)

See Also:


Attachments
WIP (27.02 KB, patch)
2017-03-03 18:47 PST, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (22.15 KB, patch)
2017-03-05 12:01 PST, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (28.53 KB, patch)
2017-03-05 12:23 PST, Saam Barati
no flags Details | Formatted Diff | Diff
patch (30.92 KB, patch)
2017-03-05 14:01 PST, Saam Barati
keith_miller: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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