Skip to content

Commit

Permalink
[GR-17457] Use copy_captured_locals for Truffle::POSIX
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4241
  • Loading branch information
eregon committed Apr 15, 2024
2 parents fa293ff + 1c5f314 commit 92b4cdd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/ruby/truffleruby/core/posix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
parsed_sig = Primitive.interop_eval_nfi "(#{nfi_args_types.join(',')}):#{nfi_return_type}"
bound_func = parsed_sig.bind(func)

on.define_singleton_method method_name, -> *args do
method_body = Truffle::Graal.copy_captured_locals -> *args do
string_args.each do |i|
str = args.fetch(i)
# TODO CS 14-Nov-17 this involves copying to a Java byte[], and then NFI will copy it again!
Expand All @@ -140,7 +140,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
result = Primitive.thread_run_blocking_nfi_system_call(bound_func, args)
end while Primitive.is_a?(result, Integer) and result == -1 and Errno.errno == EINTR
else
result = bound_func.call(*args)
result = Primitive.interop_execute(bound_func, args)
end

if return_type == :string
Expand All @@ -164,6 +164,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,

result
end
on.define_singleton_method method_name, method_body
else
on.define_singleton_method method_name, -> * do
raise NotImplementedError, "#{native_name} is not available"
Expand Down

0 comments on commit 92b4cdd

Please sign in to comment.