Comments (6)
Improvements/clarifications always welcome, but the design repo does state that the way host environments expose host-specific functionality through builtin modules (see also NonWeb.md).
Concretely, the way I was expecting this to be reflected in ml-proto:
- we'd add an
imports
field toAst.module
(reflecting imports in Modules.md) - an import would roughly look like
(import @importName "func_name" "module_name" (signature ...))
such that you could(call @importName ...)
(like everything else, the name would be optional and an index could be used instead).check.ml
would require the call's sig to match the import's sig. - per design repo, how an import is resolved is totally up to the host environment. To reflect this in ml-proto,
eval.ml
would be extended so thatEval.init
also took a list imported functions (assumed to match the signatures ofAst.imports
) and the impl ofcall
of an import simply called one of these functions. - the host part of ml-proto (
script.ml
, which is not logically part of the spec, but part of the host environment) would then, after parsing theAst.module
from SExprs would iterate down the list ofmodule.imports
, look them up in a list of builtin functionality we'd like to expose in ml-proto (stdio, etc) to build the list of imports passed toEval.init
(or fail on unknown imports).
Thus, just like the C/C++ standard (Section 1.9 Program Execution: "The semantic descriptions in this International Standard define a parameterized nondeterministic abstract machine."), the wasm semantics would be parameterized by the host environment (the import arguments to init
). When we add page_size
, that value would, I expect, be another parameter to init
.
To make the spec vs. reference interpreter embedding distinction clear in ml-proto, I have been thinking it'd be nice to split up the ML files into subdirs (e.g., spec
(containing ast.ml
, eval.ml
, check.ml
, types.ml
, values.ml
) and host
(containing script.ml
and SExpr parser). I think there should also be a 3rd subdir (say, given
) for files that implement basic functionality that we would just take as given (and not redefine) in a real spec (viz., arithmetic.ml
, after some massaging).
from spec.
On 3 September 2015 at 21:00, Luke Wagner [email protected] wrote:
Improvements/clarifications always welcome, but the design repo does state
that the way host environments expose host-specific functionality through builtin
modules
https://github.com/WebAssembly/design/blob/master/Modules.md#imports-and-exports
(see also NonWeb.md).Concretely, the way I was expecting this to be reflected in ml-proto:
- we'd add an imports field to Ast.module (reflecting imports
https://github.com/WebAssembly/design/blob/master/Modules.md#imports-and-exports
in Modules.md)- an import would roughly look like (import @importname "func_name"
"module_name" (signature ...)) such that you could (call @importname
...) (like everything else, the name would be optional and an index
could be used instead). check.ml would require the call's sig to match
the import's sig.This sounds reasonable to me. (Bikeshed: instead of
(signature ...)
I
would just reuse(param ...)
and(result ...)
there, to mirrorfunc
definitions.)
- per design repo
https://github.com/WebAssembly/design/blob/master/Modules.md#imports-and-exports,
how an import is resolved is totally up to the host environment. To reflect
this in ml-proto, eval.ml would be extended so that Eval.init also
took a list imported functions (assumed to match the signatures of
Ast.imports) and the impl of call of an import simply called one of
these functions.So the linking would be performed by the host? Makes sense. An alternative
model would be to pass in a module environment (a map from module names to
instances), and letEval.init
do the lookup.
- the host part of ml-proto (script.ml, which is not logically part of
the spec, but part of the host environment) would then, after parsing the
Ast.module from SExprs would iterate down the list of module.imports,
look them up in a list of builtin functionality we'd like to expose in
ml-proto (stdio, etc) to build the list of imports passed to Eval.init
(or fail on unknown imports).Thus, just like the C/C++ standard (Section 1.9 Program Execution: "The
semantic descriptions in this International Standard define a parameterized
nondeterministic abstract machine."), the wasm semantics would be
parameterized by the host environment (the import arguments to init).
When we add page_size, that value would, I expect, be another parameter
to init.To make the spec vs. reference interpreter embedding distinction clear in
ml-proto, I have been thinking it'd be nice to split up the ML files into
subdirs (e.g., spec (containing ast.ml, eval.ml, check.ml, types.ml,
values.ml) and host (containing script.ml and SExpr parser). I think
there is also a 3rd subdir (say, given) for files that implement basic
functionality that we would just take as given (and not redefine) in a real
spec (viz., arithmetic.ml, after some massaging).
Makes sense. Regarding arithmetic.ml, I think it would belong into spec
as well (maybe under a better name), assuming some of the actual operator
implementations are factored out into given
(in particular, Float64 and
Float32 modules like Dan is working on).
/Andreas
from spec.
So the linking would be performed by the host? Makes sense. An alternative model would be to pass > in a module environment (a map from module names to instances), and let
Eval.init
do the lookup.
I was also thinking along these lines. It would describe the builtin module situation well, but not the case where imports lead to dynamic fetches and, recursively, more module loading; for that it seems like you'd need some sort of "go load me this module that's not already in the map" callback which seems more complicated.
from spec.
Makes sense. Regarding arithmetic.ml, I think it would belong into
spec
as well (maybe under a
better name), assuming some of the actual operator implementations are factored out intogiven
(in particular, Float64 and Float32 modules like Dan is working on).
Agreed (that's what I was alluding to by "after some massaging" :)
from spec.
Make It So :-)
from spec.
Created #54.
from spec.
Related Issues (20)
- [JS Generator] Add scope for each wasm instance HOT 1
- Improve SIMD test diversity HOT 1
- web
- Is it different to compile codes from `neon` or `x86` SIMD? HOT 1
- The definition of validation of br_table is inadequate HOT 3
- Question about validation of {element, data} segments HOT 1
- Wrong test cases in memory_init.wast HOT 3
- test case `as-load-operand` have an error HOT 1
- branching on function name HOT 7
- [interpreter] Source locations are broken since menhir switch HOT 2
- SIMD test optimization? HOT 3
- [core] SIMD Compare instructions link to the wrong "execution"/"validation" sections HOT 1
- Add a note indicating that section ids and section ordering do not correspond HOT 2
- Missing ability to access built older versions of the WebAssembly specification in archivable form HOT 2
- Web HOT 1
- [JS API] 'run a host function' and 'create a host function' don't consistently handle completion records HOT 1
- Wording of README in proposals directory is misleading. HOT 6
- Test extreme alignments HOT 2
- Tests seem to cause side effects that other tests depend on HOT 2
- A question about max table size HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec.