Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Julia 1.0 #29

Open
wants to merge 4 commits into
base: julia-0.7-arrays
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.6
julia 0.7
WebAssembly
11 changes: 6 additions & 5 deletions src/wasm/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ end
wasmcall(i, f, xs...) = begin
g = deepcopy(wasmcalls)
haskey(g, f) ? g[f](i, xs...) :
Expr(:call, wasmfunc(f, exprtype.(i, xs)...), xs...)
Expr(:call, wasmfunc(f, exprtype.(Ref(i), xs)...), xs...)
end

isprimitive(x) = false
Expand Down Expand Up @@ -437,12 +437,13 @@ function lower_new(m::ModuleState, args)
end


# This doesn't work anymore
function lower_ccall(m::ModuleState, args)
(fnname, env) = args[1]
@show args
fnname = args[1].args[2].value
env = Symbol(args[1].args[3])
name = Symbol(env, :_, fnname)
m.imports[name] = Import(env, fnname, :func, map(WType, args[3]), WType(args[2]))
return Expr(:call, Call(name), args[4:2:end]...)
m.imports[name] = Import(env, fnname, name, :func, FuncType(WType[WType(x) for x in args[3]], WType[WType(args[2])]))
return Expr(:call, Call(name), args[6:2:end]...)
end

argtypes(x::Core.MethodInstance) = Tuple{x.specTypes.parameters[2:end]...}
Expand Down
24 changes: 12 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ end
m = wasm_module([mathfun => Tuple{Float64},
mathfun2 => Tuple{Float64, Float64}])

# These fail now.
# function docos(x)
# ccall((:jscos, "imports"), Float64, (Float64,), x)
# end
# m1 = wasm_module([docos => Tuple{Float64}])
#
# function docos2(x)
# ccall((:jscos, "imports"), Float64, (Float64,Float64), x, 33.3)
# end
# m2 = wasm_module([docos2 => Tuple{Float64}])
function docos(x)
ccall((:jscos, "imports"), Float64, (Float64,), x)
end
m1 = wasm_module([docos => Tuple{Float64}])

function docos2(x)
ccall((:jscos, "imports"), Float64, (Float64,Float64), x, 33.3)
end
m2 = wasm_module([docos2 => Tuple{Float64}])


# BROKEN stuff to try to test memory
# const s = "hello"
Expand Down Expand Up @@ -121,8 +121,8 @@ function arrayref_i32_(xs)
end

m = wasm_module([arrayref_i32_ => Tuple{Vector{Int32}}, sum2arr => Tuple{Array{Int32, 2}}, sumarr => Tuple{Array{Int32, 1}}]) |> mergeWithBase
# write("this.wast", string(m))
# write("this.wasm", getModule(m))
write("this.wast", string(m))
write("this.wasm", WebAssembly.getModule(m))
# s = State(m)
# push!(s.fs, :func_0 => (2, (xs...) -> [show(("error: ", xs))]))
# efs = filter(e->e.typ==:func, m.exports)
Expand Down