Skip to content

Instantly share code, notes, and snippets.

View shyouhei's full-sized avatar

卜部昌平 shyouhei

View GitHub Profile
% lldb -- ./miniruby -I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/lib /Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/enc/make_encmake.rb enc.mk
(lldb) target create "./miniruby"
Current executable set to './miniruby' (x86_64).
(lldb) settings set -- target.run-args "-I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/lib" "/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/enc/make_encmake.rb" "enc.mk"
(lldb) env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
(lldb) env MALLOC_PROTECT_BEFORE=1
(lldb) env MALLOC_CHECK_HARDER=1
(lldb) run
Process 43554 launched: './miniruby' (x86_64)
GuardMalloc[miniruby-43554]: Allocations will be placed on 16 byte boundaries.
zsh % lldb -- ./miniruby -I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/lib /Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/enc/make_encmake.rb enc.mk
(lldb) target create "./miniruby"
Current executable set to './miniruby' (x86_64).
(lldb) settings set -- target.run-args "-I/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/lib" "/Users/urabe.shyouhei/data/src/ci.ruby-lang.org/ruby/branches/ruby_2_3/enc/make_encmake.rb" "enc.mk"
(lldb) env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
(lldb) run
Process 41621 launched: './miniruby' (x86_64)
GuardMalloc[miniruby-41621]: Allocations will be placed on 16 byte boundaries.
GuardMalloc[miniruby-41621]: - Some buffer overruns may not be noticed.
GuardMalloc[miniruby-41621]: - Applications using vector instructions (e.g., SSE) should work.
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" <[email protected]>
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" <[email protected]>
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'