Skip to content

Commit

Permalink
v0.3.2 => v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Satoshi Shiba committed Nov 27, 2011
1 parent bad37de commit 83f5dd1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
* はじめに
本ツール CastOff は Ruby の高速化を支援するツールです。
一言で説明すると、Ruby1.9.3 用のコンパイラです。
本ツール CastOff は Ruby1.9.3 用のコンパイラです。
CastOff は、ユーザが与えた変数のクラス情報などを解釈し、
指定した Ruby のメソッドを C 拡張形式のメソッドへと変換します。
C 拡張に変換することで、Ruby の仮想マシンのオーバヘッドを削減し、
Expand Down
3 changes: 1 addition & 2 deletions README.en
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
* About CastOff
CastOff is a performance improvement tool for Ruby1.9.3.
In other words, CastOff is a compiler for Ruby1.9.3.
CastOff is a compiler for Ruby1.9.3.
CastOff compiles Ruby method (method written in Ruby) into C extension (method written in C)
by using given information such as class information of variables.
CastOff can reduce Ruby virtual machine overhead, so by use of CastOff,
Expand Down
4 changes: 2 additions & 2 deletions bin/cast_off
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'rubygems'
require 'optparse'
require 'cast_off'

this = File.expand_path(__FILE__)
this = File.expand_path("#{Gem.bindir()}/#{File.basename(__FILE__)}")
step = nil
verbose = false
clear = false
Expand All @@ -13,7 +13,7 @@ threshold = 100
name = nil

opt = OptionParser.new(<<-EOS, 32, ' ')
CastOff is a performance improvement tool for Ruby1.9.3.
CastOff is a compiler for Ruby1.9.3.
Usage:
cast_off [options] [programfile] [arguments]
Expand Down
6 changes: 3 additions & 3 deletions cast_off.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Gem::Specification.new do |spec|
spec.name = "cast_off"
spec.version = "0.3.2"
spec.version = "0.3.3"
spec.platform = Gem::Platform::RUBY
spec.summary = "Performance improvement tool for Ruby1.9.3"
spec.summary = "Compiler for Ruby1.9.3"
spec.description = <<-EOS
CastOff is a performance improvement tool for Ruby1.9.3
CastOff is a compiler for Ruby1.9.3
EOS
spec.files = Dir['{lib/**/*,ext/**/*}'] + %w[
cast_off.gemspec
Expand Down
28 changes: 28 additions & 0 deletions ext/cast_off/cast_off.c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,32 @@ def = me->def;
return iseq->self;
}

static VALUE cast_off_get_iseq_line(VALUE self, VALUE iseqval)
{
rb_iseq_t *iseq;

if (rb_class_of(iseqval) != rb_cISeq) {
rb_bug("cast_off_get_iseq_signiture: shoult not be reached");
}

iseq = DATA_PTR(iseqval);

return iseq->line_no;
}

static VALUE cast_off_get_iseq_filepath(VALUE self, VALUE iseqval)
{
rb_iseq_t *iseq;

if (rb_class_of(iseqval) != rb_cISeq) {
rb_bug("cast_off_get_iseq_signiture: shoult not be reached");
}

iseq = DATA_PTR(iseqval);

return iseq->filepath;
}

static VALUE cast_off_get_caller(VALUE self)
{
VALUE thval = rb_thread_current();
Expand Down Expand Up @@ -1425,6 +1451,8 @@ module = wrapper->module;
rb_define_method(rb_mCastOffCompiler, "override_target", cast_off_override_target, 2);
rb_define_method(rb_mCastOffCompiler, "get_iseq", cast_off_get_iseq, 3);
rb_define_method(rb_mCastOffCompiler, "get_iseq_from_block", cast_off_get_iseq_from_block, 1);
rb_define_method(rb_mCastOffCompiler, "get_iseq_filepath", cast_off_get_iseq_filepath, 1);
rb_define_method(rb_mCastOffCompiler, "get_iseq_line", cast_off_get_iseq_line, 1);
rb_define_method(rb_mCastOffCompiler, "load_compiled_file", cast_off_load_compiled_file, 1);
rb_define_method(rb_mCastOffCompiler, "get_caller", cast_off_get_caller, 0);
rb_define_method(rb_mCastOffCompiler, "hook_method_invocation", cast_off_hook_method_invocation, 1);
Expand Down
9 changes: 9 additions & 0 deletions lib/cast_off/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ def compiler_running(bool)
Thread.current[COMPILER_RUNNING_KEY] = bool
end

Lock = Mutex.new()
def execute_no_hook()
bug() unless block_given?
Lock.synchronize do
begin
compiler_running(true)
hook_m = hook_method_invocation(nil)
Expand All @@ -252,6 +254,7 @@ def execute_no_hook()
hook_class_definition_end(@@autoload_proc)
end
end
end
end

def compile_iseq(iseq, mid, typemap, is_proc, bind)
Expand Down Expand Up @@ -468,11 +471,17 @@ def __load(compiled)
continue_load = RUBY_VERSION != "1.9.3"
s.class_eval do
define_method(:method_added) do |mid|
return unless CastOff.respond_to?(:autoload_running?)
if CastOff.autoload_running? && (!@@skipped.empty? || continue_load) && !CastOff.compiler_running?
continue_load &= !@@autoload_proc.call()
end
end
end
Module.class_eval do
define_method(:autoload) do |*args|
raise(ExecutionError.new("Currently, CastOff doesn't support Module#autoload"))
end
end

def contain_loop?(klass, mid)
case compilation_target_type(klass, mid)
Expand Down
1 change: 1 addition & 0 deletions lib/cast_off/compile/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def union(conf)
return unless conf.bind
bug() unless conf.bind.instance_of?(BindingWrapper)
@bind = conf.bind
prefetch_constant(true)
end

def update_variable_configuration(update_hash)
Expand Down
2 changes: 1 addition & 1 deletion lib/cast_off/compile/translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def prefetch_constant(var, path, singleton_p)
#ClassWrapper.new(Env, true) => :rb_cEnv,
ClassWrapper.new(Time, true) => :rb_cTime,
ClassWrapper.new(Symbol, true) => :rb_cSymbol,
ClassWrapper.new(Mutex, true) => :rb_cMutex,
#ClassWrapper.new(Mutex, true) => :rb_cMutex,
ClassWrapper.new(Thread, true) => :rb_cThread,
ClassWrapper.new(Struct, true) => :rb_cStruct,
#ClassWrapper.new(Match, true) => :rb_cMatch,
Expand Down

0 comments on commit 83f5dd1

Please sign in to comment.