Skip to content

Commit 1c5f314

Browse files
committed
Use copy_captured_locals for Truffle::POSIX
* This way all the local variables outside the lambda are replaced by constants in the AST, making the compilation graph smaller and faster.
1 parent e7c8015 commit 1c5f314

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/ruby/truffleruby/core/posix.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
128128
parsed_sig = Primitive.interop_eval_nfi "(#{nfi_args_types.join(',')}):#{nfi_return_type}"
129129
bound_func = parsed_sig.bind(func)
130130

131-
on.define_singleton_method method_name, -> *args do
131+
method_body = Truffle::Graal.copy_captured_locals -> *args do
132132
string_args.each do |i|
133133
str = args.fetch(i)
134134
# TODO CS 14-Nov-17 this involves copying to a Java byte[], and then NFI will copy it again!
@@ -164,6 +164,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
164164

165165
result
166166
end
167+
on.define_singleton_method method_name, method_body
167168
else
168169
on.define_singleton_method method_name, -> * do
169170
raise NotImplementedError, "#{native_name} is not available"

0 commit comments

Comments
 (0)