mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-18 11:21:21 +00:00
Add various small improvements, update attributions file
This commit is contained in:
@ -1,21 +1,30 @@
|
|||||||
# Wasmer Attributions
|
# Wasmer Attributions
|
||||||
|
|
||||||
Wasmer is a community effort.
|
Wasmer is a community effort and makes use of code from various other
|
||||||
In order to build the best WebAssembly runtime it's our duty to see how other runtimes are approaching the same space
|
projects. Listed below are notable sections of code that are licensed
|
||||||
and get inspired from them on the things that they got right, so Wasmer and its community can benefit from a solid
|
from other projects and the relevant license of those projects.
|
||||||
foundation.
|
|
||||||
|
|
||||||
These are the different project that we used as inspiration:
|
These are the projects that were used as inspiration and/or that we are using code from:
|
||||||
|
|
||||||
- [Nebulet](https://github.com/nebulet/nebulet): as the base for creating a great Rust WebAssembly runtime
|
- [Nebulet](https://github.com/nebulet/nebulet): as the base for creating a great Rust WebAssembly runtime
|
||||||
- [WAVM](https://github.com/wavm/wavm): for their great integration and testing framework
|
- [WAVM](https://github.com/wavm/wavm): for their great integration and testing framework
|
||||||
- [greenwasm](https://github.com/Kimundi/greenwasm): for their [spectests framework](https://github.com/Kimundi/greenwasm/tree/master/greenwasm-spectest)
|
- [greenwasm](https://github.com/Kimundi/greenwasm): for their [spectests framework](https://github.com/Kimundi/greenwasm/tree/master/greenwasm-spectest)
|
||||||
- [wasmtime](https://github.com/CraneStation/wasmtime): for their [mmap implementation](https://github.com/CraneStation/wasmtime/blob/3f24098edc81cd9bf0f877fb7fba018cad0f039e/lib/runtime/src/mmap.rs)
|
- [wasmtime](https://github.com/CraneStation/wasmtime):
|
||||||
|
- For their [mmap implementation](https://github.com/CraneStation/wasmtime/blob/3f24098edc81cd9bf0f877fb7fba018cad0f039e/lib/runtime/src/mmap.rs)
|
||||||
|
- For the implementation of the `__jit_debug_register_code` function
|
||||||
|
in Rust, the structure of using Cranelift with the GDB JIT
|
||||||
|
interface including implementation details regarding the structure
|
||||||
|
of generating debug information for each function with Cranelift
|
||||||
|
(for example, the sorting of the extended basic blocks before
|
||||||
|
processing the instructions), and the API for transforming DWARF
|
||||||
|
see wasm-debug's attribution file for more information (TODO: link
|
||||||
|
and update here).
|
||||||
- [stackoverflow](https://stackoverflow.com/a/45795699/1072990): to create an efficient HashMap with pair keys
|
- [stackoverflow](https://stackoverflow.com/a/45795699/1072990): to create an efficient HashMap with pair keys
|
||||||
- [Emscripten](https://github.com/kripken/emscripten): for emtests test sources to ensure compatibility
|
- [Emscripten](https://github.com/kripken/emscripten): for emtests test sources to ensure compatibility
|
||||||
|
- [The WebAssembly spec](https://github.com/WebAssembly/spec/tree/master/test): for implementation details of WebAssembly and spectests
|
||||||
|
|
||||||
We would love to hear from you if you think we can take inspiration from other projects that we haven't covered here.
|
Please let us know if you believe there is an error or omission in
|
||||||
😊
|
this list and we will do our best to correct it.
|
||||||
|
|
||||||
## Licenses
|
## Licenses
|
||||||
|
|
||||||
|
@ -164,10 +164,6 @@ impl FuncResolverBuilder {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
/*let mut unwind = vec![];
|
|
||||||
ctx.emit_unwind_info(isa, &mut unwind);
|
|
||||||
dbg!(unwind.len());*/
|
|
||||||
|
|
||||||
let stack_slots = ctx
|
let stack_slots = ctx
|
||||||
.func
|
.func
|
||||||
.stack_slots
|
.stack_slots
|
||||||
@ -228,9 +224,34 @@ impl FuncResolverBuilder {
|
|||||||
if let Some(ref mut dbg_metadata) = debug_metadata {
|
if let Some(ref mut dbg_metadata) = debug_metadata {
|
||||||
let (entry, vlr, stackslots) = debug_info.unwrap();
|
let (entry, vlr, stackslots) = debug_info.unwrap();
|
||||||
dbg_metadata.func_info.push(entry);
|
dbg_metadata.func_info.push(entry);
|
||||||
dbg_metadata
|
let new_vlr = vlr
|
||||||
.inst_info
|
.into_iter()
|
||||||
.push(unsafe { std::mem::transmute(vlr) });
|
.map(|(k, v)| {
|
||||||
|
(
|
||||||
|
wasm_debug::types::ValueLabel::from_u32(k.as_u32()),
|
||||||
|
v.into_iter()
|
||||||
|
.map(|item| wasm_debug::types::ValueLocRange {
|
||||||
|
start: item.start,
|
||||||
|
end: item.end,
|
||||||
|
loc: match item.loc {
|
||||||
|
cranelift_codegen::ir::ValueLoc::Unassigned => {
|
||||||
|
wasm_debug::types::ValueLoc::Unassigned
|
||||||
|
}
|
||||||
|
cranelift_codegen::ir::ValueLoc::Reg(ru) => {
|
||||||
|
wasm_debug::types::ValueLoc::Reg(ru)
|
||||||
|
}
|
||||||
|
cranelift_codegen::ir::ValueLoc::Stack(st) => {
|
||||||
|
wasm_debug::types::ValueLoc::Stack(
|
||||||
|
wasm_debug::types::StackSlot::from_u32(st.as_u32()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect::<Vec<wasm_debug::types::ValueLocRange>>(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<wasm_debug::types::ValueLabelsRangesInner>();
|
||||||
|
dbg_metadata.inst_info.push(new_vlr);
|
||||||
dbg_metadata.stack_slot_offsets.push(stackslots);
|
dbg_metadata.stack_slot_offsets.push(stackslots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,40 +1,52 @@
|
|||||||
#![allow(missing_docs)]
|
//! Code for interacting with the
|
||||||
|
//! [GDB JIT inteface](https://sourceware.org/gdb/current/onlinedocs/gdb.html#JIT-Interface).
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// =============================================================================
|
/// Entrypoint that the debugger will use to trigger a read from the
|
||||||
// LLDB hook magic:
|
/// [`__jit_debug_descriptor`] global variable.
|
||||||
// see lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb in
|
///
|
||||||
// llvm repo for example
|
/// The debugger will wait for this function to be called and then take
|
||||||
//
|
/// control to read the data we prepared.
|
||||||
// see also https://sourceware.org/gdb/current/onlinedocs/gdb.html#JIT-Interface
|
// implementation of this function is from wasmtime and is licensed under
|
||||||
|
// the Apache 2.0 license. See ATTRIBUTIONS.md for full license and more
|
||||||
|
// information.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
extern "C" fn __jit_debug_register_code() {
|
extern "C" fn __jit_debug_register_code() {
|
||||||
// implementation of this function copied from wasmtime (TODO: link and attribution)
|
// This code exists to prevent optimization of this function so that the
|
||||||
// prevent optimization of this function
|
// GDB JIT interface behaves as expected
|
||||||
let x = 3;
|
let x = 3;
|
||||||
unsafe {
|
unsafe {
|
||||||
std::ptr::read_volatile(&x);
|
std::ptr::read_volatile(&x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The operation that the debugger should perform with the entry that we gave it.
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub(crate) enum JITAction {
|
pub(crate) enum JITAction {
|
||||||
|
/// Do nothing.
|
||||||
JIT_NOACTION = 0,
|
JIT_NOACTION = 0,
|
||||||
|
/// Register the given code.
|
||||||
JIT_REGISTER_FN = 1,
|
JIT_REGISTER_FN = 1,
|
||||||
|
/// Unregister the given code.
|
||||||
JIT_UNREGISTER_FN = 2,
|
JIT_UNREGISTER_FN = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Node of the doubly linked list that the GDB JIT interface reads from.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub(crate) struct JITCodeEntry {
|
pub(crate) struct JITCodeEntry {
|
||||||
|
/// Next entry in the linked list.
|
||||||
next: *mut JITCodeEntry,
|
next: *mut JITCodeEntry,
|
||||||
|
/// Previous entry in the linked list.
|
||||||
prev: *mut JITCodeEntry,
|
prev: *mut JITCodeEntry,
|
||||||
|
/// Pointer to the data we want the debugger to read.
|
||||||
symfile_addr: *mut u8,
|
symfile_addr: *mut u8,
|
||||||
|
/// The amount of data at the `symfile_addr` pointer.
|
||||||
symfile_size: u64,
|
symfile_size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,15 +61,24 @@ impl Default for JITCodeEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Head node of the doubly linked list that the GDB JIT interface expects.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub(crate) struct JitDebugDescriptor {
|
pub(crate) struct JitDebugDescriptor {
|
||||||
|
/// The version of the JIT interface to use (presumably, TODO: double check this)
|
||||||
version: u32,
|
version: u32,
|
||||||
|
/// Which action to perform, see [`JITAction`].
|
||||||
action_flag: u32,
|
action_flag: u32,
|
||||||
|
/// The entry in the list that the `action_flag` applies to.
|
||||||
relevant_entry: *mut JITCodeEntry,
|
relevant_entry: *mut JITCodeEntry,
|
||||||
|
/// The first entry in the doubly linked list.
|
||||||
first_entry: *mut JITCodeEntry,
|
first_entry: *mut JITCodeEntry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Global variable that the GDB JIT interface will read the data from.
|
||||||
|
/// The data is in the form of a doubly linked list. This global variable acts
|
||||||
|
/// as a head node with extra information about the operation that we want the
|
||||||
|
/// debugger to perform.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub(crate) static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
|
pub(crate) static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
|
||||||
@ -138,6 +159,7 @@ pub struct JITCodeDebugInfoManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl JITCodeDebugInfoManager {
|
impl JITCodeDebugInfoManager {
|
||||||
|
/// Register debug info relating to JIT code with the debugger.
|
||||||
pub(crate) fn register_new_jit_code_entry(
|
pub(crate) fn register_new_jit_code_entry(
|
||||||
&mut self,
|
&mut self,
|
||||||
bytes: &[u8],
|
bytes: &[u8],
|
||||||
|
Reference in New Issue
Block a user