summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Function pointer cast emulation (#1468)Alon Zakai2018-03-131-24/+0
| | | | | | | | | | | This adds a pass that implements "function pointer cast emulation" - allows indirect calls to go through even if the number of arguments or their types is incorrect. That is undefined behavior in C/C++ but in practice somehow works in native archs. It is even relied upon in e.g. Python. Emscripten already has such emulation for asm.js, which also worked for asm2wasm. This implements something like it in binaryen which also allows the wasm backend to use it. As a result, Python should now be portable using the wasm backend. The mechanism used for the emulation is to make all indirect calls use a fixed number of arguments, all of type i64, and a return type of also i64. Thunks are then placed in the table which translate the arguments properly for the target, basically by reinterpreting to i64 and back. As a result, receiving an i64 when an i32 is sent will have the upper bits all zero, and the reverse would truncate the upper bits, etc. (Note that this is different than emscripten's existing emulation, which converts (as signed) to a double. That makes sense for JS where double's can contain all numeric values, but in wasm we have i64s. Also, bitwise conversion may be more like what native archs do anyhow. It is enough for Python.) Also adds validation for a function's type matching the function's actual params and result (surprised we didn't have that before, but we didn't, and there was even a place in the test suite where that was wrong). Also simplifies the build script by moving two cpp files into the wasm/ subdir, so they can be built once and shared between the various tools.
* Minor improvements to the wasm-interpreter debug messages (#784)jgravelle-google2016-10-181-0/+24
| | | | | | | | | | | * Minor improvements to the wasm-interpreter debug messages 1. Indent nested blocks for more readable structure (with numeric labels to make it even clearer) 2. Print the names of the variables used for NOTE_EVALs 3. Print the values of arguments when entering a function call * Move Indenter class to wasm-interpreter.cpp
* start to build interpreter/jsAlon Zakai2015-10-311-284/+0
|
* refactoringAlon Zakai2015-10-311-1/+4
|
* convert and hostAlon Zakai2015-10-311-0/+10
|
* compareAlon Zakai2015-10-311-14/+37
|
* unary and binaryAlon Zakai2015-10-311-0/+35
|
* interpret all callsAlon Zakai2015-10-311-4/+25
|
* load and store shimsAlon Zakai2015-10-311-9/+25
|
* getlocal/setlocal in interpreterAlon Zakai2015-10-301-0/+6
|
* function scopesAlon Zakai2015-10-301-7/+37
|
* progress on interpreterAlon Zakai2015-10-301-27/+69
|
* refactoringAlon Zakai2015-10-301-0/+3
|
* refactorings and begin interpreterAlon Zakai2015-10-301-0/+95