Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Akshat Agarwal
    @humancalico
    Hi @sunfishcode
    Dan Gohman
    @sunfishcode
    You're right that there's not a lot of documentation for Cranelift right now.
    Part of what's going on right now is that we're in the middle of some bytecodealliance/cranelift#1344
    big changes
    But as things stablize, we'll definitely be looking to add more documentation.
    What kinds of things are you interested in in Cranelift?
    Akshat Agarwal
    @humancalico
    I have been learning Rust for the past couple of months now. I am also interested in learning about Compilers and WebAssembly which is the reason I was so attracted to this project.
    I would like to contribute to the codebase.
    Dan Gohman
    @sunfishcode
    Compilers and WebAssembly are fun :-)
    My general advice is to just try some things out, and see what works as you expect and what doesn't, and then ask questions.
    Akshat Agarwal
    @humancalico
    Is there an open-issue you recommend that I can pick up which might also help me navigating the codebase.
    Dan Gohman
    @sunfishcode
    Unfortunately, we don't have many good first issues
    slipher
    @slipher
    Any remarks on https://github.com/bytecodealliance/wasmtime/issues/39#issuecomment-581766932? Sorry to self-advertise, but the issue was unexpectedly closed so I'm afraid no one would see it.
    Dan Gohman
    @sunfishcode
    @slipher Is Yury's example (the most recent comment) helpful?
    Eric Rosenberg
    @ehaydenr

    I’m trying to embed wasmtime in a Rust program and while reading from instance memory is fairly straightforward (log callback example), I’m struggling to understand how to call WASM functions with types other than the standard WASM types. For example:

    pub fn greet(name: &str) -> String {
      format!(“Hello, {}”, name).to_string() 
    }

    Compiles to:

    (func $greet (type 4) (param i32 i32 i32)

    From Yury’s response in PR bytecodealliance/wasmtime#891:

    first two are pointer and length of name, and the third is a pointer to String structure, that is the return arg.

    If I’m understanding correctly, these pointers are pointers to the instance’s linear memory. As the caller, how should I be allocating/deallocating memory? For providing a struct, Yury suggested:

    You have to call Rust a helper function to allocate a memory for a Person struct, then you populate it based on its repr() rules. The wasmtime provides Memory object to have the access to instance memory.

    Is there any example of this? Should we export some “alloc” function from the WebAssembly module?

    Dan Gohman
    @sunfishcode
    @ehaydenr Yes, right now, if you need to do anything which involves allocating memory within the wasm module, you'll need to have an alloc function to do it.
    Eric Rosenberg
    @ehaydenr
    Thanks @sunfishcode. I understand this functionality largely comes with interfaces types, but in the meantime, do you know of any projects doing this? Anything worth looking at as an example? I think I basically have it working, but I don’t think I’m properly freeing memory after allocating it.
    Dan Gohman
    @sunfishcode
    I unfortunately don't have any great examples to point to for this.
    And yes, interface types and associated tools will make this much nicer in the future.
    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