Skip to content

Instantly share code, notes, and snippets.

@schmee
schmee / After.java
Last active May 16, 2018 22:37
Escape analysis woes
@Specialization(guards = "isLong(vframe)")
public long readLong(VirtualFrame vframe) {
try {
return vframe.getLong(getSlot());
} catch (FrameSlotTypeException e) { }
MaterializedFrame frame = getLexicalScope(vframe);
while (true) {
try {
return frame.getLong(getSlot());
} catch (FrameSlotTypeException e) {
@schmee
schmee / Point.sl
Last active April 25, 2018 18:56
Graal escape analysis test
function add(a, b) {
c = new();
c.x = a.x + b.x;
c.y = a.y + b.y;
return c;
}
function main() {
a = new();
a.x = 1;
➜ simplelanguage git:(master) ✗ ./sl -dump language/tests/SumPrint.sl
+ VERSION=0.33
+ LANGUAGE_PATH=./language/target/simplelanguage-0.33-SNAPSHOT.jar
+ LAUNCHER_PATH=./launcher/target/launcher-0.33-SNAPSHOT.jar
+ MAIN_CLASS=com.oracle.truffle.sl.launcher.SLMain
+ [[ ! -f ./language/target/simplelanguage-0.33-SNAPSHOT.jar ]]
+ [[ ! -f ./launcher/target/launcher-0.33-SNAPSHOT.jar ]]
+ [[ /Users/john.schmidt/.jenv/versions/other64-1.8.0.161 != '' ]]
++ grep GRAALVM_VERSION /Users/john.schmidt/.jenv/versions/other64-1.8.0.161/release
+ GRAALVM_VERSION='GRAALVM_VERSION="0.33"'
@schmee
schmee / core.clj
Created December 30, 2016 11:18
clojure.spec bug?
(ns spec-test.core
(:require [clojure.spec :as s]))
(defprotocol Game
(move [game]))
(s/def ::game1 #(satisfies? Game %))
(s/def ::game2 (partial satisfies? Game))
{:user {:dependencies [[im.chit/vinyasa "0.2.2"]]
:injections
[(require '[vinyasa.inject :as inject])
(inject/in
clojure.core
[clojure.pprint [pprint pp]])]}}
REPL output:
{:user {:dependencies [[im.chit/vinyasa "0.2.2"]]
:injections
[(require 'clojure.pprint)
(ns-unmap *ns* 'pp)
(def pp clojure.pprint/pprint)
(def p println)]}}
REPL output:
// Version 1:
let mut n_most_common = Vec::with_capacity(n);
for _ in range(0u, n) {
let Counted { k, v } = pq.pop().unwrap();
n_most_common.push((k, v));
}
n_most_common
pub fn most_common(&self, n: uint) -> Vec<(K, uint)> {
let data = self.data.clone();
let mut counted: Vec<Counted<K>> = data.move_iter().
map(|(k, v)| Counted {k: k, v: v}).collect();
let mut n_most_common = vec!();
let mut pq = PriorityQueue::from_vec(counted);
for _ in range(0u, n) {
let tmp = pq.pop().unwrap();
// error: use of partially moved value: `tmp`
extern crate debug;
use std::str::CharRange;
use std::str::Chars;
use std::str::raw::slice_unchecked;
fn main() {
let test = "¨återbesök på färöarna";
let v: Vec<u16> = to_utf16(test).collect();
println!("{}", v);
println!("{}", test.to_utf16());
extern crate collections;
use collections::HashMap;
fn main () {
}
static MISSING: uint = 0;
#[deriving(Clone)]