Skip to content

Instantly share code, notes, and snippets.

View SchrodingerZhu's full-sized avatar
✍️
Working!

Schrodinger ZHU Yifan SchrodingerZhu

✍️
Working!
View GitHub Profile
@SchrodingerZhu
SchrodingerZhu / ucrt-notes.md
Last active November 26, 2024 05:53
UCRT Notes

UCRT Notes

Background

At LLVM libc, I am exploring a harder approach (than MinGW) to implement a brand new CRT. As such, I am reading the UCRT code (open sourced portion). This document is for recording some interesting findings I have come across in the codebase. I will also write down some thoughts that might be useful for future implementation, which does not restrict to the UCRT codebase.

The code is from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource.

@SchrodingerZhu
SchrodingerZhu / Gimple.c
Last active November 15, 2024 16:10
GCCJIT Bug?
struct Lancern;
struct QuaticCat;
struct Float;
union Union;
struct Lancern
{
@SchrodingerZhu
SchrodingerZhu / COMMIT HASH
Created November 29, 2023 01:42
SMHasher Patch
7db446a0b8d2e29cd648fb5bf4224db9aed30905
@SchrodingerZhu
SchrodingerZhu / Generated Parser Benchmark
Last active June 12, 2023 20:23
Generated Parser Benchmark
[nix-shell:~/CLionProjects/paguroidea]$ env RUSTFLAGS="-C target-cpu=native" PAG_RANDOM_SEED=0 cargo bench
Compiling snmalloc-sys v0.3.3
Compiling pag-lexer v0.1.0-alpha.1 (/home/schrodinger/CLionProjects/paguroidea/pag-lexer)
Compiling serde_derive v1.0.163
Compiling lalrpop v0.20.0
Compiling pest_meta v2.6.0
Compiling pest_generator v2.6.0
Compiling pest_derive v2.6.0
Compiling pag-parser v0.1.0-alpha.1 (/home/schrodinger/CLionProjects/paguroidea/pag-parser)
Compiling serde v1.0.163
// Type your code here, or load an example.
pub fn square(num: i32) -> i32 {
num * num
}
// If you use `main()`, declare it as `pub` to see it in the output:
// pub fn main() { ... }
pub mod parser {
extern crate alloc;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#![no_std]
extern crate alloc;
use alloc::rc::Rc;
use core::cell::UnsafeCell;
use core::ptr::NonNull;
struct Node {
tree_parent: Option<NonNull<Self>>,
tree_left: Option<NonNull<Self>>,
@SchrodingerZhu
SchrodingerZhu / test.rs
Last active April 9, 2023 02:33
dynforest
#![no_std]
extern crate alloc;
use alloc::rc::Rc;
use core::cell::UnsafeCell;
use core::ptr::NonNull;
struct Node {
tree_parent: Option<NonNull<Self>>,
tree_left: Option<NonNull<Self>>,
#![feature(core_intrinsics)]
use std::intrinsics::likely;
use std::marker::PhantomData;
use std::ptr::NonNull;
use std::rc::{Rc, Weak};
struct Node<T> {
next: NonNull<Self>,
prev: NonNull<Self>,
@SchrodingerZhu
SchrodingerZhu / dom_tree.rs
Created January 19, 2023 18:29
Calculate domainance tree as fixed point
pub trait AssocSet<X, Y: Clone + Default> {
fn get(&self, target: X) -> Y;
fn set(&mut self, key: X, val: Y);
}
pub trait DFSGraph {
type Identifier: Clone + PartialEq + Eq + Copy;
type Set<Y>: AssocSet<Self::Identifier, Y>
where
Y: Clone + Default;
let mut postorder = Vec::new();
let mut visited = HashSet::new();
fn dfs(pool: &[BasicBlock], cursor: usize, visited: &mut HashSet<usize>, postorder: &mut Vec<usize>) {
if visited.contains(&cursor) {
return;
}
visited.insert(cursor);
for i in pool[cursor].outgoing.iter() {