Very experimental WASM code generation by MST in contexts of Int and Real #158

Closed
CommanderTvis wants to merge 16 commits from feature/binaryen into dev
4 changed files with 5055 additions and 5990 deletions
Showing only changes of commit c26c5bd145 - Show all commits

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,5 @@
package kscience.kmath.ast
import binaryen.readBinary
import kscience.kmath.operations.*
private const val ARGS_PTR = 0
@ -9,7 +8,7 @@ private const val ARGS_SIZE = 1
public fun compileMstToWasmF64(mst: MST) {
val keys = mutableListOf<String>()
val bin = with(readBinary(rt)) {
val bin = with(binaryen.parseText(INITIAL)) {
fun MST.visit(): binaryen.ExpressionRef = when (this) {
is MST.Symbolic -> {
var idx = keys.indexOf(value)
@ -48,7 +47,7 @@ public fun compileMstToWasmF64(mst: MST) {
mst.visit()
)
setMemory(0, 10000)
// setMemory(0, 10000)
addFunctionExport("executable", "executable")
optimize()
@ -58,4 +57,6 @@ public fun compileMstToWasmF64(mst: MST) {
println(emitText())
emitBinary()
}
}

View File

@ -1,6 +1,5 @@
package kscience.kmath.ast
import kscience.kmath.ast.MstExtendedField
import kscience.kmath.ast.compileMstToWasmF64
import kscience.kmath.operations.invoke
import kotlin.test.Test
@ -9,4 +8,4 @@ internal class Test {
fun c() {
compileMstToWasmF64(MstExtendedField { sin(symbol("x")) })
}
}
}