text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> }
builder.ins().return_(&[]);
builder.finalize()
}
if let Some(callbacks) = callbacks.as_ref() {
callbacks.preopt_ir(
&CompiledKind::FunctionCallTrampoline(func_type.clone()),
module_hash,
context.func.display().to_string().as_bytes... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ine_function_call;
pub use cranelift_frontend::FunctionBuilderContext;
<|fim_prefix|>#![allow(missing_docs)]
mod dynamic_function;
mod function_call;
pub use self::dynamic_function::make_trampoline_dynamic_function;
pub use self::funct<|fim_middle|>ion_call::make_trampol<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>unless they succeed.
fn compute_addr(
pos: &mut FuncCursor,
heap: &HeapData,
addr_ty: ir::Type,
index: ir::Value,
offset: u32,
) -> ir::Value {
debug_assert_eq!(pos.func.dfg.value_type(index), addr_ty);
let heap_base = pos.ins().global_value(addr_ty, heap.base);
let base_... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>f) -> Value {
*self
.stack
.last()
.expect("attempted to peek at a value on an empty stack")
}
/// Pop two values. Return them in the order they were pushed.
pub(crate) fn pop2(&mut self) -> (Value, Value) {
let v2 = self.pop1();
let... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>code is larger than 4 GB.
ir::SourceLoc::new(reader.original_position() as u32)
}
<|fim_prefix|>// This file contains code from external sources.
// Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md
//! Standalone WebAssembly to Cranelift IR translator.
//!
//! This modu... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Tools for translating wasm function bytecode to Cranelift IR.
mod code_translator;
mod func_state;
mod func_translator;
mod translation_utils;
mod unwind;
pub use self::func_translator::FuncTranslator;
pub use self::translation_utils::{
irlibcall_to_libcall, irreloc_to_relocationkind, signature_... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Helper functions and structures for the translation.
use crate::func_environ::FuncEnvironment;
use crate::translator::EXN_REF_TYPE;
use cranelift_codegen::{
binemit::Reloc,
ir::{self, AbiParam},
isa::TargetFrontendConfig,
};
use cranelift_frontend::FunctionBuilder;
use wasmer_compiler::{
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! A `Compilation` contains the compiled function bodies for a WebAssembly
//! module.
#[cfg(feature = "unwind")]
use cranelift_codegen::isa::unwind::{UnwindInfo, systemv::UnwindInfo as DwarfFDE};
#[cfg(feature = "unwind")]
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::{Conte... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ue().get_type() == intrinsics.i32_ty)
|| (value.is_float_value()
&& value.into_float_value().get_type() == intrinsics.f32_ty)
};
let is_64 = |value: BasicValueEnum| {
value.is_pointer_value()
|| (value.is_int_value() && value.... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> Some(match sret_ptr {
Some(sret_ptr) => sret_ptr,
None => err!(alloca_builder.build_alloca(llvm_params, "sret")),
})
} else {
None
};
let mut args = vec![ctx_ptr.as_basic_value_enum()];
if let Some(m0) = m0 {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::abi::Abi;
use crate::error::{err, err_nt};
use crate::translator::intrinsics::{Intrinsics, type_to_llvm};
use inkwell::{
AddressSpace,
attributes::{Attribute, AttributeLoc},
builder::Builder,
context::Context,
types::{AnyType, BasicMetadataTypeEnum, BasicType, FunctionType, ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::abi::Abi;
use crate::error::{err, err_nt};
use crate::translator::intrinsics::{Intrinsics, type_to_llvm};
use inkwell::values::BasicValue;
use inkwell::{
AddressSpace,
attributes::{Attribute, AttributeLoc},
builder::Builder,
context::Context,
types::{AnyType, BasicMetadataTy... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>n_body_inputs
.iter()
.map(|(_, body)| body.data.len() as u64)
.sum::<u64>();
let progress = progress_callback
.cloned()
.map(|cb| ProgressContext::new(cb, total_steps, "Compiling functions"));
// TODO: merge constan... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::compiler::LLVMCompiler;
use enum_iterator::Sequence;
pub use inkwell::OptimizationLevel as LLVMOptLevel;
use inkwell::targets::{
CodeModel, InitializationConfig, RelocMode, Target as InkwellTarget, TargetMachine,
TargetMachineOptions, TargetTriple,
};
use itertools::Itertools;
use std::... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ap_err(|v| CompileError::Codegen(v.to_string()))?
};
}
pub(crate) use err;
pub(crate) use err_nt;
<|fim_prefix|>macro_rules! err_nt {
($e:expr) => {
<|fim_middle|> $e.map_err(|v| CompileError::Codegen(v.to_string()))
};
}
macro_rules! err {
($e:expr) => {
$e.m<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>size=200")]
#![cfg_attr(docsrs, feature(doc_cfg))]
mod abi;
mod compiler;
mod config;
mod error;
mod object_file;
mod translator;
pub use crate::compiler::LLVMCompiler;
pub use crate::config::{InkwellMemoryBuffer, InkwellModule, LLVM, LLVMCallbacks, LLVMOptLevel};
<|fim_prefix|>#![doc(html_favicon_url =... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
object::Architecture::Riscv64 | object::Architecture::Riscv32,
object::RelocationFlags::Elf {
r_type: object::elf::R_RISCV_PCREL_LO12_I,
},
0,
) => RelocationKind::RiscvPCRelLo12I,
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Code for dealing with [LLVM][llvm-intrinsics] and VM intrinsics.
//!
//! VM intrinsics are used to interact with the host VM.
//!
//! [llvm-intrinsics]: https://llvm.org/docs/LangRef.html#intrinsic-functions
use crate::abi::Abi;
use crate::error::err;
use inkwell::values::BasicMetadataValueEnum;
use ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>pub use self::trampoline::FuncTrampoline;
<|fim_prefix|>mod code;
pub mod intrinsics;
mod state;
pub mod trampoline;
pub<|fim_middle|> use self::code::FuncTranslator;
<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use inkwell::{
basic_block::BasicBlock,
values::{BasicValue, BasicValueEnum, PhiValue},
};
use smallvec::SmallVec;
use std::{
collections::VecDeque,
ops::{BitAnd, BitOr, BitOrAssign},
};
use wasmer_types::CompileError;
#[derive(Debug)]
#[allow(dead_code)]
pub enum ControlFrame<'ctx> {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>// TODO: Remove
#![allow(unused)]
use crate::{
abi::{Abi, get_abi},
config::LLVM,
error::{err, err_nt},
object_file::{CompiledFunction, load_object_file},
translator::intrinsics::{Intrinsics, type_to_llvm},
};
use inkwell::{
AddressSpace, DLLStorageClass,
attributes::{Attribut... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use wasmer_compiler::FunctionBodyData;
use wasmer<|fim_suffix|> {
instructions,
start_srcloc,
end_srcloc,
body_offset: 0,
body_len,
}
}
<|fim_middle|>_compiler::types::address_map::{FunctionAddressMap, InstructionAddressMap};
use wasmer_types::SourceLoc;
pub fn... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> NEON::V3,
NEON::V4,
NEON::V5,
NEON::V6,
NEON::V7,
];
match ty {
Type::I32 | Type::I64 | Type::FuncRef | Type::ExternRef => {
if self.n_gprs < GPR_... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum Size {
S8,
S16,
S32,
S64,
}
im<|fim_suffix|> 8 * self.bytes()
}
pub fn bytes(&self) -> u32 {
match self {
Size::S8 => 1,
Size::S16 => 2,
Size::S32 => 4,
... | fim | wasmerio/wasmer | rust |
//! Support for compiling with Singlepass.
// Allow unused imports while developing.
#![allow(unused_imports, dead_code)]
use crate::codegen::FuncGen;
use crate::config::{self, Singlepass};
#[cfg(feature = "unwind")]
use crate::dwarf::WriterRelocate;
use crate::machine::Machine;
use crate::machine::{
gen_import_ca... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>// Allow unused imports while developing
#![allow(unused_imports, dead_code)]
use crate::{compiler::SinglepassCompiler, machine::AssemblyComment};
use std::{
collections::HashMap,
fs::File,
io::{self, Write},
num::NonZero,
path::PathBuf,
sync::Arc,
};
use target_lexicon::Architect... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use gimli::{
RunTimeEndian, SectionId,
write::{Address, EndianVec, Result, Writer},
};
use wasmer_compiler::types::{
relocation::{Relocation, RelocationKind, RelocationTarget},
section::{CustomSection, CustomSectionProtection, SectionBody},
};
use wasmer_types::{LocalFunctionIndex, entity:... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> self.emit_j_label(label, Some(tmp))?;
self.emit_label(cont)?;
Ok(())
}
fn emit_on_false_label(
&mut self,
cond: Location,
label: Label,
tmp: GPR,
) -> Result<(), CompileError> {
match cond {
Location::GPR(cond) => {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>asm!(self ; movsx Rd(dst), WORD [Rq(src) + disp]);
}
(Size::S8, Location::GPR(src), Size::S64, Location::GPR(dst)) => {
dynasm!(self ; movsx Rq(dst), Rb(src));
}
(Size::S16, Location::GPR(src), Size::S64, Location::GPR(dst)) => {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ime performance.
#![allow(clippy::unnecessary_cast)]
#![cfg_attr(docsrs, feature(doc_cfg))]
mod address_map;
mod arm64_decl;
mod codegen;
mod common_decl;
mod compiler;
mod config;
#[cfg(feature = "unwind")]
mod dwarf;
mod emitter_arm64;
mod emitter_riscv;
mod emitter_x64;
mod location;
mod machine;
mod... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
fn callee_param_location(n: usize) -> Location<R, S>;
fn caller_arg_location(n: usize) -> Location<R, S>;
fn return_location() -> Location<R, S>;
}
#[allow(unused)]
pub trait CombinedRegister: Copy + Clone + Eq + PartialEq + Debug {
/// Convert from a GPR register
fn from_gpr(x: u16)... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::{
common_decl::*,
location::{Location, Reg},
machine_arm64::MachineARM64,
machine_riscv::MachineRiscv,
machine_x64::MachineX86_64,
unwind::UnwindInstructions,
};
use dynasmrt::{AssemblyOffset, DynamicLabel};
use std::{
collections::{BTreeMap, HashMap},
fmt::Debu... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>atch ty {
Type::I32 | Type::I64 | Type::FuncRef | Type::ExternRef => {
if self.n_gprs < GPR_SEQ.len() {
let gpr = GPR_SEQ[self.n_gprs];
self.n_gprs += 1;
Some(RiscvRegister::GPR(gpr))
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>_attr(not(feature = "unwind"), allow(dead_code))]
pub enum UnwindOps<R: location::Reg, S: location::Reg> {
PushFP {
up_to_sp: u32,
},
SubtractFP {
up_to_sp: u32,
},
Push2Regs {
reg1: UnwindRegister<R, S>,
reg2: UnwindRegister<R, S>,
up_to_sp: u32... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Windows x64 ABI unwind information.
use crate::{
location::Reg,
unwind::{UnwindOps, UnwindRegister},
x64_decl::{GPR, XMM},
};
/// Maximum (inclusive) size of a "small" stack allocation
const SMALL_ALLOC_MAX_SIZE: u32 = 128;
/// Maximum (inclusive) size of a "large" stack allocation that ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>> {
if idx < 4 {
let xmm = XMM_SEQ[idx];
self.n_xmms += 1;
Some(X64Register::XMM(xmm))
} else {
None
}
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#[derive(
schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug,
)]
pub enum HealthCheckV1 {
#[serde(rename = "http")]
Http(HealthCheckHttpV1),
}
/// Health check configuration for http endpoints.
#[derive(
schemars::JsonSchema, serde::Serialize, serde::D... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::pretty_duration::PrettyDuration;
/// Defines an HTTP request.
#[derive(
schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug,
)]
pub struct HttpRequest {
/// Request path.
pub path: String,
/// HTTP method.
///
/// Defaults to GET.
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{borrow::Cow, fmt::Display, str::FromStr};
use anyhow::anyhow;
use serde::{Deserialize, Serialize, de::Error};
use indexmap::IndexMap;
use crate::package::PackageSource;
use super::{AppConfigCapabilityMemoryV1, AppVolume, HttpRequest, pretty_duration::PrettyDuration};
/// Job configuration.
... | fim | wasmerio/wasmer | rust |
//! User-facing app.yaml file config: [`AppConfigV1`].
mod healthcheck;
mod http;
mod job;
mod pretty_duration;
mod snapshot_trigger;
mod ssh;
pub use self::{healthcheck::*, http::*, job::*, pretty_duration::*, snapshot_trigger::*, ssh::*};
use anyhow::{Context, bail};
use bytesize::ByteSize;
use indexmap::IndexMap;... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>assert_deserializes_to("7d", "7D", DurationUnit::Days, 7);
}
#[test]
#[should_panic]
pub fn cant_parse_negative_duration() {
_ = "-12s".parse::<PrettyDuration>().unwrap();
}
}
<|fim_prefix|>use std::{
borrow::Cow,
fmt::{Debug, Display},
str::FromStr,
time::Dura... | fim | wasmerio/wasmer | rust |
use std::{borrow::Cow, fmt::Display, str::FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize, de::Error};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SnapshotTrigger {
/// Triggered when all the threads in the process goes idle
Idle,
/// Triggered when ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> pub users: Option<Vec<SshUserV1>>,
/// Additional unknown fields.
/// This provides a small bit of forwards compatibility.
#[serde(flatten)]
pub other: IndexMap<String, serde_json::Value>,
}
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
pub struct SshUserV1... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ame = entry
.file_name()
.to_str()
.expect("non-utf8 filename")
.to_string();
assert!(
jsonschema.contains_key(&file_name),
"Found unexpected file in the json schemas directory: '{}' - delete it!",... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>/ Binding declarations for the crate.
pub bindings: Option<Bindings>,
}
<|fim_prefix|>//! Rust and cargo specific annotations used to interoperate with external tools.
use std::path::PathBuf;
use indexmap::IndexMap;
use crate::package::{Abi, Bindings};
/// The annotation used by `cargo wapm` when ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::borrow::Cow;
/// Sha256 hash, represented as bytes.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Sha256Hash(pub [u8; 32]);
impl Sha256Hash {
pub fn as_bytes(&self) -> &[u8; 32] {
&self.0
}
pub fn from_bytes(bytes: [u8; 32]) -> Self {
Self(bytes)... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Provides configuration ty<|fim_suffix|>nnotations;
pub mod hash;
pub mod package;
<|fim_middle|>pes for Wasmer.
pub mod app;
pub mod cargo_a<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>/// Error that occurs during package ident/source parsing.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PackageParseError {
value: String,
message: String,
}
impl PackageParseError {
pub(crate) fn new(value: impl Into<String>, message: impl Into<String>) -> Self {
Self {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Wasmer package definitions.
//!
//! Describes the contents of a `wasmer.toml` file.
#![allow(deprecated)]
mod error;
mod named_package_ident;
mod package_hash;
mod package_id;
mod package_ident;
mod package_source;
pub use self::{
error::PackageParseError,
named_package_ident::{NamedPackage... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{borrow::Cow, fmt::Write, str::FromStr};
use semver::VersionReq;
use super::{NamedPackageId, PackageParseError};
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum Tag {
Named(String),
VersionReq(semver::VersionReq),
}
impl Tag {
pub fn as_named(&self) -> Option<&String> {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::borrow::Cow;
use crate::{hash::Sha256Hash, package::PackageParseError};
/// Hash for a package.
///
/// Currently only supports the format: `sha256:<hash>`.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum PackageHash {
Sha256(Sha256Hash),
}
impl Pac... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> Self::Named(n) => n.fmt(f),
Self::Hash(h) => h.fmt(f),
}
}
}
impl schemars::JsonSchema for PackageId {
fn schema_name() -> Cow<'static, str> {
Cow::Borrowed("PackageIdent")
}
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schem... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_package_ident_matches_id() {
assert!(
PackageIdent::from_str("ns/pkg")
.unwrap()
.matches_id(&PackageId::new_named("ns/pkg", "1.0.0".parse().unwrap()))
);
assert!... | fim | wasmerio/wasmer | rust |
use std::{borrow::Cow, str::FromStr};
use super::{
NamedPackageId, NamedPackageIdent, PackageHash, PackageId, PackageIdent, PackageParseError,
};
/// Source location of a package.
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum PackageSource {
/// An identifier in the format prescribed by the `WebcIdent... | fim | wasmerio/wasmer | rust |
extern crate proc_macro;
use proc_macro_error2::proc_macro_error;
use syn::{DeriveInput, parse_macro_input};
mod value_type;
#[proc_macro_error]
#[proc_macro_derive(ValueType)]
pub fn derive_value_type(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInpu... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use proc_macro_error2::abort;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{Data, DeriveInput, Fields, Member};
/// We can only validate types that have a well defined layout.
fn check_repr(input: &DeriveInput) {
if input.attrs.iter().any(|attr| {
attr.path().is_ident("repr") && {... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
#[wasmer(extraport)] //~ Unexpected identifier `extraport`. Expected `export`.
memory: LazyInit<Memory>,
}
fn main() {}
<|fim_prefix|>extern crate wasmer;
use wasmer::{LazyInit, Memory, WasmerEnv};
#[de<|fim_middle|>rive(WasmerEnv)]
struct BadAttribute {<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>extern crate wasmer;
use wasmer::{LazyInit, Memory, WasmerEnv};
#[derive(Wasmer<|fim_suffix|> #[wasmer(export("hello"))] //~ Failed to parse `wasmer` attribute: unexpected token
memory: LazyInit<Memory>,
}
fn main() {}
<|fim_middle|>Env)]
struct BadExportArg {
#[wasmer(export(this_is_not_a_real... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>extern crate wasmer;
use w<|fim_suffix|>`
}
fn main() {}
<|fim_middle|>asmer::{LazyInit, Memory, WasmerEnv};
#[derive(WasmerEnv)]
struct ExportNotWrappedInLazyInit {
#[wasmer(export)]
memory: Memory, //~ WasmerEnv derive expects all `export`s to be wrapped in `LazyInit<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>// file <|fim_suffix|>it needs to essentially run `cargo clean` to work correctly
// and that's really, really slow
fn compile_test() {
run_mode("compile-fail", "compile-fail");
}
<|fim_middle|>is a modified version of https://github.com/AltSysrq/proptest/blob/proptest-derive/proptest-derive/tests/co... | fim | wasmerio/wasmer | rust |
use std::borrow::Cow;
use lz4_flex::block::{compress_prepend_size, decompress_size_prepended};
use serde::{Deserialize, Serialize};
use serde::{Deserializer, Serializer};
pub fn serialize<S: Serializer>(v: &[u8], s: S) -> Result<S::Ok, S::Error> {
#[allow(deprecated)]
let base64 = base64::encode(compress_pre... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{borrow::Cow, ops::Deref};
use rkyv::{
Archive, Archived,
rancor::Fallible,
ser::{Allocator, WriterExt},
vec::{ArchivedVec, VecResolver},
};
#[derive(Clone)]
pub struct AlignedCowStr<'a> {
inner: Cow<'a, str>,
}
impl<'a> AlignedCowStr<'a> {
pub const ALIGNMENT: usize = ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{
borrow::{Borrow, BorrowMut, Cow},
fmt::{self, Pointer},
ops::{Deref, DerefMut},
};
use rkyv::{
Archive, Archived,
rancor::Fallible,
ser::{Allocator, WriterExt},
vec::{ArchivedVec, VecResolver},
};
/// An aligned COW vector of bytes which avoids copying data
/// whe... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>))
}
}
<|fim_prefix|>use super::*;
use std::ops::Deref;
use std::sync::Arc;
impl<R: ReadableJournal> ReadableJournal for Arc<R> {
fn read(&self) -> anyhow::Result<Option<LogReadResult<'_>>> {
self.deref().read()
}
fn as_restarted(&self) -> anyhow::Result<Box<DynReadableJournal>> ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>rchive)]
#[rkyv(attr(repr(align(8))))]
pub struct JournalEntryCreateHardLinkV1<'a> {
pub old_fd: u32,
pub old_path: AlignedCowStr<'a>,
pub old_flags: u32,
pub new_fd: u32,
pub new_path: AlignedCowStr<'a>,
}
#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Clone, RkyvSerialize, RkyvDeseria... | fim | wasmerio/wasmer | rust |
use std::borrow::Cow;
use std::time::SystemTime;
use wasmer_wasix_types::wasi;
use wasmer_wasix_types::wasix::{ThreadStartType, WasiMemoryLayout};
use super::*;
impl From<wasi::Snapshot0Clockid> for JournalSnapshot0ClockidV1 {
fn from(val: wasi::Snapshot0Clockid) -> Self {
match val {
wasi::Sn... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{
collections::HashSet,
sync::{Arc, Mutex},
};
use super::*;
/// Journal which leave itself in a consistent state once it commits
/// by closing all the file descriptors that were opened while
/// it was recording writes.
#[derive(Debug)]
pub struct AutoConsistentJournal<W: WritableJour... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{ops::Deref, sync::Arc};
use super::*;
impl<R: ReadableJournal + ?Sized> ReadableJournal for Box<R> {
fn read(&self) -> anyhow::Result<Option<LogReadResult<'_>>> {
self.deref().read()
}
fn as_restarted(&self) -> anyhow::Result<Box<DynReadableJournal>> {
self.deref()... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::sync::Arc;
use std::sync::Mutex;
use super::*;
// The buffered journal will keep all the events in memory un<|fim_suffix|>r BufferedJournalRx {
fn read(&self) -> anyhow::Result<Option<LogReadResult<'_>>> {
let mut state = self.state.lock().unwrap();
let ret = state.records.l... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>),
// },
// ],
// vec![
// JournalEntry::UpdateMemoryRegionV1 {
// region: 0..16,
// data: [11u8; 16].to_vec().into(),
// },
// JournalEntry::UpdateMemoryRegionV1 {
// ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{
path::{Path, PathBuf},
sync::{Arc, Mutex},
};
use super::*;
#[derive(Debug)]
struct State {
on_n_records: Option<u64>,
on_n_size: Option<u64>,
on_factor_size: Option<f32>,
on_drop: bool,
cnt_records: u64,
cnt_size: u64,
ref_size: u64,
}
#[derive(Debug)]
pu... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::*;
#[derive(Debug)]
pub struct CompactingTransactionJournalTx<W: WritableJournal> {
inner: TransactionJournalTx<W>,
}
#[derive(Debug)]
pub struct CompactingTransactionJournalRx<R: ReadableJournal> {
inner: TransactionJournalRx<R>,
}
/// Journal which will store the events locally in ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::sync::{
Arc,
atomic::{AtomicU64, AtomicUsize, Ordering},
};
use super::*;
/// Journal that counts the size of the entries that are written to it
#[derive(Debug, Clone, Default)]
pub struct CountingJournal {
n_cnt: Arc<AtomicUsize>,
n_size: Arc<AtomicU64>,
}
impl CountingJournal... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>nalEntry::SocketLeaveIpv6MulticastV1 { .. }
| JournalEntry::SocketSendFileV1 { .. }
| JournalEntry::SocketSendToV1 { .. }
| JournalEntry::SocketSendV1 { .. }
| JournalEntry::SocketSetOptFlagV1 { .. }
| JournalEntry::SocketSetOptSizeV1 { .. }
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>eV1 {
read_fd: 1,
write_fd: 2
})
);
assert_eq!(
event2,
Some(JournalEntry::SetThreadV1 {
id: 1,
call_stack: vec![11; 116].into(),
memory_stack: vec![22; 16].into(),
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{
fs::File,
io::{Seek, Write},
path::Path,
sync::RwLock,
};
use lz4_flex::{block, decompress};
use super::*;
/// The memory file journal processes journal entries by writing any memory mutations
/// directly to a file. Later this can be used as a mounting target for resuming
//... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>mod aligned_cow_s<|fim_suffix|>pub use compacting_transaction::*;
pub use counting::*;
pub use filter::*;
#[cfg(feature = "log-file")]
pub use log_file::*;
pub use mem_file::*;
pub use null::*;
pub use pipe::*;
pub use printing::*;
pub use recombined::*;
pub use transaction::*;
pub use unsupported::*;
<|f... | fim | wasmerio/wasmer | rust |
use super::*;
pub static NULL_JOURNAL: NullJournal = NullJournal { debug_print: false };
/// The null journal sends all the records into the abyss
#[derive(Debug, Default)]
pub struct NullJournal {
debug_print: bool,
}
impl ReadableJournal for NullJournal {
fn read(&self) -> anyhow::Result<Option<LogReadResu... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::sync<|fim_suffix|> })
.map_err(|err| {
anyhow::format_err!("failed to send journal event through the pipe - {err}")
})?;
sender.offset += entry_size;
Ok(LogWriteResult {
record_start: sender.offset,
record_end: sender... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::fmt;
use super::*;
use lz4_flex::block::uncompressed_size;
use wasmer_wasix_types::wasi;
/// Type of printing mode to use
#[derive(Debug, Default)]
pub enum JournalPrintingMode {
#[default]
Text,
Json,
}
/// The printing journal writes all the journal entries to the console
/// as ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::*;
#[derive(Debug)]
pub struct RecombinedJournal<W: WritableJournal, R: ReadableJournal> {
tx: W,
rx: R,
}
impl<W: WritableJournal, R: ReadableJournal> RecombinedJournal<W, R> {
pub fn new(tx: W, rx: R) -> Self {
Self { tx, rx }
}
}
impl<W: WritableJournal, R: Readabl... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>_eq!(std::mem::align_of::<JournalEntryPortDelAddrV1>(), 8);
assert_eq!(std::mem::align_of::<JournalEntryPortBridgeV1>(), 8);
assert_eq!(std::mem::align_of::<JournalEntryPortGatewaySetV1>(), 8);
assert_eq!(std::mem::align_of::<JournalEntryPortRouteAddV1>(), 8);
assert_eq!(std::mem::align_of... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> }
fn as_restarted(&self) -> anyhow::Result<Box<DynReadableJournal>> {
self.rx.as_restarted()
}
}
impl Journal for TransactionJournal<Box<DynWritableJournal>, Box<DynReadableJournal>> {
fn split(self) -> (Box<DynWritableJournal>, Box<DynReadableJournal>) {
(Box::new(self.tx... | fim | wasmerio/wasmer | rust |
use super::*;
pub static UNSUPPORTED_JOURNAL: UnsupportedJournal = UnsupportedJournal {};
/// The default for runtime is to use the unsupported journal
/// which will fail to write journal entries if one attempts to do so.
#[derive(Debug, Default)]
pub struct UnsupportedJournal {}
impl ReadableJournal for Unsupporte... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use serde::{Deserialize, Serialize};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::net::{Shutdown, SocketAddr};
use std::time::{Duration, SystemTime};
use std::{borrow::Cow, ops::Range};
use virtual_net::{IpCidr, StreamSecurity};
use wasmer_wasix_types::wasi::{
Addressfamily, Advice, EpollCtl, ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>l = dyn Journal + Send + Sync;
pub type DynWritableJournal = dyn WritableJournal + Send + Sync;
pub type DynReadableJournal = dyn ReadableJournal + Send + Sync;
/// A bit of manual up-casting support
pub trait AsDynReadableJournal {
fn as_dyn_readable_journal(&self) -> &DynReadableJournal;
}
impl<T:... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> ConfigSnapshotTrigger::FirstStdin => Self::FirstStdin,
ConfigSnapshotTrigger::Idle => Self::Idle,
ConfigSnapshotTrigger::NonDeterministicCall => Self::NonDeterministicCall,
ConfigSnapshotTrigger::PeriodicInterval => Self::PeriodicInterval,
ConfigSnapsh... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>R,
to: &W,
) -> anyhow::Result<()> {
while let Some(record) = from.read()? {
to.write(record.into_inner())?;
}
Ok(())
}
<|fim_prefix|>use super<|fim_middle|>::*;
pub fn copy_journal<R: ReadableJournal, W: WritableJournal>(
from: &<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#![cfg_attr(docsrs, feature(doc_cfg))]
pub mod metering;
// The most commonly used symbol are exported at top <|fim_suffix|> available via modules,
// e.g. `wasmer_middlewares::metering::get_remaining_points`
pub use metering::Metering;
<|fim_middle|>level of the
// module. Others are<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
// Infinite loop
let metering = Arc::new(Metering::new(INITIAL_POINTS, cost));
let mut compiler_config = Cranelift::default();
compiler_config.push_middleware(metering);
let mut store = Store::new(EngineBuilder::new(compiler_config));
let module = Module::... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>e(e) = &self.cause {
Some(e)
} else {
None
}
}
}
<|fim_prefix|>use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct ConversionError {
message: String,
cause: Option<Arc<dyn std::error::Error + Send + Sync>>,
}
impl ConversionError {
pub fn msg(ms... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>mod error;<|fim_suffix|>ackage;
pub use self::{error::ConversionError, webc_to_package::webc_to_package_dir};
<|fim_middle|>
mod webc_to_p<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::path::Path;
use wasmer_config::package::ModuleReference;
use webc::Container;
use super::ConversionError;
/// Convert a webc image into a directory with a wasmer.toml file that can
/// be used for generating a new package.
pub fn webc_to_package_dir(webc: &Container, target_dir: &Path) -> Res... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>s;
pub mod convert;
pub mod package;
pub mod utils;
<|fim_prefix|>#[macro_use]
<|fim_middle|>#[cfg(test)]
mod macro<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>"{} != {}", stringify!($lhs), stringify!($rhs));
};
}
<|fim_prefix|>//! Macros and abstractions used during testing.
use bytes::{Bytes, BytesMut};
use webc::Version;
/// Construct a sequence of bytes using one or more items that implement the
/// [`ToBytes`] trait.
macro_rules! bytes {
($($item... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>;
let (transformed, _) =
wasmer_manifest_to_webc(&manifest, temp.path(), Strictness::Strict).unwrap();
insta::with_settings! {
{ description => wasmer_toml },
{ insta::assert_yaml_snapshot!(&transformed); }
}
}
#[test]
fn transform... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Load a Wasmer package from disk.
pub(crate) mod manifest;
#[allow(clippy::module_inception)]
pub(crate) mod package;
pub(crate) mod strictness;
pub(crate) mod volume;
pub use self::{
manifest::ManifestError,
package::{
Package, WalkBuilderFactory, WasmerPackageError, include_everythin... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#![allow(
clippy::result_large_err,
reason = "WasmerPackageError is large, but not often used"
)]
use std::{
borrow::Cow,
collections::{BTreeMap, BTreeSet},
fmt::Debug,
fs::File,
io::{BufRead, BufReader},
path::{Path, PathBuf},
sync::Arc,
};
use anyhow::{Context, Erro... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>matches!(self, Strictness::Strict)
}
pub(crate) fn outside_base_directory(
&self,
path: &Path,
base_dir: &Path,
) -> Result<(), ManifestError> {
match self {
Strictness::Lossy => todo!(),
Strictness::Strict => Err(ManifestError::OutsideB... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{
collections::{BTreeMap, BTreeSet},
fmt::Debug,
fs::{self, File},
io::Read,
path::{Path, PathBuf},
};
use anyhow::{Context, Error};
use shared_buffer::OwnedBuffer;
use webc::{
AbstractVolume, Metadata, PathSegment, PathSegments, Timestamps, ToPathSegments, sanitize_path... | fim | wasmerio/wasmer | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.