cast_off 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -2
- data/README.en +1 -2
- data/bin/cast_off +2 -2
- data/cast_off.gemspec +3 -3
- data/ext/cast_off/cast_off.c.rb +28 -0
- data/lib/cast_off/compile/code_manager.rb +27 -4
- data/lib/cast_off/compile/configuration.rb +1 -0
- data/lib/cast_off/compile/translator.rb +1 -1
- data/lib/cast_off/compile.rb +9 -0
- metadata +4 -4
data/README
CHANGED
data/README.en
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
* About CastOff
|
2
|
-
CastOff is a
|
3
|
-
In other words, CastOff is a compiler for Ruby1.9.3.
|
2
|
+
CastOff is a compiler for Ruby1.9.3.
|
4
3
|
CastOff compiles Ruby method (method written in Ruby) into C extension (method written in C)
|
5
4
|
by using given information such as class information of variables.
|
6
5
|
CastOff can reduce Ruby virtual machine overhead, so by use of CastOff,
|
data/bin/cast_off
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'cast_off'
|
6
6
|
|
7
|
-
this = File.expand_path(__FILE__)
|
7
|
+
this = File.expand_path("#{Gem.bindir()}/#{File.basename(__FILE__)}")
|
8
8
|
step = nil
|
9
9
|
verbose = false
|
10
10
|
clear = false
|
@@ -13,7 +13,7 @@ threshold = 100
|
|
13
13
|
name = nil
|
14
14
|
|
15
15
|
opt = OptionParser.new(<<-EOS, 32, ' ')
|
16
|
-
CastOff is a
|
16
|
+
CastOff is a compiler for Ruby1.9.3.
|
17
17
|
|
18
18
|
Usage:
|
19
19
|
cast_off [options] [programfile] [arguments]
|
data/cast_off.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "cast_off"
|
3
|
-
spec.version = "0.3.
|
3
|
+
spec.version = "0.3.4"
|
4
4
|
spec.platform = Gem::Platform::RUBY
|
5
|
-
spec.summary = "
|
5
|
+
spec.summary = "Compiler for Ruby1.9.3"
|
6
6
|
spec.description = <<-EOS
|
7
|
-
CastOff is a
|
7
|
+
CastOff is a compiler for Ruby1.9.3
|
8
8
|
EOS
|
9
9
|
spec.files = Dir['{lib/**/*,ext/**/*}'] + %w[
|
10
10
|
cast_off.gemspec
|
data/ext/cast_off/cast_off.c.rb
CHANGED
@@ -466,6 +466,32 @@ static VALUE cast_off_get_iseq_from_block(VALUE self, VALUE block)
|
|
466
466
|
return iseq->self;
|
467
467
|
}
|
468
468
|
|
469
|
+
static VALUE cast_off_get_iseq_line(VALUE self, VALUE iseqval)
|
470
|
+
{
|
471
|
+
rb_iseq_t *iseq;
|
472
|
+
|
473
|
+
if (rb_class_of(iseqval) != rb_cISeq) {
|
474
|
+
rb_bug("cast_off_get_iseq_signiture: shoult not be reached");
|
475
|
+
}
|
476
|
+
|
477
|
+
iseq = DATA_PTR(iseqval);
|
478
|
+
|
479
|
+
return iseq->line_no;
|
480
|
+
}
|
481
|
+
|
482
|
+
static VALUE cast_off_get_iseq_filepath(VALUE self, VALUE iseqval)
|
483
|
+
{
|
484
|
+
rb_iseq_t *iseq;
|
485
|
+
|
486
|
+
if (rb_class_of(iseqval) != rb_cISeq) {
|
487
|
+
rb_bug("cast_off_get_iseq_signiture: shoult not be reached");
|
488
|
+
}
|
489
|
+
|
490
|
+
iseq = DATA_PTR(iseqval);
|
491
|
+
|
492
|
+
return iseq->filepath;
|
493
|
+
}
|
494
|
+
|
469
495
|
static VALUE cast_off_get_caller(VALUE self)
|
470
496
|
{
|
471
497
|
VALUE thval = rb_thread_current();
|
@@ -1425,6 +1451,8 @@ void Init_cast_off(void)
|
|
1425
1451
|
rb_define_method(rb_mCastOffCompiler, "override_target", cast_off_override_target, 2);
|
1426
1452
|
rb_define_method(rb_mCastOffCompiler, "get_iseq", cast_off_get_iseq, 3);
|
1427
1453
|
rb_define_method(rb_mCastOffCompiler, "get_iseq_from_block", cast_off_get_iseq_from_block, 1);
|
1454
|
+
rb_define_method(rb_mCastOffCompiler, "get_iseq_filepath", cast_off_get_iseq_filepath, 1);
|
1455
|
+
rb_define_method(rb_mCastOffCompiler, "get_iseq_line", cast_off_get_iseq_line, 1);
|
1428
1456
|
rb_define_method(rb_mCastOffCompiler, "load_compiled_file", cast_off_load_compiled_file, 1);
|
1429
1457
|
rb_define_method(rb_mCastOffCompiler, "get_caller", cast_off_get_caller, 0);
|
1430
1458
|
rb_define_method(rb_mCastOffCompiler, "hook_method_invocation", cast_off_hook_method_invocation, 1);
|
@@ -12,12 +12,21 @@ module CastOff
|
|
12
12
|
|
13
13
|
attr_reader :signiture, :compilation_target
|
14
14
|
|
15
|
+
def self.generate_signiture(unique_string)
|
16
|
+
unique_string.gsub(/\.|\/|-|:/, "_")
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.base_directory_name()
|
20
|
+
p = generate_signiture(File.expand_path(__FILE__))
|
21
|
+
p.gsub(/_lib_ruby_gems_1_9_1_gems_/, '.').gsub(/_lib_cast_off_compile_code_manager_rb$/, '')
|
22
|
+
end
|
23
|
+
|
15
24
|
CastOffDir = "#{ENV["HOME"]}/.CastOff"
|
16
25
|
FileUtils.mkdir(CastOffDir) unless File.exist?(CastOffDir)
|
17
|
-
BaseDir = "#{CastOffDir}/#{
|
26
|
+
BaseDir = "#{CastOffDir}/#{base_directory_name()}"
|
18
27
|
FileUtils.mkdir(BaseDir) unless File.exist?(BaseDir)
|
19
28
|
|
20
|
-
@@program_name = File.
|
29
|
+
@@program_name = File.basename($PROGRAM_NAME)
|
21
30
|
CastOff::Compiler.class_eval do
|
22
31
|
def program_name=(dir)
|
23
32
|
CastOff::Compiler::CodeManager.class_variable_set(:@@program_name, dir)
|
@@ -25,7 +34,7 @@ module CastOff
|
|
25
34
|
end
|
26
35
|
|
27
36
|
def self.program_dir()
|
28
|
-
dir = "#{BaseDir}/#{@@program_name
|
37
|
+
dir = "#{BaseDir}/#{generate_signiture(@@program_name)}"
|
29
38
|
FileUtils.mkdir(dir) unless File.exist?(dir)
|
30
39
|
dir
|
31
40
|
end
|
@@ -110,10 +119,22 @@ module CastOff
|
|
110
119
|
version.to_i
|
111
120
|
end
|
112
121
|
|
122
|
+
FILEPATH_LIMITED = CONFIG["host_os"].match(/mswin/)
|
123
|
+
FILEPATH_LIMIT = 255
|
124
|
+
def check_length()
|
125
|
+
return unless FILEPATH_LIMITED
|
126
|
+
raise(UnsupportedError.new(<<-EOS)) if @longpath.length > FILEPATH_LIMIT
|
127
|
+
|
128
|
+
Failed to generate signiture for #{@filepath}:#{@line_no}.
|
129
|
+
Signiture is generated from filepath and line_no.
|
130
|
+
Max length of signiture is #{FILEPATH_LIMIT} in this environment.
|
131
|
+
EOS
|
132
|
+
end
|
133
|
+
|
113
134
|
def initialize(filepath, line_no)
|
114
135
|
@filepath = filepath
|
115
136
|
@line_no = line_no
|
116
|
-
base_sign = "#{@filepath}_#{@line_no}"
|
137
|
+
base_sign = CodeManager.generate_signiture("#{@filepath}_#{@line_no}")
|
117
138
|
dir = self.class.program_dir()
|
118
139
|
@dstdir = "#{dir}/#{base_sign}"
|
119
140
|
@lockpath = "#{@dstdir}/lock"
|
@@ -131,6 +152,8 @@ module CastOff
|
|
131
152
|
@development_mark_file = "development"
|
132
153
|
@development_mark_path = "#{@dstdir}/#{@development_mark_file}"
|
133
154
|
@dstbin = "#{@dstdir}/#{@signiture}.so"
|
155
|
+
@longpath = @base_configuration_path # FIXME
|
156
|
+
check_length()
|
134
157
|
@compilation_target = nil
|
135
158
|
end
|
136
159
|
|
@@ -975,7 +975,7 @@ Source line is #{@root_iseq.source_line}.
|
|
975
975
|
#ClassWrapper.new(Env, true) => :rb_cEnv,
|
976
976
|
ClassWrapper.new(Time, true) => :rb_cTime,
|
977
977
|
ClassWrapper.new(Symbol, true) => :rb_cSymbol,
|
978
|
-
ClassWrapper.new(Mutex, true) => :rb_cMutex,
|
978
|
+
#ClassWrapper.new(Mutex, true) => :rb_cMutex,
|
979
979
|
ClassWrapper.new(Thread, true) => :rb_cThread,
|
980
980
|
ClassWrapper.new(Struct, true) => :rb_cStruct,
|
981
981
|
#ClassWrapper.new(Match, true) => :rb_cMatch,
|
data/lib/cast_off/compile.rb
CHANGED
@@ -234,8 +234,10 @@ module CastOff
|
|
234
234
|
Thread.current[COMPILER_RUNNING_KEY] = bool
|
235
235
|
end
|
236
236
|
|
237
|
+
Lock = Mutex.new()
|
237
238
|
def execute_no_hook()
|
238
239
|
bug() unless block_given?
|
240
|
+
Lock.synchronize do
|
239
241
|
begin
|
240
242
|
compiler_running(true)
|
241
243
|
hook_m = hook_method_invocation(nil)
|
@@ -252,6 +254,7 @@ module CastOff
|
|
252
254
|
hook_class_definition_end(@@autoload_proc)
|
253
255
|
end
|
254
256
|
end
|
257
|
+
end
|
255
258
|
end
|
256
259
|
|
257
260
|
def compile_iseq(iseq, mid, typemap, is_proc, bind)
|
@@ -468,11 +471,17 @@ Currently, CastOff cannot compile method which source file is not exist.
|
|
468
471
|
continue_load = RUBY_VERSION != "1.9.3"
|
469
472
|
s.class_eval do
|
470
473
|
define_method(:method_added) do |mid|
|
474
|
+
return unless CastOff.respond_to?(:autoload_running?)
|
471
475
|
if CastOff.autoload_running? && (!@@skipped.empty? || continue_load) && !CastOff.compiler_running?
|
472
476
|
continue_load &= !@@autoload_proc.call()
|
473
477
|
end
|
474
478
|
end
|
475
479
|
end
|
480
|
+
Module.class_eval do
|
481
|
+
define_method(:autoload) do |*args|
|
482
|
+
raise(ExecutionError.new("Currently, CastOff doesn't support Module#autoload"))
|
483
|
+
end
|
484
|
+
end
|
476
485
|
|
477
486
|
def contain_loop?(klass, mid)
|
478
487
|
case compilation_target_type(klass, mid)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cast_off
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! 'CastOff is a
|
14
|
+
description: ! 'CastOff is a compiler for Ruby1.9.3
|
15
15
|
|
16
16
|
'
|
17
17
|
email: shiba@rvm.jp
|
@@ -119,5 +119,5 @@ rubyforge_project:
|
|
119
119
|
rubygems_version: 1.8.11
|
120
120
|
signing_key:
|
121
121
|
specification_version: 3
|
122
|
-
summary:
|
122
|
+
summary: Compiler for Ruby1.9.3
|
123
123
|
test_files: []
|