Skip to content

Instantly share code, notes, and snippets.

View jimblandy's full-sized avatar

Jim Blandy jimblandy

View GitHub Profile
(defun jimb-rust-clean-error ()
"Clean up an error message from rustc to fit nicely in the book.
Run this command with point on the first line of an error message
copied from rustc and pasted into a Markdown file; we'll clean it
up and indent it as a code block."
(interactive)
(save-excursion
(forward-line 0)
(let ((top (point)))
(let ((line-was-interesting t)
fn partition<T: Ord>(a: &mut[T]) -> usize {
assert!(a.len() >= 2);
let mut pivot = 0;
let (mut i, mut j) = (0, a.len());
loop {
loop {
j -= 1;
if a[j] <= a[pivot] { break; }
mod implicit_deref {
use std::ops::Deref;
struct T(i32);
struct S<'a>(&'a T);
impl<'a> Deref for S<'a> {
type Target = T;
fn deref(&self) -> &T { &self.0; }
}
use std::str::FromStr;
use std::fmt::Debug;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
trait Game : Clone {
type Move : Copy + FromStr;
fn start() -> Self;
fn moves(&self) -> Vec<Self::Move>;
@ changeset: 252017 47888f3efe7c Thu Mar 19 15:39:53 2015 -0700
| bookmarks: mozalloc2
| summary: wip
| phase: draft
|
o changeset: 252016 9c583c9b4d2d Thu Mar 19 01:03:05 2015 -0700
| bookmarks: mozalloc-no-xpcom-config
| summary: Bug 1145051: Don't include xpcom-config.h from mozalloc.h; it's unused.
| phase: draft
|
@jimblandy
jimblandy / .hgrc
Created March 19, 2015 23:02
"hg mine" command, showing draft and secret changes
[alias]
mine=log -G -r 'not public() or parents(not public()) or bookmark()' --template "changeset: {rev} {node|short} {date|date}\n{if(bookmarks, 'bookmarks: {bookmarks}\n')}summary: {sub(r'\n', '\n ', fill(desc, '90'))}\nphase: {phase}\n\n"
Notation:
f -> g "f calls g"
f -> (a -> b) g: "f calls g, supplying async parent stack a -> b"
Suppose we have:
/* in chrome */
1: function contentVisibleChromeImplementedInJS(...) {
2: var p0 = Promise((f0, r0) => { ... });
@jimblandy
jimblandy / byteSize-of-string.js
Created February 23, 2015 21:58
ubi::Node::size test for JSStrings
// Check JS::ubi::Node::size results for strings.
// We actually hard-code specific sizes into this test, even though they're
// implementation details, because in practice there are only two architecture
// variants to consider (32-bit and 64-bit), and if these sizes change, that's
// something SpiderMonkey hackers really want to know; they're supposed to be
// stable.
// Run this test only if we're using jemalloc. Other malloc implementations
// exhibit surprising behaviors. For example, 32-bit Fedora builds have
@jimblandy
jimblandy / lazy-Debugger.Frame-invalidation.md
Last active August 29, 2015 14:13
Lazy Debugger.Frame invalidation

Lazy Debugger.Frame invalidation

I think there is a representation for Debugger.Frames that does not require frames to be removed from the Debugger::frames FrameMap when they are popped. It does still require prompt notification of:

  • frame pops for Debugger.Frame instances that have an onPop handler set, to report the pop to Debugger's users; and

  • changes of a frame's representation (on-stack replacement; bailouts; etc.), to update the key in the map.

Not needing to report pops comes at the cost of a more expensive validity check before using a Debugger.Frame. But even so, we should be able to skip this check in some circumstances.

@jimblandy
jimblandy / IUbiCoreDump.idl
Created September 25, 2014 00:44
Proposed ubi::Node core dump API
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIFile.idl"
[scriptable, uuid(bitter-hatred-towards-all-that-is-good-and-decent)]
interface IUbiCoreDump : nsISupports
{