text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> .block_on(f.call_async(&store_async));
anyhow::Ok(res)
}
});
barrier.wait();
// Make absolutely sure the function is waiting on the channel when we raise the signal
thread::sleep(Duration::from_millis(500));
interrupter_slot
.lock()
.u... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#![cfg(feature = "experimental-async")]
use std::{cell::RefCell, sync::OnceLock};
use anyhow::Result;
use futures::future;
use wasmer::{
AsyncFunctionEnvMut, Function, FunctionEnv, FunctionEnvMut, FunctionType, Instance, Module,
Store, StoreAsync, Type, TypedFunction, Value, imports,
};
use wasm... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> memory.view(&store).write(0, b"after!").unwrap();
let mut buf = [0; 6];
copied.view(©_store).read(0, &mut buf).unwrap();
assert_eq!(&buf, b"before");
}
/// See https://github.com/wasmerio/wasmer/issues/5444
#[test]
#[cfg(feature = "sys")]
fn test_wasm_slice_issue_5444() {
let mut ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use macro_wasmer_engine_test::engine_test;
#[cfg(feature = "js")]
use wasm_bindgen_test::*;
use wasmer::*;
#[cfg(unix)]
use std::ffi::OsStr;
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[engine_test]
fn module_get_name() -> Result<(), String> {
let store = Store::default();
let wat = r#"(mod... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>on(), reason)
}
other => {
panic!("expected CompileError::Aborted, got {:?}", other);
}
}
}
<|fim_prefix|>#![cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
use std::sync::{Arc, Mutex};
use wasmer::sys::NativeEngineExt as _;
use wasmer::... | fim | wasmerio/wasmer | rust |
#[cfg(feature = "sys")]
pub mod reference_types {
use anyhow::Result;
use macro_wasmer_engine_test::engine_test;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(feature = "js")]
use wasm_bindgen_test::*;
use wasmer::*;
#[engine_test]
fn func_ref_passed_and_... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#[test]
#[cfg(all(feature = "v8", feature = "sys"))]
fn multiple_engines<|fim_suffix|>");
});
#[cfg(feature = "v8")]
{
let v8: Engine = V8::new().into();
let mut v8_store = Store::new(v8);
let v8_hello = Function::new_typed(&mut v8_store, move || {
println!... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
let next_one = greenthreads.get_mut(&next_greenthread_id).unwrap();
let Some(resumer) = next_one.resumer.take() else {
panic!("Switching to greenthread that has no resumer");
};
resumer.send(()).unwrap();
}
let current_id_arc... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>_3);
let import_object = imports! {
"env" => {
"multiply_typed" => multiply_typed,
}
};
let instance = Instance::new(&mut store, &module, &import_object)?;
// Execute the WASM function 'sum'
let sum: TypedFunction<(i32, i32), i32> =
instance.exports... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>// WebAssembly C API
#ifndef WASM_H
#define WASM_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#ifndef WASM_API_EXTERN
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(LIBWASM_STATIC)
#define WASM_API_EXTERN __declspec(dllimport)
#else
#d... | fim | wasmerio/wasmer | c |
<|fim_suffix|> "sending graphql query"
);
}
let res = req.json(&operation).send().await;
let res = match res {
Ok(response) => {
let status = response.status();
if !status.is_success() {
let body_string = matc... | fim | wasmerio/wasmer | rust |
/// One or multiple errors returned by the GraphQL API.
// Mainly exists to implement [`std::error::Error`].
#[derive(Debug)]
pub struct GraphQLApiFailure {
pub errors: Vec<cynic::GraphQlError>,
}
impl GraphQLApiFailure {
pub fn from_errors(
msg: impl Into<String>,
errors: Option<Vec<cynic::Gr... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! [`GlobalId`]s are used by the backend to identify a specific object.
//!
//! This module provides a parser/encoder and related type definitions
//! for global ids.
use std::fmt::Display;
#[repr(u16)]
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum NodeKind {
User = ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>// Allowed because it makes code more readable.
#![allow(clippy::bool_comparison, clippy::match_like_matches_<|fim_suffix|>)]
pub mod subscription;
pub mod types;
use url::Url;
pub use self::{client::WasmerClient, error::GraphQLApiFailure};
/// Api endpoint for the dev environment.
pub const ENDPOINT_D... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>c move {
let vars = match vars {
Some(vars) => vars,
None => return Ok(None),
};
let page = get_all_dns_records(client, vars.clone()).await?;
let end_cursor = page.page_info.end_cursor;
let items = page
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>}
}
Poll::Ready(Some(Err(err))) => Poll::Ready(Some(Err(err))),
Poll::Pending => Poll::Pending,
}
}
}
<|fim_prefix|>use std::{collections::VecDeque, task::Poll};
use futures::{
Future,
future::{BoxFuture, OptionFuture},
};
use super::WasmerClient;
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::{
WasmerClient,
types::{
AutobuildDeploymentSubscription, AutobuildDeploymentSubscriptionVariables,
PackageVersionReadySubscription, PackageVersionReadySubscriptionVariables, Uuid,
},
};
use anyhow::Context;
use async_tungstenite::tungstenite::client::IntoClientReque... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>pub created_at: DateTime,
pub updated_at: DateTime,
pub deleted_at: Option<DateTime>,
pub name: Option<String>,
pub text: String,
pub ttl: Option<i32>,
pub d_name: String,
pub domain: DnsDomain,
}
#[derive(cynic::QueryFragment, Debug, Clone... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>-c` up.
fn running_self() -> bool {
env::var("DOCS_RS").is_err()
&& env::var("_CBINDGEN_IS_RUNNING").is_err()
&& env::var("WASMER_PUBLISH_SCRIPT_IS_RUNNING").is_err()
}
/// Build the header files for the `wasm_c_api` API.
fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>e it's not universal for
// the engines assert(0 == strcmp("The minimum requested (2147483647 pages)
// memory is greater than the maximum allowed memory (65536 pages)", error));
free(error);
wasm_memorytype_delete(memtype4);
// =====================
wasm_limits_t limits5 = {
.min = 0x... | fim | wasmerio/wasmer | c |
<|fim_suffix|>me = wasm_trap_origin(trap);
if (frame) {
print_frame(frame);
wasm_frame_delete(frame);
} else {
printf("> Empty origin.\n");
}
printf("Printing trace...\n");
own wasm_frame_vec_t trace;
wasm_trap_trace(trap, &trace);
if (trace.size > 0) {
for (size_t i = 0; i < trace.size; ... | fim | wasmerio/wasmer | c |
<|fim_suffix|> wasm_module_delete(module);
wasm_instance_delete(instance);
wasm_extern_vec_delete(&exports);
wasm_store_delete(store);
wasm_engine_delete(engine);
}
<|fim_prefix|>#include <stdio.h>
#include "wasmer.h"
int main(int argc, const char* argv[]) {
const char* wat_string =
"(module\n"
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
#include "wasmer.h"
int main(int argc, const char* argv[]) {
const char* wat_string =
"(module\n"
" (global $one (export \"one\") f32 (f32.const 1))\n"
" (global $some (e<|fim_suffix|>printf("`some` value: %.1f\n", some_value.of.f32);
wasm_globaltype_delete(on... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
#include "wasmer.h"
int main(int argc, const char* argv[]) {
const char* wat_string =
"(module\n"
" (type $swap_t (func (param i32 i64) (result i64 i32)))\n"
" (func $swap (type $swap_t) (param $x i32) (param $y i64) (result i64 "
"i32)\n"
" (local... | fim | wasmerio/wasmer | c |
<|fim_suffix|>wasm_func_t* func = wasm_extern_as_func(exports.data[0]);
if (func == NULL) {
printf("> Failed to get the exported function!\n");
return 1;
}
printf("Got the exported function: %p\n", func);
printf("Retrieving the exported global...\n");
wasm_global_t* global = wasm_extern_as_global(... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <|fim_suffix|>rlen(wat_string), wat_string);
wasm_byte_vec_t wasm_bytes;
wat2wasm(&wat, &wasm_bytes);
wasm_byte_vec_delete(&wat);
printf("Creating the store...\n");
wasm_engine_t* engine = wasm_engine_new();
wasm_store_t* store = wasm_store_new(engine);
printf("Compiling module...... | fim | wasmerio/wasmer | c |
<|fim_suffix|>m_engine_delete(engine);
}
<|fim_prefix|>#include <stdio.h>
#include "wasmer.h"
int main(int argc, const char* argv[]) {
const char* wat_s<|fim_middle|>tring =
"(module\n"
" (type $mem_size_t (func (result i32)))\n"
" (type $get_at_t (func (param i32) (result i32)))\n"
" ... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasmer.h"
#define own
// Use the last_error API to retrieve error messages
own char* get_wasmer_error() {
int error_len = wasmer_last_error_length();
printf("Error len: `%d`\n", error_len);
char* error_str ... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasmer.h"
#define BUF_SIZE 128
#define own
// Use the last_error API to retrieve error messages
void print_wasmer_error() {
int err<|fim_suffix|>ports_result) {
printf("> Error getting WA... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#[cfg(test)]
use std::error::Error;
#[cfg(test)]
static INCLUDE_REGEX: &str = "#include \"(.*)\"";
#[derive(Default)]
pub struct RemoveTestsOnDrop {}
impl Drop for RemoveTestsOnDrop {
fn drop(&mut self) {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
for entry in std::fs::read_dir(... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Utilities to read errors.
//!
//! Only one error can be registered at a time. Error are registered
//! by Rust only, and are usually read by C or C++.
//!
//! Reading an error from C or C++ happens in 2 steps: Getting the
//! error's length with [`wasmer_last_error_length`], and then reading
//! the a... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Wasmer C API.
//!
//! [Wasmer](https://github.com/wasmerio/wasmer) is the leading
//! WebAssembly runtime. Wasmer is written in Rust; t<|fim_suffix|>ard_. The API is not yet
//! stable, even though it shows maturity over time. It is described
//! by the `wasm.h` C header file. However, this crate API ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Utilities to set up tracing and logging.
//!
//! By default, wasmer does not generate any tracing output. To
//! enable tracing, one must call the `wasmer_setup_tracing()`
//! function during the initialization stage of their program.
//!
//! Tracing levels can be enabled/disabled using the [RUST_LOG
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#[cfg(feature = "sys")]
pub(crate) mod sys;
#[cfg(feature = "sys")]
pub use sys::*;
use crat<|fim_suffix|>cfg(feature = "cranelift")]
super::wasmer_backend_t::CRANELIFT => {
Self::Sys(sys::wasmer_sys_engine_config_t::default())
}
#[cfg(feature = "single... | fim | wasmerio/wasmer | rust |
// Necessary when a single backend is enabled.
#![allow(irrefutable_let_patterns)]
use crate::{
error::update_last_error,
wasm_c_api::engine::{
wasm_config_t, wasm_engine_t, wasmer_backend_config_kind_t, wasmer_backend_t,
},
};
#[cfg(feature = "middlewares")]
pub use crate::wasm_c_api::unstable::m... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::{
error::update_last_error,
wasm_c_api::engine::{wasm_config_t, was<|fim_suffix|>is [`V8`].
///
/// [`V8`]: wasmer_engine_config_t::V8
#[must_use]
pub(super) fn is_v8(&self) -> bool {
matches!(self, Self::V8(..))
}
}
<|fim_middle|>m_engine_t, wasmer_backend_t... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub use super::unstable::engine::wasm_config_set_features;
use super::unstable::features::wasmer_features_t;
use wasmer_api::{BackendKind, Engine};
mod config;
#[allow(unused_imports)]
pub use config::*;
/// Kind of engines that can be used by the store.
///
/// This is a Wasmer-specific type with Wasm... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
None
}
Err(e) => Some(Box::new(e.into())),
}
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wasm_func_param_arity(func: Option<&wasm_func_t>) -> usize {
let Some(func) = func else {
update_last_error("func pointer is null");
return 0;
};
let s... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::error::update_last_error;
use super::super::store::wasm_store_t;
use super::super::types::wasm_globaltype_t;
use super::super::value::wasm_val_t;
use s<|fim_suffix|>asm_global.get(&mut store_mut);
*out = c_try!(value.try_into(); otherwise ());
}
/// Note: This function returns nothing by ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::error::update_last_error;
use super::super::types::wasm_memorytype_t;
use super::{super::store::wasm_store_t, wasm_extern_t};
use wasmer_api::{Extern, Memory, Pages};
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone)]
pub struct wasm_memory_t {
pub(crate) extern_: wasm_extern_t,
}... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>mod function;
mod global;
mod memory;
mod table;
use super::store::StoreRef;
// use super::types::{wasm_externkind_enum, wasm_externkind_t};
pub use function::*;
pub use global::*;
pub use memory::*;
pub use table::*;
use wasmer_api::{Extern, ExternType, Function, Global, Memory, Table};
#[allow(non_cam... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::error::update_last_error;
use super::super::store::wasm_store_t;
use super::super::types::{wasm_ref_t, wasm_table_size_t, wasm_tabletype_t};
use super::wasm_extern_t;
use wasmer_api::Extern;
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone)]
pub struct wasm_table_t {
pub(crate) ex... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::wasm_c_api::store::wasm_store_t;
use std::ffi::c_void;
use wasmer_api::FunctionEnv;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FunctionCEnv {
#[allow(dead_code)]
inner: std::ptr::NonNull<c_void>,
}
impl FunctionCEnv {
#[allow(dead_code)]
pub(crate) fn as_ptr(&self) -> *mut c... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::externals::{wasm_extern_t, wasm_extern_vec_t};
use super::module::wasm_module_t;
use super::st<|fim_suffix|>nce);
///
/// // Read the exports.
/// wasm_extern_vec_t exports;
/// wasm_instance_exports(instance, &exports);
///
/// // We have 4 of them.
/// assert(exports.size ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>macro_rules! wasm_declare_vec_inner {
(
name: $name:ident,
ty: $elem_ty:ty,
c_ty: $c_ty:expr,
c_val: $c_val:expr,
new: $new:ident,
empty: $empty:ident,
uninit: $uninit:ident,
copy: $copy:ident,
delete: $delete:ident,
) => {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ity :-).
pub mod unstable;
/// Possible runtime values that a WebAssembly module can either
/// consume or produce.
///
/// cbindgen:ignore
pub mod value;
/// Wasmer-specific API to get or query the version of this Wasm C API.
///
/// The `wasmer.h` file provides the `WASMER_VERSION`,
/// `WASMER_VERSIO... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::store::wasm_store_t;
use super::types::{wasm_byte_vec_t, wasm_exporttype_vec_t, wasm_importtype_vec_t};
use std::ptr::NonNull;
use wasmer_api::Module;
/// Opaque type representing a WebAssembly module.
#[derive(Clone)]
#[allow(non_camel_case_types)]
pub struct wasm_module_t {
pub(crate) in... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> }
}
/// Opaque type representing a WebAssembly store.
#[allow(non_camel_case_types)]
pub struct wasm_store_t {
pub(crate) inner: StoreRef,
}
/// Creates a new WebAssembly store given a specific [engine][super::engine].
///
/// # Example
///
/// See the module's documentation.
#[unsafe(no_mangle)]
p... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> 7);
wasm_name_delete(&original_message);
wasm_name_delete(&retrieved_message);
wasm_trap_delete(trap);
wasm_store_delete(store);
wasm_engine_delete(engine);
return 0;
}
})
.succes... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>sm_exporttype_t {
fn from(other: ExportType) -> Self {
(&other).into()
}
}
impl From<&ExportType> for wasm_exporttype_t {
fn from(other: &ExportType) -> Self {
let name: wasm_name_t = other.name().to_string().into();
let extern_type: wasm_externtype_t = other.ty().into... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::super::externals::wasm_extern_t;
use super::{
WasmFunctionType, WasmGlobalType, WasmMemoryType, WasmTableType, WasmTagType, wasm_functype_t,
wasm_globaltype_t, wasm_memorytype_t, wasm_tabletype_t,
};
use std::convert::{TryFrom, TryInto};
use std::mem;
use thiserror::Error;
use wasmer_ap... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>= CStr::from_ptr(wasm_frame_module_name.name);
assert_eq!(s.to_str().unwrap(), "module_name");
wasm_name_delete(Some(&mut wasm_frame_module_name));
}
println!("{info:#?}");
}
<|fim_prefix|>use super::super::instance::wasm_instance_t;
use libc::c_char;
use std::ffi::CString;
use wa... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::{WasmExternType, wasm_externtype_t, wasm_valtype_vec_t};
use std::fmt;
use wasmer_api::{ExternType, FunctionType};
use wasmer_types::Type;
pub(crate) struct WasmFunctionType {
pub(crate) function_type: Fun<|fim_suffix|>:<Vec<_>>();
Some(Box::new(wasm_functype_t::new(FunctionType::new(... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::{
WasmExternType, wasm_externtype_t, wasm_mutability_enum, wasm_mutability_t,
wasm_valtype_delete, wasm_valtype_t,
};
use std::convert::TryInto;
use wasmer_api::{ExternType, GlobalType};
#[derive(Debug, Clone)]
pub(crate) struct WasmGlobalType {
pub(crate) global_type: GlobalType,
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>tern "C" fn wasm_importtype_name(import_type: &wasm_importtype_t) -> &wasm_name_t {
&import_type.name
}
#[unsafe(no_mangle)]
pub extern "C" fn wasm_importtype_type(import_type: &wasm_importtype_t) -> &wasm_externtype_t {
&import_type.extern_type
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wa... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> = u32::MAX;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wasm_memorytype_limits(memory_type: &wasm_memorytype_t) -> &wasm_limits_t {
&memory_type.inner().limits
}
<|fim_prefix|>use super::{WasmExternType, wasm_externtype_t};
use wasmer_api::{ExternType, MemoryType, Pages};
#[derive(Debug, Clone)]
... | fim | wasmerio/wasmer | rust |
mod export;
mod extern_;
mod frame;
mod function;
mod global;
mod import;
mod memory;
mod mutability;
mod table;
mod tag;
mod value;
pub use export::*;
pub use extern_::*;
pub use frame::*;
pub use function::*;
pub use global::*;
pub use import::*;
pub use memory::*;
pub use mutability::*;
pub use table::*;
use tag::*... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::convert::TryFrom;
use wasmer_api::Mutability;
#[allow(non_camel_case_types)]
pub type wasm_mutability_t = u8;
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum wasm_mutability_enum {
WASM_CONST = 0,
WASM_VAR,
}
impl wasm_mutability_enum {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::{
WasmExternType, wasm_externtype_t, wasm_limits_t, wasm_valtype_delete, wasm_valtype_t,
};
use wasm<|fim_suffix|> LIMITS_MAX_SENTINEL {
None
} else {
Some(limits.max as _)
};
let table_type = Box::new(wasm_tabletype_t::new(TableType::new(
(*valtype).into... | fim | wasmerio/wasmer | rust |
use wasmer_types::TagType;
use super::wasm_valtype_vec_t;
#[allow(unused)]
pub(crate) struct WasmTagType {
pub(crate) tag_type: TagType,
params: wasm_valtype_vec_t,
}
impl WasmTagType {
pub(crate) fn new(tag_type: TagType) -> Self {
Self {
params: tag_type
.params()
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>, Copy)]
pub struct wasm_valtype_t {
valkind: wasm_valkind_enum,
}
impl Default for wasm_valtype_t {
fn default() -> Self {
Self {
valkind: wasm_valkind_enum::WASM_I32,
}
}
}
wasm_declare_boxed_vec!(valtype);
impl From<wasm_valtype_t> for Type {
fn from(other... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Unstable non-standard Wasmer-specific types for the
//! `wasm_engine_t` and siblings.
use super::{
super::engine::{wasm_config_t, wasmer_backend_t},
features::wasmer_features_t,
};
/// Unstable non-standard Wasmer-specific API to update the
/// configuration to specify particular features fo... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Unstable non-standard Wasmer-specific API that contains a Features
//! API for the engine and the compiler.
//!
//!
//! # Example
//!
//! ```rust
//! # use wasmer_inline_c::assert_c;
//! # fn main() {
//! # (assert_c! {
//! # #include "tests/wasmer.h"
//! #
//! int main() {
//! // Declare featu... | fim | wasmerio/wasmer | rust |
//! Unstable non-standard Wasmer-specific API that contains everything
//! to create the middleware metering API.
//!
//! The metering middleware is used for tracking how many operators
//! are executed in total and putting a limit on the total number of
//! operators executed.
//!
//! # Example
//!
//! ```rust
//! # u... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Unstable no<|fim_suffix|> ModuleMiddleware>,
}
<|fim_middle|>n-standard Wasmer-specific types to manipulate module
//! middlewares.
pub mod metering;
use std::sync::Arc;
use wasmer_api::sys::ModuleMiddleware;
#[cfg(all(feature = "middlewares", not(feature = "compiler")))]
compile_error!("The `middl... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>target_lexicon;
#[cfg(feature = "wasi")]
pub mod wasi;
<|fim_prefix|>pub mod engine;
pub mod features;
#[cfg(feature = "middlewares")]<|fim_middle|>
pub mod middlewares;
pub mod module;
#[cfg(feature = "compiler")]
pub mod parser;
pub mod <|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Unstable non-standard Wasmer-specific extensions to the Wasm C API.
use super::super::engine::wasm_engine_t;
use super::super::module::wasm_module_t;
use super::super::types::{wasm_byte_vec_t, wasm_name_t};
use std::ptr;
use std::str;
use wasmer_api::Module;
/// Unstable non-standard Wasmer-specific... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>d operator;
<|fim_prefix|>//! Unstable non-standard Wasmer-specific ty<|fim_middle|>pes about WebAssembly parser.
pub mo<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use wasmer_api::wasmparser::Operator;
#[repr(C)]
#[allow(non_camel_case_types)]
pub enum wasmer_parser_operator_t {
Unreachable,
Nop,
Block,
Loop,
If,
Else,
Try,
Catch,
CatchAll,
Delegate,
Throw,
Rethrow,
Unwind,
End,
Br,
BrIf,
BrTable,
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>{
/// # (assert_c! {
/// # #include "tests/wasmer.h"
/// #
/// int main() {
/// wasmer_triple_t* triple = wasmer_triple_new_from_host();
/// assert(triple);
///
/// wasmer_triple_delete(triple);
///
/// return 0;
/// }
/// # })
/// # .success();
/// # }
/// ```
///
/// See also [`... | fim | wasmerio/wasmer | rust |
//! Unstable non-standard Wasmer-specific API that contains more WASI
//! API.
use super::super::{
externals::wasm_extern_t, module::wasm_module_t, types::wasm_name_t, wasi::wasi_env_t,
};
/// Unstable non-standard type wrapping `wasm_extern_t` with the
/// addition of two `wasm_name_t` respectively for the modul... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>}
Err(_) => {
ds.field("value", &"Invalid value type");
}
}
ds.finish()
}
}
wasm_declare_vec!(val);
impl Clone for wasm_val_t {
fn clone(&self) -> Self {
wasm_val_t {
kind: self.kind,
of: self.of,
}
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::os::raw::c_char;
use std::sync::LazyLock;
const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "\0");
const VERSION_PRE: &str = concat!(env!("CARGO_PKG_VERSION_PRE"), "\0");
static VERSION_MAJOR: LazyLock<u8> = LazyLock::new(|| {
env!("CARGO_PKG_VERSION_MAJOR")
.parse()
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>_delete(module);
wasm_byte_vec_delete(&wasm);
wasm_byte_vec_delete(&wat);
wasmer_funcenv_delete(env);
wasm_store_delete(store);
wasm_engine_delete(engine);
return 0;
}
})
.success()... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::types::wasm_byte_vec_t;
/// Parses in-memory bytes as either the WAT format, or a binary Wasm
/// module. This is wasmer-specific.
///
/// In case of failure, `wat2wasm` sets the `out->data = NULL` and `out->size = 0`.
///
/// # Example
///
/// See the module's documentation.
///
/// # Safety
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ata[0]);
if (run_func == NULL) {
printf("> Error accessing export!\n");
return 1;
}
wasm_module_delete(module);
wasm_instance_delete(instance);
// Call.
printf("Calling export...\n");
wasm_val_t as[2] = {WASM_I32_VAL(3), WASM_I32_VAL(4)};
wasm_val_t rs[1] = {WASM_INIT_VAL};
was... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
// Print a Wasm value
auto operator<<(std::ostream& out, const wasm::Val& val) -> std::ostream& {
switch (val.kind()) {
case wasm::ValKind::I32: {
out << val.i32();
} break... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
const int iterations = 100000;
int live_count = 0;
void finalize(void* data) {
intptr_t i = (intptr_t)data;
if (i % (iterations / 10) == 0) printf("Finalizing #%" PRIdPTR "...\n", i);
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
const int iterations = 100000;
int live_count = 0;
void finalize(void* data) {
intptr_t i = reinterpret_cast<intptr_t>(data);
if (i % (iterations / 10) == 0) {
std::cout << "Fin... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
wasm_global_t* get_export_global(const wasm_extern_vec_t* exports, size_t i) {
if (exports->size <= i || !wasm_extern_as_global(exports->data[i])) {
printf("> Error accessing global expo... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
auto get_export_global(wasm::ownvec<wasm::Extern>& exports, size_t i) -> wasm::Global* {
if (exports.size() <= i || !exports[i]->global()) {
std::cout << "> Error accessing global e... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
// A function to be called from Wasm code.
o<|fim_suffix|>;
}
// Compile.
printf("Compiling module...\n");
own wasm_module_t* module = wasm_module_new(store, &binary);
if (!module) ... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
// A function to be called from Wasm code.
auto hello_callback(
const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
) -> wasm::own<wasm::Trap> {
std::cout << "Calling back... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>WASM_ARRAY_VEC(externs);
own wasm_instance_t* instance =
wasm_instance_new(store, module, &imports, NULL);
if (!instance) {
printf("> Error instantiating module!\n");
return 1;
}
wasm_func_delete(callback_func);
wasm_module_delete(module);
// Extract export.
printf("Extractin... | fim | wasmerio/wasmer | c |
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
// A function to be called from Wasm code.
auto callback(
const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
) -> wasm::own<wasm::Trap> {
std::cout << "Calling back..." << std::endl;
... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>, 0x1000, 1);
check_call1(load_func, 0x1003, 4);
check_call1(load_func, 0x1ffff, 0);
check_trap1(load_func, 0x20000);
// Mutate memory.
printf("Mutating memory...\n");
wasm_memory_data(memory)[0x1003] = 5;
check_ok2(store_func, 0x1002, 6);
check_trap2(store_func, 0x20000, 0);
check(was... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
auto get_export_memory(wasm::ownvec<wasm::Extern>& exports, size_t i) -> wasm::Memory* {
if (exports.size() <= i || !exports[i]->memory()) {
std::cout << "> Error accessing memory e... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>
// Shut down.
printf("Shutting down...\n");
wasm_store_delete(store);
wasm_engine_delete(engine);
// All done.
printf("Done.\n");
return 0;
}
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
// A function to be ... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
// A function to be called from Wasm code.
auto callback(
const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
) -> wasm::own<wasm::Trap> {
std::cout << "Calling back..." <<... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ec_t export_types;
own wasm_extern_vec_t exports;
wasm_module_exports(module, &export_types);
wasm_instance_exports(instance, &exports);
assert(exports.size == export_types.size);
for (size_t i = 0; i < exports.size; ++i) {
assert(wasm_extern_kind(exports.data[i]) ==
wasm_externt... | fim | wasmerio/wasmer | c |
<|fim_suffix|>t(), name.size()) << "\"";
return out;
}
void run() {
// Initialize.
std::cout << "Initializing..." << std::endl;
auto engine = wasm::Engine::make();
auto store_ = wasm::Store::make(engine.get());
auto store = store_.get();
// Load binary.
std::cout << "Loading binary..." << std::endl;
... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
// A function to be called from Wasm code.
own wasm_trap_t* hello_callback(const wasm_val_vec_t* args,
wasm_val_vec_t* results) {
printf("Calling back...\n");... | fim | wasmerio/wasmer | c |
<|fim_suffix|>llo_type.get(), hello_callback);
// Instantiate.
std::cout << "Instantiating deserialized module..." << std::endl;
auto imports = wasm::vec<wasm::Extern*>::make(hello_func.get());
auto instance = wasm::Instance::make(store, deserialized.get(), imports);
if (!instance) {
std::cout << "> Erro... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>rap, &trace);
if (trace.size > 0) {
for (size_t i = 0; i < trace.size; ++i) {
print_frame(trace.data[i]);
}
} else {
printf("> Empty trace.\n");
}
wasm_frame_vec_delete(&trace);
wasm_trap_delete(trap);
wasm_name_delete(&message);
// Shut down.
printf("Shutting down...\n... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttypes>
#include "wasm.hh"
void print_frame(const wasm::Frame* frame) {
std::cout << "> " << frame->instance();
std::cout << " @ 0x" << std::hex << frame->module_offset();
std::cout << " = " << frame->func_in... | fim | wasmerio/wasmer | cpp |
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
// A function to be called from Wasm code.
own wasm_trap_t* neg_callback(const wasm_val_vec_t* args,
wasm_val_vec_t* results) {
printf("Calling back...\n");
results->data[0... | fim | wasmerio/wasmer | c |
<|fim_suffix|>;
check(table2->grow(0));
// Shut down.
std::cout << "Shutting down..." << std::endl;
}
int main(int argc, const char* argv[]) {
run();
std::cout << "Done." << std::endl;
return 0;
}
<|fim_prefix|>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cinttype... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>pen("threads.wasm", "rb");
if (!file) {
printf("> Error loading module!\n");
return 1;
}
fseek(file, 0L, SEEK_END);
size_t file_size = ftell(file);
fseek(file, 0L, SEEK_SET);
wasm_byte_vec_t binary;
wasm_byte_vec_new_uninitialized(&binary, file_size);
if (fread(binary.data, file_si... | fim | wasmerio/wasmer | c |
<|fim_suffix|>t i = 0; i < N_THREADS; ++i) {
{
std::lock_guard<std::mutex> lock(mutex);
std::cout << "Initializing thread " << i << "..." << std::endl;
}
threads[i] = std::thread(run, engine.get(), shared.get(), &mutex, i);
}
for (int i = 0; i < N_THREADS; ++i) {
{
std::lock_guard... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wasm.h"
#define own
// A function to be called from Wasm code.
own wasm_trap_t* fail_callback(void* env, const wasm_val_vec_t* args,
wasm_val_vec_t* results) {
printf("Calling bac... | fim | wasmerio/wasmer | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.