Coder Social home page Coder Social logo

mdn / webassembly-examples Goto Github PK

View Code? Open in Web Editor NEW
1.1K 51.0 252.0 445 KB

Code examples that accompany the MDN WebAssembly documentation — see https://developer.mozilla.org/en-US/docs/WebAssembly.

License: Creative Commons Zero v1.0 Universal

JavaScript 41.00% C 0.45% HTML 2.87% WebAssembly 55.66% Rust 0.03%
wasm webassembly

webassembly-examples's Introduction

webassembly-examples

Code examples that accompany the MDN WebAssembly documentation — see https://developer.mozilla.org/en-US/docs/WebAssembly.

Testing/modifying the examples

The examples can be tested locally by running a local server to serve your directory of choice.

If you modify any .wat files for testing you will need to generate a corresponding .wasm file, replacing the existing version in the folder. This can be done using the wat2wasm tool, which is part of the WABT: The WebAssembly Binary Toolkit (for setup/usage see Converting the text .wat into a binary .wasm file on MDN and the readme in the WABT GitHub repo.

Note that some examples use features that are still considered optional. These are listed in the supported proposals section on the WABT README.md, along with the flags used to invoke them. For example, to build WASM for the multi-memory example you will need to specify the --enable-multi-memory flag as shown:

wat2wasm --enable-multi-memory multi-memory.wat

webassembly-examples's People

Contributors

bsmth avatar chrisdavidmills avatar daniel-mccarthy avatar hamishwillee avatar josh-cena avatar kablaa avatar konojunya avatar lukewagner avatar mendyberger avatar mozilla-github-standards avatar raphamorim avatar vimirage avatar yurydelendik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webassembly-examples's Issues

Provide source code that you used for demos

There are cool examples inside understanding-text-format folder.
And compiled wasm files. But what the source for them? Is it C code or C++. How does it look like. Because without it, demos are useless.

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

How dose "WebAssembly.Memory" work?

I see that you add the code below in js-api-example/memory.html, but the variable "memory" not been used in anywhere.

var memory = new WebAssembly.Memory({initial:10, maximum:100});

Thanks.

#<Module> could not be cloned

When I try to execute scripts at this demo page I see the next errors:

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Worker': #<Module> could not be cloned.
    at fetch.then.then.then.mod (https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html:19:16)
    at <anonymous>
fetch.then.then.then.mod @ index-compile.html:19
Promise resolved (async)
(anonymous) @ index-compile.html:18

My browser is Chrome 62.0.3202.89

Which format is relevant?

When I check the examples, the simple add function looks like below:

(module
  (func $add (param $lhs i32) (param $rhs i32) (result i32)
    get_local $lhs
    get_local $rhs
    i32.add)
  (export "add" (func $add))
)

But other examples use the format below:

(module
  (func $add (param $lhs i32) (param $rhs i32) (result i32)
    (i32.add
      (get_local $lhs)
      (get_local $rhs))
  (export "add" (func $add))
)

For instance: https://cdn.rawgit.com/WebAssembly/sexpr-wasm-prototype/2bb13aa785be9908b95d0e2e09950b39a26004fa/demo/index.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.