Skip to content

Commit

Permalink
RJIT: Fix unwanted shadowing in set_local_type
Browse files Browse the repository at this point in the history
local_idx should not be overwritten.
  • Loading branch information
k0kubun committed Dec 21, 2023
1 parent ffa5f16 commit 68bcca4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions bootstraptest/test_rjit.rb
Expand Up @@ -42,3 +42,17 @@ def entry
entry
}

# Updating local type in Context
assert_normal_exit %q{
def foo(flag, object)
klass = if flag
object
end
klass ||= object
return klass.new
end
foo(false, Object)
foo(true, Object)
}
6 changes: 3 additions & 3 deletions lib/ruby_vm/rjit/context.rb
Expand Up @@ -264,9 +264,9 @@ def set_local_type(local_idx, local_type)
# noop
in MapToSelf
# noop
in MapToLocal[local_idx]
if stack_idx == local_idx
self.temp_types[stack_idx] = self.local_types[local_idx];
in MapToLocal[temp_local_idx]
if stack_idx == temp_local_idx
self.temp_types[stack_idx] = self.local_types[temp_local_idx]
self.temp_mapping[stack_idx] = MapToStack
else
# noop
Expand Down

0 comments on commit 68bcca4

Please sign in to comment.