Skip to content

Instantly share code, notes, and snippets.

View John-Colvin's full-sized avatar

John Colvin John-Colvin

  • Wiltshire, UK
  • 05:47 (UTC +01:00)
View GitHub Profile
bin/sdc -c -o obj/sdlib/gc.o sdlib/d/gc/allocclass.d sdlib/d/gc/arena.d sdlib/d/gc/base.d sdlib/d/gc/bin.d sdlib/d/gc/bitmap.d sdlib/d/gc/capi.d sdlib/d/gc/emap.d sdlib/d/gc/extent.d sdlib/d/gc/finddivisor.d sdlib/d/gc/heap.d sdlib/d/gc/hpd.d sdlib/d/gc/pages.d sdlib/d/gc/rbtree.d sdlib/d/gc/region.d sdlib/d/gc/ring.d sdlib/d/gc/rtree.d sdlib/d/gc/sizeclass.d sdlib/d/gc/spec.d sdlib/d/gc/tcache.d sdlib/d/gc/util.d -Isdlib
; ModuleID = 'sdlib/d/gc/allocclass.d'
source_filename = "sdlib/d/gc/allocclass.d"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
@__ctBuf = global i64 undef
define i64 @__ctfe() #0 {
store i64 1, ptr @__ctBuf, align 8
ret i64 ptrtoint (ptr @__ctBuf to i64)

The DIP provides 2 examples to justify itself:

  1. unpredictable mutable aliasing after appends

  2. unpredictable changes of ownership caused by appends

They can share the same cause (~=), but are two distinct symptoms, and can also have other causes. They have a unifying aspect which is unpredictable aliasing.

The breakage of the DIP is immense, so there needs to be a commensurately large upside and no reasonable alternative path with less breakage.

/// map only on the specified index of each tuple element of the range `r`
auto mapOnPart(size_t i, alias f, R)(R r)
{
return r.map!(t => tuple(t[0 .. i].expand, f(t[i]), t[i + 1 .. $].expand));
}
/// map the whole tuple element to one part, copying the rest untouched
auto mapAllToPart(size_t i, alias f, R)(R r)
{
@John-Colvin
John-Colvin / withIopipe.d
Last active May 26, 2017 14:20
tsv with iopipe
import iopipe.textpipe;
import iopipe.bufpipe;
import iopipe.stream;
import iopipe.buffer;
int main(string[] args)
{
import std.stdio;
if (args.length < 4)
{
@John-Colvin
John-Colvin / mutablerangewrapper.d
Created May 13, 2017 12:56
mutable range wrapper
auto mutableView(R)(R r)
if (isRandomAccessRange!R)
{
return MutableRangeView!R(r);
}
alias MutableRangeView(R) = MutableRangeViewImpl!(R, false);
struct MutableRangeViewImpl(R, bool forceBack)
if (isRandomAccessRange!(Unqual!R))
@John-Colvin
John-Colvin / sigmoidContrast.py
Last active April 19, 2016 18:22
contrast function based on the error function
def sigmoidContrastGetRawSlope(bias, slope):
'''Get a value for rawSlope (as used in sigmoidContrast)'''
import scipy.optimize
import scipy.special
assert slope >= 1, "slope must be in [1, oo]"
if slope == 1:
return 0
2015-11-21 14:03:29 +0000
cmake
..
-DCMAKE_C_FLAGS_RELEASE=
-DCMAKE_CXX_FLAGS_RELEASE=
-DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/scalapack/2.0.2_4
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON
@John-Colvin
John-Colvin / tube_dist.html
Created November 12, 2015 18:35
most isolated tube stops in zone 1, as the crow files
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>Closest</th>
<th>dist</th>
</tr>
</thead>
<tbody>
<tr>
@John-Colvin
John-Colvin / pairwiseFast.d
Created October 4, 2015 17:34
fast pairwise
import std.range, std.traits;
import core.bitop : bsf;
import std.stdio;
/++
$(LUCKY Pairwise summation) algorithm. Range must be a finite range.
+/
F sumPairwise(F, R)(R data)
if(isInputRange!R && !isInfinite!R)
@John-Colvin
John-Colvin / pairWise.d
Last active October 1, 2015 15:14
pairWise summation for input ranges
/++
$(LUCKY Pairwise summation) algorithm. Range must be a finite range.
+/
private F sumPairwise(Range, F = Unqual!(ForeachType!Range))(Range data)
if (isInputRange!Range && !isInfinite!Range)
{
import core.bitop : bsf;
// Works for r with length < 2^^64, in keeping with the use of size_t
// elsewhere in std.algorithm and std.range on 64 bit platforms.
F[64] store = F.max;