fastruby 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/{README → README.rdoc} +6 -1
- data/Rakefile +7 -7
- data/benchmarks/benchmark.rb~ +14 -2
- data/ext/fastruby_base/fastruby_base.inl +8 -4
- data/lib/fastruby/builder/inference_updater.rb +76 -0
- data/lib/fastruby/builder/inference_updater.rb~ +76 -0
- data/lib/fastruby/builder/inferencer.rb +38 -0
- data/lib/fastruby/{inliner → builder}/inliner.rb +16 -27
- data/lib/fastruby/builder/inliner.rb~ +60 -0
- data/lib/fastruby/builder/locals_inference.rb +53 -0
- data/lib/fastruby/builder/lvar_type.rb +43 -0
- data/lib/fastruby/builder/lvar_type.rb~ +44 -0
- data/lib/fastruby/builder/pipeline.rb +43 -0
- data/lib/fastruby/builder/pipeline.rb~ +43 -0
- data/lib/fastruby/{reductor → builder}/reductor.rb +6 -3
- data/lib/fastruby/builder/reductor.rb~ +42 -0
- data/lib/fastruby/builder.rb +73 -25
- data/lib/fastruby/builder.rb~ +311 -0
- data/lib/fastruby/corelib/fixnum.rb +75 -0
- data/lib/fastruby/corelib/fixnum.rb~ +146 -0
- data/lib/fastruby/corelib/integer.rb +96 -0
- data/lib/fastruby/corelib/integer.rb~ +96 -0
- data/lib/fastruby/corelib.rb +23 -0
- data/lib/fastruby/corelib.rb~ +23 -0
- data/lib/fastruby/getlocals.rb +3 -1
- data/lib/fastruby/logging.rb +2 -2
- data/lib/fastruby/modules/inferencer/infer.rb +31 -0
- data/lib/fastruby/modules/inferencer/literal.rb +42 -0
- data/lib/fastruby/modules/inliner/call.rb +327 -0
- data/lib/fastruby/{inliner/modules/call.rb → modules/inliner/call.rb~} +14 -24
- data/lib/fastruby/modules/inliner/defn.rb +41 -0
- data/lib/fastruby/modules/inliner/defn.rb~ +29 -0
- data/lib/fastruby/modules/inliner/recursive.rb +40 -0
- data/lib/fastruby/{inliner/modules/recursive.rb → modules/inliner/recursive.rb~} +1 -1
- data/lib/fastruby/modules/lvar_type/call.rb +36 -0
- data/lib/fastruby/modules/lvar_type/call.rb~ +36 -0
- data/lib/fastruby/modules/lvar_type/defn.rb +42 -0
- data/lib/fastruby/modules/lvar_type/defn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb +41 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb +33 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb~ +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/case.rb +0 -0
- data/lib/fastruby/modules/reductor/fastruby_flag.rb +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/for.rb +0 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/nontree.rb +0 -0
- data/lib/fastruby/modules/reductor/nontree.rb~ +32 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/recursive.rb +1 -1
- data/lib/fastruby/modules/reductor/recursive.rb~ +31 -0
- data/lib/fastruby/{translator/modules → modules/translator}/block.rb +0 -0
- data/lib/fastruby/modules/translator/call.rb +344 -0
- data/lib/fastruby/{translator/modules/call.rb → modules/translator/call.rb~} +24 -3
- data/lib/fastruby/{translator/modules → modules/translator}/defn.rb +10 -9
- data/lib/fastruby/modules/translator/defn.rb~ +267 -0
- data/lib/fastruby/{translator/modules → modules/translator}/directive.rb +3 -1
- data/lib/fastruby/modules/translator/directive.rb~ +44 -0
- data/lib/fastruby/{translator/modules → modules/translator}/exceptions.rb +3 -1
- data/lib/fastruby/modules/translator/exceptions.rb~ +120 -0
- data/lib/fastruby/{translator/modules → modules/translator}/flow.rb +0 -0
- data/lib/fastruby/modules/translator/iter.rb +745 -0
- data/lib/fastruby/{translator/modules/iter.rb → modules/translator/iter.rb~} +103 -48
- data/lib/fastruby/modules/translator/literal.rb +150 -0
- data/lib/fastruby/{translator/modules/literal.rb → modules/translator/literal.rb~} +3 -3
- data/lib/fastruby/{translator/modules → modules/translator}/logical.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/method_group.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/nonlocal.rb +18 -6
- data/lib/fastruby/modules/translator/nonlocal.rb~ +298 -0
- data/lib/fastruby/modules/translator/static.rb +290 -0
- data/lib/fastruby/{translator/modules/static.rb → modules/translator/static.rb~} +66 -17
- data/lib/fastruby/modules/translator/variable.rb +280 -0
- data/lib/fastruby/{translator/modules/variable.rb → modules/translator/variable.rb~} +14 -44
- data/lib/fastruby/modules.rb +30 -0
- data/lib/fastruby/object.rb +42 -6
- data/lib/fastruby/object.rb~ +159 -0
- data/lib/fastruby/set_tree.rb +7 -11
- data/lib/fastruby/set_tree.rb~ +71 -0
- data/lib/fastruby/sexp_extension.rb +29 -7
- data/lib/fastruby/sexp_extension.rb~ +262 -0
- data/lib/fastruby/translator/scope_mode_helper.rb~ +138 -0
- data/lib/fastruby/translator/translator.rb +87 -92
- data/lib/fastruby/translator/translator.rb~ +1600 -0
- data/lib/fastruby/translator/translator_modules.rb +3 -1
- data/lib/fastruby/translator/translator_modules.rb~ +53 -0
- data/lib/fastruby.rb +3 -1
- data/lib/fastruby.rb~ +3 -1
- data/lib/fastruby_only/base.rb +1 -0
- data/spec/corelib/numeric/fixnum_spec.rb +110 -0
- data/spec/corelib/numeric/fixnum_spec.rb~ +104 -0
- data/spec/corelib/numeric/integer_spec.rb +173 -0
- data/spec/corelib/numeric/integer_spec.rb~ +173 -0
- data/spec/fastruby_only/base_spec.rb +74 -0
- data/spec/graph/base_spec.rb +2 -1
- data/spec/graph/base_spec.rb~ +35 -0
- data/spec/graph/path_spec.rb +2 -2
- data/spec/graph/path_spec.rb~ +48 -0
- data/spec/graph/vertex_spec.rb +2 -1
- data/spec/graph/vertex_spec.rb~ +58 -0
- data/spec/reductor/base_spec.rb +1 -1
- data/spec/ruby/block/lambda_spec.rb~ +163 -0
- data/spec/ruby/block/proc_as_block_spec.rb~ +69 -1
- data/spec/ruby/block_spec.rb~ +2 -494
- data/spec/ruby/call/base_call_spec.rb +1 -1
- data/spec/ruby/call/base_call_spec.rb~ +2 -60
- data/spec/ruby/defn/replacement_spec.rb +26 -14
- data/spec/ruby/defn/replacement_spec.rb~ +13 -3
- data/spec/ruby/exception/internal_ex_spec.rb~ +86 -0
- data/spec/ruby/integrity_spec.rb~ +35 -1
- data/spec/ruby/variable_spec.rb~ +31 -0
- data/spec/scope_mode/flow_spec.rb +1 -1
- data/spec/scope_mode/flow_spec.rb~ +109 -0
- data/spec/sugar/base_spec.rb +29 -0
- data/spec/sugar/base_spec.rb~ +16 -0
- metadata +100 -43
- data/spec/fastruby/inliner/modules/call_spec.rb +0 -0
- data/spec/fastruby/translator/modules/nonlocal_spec.rb +0 -0
- data/spec/fastruby/translator/translator_spec.rb +0 -0
- data/spec/ruby/block/arguments_spec.rb~ +0 -214
- data/spec/ruby/block/break_spec.rb~ +0 -236
- data/spec/ruby/block/next_spec.rb~ +0 -85
- data/spec/ruby/block/retry_spec.rb~ +0 -43
@@ -0,0 +1,138 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of the fastruby project, http://github.com/tario/fastruby
|
4
|
+
|
5
|
+
Copyright (c) 2011 Roberto Dario Seminara <robertodarioseminara@gmail.com>
|
6
|
+
|
7
|
+
fastruby is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the gnu general public license as published by
|
9
|
+
the free software foundation, either version 3 of the license, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
fastruby is distributed in the hope that it will be useful,
|
13
|
+
but without any warranty; without even the implied warranty of
|
14
|
+
merchantability or fitness for a particular purpose. see the
|
15
|
+
gnu general public license for more details.
|
16
|
+
|
17
|
+
you should have received a copy of the gnu general public license
|
18
|
+
along with fastruby. if not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
=end
|
21
|
+
require "fastruby/sexp_extension"
|
22
|
+
|
23
|
+
module FastRuby
|
24
|
+
class ScopeModeHelper
|
25
|
+
def self.get_scope_mode(tree_)
|
26
|
+
new.get_scope_mode(tree_)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_scope_mode(tree_)
|
30
|
+
tree = FastRuby::FastRubySexp.from_sexp(tree_)
|
31
|
+
|
32
|
+
if tree.node_type == :defn
|
33
|
+
args_tree = tree[2]
|
34
|
+
impl_tree = tree[3]
|
35
|
+
elsif tree.node_type == :defs
|
36
|
+
args_tree = tree[3]
|
37
|
+
impl_tree = tree[4]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
p $search_array.call(impl_tree)
|
42
|
+
graph = impl_tree.to_graph
|
43
|
+
|
44
|
+
args_tree[1..-1].each do |subtree|
|
45
|
+
return :dag if subtree.to_s =~ /^\&/
|
46
|
+
end
|
47
|
+
|
48
|
+
tree.walk_tree do |subtree|
|
49
|
+
if subtree.node_type == :iter
|
50
|
+
iter_impl = subtree[3]
|
51
|
+
|
52
|
+
return :dag if has_local_variable_access?(subtree[3])
|
53
|
+
return :dag if subtree[2]
|
54
|
+
|
55
|
+
if iter_impl
|
56
|
+
return_node = iter_impl.find_tree{|st2| st2.node_type == :return}
|
57
|
+
|
58
|
+
if return_node
|
59
|
+
return :dag
|
60
|
+
end
|
61
|
+
end
|
62
|
+
elsif subtree.node_type == :block_pass
|
63
|
+
return :dag
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
impl_tree.walk_tree do |subtree|
|
68
|
+
graph.each_path_from(subtree) do |path|
|
69
|
+
# verify path prohibitive for :linear scope (local variable read after call)
|
70
|
+
has_call = false
|
71
|
+
writes = Set.new
|
72
|
+
|
73
|
+
path.each do |st2|
|
74
|
+
next unless st2
|
75
|
+
if st2.node_type == :call
|
76
|
+
if has_call and st2[1] == nil
|
77
|
+
return :dag
|
78
|
+
end
|
79
|
+
|
80
|
+
writes.clear
|
81
|
+
has_call = true
|
82
|
+
elsif st2.node_type == :iter
|
83
|
+
if has_call and st2[1][1] == nil
|
84
|
+
return :dag
|
85
|
+
end
|
86
|
+
|
87
|
+
writes.clear
|
88
|
+
has_call = true
|
89
|
+
elsif st2.node_type == :lasgn
|
90
|
+
writes << st2[1] # record local writes
|
91
|
+
elsif st2.node_type == :lvar or st2.node_type == :self or
|
92
|
+
st2.node_type == :return or st2.node_type == :yield
|
93
|
+
|
94
|
+
if has_call
|
95
|
+
if st2.node_type == :lvar
|
96
|
+
if writes.include? st2[1]
|
97
|
+
# no problem
|
98
|
+
else
|
99
|
+
# read after call, the scope of this function must be implemented on heap
|
100
|
+
return :dag
|
101
|
+
end
|
102
|
+
else
|
103
|
+
return :dag
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
:linear
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
def has_local_variable_access?(*trees)
|
116
|
+
trees.each do |tree|
|
117
|
+
return false unless tree.kind_of? FastRuby::FastRubySexp
|
118
|
+
|
119
|
+
tree.walk_tree do |subtree|
|
120
|
+
if subtree.node_type == :lvar or
|
121
|
+
subtree.node_type == :self or
|
122
|
+
subtree.node_type == :yield or
|
123
|
+
subtree.node_type == :return or
|
124
|
+
subtree.node_type == :lasgn
|
125
|
+
return true
|
126
|
+
end
|
127
|
+
|
128
|
+
if subtree.node_type == :call
|
129
|
+
if subtree[1] == nil
|
130
|
+
return true
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
false
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -26,16 +26,14 @@ require "fastruby/set_tree"
|
|
26
26
|
require "fastruby/exceptions"
|
27
27
|
require "fastruby/translator/translator_modules"
|
28
28
|
require "fastruby/translator/scope_mode_helper"
|
29
|
+
require "fastruby/modules"
|
29
30
|
require "define_method_handler"
|
31
|
+
require "base64"
|
30
32
|
|
31
33
|
module FastRuby
|
32
34
|
class Context
|
33
|
-
attr_accessor :infer_lvar_map
|
34
|
-
attr_accessor :alt_method_name
|
35
35
|
attr_accessor :locals
|
36
36
|
attr_accessor :options
|
37
|
-
attr_accessor :infer_self
|
38
|
-
attr_accessor :snippet_hash
|
39
37
|
attr_reader :no_cache
|
40
38
|
attr_reader :init_extra
|
41
39
|
attr_reader :extra_code
|
@@ -73,13 +71,17 @@ module FastRuby
|
|
73
71
|
"#{result_var} = #{to_c(tree)};"
|
74
72
|
}.condition{|*x| x.size == 2 }
|
75
73
|
|
76
|
-
define_method_handler(:to_c, :priority => -10000) do |
|
74
|
+
define_method_handler(:to_c, :priority => -10000) do |*x|
|
75
|
+
tree, result_var = x
|
76
|
+
|
77
77
|
raise "undefined translator for node type :#{tree.node_type}"
|
78
78
|
end
|
79
79
|
|
80
80
|
define_method_handler(:initialize_to_c){|*x|}.condition{|*x|false}
|
81
81
|
|
82
|
-
define_translator_for(:call, :priority => 100){ |
|
82
|
+
define_translator_for(:call, :priority => 100){ |*x|
|
83
|
+
tree, result_var = x
|
84
|
+
|
83
85
|
tree[2] = :fastruby_require
|
84
86
|
to_c(tree)
|
85
87
|
}.condition{|*x|
|
@@ -89,13 +91,8 @@ module FastRuby
|
|
89
91
|
define_method_handler(:infer_value, :priority => -1000) do |tree|
|
90
92
|
nil
|
91
93
|
end
|
92
|
-
|
93
|
-
|
94
|
-
groupname = path.split("/").last.split(".").first.to_sym
|
95
|
-
handler_scope(:group => groupname) do
|
96
|
-
require path
|
97
|
-
end
|
98
|
-
end
|
94
|
+
|
95
|
+
FastRuby::Modules.load_all("translator")
|
99
96
|
|
100
97
|
def catch_block(*catchs)
|
101
98
|
old_catch_blocks = @catch_blocks.dup
|
@@ -107,11 +104,11 @@ module FastRuby
|
|
107
104
|
end
|
108
105
|
end
|
109
106
|
|
110
|
-
def initialize(common_func = true)
|
107
|
+
def initialize(common_func = true, inferencer = nil)
|
111
108
|
initialize_to_c
|
112
109
|
|
110
|
+
@inferencer = inferencer
|
113
111
|
@catch_blocks = []
|
114
|
-
@infer_lvar_map = Hash.new
|
115
112
|
@no_cache = false
|
116
113
|
@extra_code = ""
|
117
114
|
@options = {}
|
@@ -409,7 +406,7 @@ module FastRuby
|
|
409
406
|
if (address == 0) {
|
410
407
|
address = malloc(sizeof(void*));
|
411
408
|
}
|
412
|
-
*address = #{alt_method_name};
|
409
|
+
*address = #{@alt_method_name};
|
413
410
|
|
414
411
|
rb_funcall(
|
415
412
|
class_self_,
|
@@ -447,6 +444,12 @@ module FastRuby
|
|
447
444
|
impl_tree = tree[4][1]
|
448
445
|
end
|
449
446
|
|
447
|
+
if "0".respond_to?(:ord)
|
448
|
+
@alt_method_name = "_" + method_name.to_s.gsub("_x_", "_x__x_").gsub(/\W/){|x| "_x_#{x.ord}" } + "_" + rand(10000000000).to_s
|
449
|
+
else
|
450
|
+
@alt_method_name = "_" + method_name.to_s.gsub("_x_", "_x__x_").gsub(/\W/){|x| "_x_#{x[0]}" } + "_" + rand(10000000000).to_s
|
451
|
+
end
|
452
|
+
|
450
453
|
args_tree = original_args_tree.select{|x| x.to_s[0] != ?&}
|
451
454
|
|
452
455
|
initialize_method_structs(original_args_tree)
|
@@ -592,9 +595,28 @@ module FastRuby
|
|
592
595
|
|
593
596
|
end
|
594
597
|
|
595
|
-
require "fastruby/sexp_extension"
|
596
|
-
|
598
|
+
require "fastruby/sexp_extension"
|
599
|
+
|
600
|
+
trs = lambda{|tree|
|
601
|
+
if not tree.respond_to? :node_type
|
602
|
+
next tree
|
603
|
+
elsif tree.node_type == :call
|
604
|
+
mmname = tree[2]
|
605
|
+
next trs.call(tree[1]) || tree[1] if mmname == :infer
|
606
|
+
next fs(:nil) if mmname == :_throw or mmname == :_loop or mmname == :_raise
|
607
|
+
next fs(:nil) if mmname == :== and infer_value(tree)
|
608
|
+
elsif tree.node_type == :iter
|
609
|
+
mmname = tree[1][2]
|
610
|
+
next fs(:nil) if mmname == :_static
|
611
|
+
next fs(:block, trs.call(tree[3]) || tree[3]) if mmname == :_catch
|
612
|
+
end
|
597
613
|
|
614
|
+
tree.map &trs
|
615
|
+
}
|
616
|
+
|
617
|
+
evaluate_tree = tree.transform &trs
|
618
|
+
|
619
|
+
scope_mode = FastRuby::ScopeModeHelper.get_scope_mode(evaluate_tree)
|
598
620
|
ret = "VALUE #{@alt_method_name || method_name}(#{options[:main] ? "VALUE self" : strargs}) {
|
599
621
|
#{validate_arguments_code}
|
600
622
|
|
@@ -746,7 +768,7 @@ end
|
|
746
768
|
extra_code << ret
|
747
769
|
|
748
770
|
"
|
749
|
-
static VALUE dummy_#{
|
771
|
+
static VALUE dummy_#{@alt_method_name}_#{rand(1000000000000000000000000000000000)}(VALUE a) {
|
750
772
|
return Qnil;
|
751
773
|
}
|
752
774
|
"
|
@@ -783,16 +805,10 @@ end
|
|
783
805
|
end
|
784
806
|
|
785
807
|
def infer_type(recv)
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
elsif recv[0] == :lvar
|
791
|
-
@infer_lvar_map[recv[1]]
|
792
|
-
elsif recv[0] == :self
|
793
|
-
@infer_self
|
794
|
-
elsif recv[0] == :str or recv[0] == :lit
|
795
|
-
recv[1].class
|
808
|
+
array = @inferencer.infer(recv).to_a
|
809
|
+
|
810
|
+
if array.size == 1
|
811
|
+
array[0]
|
796
812
|
else
|
797
813
|
nil
|
798
814
|
end
|
@@ -813,12 +829,6 @@ end
|
|
813
829
|
|
814
830
|
if mname == :infer
|
815
831
|
return to_c(recv)
|
816
|
-
elsif mname == :lvar_type
|
817
|
-
lvar_name = args[1][1] || args[1][2]
|
818
|
-
lvar_type = eval(args[2][1].to_s)
|
819
|
-
|
820
|
-
@infer_lvar_map[lvar_name] = lvar_type
|
821
|
-
return "Qnil"
|
822
832
|
elsif mname == :block_given?
|
823
833
|
return "plocals->block_function_address == 0 ? Qfalse : Qtrue"
|
824
834
|
elsif mname == :inline_c
|
@@ -1154,8 +1164,6 @@ fastruby_local_next:
|
|
1154
1164
|
"
|
1155
1165
|
else
|
1156
1166
|
|
1157
|
-
require "base64"
|
1158
|
-
|
1159
1167
|
init_extra << "
|
1160
1168
|
|
1161
1169
|
{
|
@@ -1181,13 +1189,18 @@ fastruby_local_next:
|
|
1181
1189
|
name
|
1182
1190
|
end
|
1183
1191
|
|
1184
|
-
def encode_address(recvtype,signature,mname,call_tree,inference_complete,convention_global_name = nil)
|
1192
|
+
def encode_address(recvtype,signature,mname,call_tree,inference_complete,convention_global_name = nil, is_block_call = false)
|
1185
1193
|
name = self.add_global_name("void*", 0);
|
1186
1194
|
address_name = self.add_global_name("void**", 0);
|
1187
1195
|
@last_address_name = address_name
|
1188
1196
|
cfunc_address_name = self.add_global_name("void**", 0);
|
1189
1197
|
cfunc_real_address_name = self.add_global_name("void*", 0);
|
1190
1198
|
tree_pointer_name = self.add_global_name("VALUE*", 0);
|
1199
|
+
|
1200
|
+
if call_tree[3].select{|st| st.respond_to?(:node_type) ? st[0] == :block_pass : false}
|
1201
|
+
is_block_call = true
|
1202
|
+
end
|
1203
|
+
|
1191
1204
|
args_tree = call_tree[3].reject{|st| st.respond_to?(:node_type) ? st[0] == :block_pass : false}
|
1192
1205
|
method_tree = nil
|
1193
1206
|
|
@@ -1280,9 +1293,9 @@ fastruby_local_next:
|
|
1280
1293
|
#{@block_struct} *pblock;
|
1281
1294
|
pblock = (typeof(pblock))( ((VALUE*)method_arguments)[3] );
|
1282
1295
|
last_expression = rb_iterate(
|
1283
|
-
#{anonymous_function{|
|
1296
|
+
#{anonymous_function{|name_|
|
1284
1297
|
"
|
1285
|
-
static VALUE #{
|
1298
|
+
static VALUE #{name_} (VALUE data) {
|
1286
1299
|
VALUE* method_arguments = (VALUE*)data;
|
1287
1300
|
return rb_funcall2(((VALUE*)method_arguments)[2], #{intern_num mname.to_sym}, ((int*)method_arguments)[0], ((VALUE**)method_arguments)[1]);
|
1288
1301
|
}
|
@@ -1290,9 +1303,9 @@ fastruby_local_next:
|
|
1290
1303
|
}},
|
1291
1304
|
(VALUE)method_arguments,
|
1292
1305
|
|
1293
|
-
#{anonymous_function{|
|
1306
|
+
#{anonymous_function{|name_|
|
1294
1307
|
"
|
1295
|
-
static VALUE #{
|
1308
|
+
static VALUE #{name_} (VALUE arg_, VALUE param, int argc, VALUE* argv) {
|
1296
1309
|
|
1297
1310
|
VALUE arg;
|
1298
1311
|
#{
|
@@ -1338,7 +1351,7 @@ fastruby_local_next:
|
|
1338
1351
|
cfunc_value_cast = (["VALUE"]*args_tree.size).join(",")
|
1339
1352
|
cfunc_wrapper = anonymous_function{ |funcname| "
|
1340
1353
|
static VALUE #{funcname}(VALUE self, void* block,void* frame, int argc, VALUE* argv){
|
1341
|
-
|
1354
|
+
return rb_vm_call(ruby_current_thread, self, #{intern_num mname.to_sym}, argc, argv, #{cfunc_real_address_name});
|
1342
1355
|
}
|
1343
1356
|
"
|
1344
1357
|
}
|
@@ -1370,55 +1383,33 @@ fastruby_local_next:
|
|
1370
1383
|
if (1) {
|
1371
1384
|
*default_address = 0;
|
1372
1385
|
|
1373
|
-
#
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
NODE* body = rb_method_node(recvtype,#{intern_num mname});
|
1378
|
-
if (body != 0) {
|
1379
|
-
if (nd_type(body) == NODE_CFUNC) {
|
1380
|
-
if (body->nd_argc == #{args_tree.size-1}) {
|
1381
|
-
*default_address = #{cfunc_wrapper};
|
1382
|
-
#{cfunc_real_address_name} = (void*)body->nd_cfnc;
|
1383
|
-
} else if (body->nd_argc == -1) {
|
1384
|
-
*default_address = #{cfunc_wrapper_1};
|
1385
|
-
#{cfunc_real_address_name} = (void*)body->nd_cfnc;
|
1386
|
-
} else if (body->nd_argc == -2) {
|
1387
|
-
*default_address = #{cfunc_wrapper_2};
|
1388
|
-
#{cfunc_real_address_name} = (void*)body->nd_cfnc;
|
1389
|
-
}
|
1390
|
-
}
|
1391
|
-
}
|
1392
|
-
#endif
|
1393
|
-
#ifdef RUBY_1_9
|
1386
|
+
#{
|
1387
|
+
if RUBY_VERSION == "1.9.2"
|
1388
|
+
|
1389
|
+
"
|
1394
1390
|
rb_method_entry_t* me = rb_method_entry(recvtype,#{intern_num mname});
|
1395
1391
|
if (me != 0) {
|
1396
1392
|
rb_method_definition_t* def = me->def;
|
1397
1393
|
|
1398
1394
|
if (def->type == VM_METHOD_TYPE_CFUNC) {
|
1399
|
-
|
1400
|
-
|
1401
|
-
#{cfunc_real_address_name} = (void*)def->body.cfunc.func;
|
1402
|
-
} else if (def->body.cfunc.argc == -1) {
|
1403
|
-
*default_address = #{cfunc_wrapper_1};
|
1404
|
-
#{cfunc_real_address_name} = (void*)def->body.cfunc.func;
|
1405
|
-
} else if (def->body.cfunc.argc == -2) {
|
1406
|
-
*default_address = #{cfunc_wrapper_2};
|
1407
|
-
#{cfunc_real_address_name} = (void*)def->body.cfunc.func;
|
1408
|
-
}
|
1395
|
+
*default_address = #{cfunc_wrapper};
|
1396
|
+
#{cfunc_real_address_name} = (void*)me;
|
1409
1397
|
}
|
1410
1398
|
}
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1399
|
+
"
|
1400
|
+
end
|
1401
|
+
}
|
1402
|
+
if (default_address != 0) {
|
1403
|
+
if (recvtype != Qnil) {
|
1404
|
+
rb_funcall(
|
1405
|
+
recvtype,
|
1406
|
+
#{intern_num :register_method_value},
|
1407
|
+
3,
|
1408
|
+
#{literal_value mname},
|
1409
|
+
PTR2NUM(default_id),
|
1410
|
+
PTR2NUM(default_address)
|
1411
|
+
);
|
1412
|
+
}
|
1422
1413
|
}
|
1423
1414
|
}
|
1424
1415
|
return Qnil;
|
@@ -1473,14 +1464,18 @@ fastruby_local_next:
|
|
1473
1464
|
*default_address = 0;
|
1474
1465
|
}
|
1475
1466
|
#{cfunc_address_name} = default_address;
|
1476
|
-
|
1477
|
-
#{update_cfunc_method}();
|
1478
|
-
rb_iterate(#{anonymous_function{|funcname|
|
1479
|
-
"static VALUE #{funcname}(VALUE recv) {
|
1480
|
-
return rb_funcall(recv, #{intern_num :observe}, 1, #{literal_value(alt_method_name + "#" + cfunc_address_name)});
|
1481
|
-
}
|
1467
|
+
#{unless is_block_call
|
1482
1468
|
"
|
1483
|
-
|
1469
|
+
#{update_cfunc_method}();
|
1470
|
+
rb_iterate(#{anonymous_function{|funcname|
|
1471
|
+
"static VALUE #{funcname}(VALUE recv) {
|
1472
|
+
return rb_funcall(recv, #{intern_num :observe}, 1, #{literal_value(@alt_method_name + "#" + cfunc_address_name)});
|
1473
|
+
}
|
1474
|
+
"
|
1475
|
+
}},fastruby_method,#{update_cfunc_method},Qnil);
|
1476
|
+
"
|
1477
|
+
end
|
1478
|
+
}
|
1484
1479
|
|
1485
1480
|
if (address==0) {
|
1486
1481
|
address = malloc(sizeof(void*));
|