Skip to content

Introduce WebAssembly.LinkError - #901

Merged
rossberg merged 3 commits into
masterfrom
linkerror
Dec 14, 2016
Merged

rossberg merged 3 commits into
masterfrom
linkerror

Conversation

@rossberg

@rossberg rossberg commented Dec 12, 2016 •

Copy link
Copy Markdown
Member

In order to distinguish WebAssembly link-time failure from JS-level errors, introduce a new error class WebAssembly.LinkError, which arises from instantiation in analogy to CompileError and RuntimeError. It indicates link-time type errors (function signatures, memory/table bounds mismatches), data/elem initialisation errors (out-of-bounds), and other potential future error causes. Traps from the start function will still raise a RuntimeError.

Addresses #889.

Comment thread JS.md Outdated
* `WebAssembly.CompileError` : a [NativeError](http://tc39.github.io/ecma262/#sec-nativeerror-object-structure)
which indicates an error during WebAssembly decoding or validation
* `WebAssembly.LinkError` : a [NativeError](http://tc39.github.io/ecma262/#sec-nativeerror-object-structure)
which indicates an error during WebAssembly instantiating a mdoule

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC: CompileError is for Module creation, and LinkError is for Instance creation up to but excluding calling the start function? I'd call that out explicitly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "mdoule"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jfbastien

Copy link
Copy Markdown
Member

Should we call out out-of-memory errors separately, or do they cause Compile / Link errors? This seems similar to @gahaas' clarification w.r.t. stack error in #875.

If we split out memory error then let's not do it in this PR, but if we don't then let's address it in this PR (as a Link error).

@rossberg

Copy link
Copy Markdown
Member Author

@jfbastien, excellent question, but I think it's a somewhat tricky issue that's better discussed separately. Nothing specified in this PR depends on how that's resolved.

@jfbastien jfbastien mentioned this pull request Dec 13, 2016
@jfbastien

Copy link
Copy Markdown
Member

The proposed wording lgtm

Comment thread JS.md Outdated
`WebAssembly.Module` and `WebAssembly.Instance`. On failure, the `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
`WebAssembly.CompileError`.
`WebAssembly.CompileError`, `WebAssemlby.LinkError`, or `WebAssembly.RuntimeError`, depending on the cause of failure.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/WebAssemlby/WebAssembly/

Comment thread JS.md Outdated
with the resulting `WebAssembly.Instance` object. On failure, the `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
`WebAssembly.CompileError`.
`WebAssembly.CompileError`, `WebAssemlby.LinkError`, or `WebAssembly.RuntimeError`, depending on the cause of failure.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both typos fixed.

@titzer

titzer commented Dec 14, 2016

Copy link
Copy Markdown

lgtm

@rossberg
rossberg merged commit 2ae1144 into master Dec 14, 2016
@rossberg
rossberg deleted the linkerror branch December 14, 2016 12:20
Comment thread JS.md
with the resulting `WebAssembly.Instance` object. On failure, the `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
`WebAssembly.CompileError`.
`WebAssembly.CompileError`, `WebAssembly.LinkError`, or `WebAssembly.RuntimeError`, depending on the cause of failure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

driveby nit: IIUC, no CompileError is possible here.

Comment thread JS.md
@@ -288,10 +290,10 @@ For each [`import`](https://github.com/WebAssembly/spec/blob/master/interpreter/
1. Let `v` be the value of performing [`Get`](http://tc39.github.io/ecma262/#sec-get-o-p)(`o`, [`i.item_name`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L171))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The omission of the above TypeError ("If Type(o) is not Object") is on purpose, right? It kinda happens before the constructor is called I guess?

Same question for "If the importObject parameter is not undefined and Type(importObject) is not Object".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The required type of v differs depending on what type of import they match, so is tested in the individual cases below. In particular, for globals it must not be an object.

hubot pushed a commit to WebKit/WebKit-http that referenced this pull request Dec 20, 2016
https://bugs.webkit.org/show_bug.cgi?id=165805
<rdar://problem/29747874>

JSTests:

Reviewed by Mark lam.

Update all exception sites which now throw WebAssembly.LinkError.

* wasm/js-api/element-data.js:
* wasm/js-api/element.js:
(assert.throws):
* wasm/js-api/global-error.js:
(new.Number):
* wasm/js-api/table.js:
(assert.throws):
(new.WebAssembly.Table):
* wasm/js-api/test_Data.js:
* wasm/js-api/test_basic_api.js:
(const.c.in.constructorProperties.switch):
* wasm/js-api/test_memory.js:
(test):
(test.testMemImportError): Deleted.

Source/JavaScriptCore:

Reviewed by Mark Lam.

As described here: WebAssembly/design#901
Some TypeError and RangeError are now converted to WebAssembly.LinkError.

* CMakeLists.txt: add files
* DerivedSources.make: add autoget .lut.h files
* JavaScriptCore.xcodeproj/project.pbxproj: add files
* builtins/BuiltinNames.h: new name LinkError
* runtime/JSGlobalObject.h: auto-register LinkError using existing macro magic
* wasm/JSWebAssembly.h: make the new includes available
* wasm/js/JSWebAssemblyLinkError.cpp: Copied from Source/JavaScriptCore/wasm/JSWebAssemblyCompileError.cpp.
(JSC::JSWebAssemblyLinkError::create):
(JSC::JSWebAssemblyLinkError::JSWebAssemblyLinkError):
(JSC::createWebAssemblyLinkError):
* wasm/js/JSWebAssemblyLinkError.h: Copied from Source/JavaScriptCore/wasm/JSWebAssemblyCompileError.h.
(JSC::JSWebAssemblyLinkError::create):
* wasm/js/WebAssemblyInstanceConstructor.cpp: update as per spec change
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyLinkErrorConstructor.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorConstructor.cpp.
(JSC::constructJSWebAssemblyLinkError):
(JSC::callJSWebAssemblyLinkError):
(JSC::WebAssemblyLinkErrorConstructor::create):
(JSC::WebAssemblyLinkErrorConstructor::createStructure):
(JSC::WebAssemblyLinkErrorConstructor::finishCreation):
(JSC::WebAssemblyLinkErrorConstructor::WebAssemblyLinkErrorConstructor):
(JSC::WebAssemblyLinkErrorConstructor::getConstructData):
(JSC::WebAssemblyLinkErrorConstructor::getCallData):
* wasm/js/WebAssemblyLinkErrorConstructor.h: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorConstructor.h.
* wasm/js/WebAssemblyLinkErrorPrototype.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorPrototypr.cpp.
(JSC::WebAssemblyLinkErrorPrototype::create):
(JSC::WebAssemblyLinkErrorPrototype::createStructure):
(JSC::WebAssemblyLinkErrorPrototype::finishCreation):
(JSC::WebAssemblyLinkErrorPrototype::WebAssemblyLinkErrorPrototype):
* wasm/js/WebAssemblyLinkErrorPrototype.h: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorPrototypr.h.
* wasm/js/WebAssemblyModuleRecord.cpp: update as per spec change
(JSC::dataSegmentFail):
(JSC::WebAssemblyModuleRecord::evaluate):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@210028 268f45cc-cd09-0410-ab3c-d52691b4dbfc
ryanhaddad pushed a commit to WebKit/WebKit that referenced this pull request Dec 22, 2020
https://bugs.webkit.org/show_bug.cgi?id=165805
<rdar://problem/29747874>

JSTests:

Reviewed by Mark lam.

Update all exception sites which now throw WebAssembly.LinkError.

* wasm/js-api/element-data.js:
* wasm/js-api/element.js:
(assert.throws):
* wasm/js-api/global-error.js:
(new.Number):
* wasm/js-api/table.js:
(assert.throws):
(new.WebAssembly.Table):
* wasm/js-api/test_Data.js:
* wasm/js-api/test_basic_api.js:
(const.c.in.constructorProperties.switch):
* wasm/js-api/test_memory.js:
(test):
(test.testMemImportError): Deleted.

Source/JavaScriptCore:

Reviewed by Mark Lam.

As described here: WebAssembly/design#901
Some TypeError and RangeError are now converted to WebAssembly.LinkError.

* CMakeLists.txt: add files
* DerivedSources.make: add autoget .lut.h files
* JavaScriptCore.xcodeproj/project.pbxproj: add files
* builtins/BuiltinNames.h: new name LinkError
* runtime/JSGlobalObject.h: auto-register LinkError using existing macro magic
* wasm/JSWebAssembly.h: make the new includes available
* wasm/js/JSWebAssemblyLinkError.cpp: Copied from Source/JavaScriptCore/wasm/JSWebAssemblyCompileError.cpp.
(JSC::JSWebAssemblyLinkError::create):
(JSC::JSWebAssemblyLinkError::JSWebAssemblyLinkError):
(JSC::createWebAssemblyLinkError):
* wasm/js/JSWebAssemblyLinkError.h: Copied from Source/JavaScriptCore/wasm/JSWebAssemblyCompileError.h.
(JSC::JSWebAssemblyLinkError::create):
* wasm/js/WebAssemblyInstanceConstructor.cpp: update as per spec change
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyLinkErrorConstructor.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorConstructor.cpp.
(JSC::constructJSWebAssemblyLinkError):
(JSC::callJSWebAssemblyLinkError):
(JSC::WebAssemblyLinkErrorConstructor::create):
(JSC::WebAssemblyLinkErrorConstructor::createStructure):
(JSC::WebAssemblyLinkErrorConstructor::finishCreation):
(JSC::WebAssemblyLinkErrorConstructor::WebAssemblyLinkErrorConstructor):
(JSC::WebAssemblyLinkErrorConstructor::getConstructData):
(JSC::WebAssemblyLinkErrorConstructor::getCallData):
* wasm/js/WebAssemblyLinkErrorConstructor.h: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorConstructor.h.
* wasm/js/WebAssemblyLinkErrorPrototype.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorPrototypr.cpp.
(JSC::WebAssemblyLinkErrorPrototype::create):
(JSC::WebAssemblyLinkErrorPrototype::createStructure):
(JSC::WebAssemblyLinkErrorPrototype::finishCreation):
(JSC::WebAssemblyLinkErrorPrototype::WebAssemblyLinkErrorPrototype):
* wasm/js/WebAssemblyLinkErrorPrototype.h: Copied from Source/JavaScriptCore/wasm/WebAssemblyCompileErrorPrototypr.h.
* wasm/js/WebAssemblyModuleRecord.cpp: update as per spec change
(JSC::dataSegmentFail):
(JSC::WebAssemblyModuleRecord::evaluate):


Canonical link: https://commits.webkit.org/183647@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210028 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants