Skip to content

Commit 92b4cdd

Browse files
committed
[GR-17457] Use copy_captured_locals for Truffle::POSIX
PullRequest: truffleruby/4241
2 parents fa293ff + 1c5f314 commit 92b4cdd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
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!
@@ -140,7 +140,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
140140
result = Primitive.thread_run_blocking_nfi_system_call(bound_func, args)
141141
end while Primitive.is_a?(result, Integer) and result == -1 and Errno.errno == EINTR
142142
else
143-
result = bound_func.call(*args)
143+
result = Primitive.interop_execute(bound_func, args)
144144
end
145145

146146
if return_type == :string
@@ -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)