mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
Run clang-format and cargo fmt
This commit is contained in:
parent
0e0573c73c
commit
98ef9182d7
@ -9,21 +9,13 @@ struct MemoryManager : llvm::RuntimeDyld::MemoryManager {
|
||||
public:
|
||||
MemoryManager(callbacks_t callbacks) : callbacks(callbacks) {}
|
||||
|
||||
uint8_t * get_stack_map_ptr() const {
|
||||
return stack_map_ptr;
|
||||
}
|
||||
uint8_t *get_stack_map_ptr() const { return stack_map_ptr; }
|
||||
|
||||
size_t get_stack_map_size() const {
|
||||
return stack_map_size;
|
||||
}
|
||||
size_t get_stack_map_size() const { return stack_map_size; }
|
||||
|
||||
uint8_t * get_code_ptr() const {
|
||||
return (uint8_t *) code_start_ptr;
|
||||
}
|
||||
uint8_t *get_code_ptr() const { return (uint8_t *)code_start_ptr; }
|
||||
|
||||
size_t get_code_size() const {
|
||||
return code_size;
|
||||
}
|
||||
size_t get_code_size() const { return code_size; }
|
||||
|
||||
virtual ~MemoryManager() override {
|
||||
deregisterEHFrames();
|
||||
@ -33,34 +25,38 @@ public:
|
||||
callbacks.dealloc_memory(readwrite_section.base, readwrite_section.size);
|
||||
}
|
||||
|
||||
virtual uint8_t* allocateCodeSection(uintptr_t size, unsigned alignment, unsigned section_id, llvm::StringRef section_name) override {
|
||||
virtual uint8_t *allocateCodeSection(uintptr_t size, unsigned alignment,
|
||||
unsigned section_id,
|
||||
llvm::StringRef section_name) override {
|
||||
return allocate_bump(code_section, code_bump_ptr, size, alignment);
|
||||
}
|
||||
|
||||
virtual uint8_t* allocateDataSection(uintptr_t size, unsigned alignment, unsigned section_id, llvm::StringRef section_name, bool read_only) override {
|
||||
// Allocate from the read-only section or the read-write section, depending on if this allocation
|
||||
// should be read-only or not.
|
||||
virtual uint8_t *allocateDataSection(uintptr_t size, unsigned alignment,
|
||||
unsigned section_id,
|
||||
llvm::StringRef section_name,
|
||||
bool read_only) override {
|
||||
// Allocate from the read-only section or the read-write section, depending
|
||||
// on if this allocation should be read-only or not.
|
||||
uint8_t *ret;
|
||||
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"))) {
|
||||
if (section_name.equals(llvm::StringRef("__llvm_stackmaps")) ||
|
||||
section_name.equals(llvm::StringRef(".llvm_stackmaps"))) {
|
||||
stack_map_ptr = ret;
|
||||
stack_map_size = size;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual void reserveAllocationSpace(
|
||||
uintptr_t code_size,
|
||||
uint32_t code_align,
|
||||
virtual void 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,
|
||||
uint32_t read_write_data_align
|
||||
) override {
|
||||
uint32_t read_write_data_align) override {
|
||||
auto aligner = [](uintptr_t ptr, size_t align) {
|
||||
if (ptr == 0) {
|
||||
return align;
|
||||
@ -68,10 +64,11 @@ public:
|
||||
return (ptr + align - 1) & ~(align - 1);
|
||||
};
|
||||
|
||||
|
||||
uint8_t *code_ptr_out = nullptr;
|
||||
size_t code_size_out = 0;
|
||||
auto code_result = callbacks.alloc_memory(aligner(code_size, 4096), PROTECT_READ_WRITE, &code_ptr_out, &code_size_out);
|
||||
auto code_result =
|
||||
callbacks.alloc_memory(aligner(code_size, 4096), PROTECT_READ_WRITE,
|
||||
&code_ptr_out, &code_size_out);
|
||||
assert(code_result == RESULT_OK);
|
||||
code_section = Section{code_ptr_out, code_size_out};
|
||||
code_bump_ptr = (uintptr_t)code_ptr_out;
|
||||
@ -80,14 +77,18 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
uint8_t *readwrite_ptr_out = nullptr;
|
||||
size_t readwrite_size_out = 0;
|
||||
auto readwrite_result = callbacks.alloc_memory(aligner(read_write_data_size, 4096), PROTECT_READ_WRITE, &readwrite_ptr_out, &readwrite_size_out);
|
||||
auto readwrite_result = callbacks.alloc_memory(
|
||||
aligner(read_write_data_size, 4096), PROTECT_READ_WRITE,
|
||||
&readwrite_ptr_out, &readwrite_size_out);
|
||||
assert(readwrite_result == RESULT_OK);
|
||||
readwrite_section = Section{readwrite_ptr_out, readwrite_size_out};
|
||||
readwrite_bump_ptr = (uintptr_t)readwrite_ptr_out;
|
||||
@ -252,7 +253,6 @@ size_t WasmModule::get_stack_map_size() const {
|
||||
return local_mm->get_stack_map_size();
|
||||
}
|
||||
|
||||
|
||||
uint8_t *WasmModule::get_code_ptr() const {
|
||||
llvm::RuntimeDyld::MemoryManager &mm = *memory_manager;
|
||||
MemoryManager *local_mm = dynamic_cast<MemoryManager *>(&mm);
|
||||
|
@ -83,12 +83,9 @@ public:
|
||||
uintptr_t callback;
|
||||
};
|
||||
|
||||
struct WasmModule
|
||||
{
|
||||
struct WasmModule {
|
||||
public:
|
||||
WasmModule(
|
||||
const uint8_t *object_start,
|
||||
size_t object_size,
|
||||
WasmModule(const uint8_t *object_start, size_t object_size,
|
||||
callbacks_t callbacks);
|
||||
|
||||
void *get_func(llvm::StringRef name) const;
|
||||
@ -98,6 +95,7 @@ struct WasmModule
|
||||
size_t get_code_size() const;
|
||||
|
||||
bool _init_failed = false;
|
||||
|
||||
private:
|
||||
std::unique_ptr<llvm::RuntimeDyld::MemoryManager> memory_manager;
|
||||
std::unique_ptr<llvm::object::ObjectFile> object_file;
|
||||
|
@ -4,9 +4,7 @@
|
||||
use crate::emitter_x64::*;
|
||||
use crate::machine::*;
|
||||
use crate::protect_unix;
|
||||
use dynasmrt::{
|
||||
x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi,
|
||||
};
|
||||
use dynasmrt::{x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
||||
use smallvec::SmallVec;
|
||||
use std::ptr::NonNull;
|
||||
use std::{
|
||||
|
Loading…
Reference in New Issue
Block a user