Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Eric Rosenberg
    @ehaydenr
    Thanks for help, I’ll keep a lookout
    Jakub Hlusička
    @Limeth
    Hello! Are there any plans on implementing the higher level API for imports into wasmtime, in the near future? I am interested in using this feature along with the Interface Types.
    Dan Gohman
    @sunfishcode
    @Limeth Work is underway on some of the infrastructure pieces which will support this, but I don't know the specific timeline offhand.
    You can also follow bytecodealliance/wasmtime#727 :-).
    Jakub Hlusička
    @Limeth
    Will do, thanks!
    Lapinot
    @Lapin0t
    hi folks
    Lapinot
    @Lapin0t
    is anybody familiar with the pypy JIT? They have this language, "RPython", which is a subset of python designed to be AOT or JIT compiled, in which they write interpreters (notably the pypy python interpreter). Using some markers one can add some metadata to the interpreter mainloop, which is then used to compile several versions of it, one which is simply AOT compiled and another which additionally emits execution traces, to be passed to a JIT compiler. They call it a meta-tracing JIT and it makes it super easy to build JIT-enabled interpreters for any kind of stuff (regex, gameboy, python).
    Obviously the downside is this custom rpython language, which has pretty rough edges and not much support. But seing the cranelift project advance into supporting compilation from MIR, maybe there could be room to do meta-tracing jit using rust.
    Niels
    @nielsdos
    Hi everybody
    First of all, I don't mean to interrupt the previous question. If it's not allowed to post a question while the other is still not answered, my apologies.
    I'm using Cranelift with Wasm to use in a sandboxed environment. There are multiple Wasm programs in the same address space. My concern is stack overflows: how to catch them properly. I found issue #349 in the Cranelift repo, it implies it was enough to put a guard page to catch overflows. Is a single guard page still enough nowadays? I also found the "enable_probestack" option, I assume it's also needed?
    Thanks in advance.
    Akshat Agarwal
    @humancalico
    Hey @sunfishcode Did any beginner-friendly issues open up since the last time we talked? Also could you point to some resources or things I should learn so that I could better contribute to this project
    CactusBlue
    @TheCactusBlue
    this is the place to talk about CraneLift, right?
    is there any good guides on how to use cranelift?
    Maciej Woś
    @lostman
    @sunfishcode I'm looking at recent changes in wasmtime 0.11, in particular this: https://github.com/bytecodealliance/wasmtime/commit/3dd5a3cb3f0943bfa2c448f5029e975d343e9a2b#diff-1233f76790ef403921005c62adb1a105R20. It looks like 0.11 removed the possibility of constructing a module with access to memory? Everything looks WASI specific. This looks like a breaking change for us. Or is there something I'm missing? I need to provide my own API functions which need access to module's memory
    Dan Gohman
    @sunfishcode
    @lostman Is the problem the removal of the get_wasmtime_memory method?
    If so, you can do get_export("memory") instead; see the code in tests/custom_signal_handler.rs for an example of this.
    Maciej Woś
    @lostman

    @sunfishcode we are constructing a module with our own hostcalls (some of which accessed the memory) using Instance::from_handle. This is because InstanceHandle could accept host state which we need in the hostcall functions. With the latest master I don't see how to construct that module anymore. We have a number of functions like this:

    pub unsafe extern "C" fn f(vmctx: *mut VMContext, caller_vmctx: *mut VMContext, x: u32, y: u32, z: u32) -> () { ... }

    where we get the memory from caller_vmctx and host state from vmctx. Then we construct a wasmtime_environ::Module, and InstanceHandle from that Module, and finally Instance from the InstanceHandle. With the latest master I just don't see how to implement own hostcalls.

    Benjamin Bouvier
    @bnjbvr
    hi all! We now have a Bytecode Alliance Zulip stream for Cranelift, and there's a general discussions topic there. The goal here is to reduce the number of different communication platforms we're using, and it has been decided among the Bytecode Alliance core team that Zulip would be the One True And Only messaging platform. So everybody is encouraged to join the chat room there! https://bytecodealliance.zulipchat.com/#narrow/stream/217117-cranelift/topic/general
    Dan Gohman
    @sunfishcode
    @lostman We do definitely want to support people defining their own host functions, and instances with custom host state.
    I was hoping that at least the wasi implementation would be an example of how to do that, but if that doesn't work, or isn't clear, we should figure that out.
    If you wouldn't mind joining our Zulip instance, we actually have several more people who work in this area who may be able to help as well.
    YAMAMOTO Yuji
    @igrep
    Thank you! I've signed up for Zulip account!
    NotWearingPants
    @NotWearingPants
    is anyone here?
    Dan Gohman
    @sunfishcode
    Yes
    Maciej Woś
    @lostman
    @sunfishcode sure, I'll join Zulip
    mental
    @mental32
    What's the difference between declare_var and def_var for cranelife_frontend::FunctionBuilder?
    Dan Gohman
    @sunfishcode
    @mental32 declare_var creates a new variable, def_var indicates a place where the variable is "defined" -- assigned to
    mental
    @mental32
    @sunfishcode Thanks for the clarification! I managed to figure it out by dissecting the docs a bit more
    Divya Agrawal
    @divag711
    Hi all, I have recently started playing with cranelift IR and would like to know how we transform a C++ string array to IR? I am aware of the create_data example used in simplejit_demo, is there a simpler API to create this ?
    mental
    @mental32
    Is there somewhere I could get a list of valid flags/settings for https://docs.rs/cranelift-codegen/0.61.0/cranelift_codegen/settings/index.html?
    Dan Gohman
    @sunfishcode
    playX
    @playXE
    Hello! Is there any way to do jump to pointer? Like goto* addr
    Dan Gohman
    @sunfishcode
    call_indirect can do that, if the place you want to jump to is another function
    br_table can do a similar thing if the place you want to jump to is within the function
    playX
    @playXE
    call_indirect is guaranteed to emit jmp instruction on x86_64?
    I need jmp because I use cranelift in interpreter generator and dispatch loop might fail with segmentation fault if a lot of instructions is executed
    Dan Gohman
    @sunfishcode
    call_indirect is not a tail call, so it will consume stack space. Cranelift doesn't yet have support for tail calls.
    playX
    @playXE
    Is there any way to get all instructions that uses some other instruction value?
    Dan Gohman
    @sunfishcode
    No; in compiler terminology, that's typically called def-use lists, and Cranelift IR doesn't include those
    playX
    @playXE
    that's sad :(
    I would like to implement mem2reg pass
    Dan Gohman
    @sunfishcode
    It's a tradeoff aimed at reducing memory usage and compile time.
    It's straightforward to compute that information manually if you need it. With a single traversal of the function body, you can collect the uses for each def.
    playX
    @playXE
    I will do this then, thanks!
    playX
    @playXE
    Is stack_addr translated into stack_load?
    playX
    @playXE
    I think I implemented mem2reg pass and it seems to work:
    function u0:0(i32) -> i32 system_v {
        ss0 = explicit_slot 4
    
    block0(v0: i32):
        v1 = iconst.i32 37
        v2 = stack_addr.i64 ss0
        store v1, v2
        v3 = stack_addr.i64 ss0
        v4 = load.i32 v3
        v5 = iadd v4, v0
        return v5
    }
    // after mem2reg
    function u0:0(i32) -> i32 system_v {
        ss0 = explicit_slot 4
    
    block0(v0: i32):
        v1 = iconst.i32 37
        v6 = copy v1
        v4 = copy v6
        v5 = iadd v4, v0
        return v5
    }
    but I still have one question: is there any way to remove stack slot?
    Or unused stack slots does not emit machine code to save space on stack?
    Laurent Julliard
    @ljulliar
    tried to switch to Zulip as advised but got stuck on the login screen of bytealliance.zulip.com saying I'm part of the organization. Any tip for me ?
    Ok my bad. I found what I was doing wrong :-(