Skip to content

Instantly share code, notes, and snippets.

View mraleph's full-sized avatar
🐌

Slava Egorov mraleph

🐌
View GitHub Profile
@mraleph
mraleph / dart.asm
Last active April 30, 2017 02:15
LuaJIT's SINK can't sink compounds. Dart VM sinking pass can :-(
;; B2
;; Loop 0
;; CheckStackOverflow:24(depth 1)
0x7f845e4afcb6 48c7c25884f501 movq rdx,0x1f58458
0x7f845e4afcbd 483b22 cmpq rsp,[rdx]
0x7f845e4afcc0 0f862c000000 jna 0x7f845e4afcf2
;; Branch if RelationalOp:26(<, v6, v8) T{bool} goto (12, 4)
0x7f845e4afcc6 4881f9204e0000 cmpq rcx,0x4e20
0x7f845e4afccd 0f8d15000000 jge 0x7f845e4afce8
;; B12
$ time ./pypy-c test.py 1000000
./pypy-c test.py 1000000  11.65s user 0.41s system 99% cpu 12.063 total
$ time src/luajit test.lua 1000000                                                 
src/luajit test.lua 1000000  2.43s user 0.01s system 100% cpu 2.438 total
$ time dart test.dart 1000000
dart test.dart 1000000  0.29s user 0.02s system 107% cpu 0.284 total
@mraleph
mraleph / koan.lua
Last active December 2, 2015 17:15
-- Make this function more LuaJIT friendly while keeping its semantics intact.
-- Assume that t are always small table literals (<5 elements) and surrounding loop
-- is traced.
local function len(t)
return #t
end
-- Make this loop 50x faster by tweaking len above.
local sum = 0
for i = 1, 10000000 do
$ src/luajit test1.lua                                            
test3/lua 0.000812
test2/lua 0.047739
$ src/luajit test2.lua
test2/lua 0.050938
test3/lua 0.000856
--- Raw source ---
() {
var sum = 0;
for (var i = 0; i < 1000; i++) {
sum += i;
}
}
--- Optimized code ---
@mraleph
mraleph / test.js
Last active January 7, 2016 00:03
Object.keys({a:1}) ----------------------
DebugPrint: 0x4c012f99: [JSObject]
- map = 0x5f30a2e1 [FAST_HOLEY_ELEMENTS]
- prototype = 0x24976009
{
#length: 0x24962489 <ExecutableAccessorInfo> (accessor constant)
0: 0x2492fdb1 <String[1]: a>
}
0x5f30a2e1: [Map]
(function () {
var now = typeof performance !== 'undefined' ? performance.now.bind(performance) : Date.now;
function Accessor() {
var obj = { }
obj.x = 0;
delete obj.x;
var _a = 0;
Object.defineProperty(obj, 'a', {
function A() { }
A.prototype.foo = function () { };
function opt(obj) {
for (var i = 0; i < 1000000; i++) obj.foo();
}
opt(new A);
// d8 --allow-natives-syntax --trace-opt --trace-deopt test.js
var o = { x: 0, y: 0 };
print(%HasFastProperties(o)); // => true
Object.setPrototypeOf(o, { random: 'stuff', stuff: function() { } });
print(%HasFastProperties(o)); // => true
function foo (o) {
return o.x;
}
commit 4ff0340157287ca9082bca8d70e5958d96ccfd59
Author: Vyacheslav Egorov <[email protected]>
Date: Mon Aug 15 12:11:24 2016 +0200
Use library snapshot on Android instead of blobs
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 04d4bd9..735a808 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn