Skip to content

Issue with code that calls log #18

@samakins

Description

@samakins

Hey Tshort,

I think I'm using this as intended but seemingly have an issue with argument count every time i call log(x::Float64).

I see its overwritten in quirks.jl and I've tried playing around with overlay myself but with no luck. Wondering if this was a bug or something dumb on my part.

Here is a very basic example where the first compile attempt has no problem but the second one doesn't work.

I tested this on a linux machine julia 1.10.4 as well as a couple versions of 1.8.*

using WebAssemblyCompiler

function expensivecalc1(a::Float64, b::Float64)
    a + b
end

function expensivecalc2(a::Float64, b::Float64)
    log(a + b)
end



  compile((expensivecalc1, Float64, Float64);
filepath = "bin/expensivecalc1.wasm",
 validate = false,
  optimize = false)


  compile((expensivecalc2, Float64, Float64);
  filepath = "bin/expensivecalc2.wasm",
   validate = false,
    optimize = false)

here is a corresponding manifest

[[deps.WebAssemblyCompiler]]
deps = ["Binaryen_jll", "CEnum", "CodeInfoTools", "CompTime", "GPUCompiler", "NodeCall", "Reexport", "Unrolled", "libjlnode_jll", "libnode_jll"]
git-tree-sha1 = "b9166ab12916a96d60bb65e4827edcee240c9844"
uuid = "9bc180e8-272c-4d08-a460-9682f1716cbe"
version = "0.1.15"

The error output looks something like this

ERROR: KeyError: key 3 not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] _compile(ctx::WebAssemblyCompiler.CompilerContext, x::Core.SSAValue; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/_compile.jl:21
  [3] _compile(ctx::WebAssemblyCompiler.CompilerContext, x::Core.SSAValue)
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/_compile.jl:16
  [4] compile_block(ctx::WebAssemblyCompiler.CompilerContext, cfg::Core.Compiler.CFG, phis::Dict{Int64, Any}, idx::Int64)
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/compile_block.jl:86
  [5] (::WebAssemblyCompiler.var"#283#284"{WebAssemblyCompiler.CompilerContext, Dict{Int64, Any}, Ptr{WebAssemblyCompiler.LibBinaryen.Relooper}, Core.Compiler.CFG})(idx::Int64)
    @ WebAssemblyCompiler ./none:0
  [6] iterate(::Base.Generator{Base.OneTo{Int64}, WebAssemblyCompiler.var"#283#284"{WebAssemblyCompiler.CompilerContext, Dict{Int64, Any}, Ptr{WebAssemblyCompiler.LibBinaryen.Relooper}, Core.Compiler.CFG}})
    @ Base ./generator.jl:47
  [7] collect(itr::Base.Generator{Base.OneTo{Int64}, WebAssemblyCompiler.var"#283#284"{WebAssemblyCompiler.CompilerContext, Dict{Int64, Any}, Ptr{WebAssemblyCompiler.LibBinaryen.Relooper}, Core.Compiler.CFG}})
    @ Base ./array.jl:787
  [8] compile_method_body(ctx::WebAssemblyCompiler.CompilerContext)
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/compiler.jl:145
  [9] compile_method(ctx::WebAssemblyCompiler.CompilerContext, funname::String; sig::Type, exported::Bool)
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/compiler.jl:101
 [10] compile(funs::Tuple{typeof(expensivecalc2), DataType, DataType}; filepath::String, jspath::String, validate::Bool, optimize::Bool, experimental::Bool, names::Nothing)
    @ WebAssemblyCompiler ~/.julia/packages/WebAssemblyCompiler/MqjfR/src/compiler.jl:58
 [11] top-level scope
    @ ~/Projects/Test/WasmTest.jl/expensivecalc.jl:19

Appreciate any thoughts on this, very cool Pkg otherwise!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions