This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn new(obj: T) -> Result<Self, AllocError> { | |
unsafe { | |
match ARENA { | |
Some(arena) => match Arena::allocate::<T>(arena) { | |
ArenaResult::Okay(pointer) => Ok(Self { pointer, arena }), | |
ArenaResult::RecoverAndSpawn => { | |
match Arena::find_arena(arena, size_of::<T>()) { | |
Some(arena) => match Arena::allocate::<T>(arena) { | |
ArenaResult::Okay(pointer) => { | |
Arena::increment(arena); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[repr(C)] | |
pub struct Arena<A: Allocator> { | |
count: u32, | |
free: bool, | |
size: usize, | |
end: NonNull<u8>, | |
pointer: NonNull<u8>, | |
next: Option<NonNull<Self>>, | |
allocator: A, | |
arena: NonNull<[u8]>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use mimalloc::MiMalloc; | |
#[cfg(not(miri))] | |
#[global_allocator] | |
static GLOBAL: MiMalloc = MiMalloc; | |
use k_gc::Rc; | |
#[allow(dead_code)] | |
pub struct Node { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(ptr_metadata, let_chains)] | |
use std::{ | |
alloc::{alloc, dealloc, Layout}, | |
ops::Deref, | |
ptr, | |
}; | |
use libc::{mmap, munmap, MAP_ANON, MAP_PRIVATE, PROT_READ, PROT_WRITE}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::arch::asm; | |
use std::hint::unreachable_unchecked; | |
use std::clone::Clone; | |
use std::ops::Drop; | |
#[repr(C)] | |
struct Rc<T>(*mut T); | |
impl<T> Clone for Rc<T> { | |
#[inline(always)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(unused_imports)] use std::hint::black_box; | |
#[inline(never)] | |
extern "C" fn fib_impl(x: u64, prev: u64, cur: u64) -> u64 { | |
match x { | |
0 => prev, | |
1 => cur, | |
_ => unsafe { be(fib_impl, x - 1, cur, prev + cur) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Runtime.InteropServices | |
module Program = | |
[<Struct>] | |
[<RequireQualifiedAccess>] | |
type NormalDU = | |
| ManagedObject of array: int[] | |
| String of str: string | |
| Int of int: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(cell_update)] | |
use crossbeam::channel::{unbounded, Receiver, Sender}; | |
use once_cell::sync::Lazy; | |
use std::cell::Cell; | |
use std::mem::MaybeUninit; | |
use std::ops::Deref; | |
use std::ptr::{NonNull, null_mut}; | |
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
use std::sync::atomic::{AtomicU16, AtomicUsize}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use mimalloc::MiMalloc; | |
#[global_allocator] | |
static GLOBAL: MiMalloc = MiMalloc; | |
mod rcute { | |
use std::alloc::Layout; | |
use std::fmt::{Debug, Formatter}; | |
use std::ops::Deref; | |
use std::ptr::NonNull; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec private lex_ (source: char ReadOnlySpan) (index: int) (collector: Token array) = | |
if index = source.Length then | |
collector | |
else | |
let character = source[index] | |
match character with | |
| ' ' -> lex_ source (index + 1) collector | |
| '+' -> lex_ source (index + 1) (Array.append collector [| RParen; RParen; Add; LParen; LParen |]) | |
| '-' -> lex_ source (index + 1) (Array.append collector [| RParen; RParen; Sub; LParen; LParen |]) |
NewerOlder