Skip to content

Instantly share code, notes, and snippets.

View shyouhei's full-sized avatar

卜部昌平 shyouhei

View GitHub Profile
zsh % make miniruby
CC = clang-4.0
LD = ld
LDSHARED = clang-4.0 -dynamic -bundle
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -Werror=division-by-zero -Werror=deprecated-declarations -Werror=extra-tokens -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -I/usr/local/opt/libressl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin15 -I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/trunk/include -I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/tru
send-keys -X copy-pipe-and-cancel
From a22a135574b79c3132e4bc1faf3ec275503b94d7 Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Wed, 19 Apr 2017 11:01:51 +0900
Subject: [PATCH] refactor extract binop dispatcher
Those opt_something instructions are worth refactoring. They tend to
have similar ways of executions. By extracting the common part,
generated vm_exec_core function shrinks from 26,816 bytes to 26,256
bytes (according to nm(1)).
CC = gcc-4
LD = ld
LDSHARED = gcc-4 -dynamic -bundle
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE
CPPFLAGS = -I/usr/local/opt/libressl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin15 -I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/trunk/include -I/Users/urabe.shyouhei/data/src/ci.ruby-lang
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h (revision 57788)
+++ include/ruby/ruby.h (revision 57807)
@@ -1504,6 +1504,17 @@
}
#endif
+static inline int
+rb_long_is_fixable_p(long v)
From 8ecef9e3ed8003a1cb6c1601cfa56d82f70e9900 Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Wed, 8 Mar 2017 13:14:04 +0900
Subject: [PATCH] re-introduce __builtin_add_overflow
r57789 (74cdd89) was gradually "improve"d by naruse through r57793 to
r57806, resulted in reverting the efect of r57789 while retaining its
complexity. I think the current situation is slightly worse than
before (same output complicated source code).
@shyouhei
shyouhei / md2dom.rb
Created February 20, 2017 03:57
DOM of a Markdown document. Because Redcarpet is strongly HTML-centric we cannot pass non-String return values around. We instead have to retain all generated s-expressions and left markers of them in the return value. The DOM is constructed back from that info after we finished rendering.
#! /your/favourite/path/to/ruby
# -*- coding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-
require 'redcarpet'
class MD2DOM < Redcarpet::Render::Base
def preprocess str
@sexp = []
@shyouhei
shyouhei / Gemfile
Last active February 13, 2017 00:59
#! /your/favourite/path/to/bundler
# -*- coding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-
source 'https://rubygems.org'
gem 'test-unit-full'
@shyouhei
shyouhei / -
Created January 17, 2017 22:28
zsh % ./miniruby --dump=insns -ve '[*ary1, *ary2]'
ruby 2.5.0dev (2017-01-17) [x86_64-darwin15]
== disasm: #<ISeq:<main>@-e>============================================
0000 trace 1 ( 1)
0002 putself
0003 opt_send_without_block <callinfo!mid:ary1, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0006 splatarray true
0008 putself
0009 opt_send_without_block <callinfo!mid:ary2, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0012 concatarray
@shyouhei
shyouhei / -
Created January 17, 2017 07:33
zsh % ./miniruby --dump=insns -ve '$~ = 1234'
ruby 2.5.0dev (2017-01-17) [x86_64-darwin15]
== disasm: #<ISeq:<main>@-e>============================================
0000 trace 1 ( 1)
0002 putobject 1234
0004 dup
0005 setglobal $~
0007 leave