Skip to content

Instantly share code, notes, and snippets.

View mutex-atomic.cc
#include <iostream>
#include <chrono>
#include <atomic>
#include <cassert>
#include <mutex>
const int ITERATIONS = 10'000'000;
std::mutex mtx;
int state = 2;
@dinfuehr
dinfuehr / richards-fixed.js
Last active Oct 9, 2018
richards sampling
View richards-fixed.js
function runRichards() {
var scheduler = new Scheduler();
scheduler.addIdleTask(0, null, 1000);
var queue = new Packet();
scheduler.addWorkerTask(1, queue);
if (scheduler.queueCount != 2322) {}
}
function Scheduler() { }
View FwdptrDataModel.java
package org.openjdk.jol.datamodel;
import org.openjdk.jol.util.MathUtil;
public class FwdptrDataModel implements DataModel {
private final int align;
private final boolean compressedOops;
private final FwdptrModel fwdptrModel;
@dinfuehr
dinfuehr / aarch64-logical-immediates.rb
Last active May 2, 2017
output all logical immediate values with n, immr and imms
View aarch64-logical-immediates.rb
def get_imms(size, length)
length | case size
when 2 then 0b111100
when 4 then 0b111000
when 8 then 0b110000
when 16 then 0b100000
when 32 then 0b000000
when 64 then 0b000000
end
end
@dinfuehr
dinfuehr / aarch64-logical-immediates.txt
Last active Jan 23, 2022
all possible logical immediates
View aarch64-logical-immediates.txt
5555555555555555 0101010101010101010101010101010101010101010101010101010101010101 size=02 length=00 rotation=00 N=0 immr=000000 imms=111100
aaaaaaaaaaaaaaaa 1010101010101010101010101010101010101010101010101010101010101010 size=02 length=00 rotation=01 N=0 immr=000001 imms=111100
1111111111111111 0001000100010001000100010001000100010001000100010001000100010001 size=04 length=00 rotation=00 N=0 immr=000000 imms=111000
8888888888888888 1000100010001000100010001000100010001000100010001000100010001000 size=04 length=00 rotation=01 N=0 immr=000001 imms=111000
4444444444444444 0100010001000100010001000100010001000100010001000100010001000100 size=04 length=00 rotation=02 N=0 immr=000010 imms=111000
2222222222222222 0010001000100010001000100010001000100010001000100010001000100010 size=04 length=00 rotation=03 N=0 immr=000011 imms=111000
3333333333333333 0011001100110011001100110011001100110011001100110011001100110011 size=04 length=01 rotation=00 N=0 immr=000000 imms=111001
9999999999999999 100110011001100110011001100
View growable_vec.rs
use std::cell::RefCell;
use std::ops::Index;
struct GrowableVec<T> {
elements: RefCell<Vec<Box<RefCell<T>>>>,
}
impl<T> GrowableVec<T> {
fn new() -> GrowableVec<T> {
GrowableVec {
@dinfuehr
dinfuehr / diff.md
Last active Nov 4, 2016
rust compilation difference
View diff.md

Nightly (f09420685 2016-10-20)

0000000000000000 <__rust_maybe_catch_panic>:
   0:   55                      push   %rbp
   1:   41 57                   push   %r15
   3:   41 56                   push   %r14
   5:   53                      push   %rbx
   6:   50                      push   %rax
@dinfuehr
dinfuehr / Dockerfile
Created Jul 10, 2016
cacao-jvm-dockerfile
View Dockerfile
FROM ubuntu:16.04
MAINTAINER dominik.infuehr@gmail.com
RUN apt-get update \
&& apt-get install -y \
mercurial \
wget \
unzip \
libtool \
autoconf \
View gist:ce18127c5aaa3babcc91
type Date = chrono::Date<chrono::Local>;
pub struct DateIterator {
start: Date,
end: Date
}
impl Iterator for DateIterator {
// ... not important
}
@dinfuehr
dinfuehr / error.rs
Created Jan 26, 2015
Rust: cannot move out of borrowed content
View error.rs
struct Foo {
value: String
}
impl Foo {
fn test(&mut self) -> String {
let old = self.value;
self.value = "new".to_string();
old
}