Skip to content

Instantly share code, notes, and snippets.

View rednaxelafx's full-sized avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / MHTest.java
Last active April 8, 2018 02:12
Example of HotSpot 25's C1 compiling a MethodHandle (Part II): inlines the MH graph, because root of compilation is the driver() which contains the MH.invokeExact() call site, and sees the MH is a "constant". Part I is at https://gist.github.com/rednaxelafx/8107598
import java.lang.invoke.*;
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
public class MHTest {
private static final Lookup LK = lookup();
private static final MethodHandle MH0;
private static final MethodHandle MH1;
static {
@rednaxelafx
rednaxelafx / .hotspot_compiler
Created December 24, 2013 01:38
Example of HotSpot 25's C1 compiling a MethodHandle (Part I): unable to inline, because root of compilation is the invokeExact() itself, and it can't see the MH is a "constant".
exclude java/io/* *
exclude java/nio/* *
exclude java/util/* *
exclude java/lang/StringBuilder *
exclude java/lang/String *
exclude java/lang/Integer *
exclude java/lang/AbstractStringBuilder *
@rednaxelafx
rednaxelafx / command_prompt
Created December 13, 2013 01:47
Logs from installing Homebrew on Mac OS X 10.9
krismo-mbp:/Users/krismo
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
/usr/local/include

尝试调整新生代的内存大小

默认不加任何参数 (16MB)

$ ./bin/node/bin/node --trace_gc dispatch.js
[29594]       31 ms: Scavenge 1.6 (37.1) -> 1.5 (38.1) MB, 1.3 ms [Runtime::PerformGC].
[29594]       63 ms: Scavenge 2.9 (39.1) -> 2.7 (40.1) MB, 1.4 ms [Runtime::PerformGC].
[29594]       87 ms: Scavenge 3.8 (40.1) -> 3.4 (41.1) MB, 0.8 ms [allocation failure].
[29594]      121 ms: Scavenge 5.8 (41.1) -> 4.8 (42.1) MB, 1.6 ms [allocation failure].
@rednaxelafx
rednaxelafx / irb_session
Created November 1, 2013 20:44
Explore the actual value of VALUE for Symbol in Ruby 1.8.7, on Mac OS X 10.7.5 (64-bit)
#define SYMBOL_FLAG 0x0e
#define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
#define SYM2ID(x) RSHIFT((unsigned long)x,8)
#define T_SYMBOL 0x24
ID | ID_LOCAL | SYMBOL_FLAG
000000000101111100111 | 001 | 00001110
000000000101111101000 | 001 | 00001110
000000000101111101001 | 001 | 00001110
@rednaxelafx
rednaxelafx / Program.cs
Last active April 8, 2018 01:21
Explore 32-bit .NET 4.0 System.String's memory layout. ObjSize command gives the size of the whole object (with padding due to alignment), including the object header (at negative offset just before the object). DumpObj command gives the size of object without the padding bytes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test1
{
class Program
{
@rednaxelafx
rednaxelafx / gdb_session
Created October 31, 2013 02:24
explore memory layout of g++-4.4.5/libstdc++'s std::string
rednaxelafx@fx-laptop:/tmp
$ gedit xx.cpp
rednaxelafx@fx-laptop:/tmp
$ g++ -g xx.cpp
rednaxelafx@fx-laptop:/tmp
$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
@rednaxelafx
rednaxelafx / u16str.cpp
Created September 18, 2013 07:11
Demo of using C++11's u16string with Unicode string literal syntax
#include <codecvt> // for codecvt_utf8
#include <iostream> // cor cout
#include <locale> // for wstring_convert
#include <string> // for string, u16string
using namespace std;
// Compiles on LLVM 3.3 with:
// clang++ -std=c++11 -stdlib=libc++ xxx.cpp
@rednaxelafx
rednaxelafx / x.java
Created September 9, 2013 08:35
Just trying to trigger stack overflow with large stack frames
public class x {
static void foo() {
long v0;
long v1;
long v2;
long v3;
long v4;
long v5;
long v6;
long v7;
@rednaxelafx
rednaxelafx / Notes.md
Last active April 8, 2018 01:21
Mappings of project name -> actual purpose in iv/lv5 ECMAScript engine

iv/lv5 ECMAScript Engine: https://github.com/Constellation/iv

  • teleporter -> 白井黒子/空間移動(テレポート) -> 古いASTインタプリタ
  • railgun -> 御坂美琴/超電磁砲(レールガン) -> Stack VM -> Register VM
  • aero (Aero Hand Project) -> 婚后光子/空力使い(エアロハンド) -> 正規表現エンジン
  • breaker (Imagine Breaker Project) -> 上条当麻/幻想殺し(イマジンブレイカー) -> Context-threading JITコンパイラ
  • radio (Radio Noise Project) -> 妹達(シスターズ)/欠陥電気(レディオノイズ) -> Exact GC
  • phonic -> ? -> ruby binding for iv AST API
  • accelerator -> 一方通行(アクセラレータ) -> ?
  • melt (Meltdowner) -> 麦野沈利/原子崩し(メルトダウナー) -> ECMAScript extensions