mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
Format everything
This commit is contained in:
parent
53ebcc355a
commit
56e735349d
@ -14,17 +14,14 @@ MemoryManager::~MemoryManager() {
|
||||
callbacks.dealloc_memory(readwrite_section.base, readwrite_section.size);
|
||||
}
|
||||
void unwinding_setjmp(jmp_buf stack_out, void (*func)(void *), void *userdata) {
|
||||
if(setjmp(stack_out)) {
|
||||
if (setjmp(stack_out)) {
|
||||
|
||||
} else {
|
||||
func(userdata);
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void unwinding_longjmp(jmp_buf stack_in) {
|
||||
longjmp(stack_in, 42);
|
||||
}
|
||||
[[noreturn]] void unwinding_longjmp(jmp_buf stack_in) { longjmp(stack_in, 42); }
|
||||
|
||||
struct UnwindPoint {
|
||||
UnwindPoint *prev;
|
||||
@ -36,25 +33,25 @@ struct UnwindPoint {
|
||||
static thread_local UnwindPoint *unwind_state = nullptr;
|
||||
|
||||
static void unwind_payload(void *_point) {
|
||||
UnwindPoint *point = (UnwindPoint *) _point;
|
||||
UnwindPoint *point = (UnwindPoint *)_point;
|
||||
(*point->f)();
|
||||
}
|
||||
|
||||
void catch_unwind(std::function<void()>&& f) {
|
||||
void catch_unwind(std::function<void()> &&f) {
|
||||
UnwindPoint current;
|
||||
current.prev = unwind_state;
|
||||
current.f = &f;
|
||||
unwind_state = ¤t;
|
||||
|
||||
unwinding_setjmp(current.stack, unwind_payload, (void *) ¤t);
|
||||
if(current.exception) {
|
||||
unwinding_setjmp(current.stack, unwind_payload, (void *)¤t);
|
||||
if (current.exception) {
|
||||
throw *current.exception;
|
||||
}
|
||||
}
|
||||
|
||||
void unsafe_unwind(std::exception *exception) {
|
||||
UnwindPoint *state = unwind_state;
|
||||
if(state) {
|
||||
if (state) {
|
||||
state->exception.reset(exception);
|
||||
unwinding_longjmp(state->stack);
|
||||
} else {
|
||||
@ -78,8 +75,7 @@ uint8_t *MemoryManager::allocateDataSection(uintptr_t size, unsigned alignment,
|
||||
if (read_only) {
|
||||
ret = allocate_bump(read_section, read_bump_ptr, size, alignment);
|
||||
} else {
|
||||
ret =
|
||||
allocate_bump(readwrite_section, readwrite_bump_ptr, size, alignment);
|
||||
ret = allocate_bump(readwrite_section, readwrite_bump_ptr, size, alignment);
|
||||
}
|
||||
if (section_name.equals(llvm::StringRef("__llvm_stackmaps")) ||
|
||||
section_name.equals(llvm::StringRef(".llvm_stackmaps"))) {
|
||||
@ -89,7 +85,8 @@ uint8_t *MemoryManager::allocateDataSection(uintptr_t size, unsigned alignment,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MemoryManager::reserveAllocationSpace(uintptr_t code_size, uint32_t code_align,
|
||||
void MemoryManager::reserveAllocationSpace(uintptr_t code_size,
|
||||
uint32_t code_align,
|
||||
uintptr_t read_data_size,
|
||||
uint32_t read_data_align,
|
||||
uintptr_t read_write_data_size,
|
||||
@ -113,9 +110,9 @@ void MemoryManager::reserveAllocationSpace(uintptr_t code_size, uint32_t code_al
|
||||
|
||||
uint8_t *read_ptr_out = nullptr;
|
||||
size_t read_size_out = 0;
|
||||
auto read_result = callbacks.alloc_memory(aligner(read_data_size, 4096),
|
||||
PROTECT_READ_WRITE, &read_ptr_out,
|
||||
&read_size_out);
|
||||
auto read_result =
|
||||
callbacks.alloc_memory(aligner(read_data_size, 4096), PROTECT_READ_WRITE,
|
||||
&read_ptr_out, &read_size_out);
|
||||
assert(read_result == RESULT_OK);
|
||||
read_section = Section{read_ptr_out, read_size_out};
|
||||
read_bump_ptr = (uintptr_t)read_ptr_out;
|
||||
@ -176,8 +173,8 @@ bool MemoryManager::finalizeMemory(std::string *ErrMsg) {
|
||||
void MemoryManager::notifyObjectLoaded(llvm::RuntimeDyld &RTDyld,
|
||||
const llvm::object::ObjectFile &Obj) {}
|
||||
|
||||
uint8_t *MemoryManager::allocate_bump(Section §ion, uintptr_t &bump_ptr, size_t size,
|
||||
size_t align) {
|
||||
uint8_t *MemoryManager::allocate_bump(Section §ion, uintptr_t &bump_ptr,
|
||||
size_t size, size_t align) {
|
||||
auto aligner = [](uintptr_t &ptr, size_t align) {
|
||||
ptr = (ptr + align - 1) & ~(align - 1);
|
||||
};
|
||||
|
@ -3,10 +3,10 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <setjmp.h>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <setjmp.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <llvm/ExecutionEngine/RuntimeDyld.h>
|
||||
|
||||
@ -106,12 +106,12 @@ private:
|
||||
size_t stack_map_size = 0;
|
||||
};
|
||||
|
||||
struct WasmException: std::exception {
|
||||
struct WasmException : std::exception {
|
||||
public:
|
||||
virtual std::string description() const noexcept = 0;
|
||||
};
|
||||
|
||||
void catch_unwind(std::function<void()>&& f);
|
||||
void catch_unwind(std::function<void()> &&f);
|
||||
[[noreturn]] void unsafe_unwind(std::exception *exception);
|
||||
|
||||
struct UncatchableException : WasmException {
|
||||
@ -239,7 +239,9 @@ result_t module_load(const uint8_t *mem_ptr, size_t mem_size,
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
[[noreturn]] void throw_trap(WasmTrap::Type ty) { unsafe_unwind(new WasmTrap(ty)); }
|
||||
[[noreturn]] void throw_trap(WasmTrap::Type ty) {
|
||||
unsafe_unwind(new WasmTrap(ty));
|
||||
}
|
||||
|
||||
void module_delete(WasmModule *module) { delete module; }
|
||||
|
||||
|
@ -331,7 +331,7 @@ impl LLVMBackend {
|
||||
local_func_id_to_offset,
|
||||
},
|
||||
LLVMCache { buffer },
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,9 @@ use libc::{
|
||||
c_void, mmap, mprotect, munmap, siginfo_t, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_NONE,
|
||||
PROT_READ, PROT_WRITE,
|
||||
};
|
||||
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, SIGBUS, SIGSEGV, SIGILL};
|
||||
use nix::sys::signal::{
|
||||
sigaction, SaFlags, SigAction, SigHandler, SigSet, SIGBUS, SIGILL, SIGSEGV,
|
||||
};
|
||||
use std::ptr;
|
||||
|
||||
/// `__register_frame` and `__deregister_frame` on macos take a single fde as an
|
||||
|
@ -232,10 +232,8 @@ impl StackmapEntry {
|
||||
if loc.offset_or_small_constant >= 0 {
|
||||
assert!(loc.offset_or_small_constant >= 16); // (saved_rbp, return_address)
|
||||
assert!(loc.offset_or_small_constant % 8 == 0);
|
||||
prev_frame_diff.insert(
|
||||
(loc.offset_or_small_constant as usize - 16) / 8,
|
||||
Some(mv),
|
||||
);
|
||||
prev_frame_diff
|
||||
.insert((loc.offset_or_small_constant as usize - 16) / 8, Some(mv));
|
||||
} else {
|
||||
let stack_offset = ((-loc.offset_or_small_constant) / 4) as usize;
|
||||
assert!(
|
||||
|
@ -726,10 +726,7 @@ pub mod x64 {
|
||||
assert_eq!(vmctx.internal.memory_bound, memory.len());
|
||||
}
|
||||
|
||||
std::slice::from_raw_parts_mut(
|
||||
vmctx.internal.memory_base,
|
||||
vmctx.internal.memory_bound,
|
||||
)
|
||||
std::slice::from_raw_parts_mut(vmctx.internal.memory_base, vmctx.internal.memory_bound)
|
||||
.copy_from_slice(memory);
|
||||
}
|
||||
|
||||
|
@ -210,8 +210,7 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
|
||||
if let Err(e) = ret {
|
||||
if let Ok(new_image) = e.downcast::<InstanceImage>() {
|
||||
// Tier switch event
|
||||
if !was_sigint_triggered_fault() && opt_state.outcome.lock().unwrap().is_some()
|
||||
{
|
||||
if !was_sigint_triggered_fault() && opt_state.outcome.lock().unwrap().is_some() {
|
||||
resume_image = Some(*new_image);
|
||||
continue;
|
||||
}
|
||||
|
@ -587,7 +587,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
let start_raw: extern "C" fn(&mut wasmer_runtime_core::vm::Ctx) =
|
||||
unsafe { ::std::mem::transmute(start.get_vm_func()) };
|
||||
|
||||
unsafe { run_tiering(
|
||||
unsafe {
|
||||
run_tiering(
|
||||
module.info(),
|
||||
&wasm_binary,
|
||||
if let Some(ref path) = options.resume {
|
||||
@ -612,7 +613,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
})
|
||||
.collect(),
|
||||
interactive_shell,
|
||||
)? };
|
||||
)?
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "managed"))]
|
||||
|
Loading…
Reference in New Issue
Block a user