text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>use std::path::PathBuf; use anyhow::Context; use dialoguer::console::{Emoji, style}; use indicatif::ProgressBar; use sha2::Digest; use wasmer_config::package::PackageHash; use wasmer_package::package::Package; use crate::utils::load_package_manifest; /// Build a container from a package manifest. #[der...
fim
wasmerio/wasmer
rust
<|fim_suffix|>0)); pb.set_style( indicatif::ProgressStyle::with_template("{spinner:.magenta} {msg}") .unwrap() .tick_strings(&["✶", "✸", "✹", "✺", "✹", "✷", "✶"]), ); pb.set_message($msg); pb }}; ($quiet:expr, $msg:expr, $($spinner:ex...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{ commands::{AsyncCliCommand, Login}, config::WasmerEnv, utils::load_package_manifest, }; use bytes::Bytes; use colored::Colorize; use dialoguer::Confirm; use indicatif::{ProgressBar, ProgressStyle}; use reqwest::Body; use std::path::{Path, PathBuf}; use wasmer_backend_api::{WasmerC...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use futures::StreamExt; use wasmer_backend_api::{WasmerClient, types::PackageVersionState}; /// Different conditions that can be "awaited" when publishing a package. #[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)] pub enum PublishWait { None, Container, NativeExecutables, Bi...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{env::current_dir, path::PathBuf}; use anyhow::{Context, bail}; use dialoguer::console::{Emoji, style}; use indicatif::{ProgressBar, ProgressStyle}; use tempfile::NamedTempFile; use wasmer_config::package::{PackageIdent, PackageSource}; use wasmer_package::utils::from_disk; use crate::config::W...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod build; mod<|fim_suffix|> Tag(tag::PackageTag), Push(push::PackagePush), Publish(publish::PackagePublish), Unpack(unpack::PackageUnpack), } <|fim_middle|> common; mod download; pub mod publish; mod push; mod tag; mod unpack; pub use build::PackageBuild; pub use common::wait::PublishWait; ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>", "𖥔".yellow().bold()); } PackageIdent::Hash(ref h) => { eprintln!( "\n{} Successfully published package ({h})", "✔".green().bold() ); } } Ok(ident) } } <|fim_prefix|>use crat...
fim
wasmerio/wasmer
rust
<|fim_suffix|> } } else { eprintln!( "{} Successfully pushed package ({hash})", "✔".green().bold() ); } Ok(()) } } <|fim_prefix|>use super::common::{macros::*, *}; use crate::{ commands::{AsyncCliCommand, PackageBuild}, config:...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{ commands::{ AsyncCliCommand, package::common::{macros::*, wait::wait_package, *}, }, config::WasmerEnv, }; use anyhow::Context; use colored::Colorize; use dialoguer::{Confirm, theme::ColorfulTheme}; use std::io::IsTerminal as _; use std::{ path::{Path, PathBuf}...
fim
wasmerio/wasmer
rust
<|fim_suffix|>693bb7.webc"); assert!(package_path.is_file()); let cmd = PackageUnpack { out_dir: dir.path().to_owned(), overwrite: false, package_path, quiet: true, format: Format::Webc, }; cmd.execute().unwrap(); le...
fim
wasmerio/wasmer
rust
<|fim_suffix|>.duration_since(UNIX_EPOCH)? .as_millis() .to_be_bytes(), ); format!("path_{}.json", hex::encode(hash.finalize())) } CliPackageSource::Package(p) => match p { PackageSpecifier::Ident(id) => match id { ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ fmt::Display, net::{IpAddr, SocketAddr}, path::PathBuf, str::FromStr, sync::OnceLock, time::Duration, }; use super::{super::CliPackageSource, PkgCapabilityCache}; use anyhow::Context; use colored::Colorize; use dialoguer::theme::ColorfulTheme; use virtual_net::{ Dyn...
fim
wasmerio/wasmer
rust
#![allow(missing_docs, unused)] mod capabilities; mod package_source; mod runtime; mod target; mod wasi; use std::{ borrow::Cow, collections::{BTreeMap, hash_map::DefaultHasher}, fmt::{Binary, Display}, fs::File, hash::{BuildHasherDefault, Hash, Hasher}, io::{ErrorKind, LineWriter, Read, Write...
fim
wasmerio/wasmer
rust
<|fim_suffix|>f, "{p}"), } } } <|fim_prefix|>use std::{ path::{Path, PathBuf}, sync::Arc, }; use anyhow::Error; use indicatif::ProgressBar; use wasmer_config::package::PackageSource; use wasmer_wasix::{ Runtime, bin_factory::BinaryPackage, runtime::task_manager::VirtualTaskManagerExt as _, }; ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> .template("{spinner} {wide_bar:.cyan/blue} {msg}") .expect("invalid progress bar template"); self.progress.set_style(style); self.progress.reset(); if self.progress.is_hidden() { self.progress .set_draw_target(indicatif::ProgressDrawTarge...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ fs::File, io::Read as _, path::{Path, PathBuf}, sync::Arc, }; use anyhow::{Context as _, Error, bail}; use indicatif::ProgressBar; use wasmer::Module; #[cfg(feature = "compiler")] use wasmer_compiler::ArtifactBuild; use wasmer_types::ModuleHash; use wasmer_wasix::{ Runtime,...
fim
wasmerio/wasmer
rust
use std::{ collections::{BTreeSet, HashMap}, path::{Path, PathBuf}, str::FromStr, sync::{Arc, mpsc::Sender}, time::Duration, }; use anyhow::{Context, Result, bail}; use bytes::Bytes; use clap::Parser; use itertools::Itertools; use tokio::runtime::Handle; use url::Url; use virtual_fs::{ ArcFileS...
fim
wasmerio/wasmer
rust
<|fim_suffix|>"))] fn inner_execute(&self) -> Result<(), anyhow::Error> { use std::process::{Command, Stdio}; println!("Fetching latest installer"); let cmd = Command::new("curl") .arg("https://get.wasmer.io") .arg("-sSfL") .stdout(Stdio::piped()) ...
fim
wasmerio/wasmer
rust
//! Edge SSH command. use anyhow::Context; use wasmer_backend_api::{WasmerClient, types::DeployApp}; use super::{AsyncCliCommand, app::AppIdentArgOpts}; use crate::{config::WasmerEnv, edge_config::LoadedEdgeConfig}; /// Start a remote SSH session. #[derive(clap::Parser, Debug)] pub struct CmdSsh { #[clap(flatten...
fim
wasmerio/wasmer
rust
<|fim_suffix|>dule_contents, &Target::default())?; Module::validate(&engine, &module_contents)?; eprintln!("Validation passed for `{}`.", self.path.display()); Ok(()) } } <|fim_prefix|>use std::path::PathBuf; use anyhow::{Context, Result, bail}; use clap::Parser; use wasmer::{Module, is_was...
fim
wasmerio/wasmer
rust
<|fim_prefix|> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "wasmer.h" // EXTRA_HEADERS #define own #define WASI // DECLARE_VOLUMES // DECLARE_MODULES static void print_wasmer_error() { int error_len = wasmer_last_error_length(); // printf("Error len: `%d`\n", error_len); char* error_s...
fim
wasmerio/wasmer
c
//! Runs a .wast WebAssembly test suites use std::path::PathBuf; use anyhow::{Context, Result}; use clap::Parser; use wasmer::{Store, sys::Target}; use wasmer_wast::Wast as WastSpectest; use crate::backend::RuntimeOptions; #[derive(Debug, Parser)] /// The options for the `wasmer wast` subcommand pub struct Wast { ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Common module with common used structures across differ<|fim_suffix|>truct WasmFeatures { /// Enable support for the SIMD proposal. #[clap(long = "enable-simd")] pub simd: bool, /// Disable support for the threads proposal. #[clap(long = "disable-threads")] pub disable_threads...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::WasmerConfig; use anyhow::{Context, Error}; use std::path::{Path, PathBuf}; use std::sync::LazyLock; use url::Url; use wasmer_backend_api::WasmerClient; pub static DEFAULT_WASMER_CLI_USER_AGENT: LazyLock<String> = LazyLock::new(|| format!("WasmerCLI-v{}", env!("CARGO_PKG_VERSION"))); /// ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod env; pub use env::*; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use std::sync::LazyLock; use url::Url; use wasmer_backend_api::WasmerClient; pub static GLOBAL_CONFIG_FILE_NAME: &str = "wasmer.toml"; pub static DEFAULT_PROD_REGISTRY: &str = "https://registry.wasmer.io/graphq...
fim
wasmerio/wasmer
rust
<|fim_suffix|>t: expected 3 parts."); } let payload_base64 = parts[1]; // Decode the Base64 URL-encoded payload let decoded_payload_bytes = base64::prelude::BASE64_URL_SAFE_NO_PAD .decode(payload_base64) .with_context(|| "Failed to base64 decode payload")?; let decoded_payload_str...
fim
wasmerio/wasmer
rust
<|fim_suffix|> if !self.is_last { write!( self.inner, "{} {: >4} ", "│".bold().blue(), format!("{number}:").dimmed() ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>#![deny( missing_docs, // dead_code, nonstandard_style, unused_mut, // unused_variables, unused_unsafe, unreachable_patterns )] // Allowed because it makes code more readable. #![allow(clippy::bool_comparison, clippy::match_like_matches_macro)] #![cfg_attr(docsrs, feature(doc_c...
fim
wasmerio/wasmer
rust
<|fim_suffix|>, /// Do not print progress messages. #[clap(short, long, global = true, conflicts_with = "verbose")] pub quiet: bool, /// The format to use when generating logs. #[clap(long, global = true, env, default_value = "text")] pub log_format: LogFormat, /// Which span events to log. ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod tun<|fim_suffix|>Driver, TunTapSocket}; <|fim_middle|>; pub use tun::{TunTap<|endoftext|>
fim
wasmerio/wasmer
rust
use std::{ collections::{HashSet, VecDeque}, io::{self, ErrorKind}, mem::MaybeUninit, os::fd::{AsRawFd, RawFd}, pin::Pin, process::Command, sync::Arc, task::{Context, Poll, Waker}, }; use anyhow::Context as _; use bytes::Bytes; use futures_util::{Future, StreamExt}; use mio::{event, uni...
fim
wasmerio/wasmer
rust
use crate::utils::render::ItemFormat; /// Formatting options for a single item. #[derive(clap::Parser, Debug, Default)] pub struct ItemFormatOpts { /// Output format. (yaml, json, table) /// /// This value is optional instead of using a default value to allow code /// to distinguish between the user no...
fim
wasmerio/wasmer
rust
<|fim_suffix|>item_table(&self) -> String { let mut table = Table::new(); table.add_rows([ vec!["Id".to_string(), self.id.clone().into_inner()], vec!["Status".to_string(), self.status.as_str().to_string()], vec!["Created at".to_string(), self.created_at.0.clone()], ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>> anyhow::Result<Option<i32>> { // let ecode = Command::new(cmd).args(args).spawn()?.wait()?; // if ecode.success() { // Ok(ecode.code()) // } else { // Err(anyhow::format_err!( // "failed to execute linux command (code={:?})", // ecode.code() // ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> PackageWizard { // path: dir.path().to_owned(), // type_: Some(PackageType::StaticWebsite), // create_mode: CreateMode::Create, // namespace: None, // namespace_default: None, // name: None, // user: None, // } /...
fim
wasmerio/wasmer
rust
<|fim_suffix|>on" }, }); } // Register the listener that handles incoming requests. addEventListener("fetch", (event) => { event.respondWith(handleRequest(event)); }); <|fim_prefix|> // Handler function. // Receives a request and returns a response. async function handleRequest(ev) { const request = ev.request; ...
fim
wasmerio/wasmer
javascript
<|fim_prefix|>import os import json from http.server import SimpleHTTPRequestHandler, HTTPServer class CustomHandler(SimpleHTTPRequestHandler): def do_GET(s<|fim_suffix|> } self.wfile.write(json.dumps(data).encode('utf-8')) if __name__ == "__main__": host = os.environ.get('HOST', '127.0.0.1') ...
fim
wasmerio/wasmer
python
<|fim_prefix|>use anyhow::Context; use colored::Colorize; use dialoguer::{Select, theme::ColorfulTheme}; use wasmer_backend_api::WasmerClient; use wasmer_config::package::NamedPackageIdent; pub fn prompt_for_ident(message: &str, default: Option<&str>) -> Result<String, anyhow::Error> { loop { let theme = C...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub enum ItemFormat { Json, Yaml, #[default] Table, } impl ItemFormat { pub fn render<T: CliRender>(self, item: &T) -> String { <|fim_suffix|>tems).unwrap(), ListFormat::Yaml => serde_yaml::to_string(items).unwrap...
fim
wasmerio/wasmer
rust
use time::{ Date, OffsetDateTime, PrimitiveDateTime, Time, format_description::well_known::{Rfc2822, Rfc3339}, }; /// Try to parse the string as a timestamp in a number of well-known formats. /// /// Supported formats, /// /// - RFC 3339 (`2006-01-02T03:04:05-07:00`) /// - RFC 2822 (`Mon, 02 Jan 2006 03:04:05 ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>.display() ) }) } else { ar.unpack(target_path).map_err(|e| { anyhow::anyhow!( "failed to unpack (with parent) {}: {e}", target_targz_path.display() ) }) } }; ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> "--exclude=*" ], fallback = "", ) .to_string(); if !git_version.is_empty() { git_version = format!("commit-hash: {git_version}"); } let build_date = format!("commit-date: {}", env!("WASMER_BUILD_DATE")); let expected_features_line = "features: wasi...
fim
wasmerio/wasmer
rust
<|fim_suffix|>s ref pub fn get_function_call_trampolines_ref(&self) -> &PrimaryMap<SignatureIndex, FunctionBody> { &self.serializable.compilation.function_call_trampolines } /// Get Dynamic Functions Call Trampolines ref pub fn get_dynamic_function_trampolines_ref(&self) -> &PrimaryMap<Function...
fim
wasmerio/wasmer
rust
<|fim_suffix|>self::trampoline::*; <|fim_prefix|>//! Generic Artifact abst<|fim_middle|>raction for Wasmer Engines. mod artifact_builder; mod trampoline; pub use self::artifact_builder::{ArtifactBuild, ArtifactBuildFromArchive, ModuleFromArchive}; pub use self::trampoline::get_libcall_trampoline; #[cfg(feature = "com...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Trampolines for libcalls. //! //! This is needed because the target of libcall relocations are not reachable //! through normal branch instructions. #![cfg_attr(not(feature = "compiler"), allow(dead_code))] use wasmer_types::LibCall; use wasmer_types::target::{Architecture, Target}; use crate::type...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! This module mainly outputs the `Compiler` trait that custom //! compilers will need to implement. use std::cmp::Reverse; use crate::progress::ProgressContext; use crate::types::module::CompileModuleInfo; use crate::{ FunctionBodyData, ModuleTranslationState, lib::std::{boxed::Box, sync::Arc}...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// Constants for the bounds of truncation operations. These are the least or // greatest exact floats in either f32 or f64 representation // greater-than-or-equal-to (for least) or less-than-or-equal-to (for greatest) // the i32 or i64 or u32 or u64 min (for least) or max (for greatest), when // rounding ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> in order now... for _i in 0..num_finished_functions { let byte_buffer_slice = Self::get_byte_slice(bytes, cur_offset, cur_offset + WORD_SIZE)?; byte_buffer[0..WORD_SIZE].clone_from_slice(byte_buffer_slice); let fp = FunctionB...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::Engine; #[cfg(feature = "compiler")] use crate::CompilerConfig; use wasmer_types::{Features, target::Target}; /// The Builder contents of `Engine` pub struct EngineBuilder { /// The compiler #[cfg(feature = "compiler")] compiler_config: Option<Box<dyn CompilerConfig>>, /// Th<|...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Memory management for executable code. use super::unwind::UnwindRegistry; use crate::{ GlobalFrameInfoRegistration, types::{ function::FunctionBodyLike, secti...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! The WebAssembly possible errors use thiserror::Error; pub use wasmer_types::ImportError; #[cfg(not(target_arch = "wasm32"))] use wasmer_vm::Trap; /// The WebAssembly.LinkError object indicates an error during /// module instantiation (besides traps from the start function). /// /// This is based on t...
fim
wasmerio/wasmer
rust
<|fim_suffix|>frame) .map_err(|e| { CompileError::Resource(format!("Error while publishing the unwind code: {e}")) })?; Ok(()) } #[cfg(all(target_os = "macos", target_arch = "aarch64"))] /// Register macos-specific exception handling information associated wit...
fim
wasmerio/wasmer
rust
<|fim_suffix|>let (reloc_address, reloc_abs) = r.for_address(body, target_func_address as u64); let value = read_unaligned(reloc_address as *mut u16); write_unaligned( reloc_address as *mut u16, value.wrapping_sub(reloc_abs as u16), ); }, ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! The Wasmer Engine. mod error; #[cfg(not(target_arch = "wasm32"))] mod resolver; #[cfg(not(target_arch = "wasm32"))] mod trap; #[cfg(not(target_arch = "wasm32"))] mod tunables; #[cfg(not(target_arch = "wasm32"))] mod artifact; mod builder; #[cfg(not(target_arc<|fim_suffix|> #[cfg(not(target_arch = "w...
fim
wasmerio/wasmer
rust
<|fim_suffix|>pushed to it. This is because /// we need every tag to have a unique `VMSharedTagIndex` in the `StoreObjects`, regardless /// of whether it's local or imported, so that exception handling can correctly resolve /// cross-module exceptions. // TODO: I feel this code can be cleaned up. Maybe we can handle ta...
fim
wasmerio/wasmer
rust
<|fim_suffix|> the array, so no // instructions cover `pc`. Err(0) => None, // This would be at the `nth` slot, so check `n-1` to see if we're // part of that instruction. This happens due to the minus one when // this function is called form trap symbolicati...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ck::{get_trace_and_trapcode, wasm_trace_from_current_stack}; <|fim_prefix|>mod frame_info; mod stack; pub use frame_info::{ CompiledFunctionFrameInfoVariant, FRAME_INFO, FrameInfosVariant, FunctionExtent, GlobalFrameInfoRegistration, register as register_frame_info, };<|fim_middle|> pub use sta<|e...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#[cfg(unix)] use crate::engine::unwind::EXIT_CALLED; #[cfg(unix)] use std::sync::atomic::Ordering; use super::frame_info::{FRAME_INFO, GlobalFrameInfo}; use backtrace::Backtra<|fim_suffix|>ace, .. } => ( wasm_trace(&info, None, backtrace), Some(TrapCode::UncaughtException), ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>Self { let triple = target.triple(); let pointer_width: PointerWidth = triple.pointer_width().unwrap(); let (static_memory_bound, static_memory_offset_guard_size): (Pages, u64) = match pointer_width { PointerWidth::U16 => (0x400.into(), 0x1000), ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Module for Dummy unwind registry. use c<|fim_suffix|>b fn register( &mut self, _base_address: usize, _func_start: u32, _func_len: u32, _info: &CompiledFunctionUnwindInfoReference, ) -> Result<(), String> { // Do nothing Ok(()) } ///...
fim
wasmerio/wasmer
rust
<|fim_suffix|>// Otherwise, we provide a dummy fallback without unwinding mod dummy; pub use self::dummy::DummyUnwindRegistry as UnwindRegistry; } } <|fim_prefix|>cfg_if::cfg_if! { if #[cfg(all(windows, target_arch = "x86_64"))] { mod windows_x64; pub use self::windows_x64<|fim_m...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#[derive(Clone)] pub struct CompactUnwindEntryReader { pub ptr: *const u8, pub len: usize, } impl CompactUnwindEntryReader { pub fn new(ptr: *const u8, len: usize) -> Self { Self { ptr, len } } pub unsafe fn read<T: Copy>(&mut self) -> T { unsafe { if self...
fim
wasmerio/wasmer
rust
<|fim_suffix|>und. We don't use it, // therefore... self.write(Self::UNWIND_INFO_SECTION_HEADER_SIZE as u32)?; // Its size is zero. self.write(0u32)?; // The offset from the base pointer at which the `personalityArraySection` can be found. It is right after the // heade...
fim
wasmerio/wasmer
rust
<|fim_suffix|> .finalize() .map_err(|v| v.to_string())?; self.compact_unwind_mgr.register(); } self.published = true; Ok(()) } } /// Global flag indicating whether the program exit has been initiated. /// Set to true by an atexit handler to prevent crashe...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Module for Windows x64 ABI unwind registry. use crate::types::unwind::CompiledFunctionUnwindInfoReference; use std::collections::HashMap; use windows_sys::Win32::System...
fim
wasmerio/wasmer
rust
//! The `wasmer-compiler` crate provides the necessary abstractions //! to create a compiler. //! //! It provides an universal way of parsing a module via `wasmparser`, //! while giving the responsibility of compiling specific function //! WebAssembly bodies to the `Compiler` implementation. #![deny(missing_docs, triv...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! A common functionality used among various compilers. use core::fmt::Display; use std::{collections::HashMap, path::PathBuf}; #[cfg(not(target_arch = "wasm32"))] use std::process::{Command, Stdio}; use itertools::Itertools; use target_lexicon::Architecture; use wasmer_types::{CompileError, FunctionT...
fim
wasmerio/wasmer
rust
<|fim_suffix|> /// The object was provided a not-supported architecture #[error("Architecture {0} not supported")] UnsupportedArchitecture(String), /// The object was provided an unknown endianness #[error("Unknown Endianness")] UnknownEndianness, /// The object was provided a not-supported ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>b use self::error::ObjectError; pub use self::module::{ ObjectMetadataBuilder, emit_compilation, emit_data, emit_serialized, get_object_for_target, }; pub use object::{self, write::Object}; <|fim_prefix|>//! Object creator for Wasm Compilations. //! //! Given a compilation result (this is, the result ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::error::ObjectError; use crate::{ serialize::MetadataHeader, types::{ function::Compilation, relocation::{RelocationKind as Reloc, RelocationTarget}, section::{CustomSectionProtection, SectionIndex}, symbols::{ModuleMetadata, Symbol, SymbolRegistry}, }...
fim
wasmerio/wasmer
rust
<|fim_suffix|>that the next step in the phase has completed. pub fn notify(&self) -> Result<(), CompileError> { self.notify_steps(1) } /// Notifies the callback that the next N steps in the phase are completed. pub fn notify_steps(&self, steps: u64) -> Result<(), CompileError> { let ste...
fim
wasmerio/wasmer
rust
<|fim_suffix|>:deserialize`], this function will validate the data. /// /// # Safety /// Unsafe because it loads executable code into memory. /// The loaded bytes must be trusted. pub unsafe fn deserialize(metadata_slice: &[u8]) -> Result<Self, DeserializeError> { let archived = Self::archiv...
fim
wasmerio/wasmer
rust
<|fim_suffix|>.downcast_mut::<T>() } } <|fim_prefix|>//! Generic Artifact abstraction for Wasmer Engines. use crate::Features; use enumset::EnumSet; use std::any::Any; use std::sync::Arc; use wasmer_types::SerializeError; use wasmer_types::entity::PrimaryMap; use wasmer_types::{ DataInitializerLike, MemoryInde...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md use super::state::ModuleTranslationState; use crate::lib::std::string::ToString; use crate::lib::std::{boxed::Box, string::String, vec::Vec}; use crate::translate_module; use crate::wasmp...
fim
wasmerio/wasmer
rust
use wasmer_types::{CompileError, WasmError}; use wasmparser::BinaryReaderError; /// Return an `Err(WasmError::Unsupported(msg))` where `msg` the string built by calling `format!` /// on the arguments to this macro. #[macro_export] macro_rules! wasm_unsupported { ($($arg:tt)*) => { wasmer_types::WasmError::Unsuppor...
fim
wasmerio/wasmer
rust
<|fim_suffix|>erator_reader.get_binary_reader().range() } } } } <|fim_prefix|>//! The middleware parses the function binary bytecodes and transform them //! with the chosen functions. use smallvec::SmallVec; use std::collections::VecDeque; use std::fmt::Debug; use std::ops::{Deref, Range}; use ...
fim
wasmerio/wasmer
rust
//! This module defines the parser and translator from wasmparser //! to a common structure `ModuleInfo`. //! //! It's derived from [cranelift-wasm] but architected for multiple //! compilers rather than just Cranelift. //! //! [cranelift-wasm]: https://crates.io/crates/cranelift-wasm/ mod environ; mod middleware; mod ...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Translation skeleton that traverses the whole WebAssembly module and call helper functions //! to deal with each part of it. use std::sync::atomic::{AtomicBool, Ordering}; use crate...
fim
wasmerio/wasmer
rust
<|fim_suffix|> range: _, } = elem.map_err(from_binaryreadererror_wasmerror)?; match kind { ElementKind::Active { table_index, offset_expr, } => { let segments = read_elems(&items)?; let table_index = Tab...
fim
wasmerio/wasmer
rust
<|fim_suffix|> of values. pub fn len(&self) -> usize { match self { SingleOrMultiValue::Single(_) => 1, SingleOrMultiValue::Multi(values) => values.len(), } } /// Iterate offer the value types. pub fn iter(&self) -> SingleOrMultiValueIterator<'_> { match ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>Instructions maps. /// The array is sorted by the InstructionAddressMap::code_offset field. pub instructions: Vec<InstructionAddressMap>, /// Function start source location (normally declaration). pub start_srcloc: SourceLoc, /// Function end source location. pub end_srcloc: Sour...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ffset Table - for this Compilation. /// /// The GOT is but a list of pointers to objects (functions, data, sections..); in our context the /// GOT is represented simply as a custom section. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] #[cfg_attr(feature = "artifact-size", derive(l...
fim
wasmerio/wasmer
rust
<|fim_suffix|>_map; pub mod function; pub mod module; pub mod relocation; pub mod section; pub mod symbols; pub mod unwind; <|fim_prefix|>//! <|fim_middle|>Types for compilation. pub mod address<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>/* * ! Remove me once rkyv generates doc-comments for fie<|fim_suffix|>b module: Arc<ModuleInfo>, /// The memory styles used for compiling. /// /// The compiler will emit the most optimal code based /// on the memory style (static or dynamic) chosen. pub memory_styles: PrimaryMap<Memo...
fim
wasmerio/wasmer
rust
<|fim_prefix|>/* * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] * on their own. */ #![allow(missing_docs)] //! Relocation is the process of assigning load addresses for position-dependent //! code and data of a program and adjusting the code and data to reflect the ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>t in case it's /// > needed in the future. pub bytes: SectionBody, /// Relocations that apply to this custom section. pub relocations: Vec<Relocation>, } /// Any struct that acts like a `CustomSection`. #[allow(missing_docs)] pub trait CustomSectionLike<'a> { type Relocations: Reloca...
fim
wasmerio/wasmer
rust
<|fim_prefix|>/* * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] * on their own. */ #![allow(missing_docs)] //! This module define the required structures for compilation symbols. use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(...
fim
wasmerio/wasmer
rust
<|fim_suffix|>, /// The unwind info is added to the Dwarf section in `Compilation`. Dwarf, } /// Generic reference to data in a `CompiledFunctionUnwindInfo` #[allow(missing_docs)] #[derive(Debug, Clone, PartialEq, Eq)] pub enum CompiledFunctionUnwindInfoReference<'a> { WindowsX64(&'a [u8]), Dwarf, ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md use cranelift_codegen::{Context, MachSrcLoc}; use std::ops::Range; use wasmer_compiler::types::address_map::{FunctionAddressMap, InstructionAddressMap}; use wasmer_types::S...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Support for compiling with Cranelift. #[cfg(feature = "unwind")] use crate::dwarf::WriterRelocate; #[cfg(feature = "unwind")] use crate::eh::{FunctionLsdaData, build_function_lsda, build_lsda_section, build_tag_section}; #[cfg(feature = "unwind")] use crate::translator::CraneliftUnwindInfo; use cra...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ature::SSE2) { panic!("x86 support requires SSE2"); } if cpu_features.contains(CpuFeature::SSE3) { builder.enable("has_sse3").expect("should be valid flag"); } if cpu_features.contains(CpuFeature::SSSE3) { builder.enable("has_ssse...
fim
wasmerio/wasmer
rust
<|fim_suffix|>t_codegen::ValueLabelsRanges>; /// Stack slots for functions. pub type StackSlots = PrimaryMap<LocalFunctionIndex, ir::StackSlots>; /// Memory definition offset in the VMContext structure. #[derive(Debug, Clone)] pub enum ModuleInfoMemoryOffset { /// Not available. None, /// Offset to the de...
fim
wasmerio/wasmer
rust
<|fim_suffix|>foMemoryOffset, ModuleInfoVmctxInfo, ValueLabelsRanges}; <|fim_prefix|>mod address_map; pub use self<|fim_middle|>::address_map::{ModuleIn<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_suffix|>, _offset: usize, _val: usize, _section: SectionId, _size: u8, ) -> Result<()> { unimplemented!("write_offset_at not yet implemented"); } } <|fim_prefix|>use gimli::write::{Address, EndianVec, Result, Writer}; use gimli::{RunTimeEndian, SectionId, constants}...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Helpers for generating DWARF LSDA data for Cranelift-compiled functions. //! //! The structures and encoding implemented here mirror what LLVM produces for //! Wasm exception handling so that Wasmer's libunwind personalities can parse //! the tables without any runtime changes. use cranelift_codegen:...
fim
wasmerio/wasmer
rust
<|fim_suffix|> seg_index: u32, ) -> WasmResult<()> { let (func_sig, func_idx) = self.get_data_drop_func(pos.func); let seg_index_arg = pos.ins().iconst(I32, seg_index as i64); let (vmctx, func_addr) = self.translate_load_builtin_function_address(&mut pos, func_idx); pos.ins() ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Heaps to implement WebAssembly linear memories. use cranelift_codegen::ir::{GlobalValue, Type}; use wasmer_types::entity::entity_impl; /// An opaque reference to a [`HeapData`][crate::HeapData]. /// /// While the order is stable, it is arbitrary. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! A WebAssembly `Compiler` implementation using Cranelift. //! //! Cranelift is a fast IR generator created by Mozilla for usage in //! Firefox as a next JS compiler generator. //! //! Compared to LLVM, Cranelift is a bit faster and made entirely in Rust. #![deny(missing_docs, trivial_numeric_casts, unu...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use cranelift_codegen::cursor::FuncCursor; use cranelift_codegen::ir::{self, InstBuilder, condcodes::IntCC, immediates::Imm64}; use cranelift_frontend::FunctionBuilder; /// Size of a WebAssembly table, in elements. #[derive(Clone, Debug)] pub enum TableSize { /// Non-resizable table. Static { ...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! A trampoline generator for calling dynamic host functions from Wasm. use crate::{ CraneliftCallbacks, translator::{compiled_function_unwind_info, signature_to_cranelift_ir},...
fim
wasmerio/wasmer
rust