Skip to content

Instantly share code, notes, and snippets.

View mraleph's full-sized avatar
🐌

Slava Egorov mraleph

🐌
View GitHub Profile

I have a strange feeling today... It's not like this feeling actually appeared today, jumped out of nowhere and consumed all of me.

No, this strange feeling was always there, deep and covered with ripples like a dark lake under the cold autumn rain.

I want to talk.

No.

I WANT TO TALK.

function B1() {
/* Benchmark.prototype.setup goes here */
// Populate the base array
var arr = [];
for (var i = 0; i < 1024; i++) arr[i] = i;
var start = new Date;
for (...) { /* do N iterations of test body */
for (var i = 0; i < arr.length; i++) { arr[i] + 1 }
}
var end = new Date;
function GeneratedBenchmarkingFunction() {
/* Benchmark.prototype.setup goes here */
var start = new Date;
for (...) { /* do N iterations of test body */
/* test case goes here */
}
var end = new Date;
/* Benchmark.prototype.teardown goes here */
/* N / (end - start) gives ops per ms result */
};
if (!Math.fround) {
Math.fround = (function() {
var temp = new Float32Array(1);
return function fround(x) {
temp[0] = +x;
return temp[0];
}
})();
}
@mraleph
mraleph / gist:11093692
Last active August 29, 2015 14:00
tl;dr I want to be able to write `obj.td.lookup()` instead of `obj.ptr().td.handle().lookup()` but Rust's Deref trait does not work for that.
// This is an experiment to express within Rust typesystem a handle-system for
// a managed runtime similar to ones used internally by V8 and Dart VM.
//
// In short: managed runtime needs to know about any pointer into its heap. If
// implementation language (e.g. C++) does not provide stack walking
// capabilities we have to explicitly tell GC about each and every pointer we
// are working with so that it can discover and update them when necessary.
//
extern crate libc;
diff --git a/web/fc-app.dart b/web/fc-app.dart
index 9ab1b10..f8982d3 100644
--- a/web/fc-app.dart
+++ b/web/fc-app.dart
@@ -1,11 +1,30 @@
import "package:polymer/polymer.dart";
import "dart:html";
-import "dart:js";
~ ∮ dig cdnjs.com AAAA +short
2400:cb00:2048:1::a29f:f729
2400:cb00:2048:1::a29f:f829
~ ∮ curl -m 20 -v -o /dev/null -s -w "got %{size_download} bytes." -g --header 'Host: cdnjs.com' 'http://[2400:cb00:2048:1::a29f:f829]/'
* About to connect() to 2400:cb00:2048:1::a29f:f829 port 80 (#0)
* Trying 2400:cb00:2048:1::a29f:f829... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Accept: */*
> Host: cdnjs.com
function B1() {
/* Benchmark.prototype.setup goes here {{{ */
var arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
seed_data = 3,
result = 0;
/* }}} */
var start = new Date;
while (...) { /* do N iterations of test body */
/* body of the case goes here {{{ */
for (var i = 0; i < arr1.length; i++) {

new Fn(...) vs Object.create(P)

Basics of object layout in V8

Each JavaScript object in V8 looks like this

+-------+
|  map  | -> pointer to the hidden class
+-------+
function foo(x) {
function getCapacity(smth) {
}
this.x = function () {
getCapacity(yyy);
};
return this;
}