зеркало из https://github.com/github/ruby.git
YJIT: Save PC on rb_str_concat (#7586)
[Bug #19483] Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
This commit is contained in:
Родитель
8286544dc5
Коммит
b4e438d8aa
|
@ -1216,6 +1216,25 @@ class TestYJIT < Test::Unit::TestCase
|
|||
RUBY
|
||||
end
|
||||
|
||||
def test_str_concat_encoding_mismatch
|
||||
assert_compiles(<<~'RUBY', result: "incompatible character encodings: ASCII-8BIT and EUC-JP")
|
||||
def bar(a, b)
|
||||
a << b
|
||||
rescue => e
|
||||
e.message
|
||||
end
|
||||
|
||||
def foo(a, b, h)
|
||||
h[nil]
|
||||
bar(a, b) # Ruby call, not set cfp->pc
|
||||
end
|
||||
|
||||
h = Hash.new { nil }
|
||||
foo("\x80".b, "\xA1A1".force_encoding("EUC-JP"), h)
|
||||
foo("\x80".b, "\xA1A1".force_encoding("EUC-JP"), h)
|
||||
RUBY
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def code_gc_helpers
|
||||
|
|
|
@ -4479,8 +4479,10 @@ fn jit_rb_str_concat(
|
|||
// Guard that the concat argument is a string
|
||||
guard_object_is_string(ctx, asm, ctx.stack_opnd(0), StackOpnd(0), side_exit);
|
||||
|
||||
// Guard buffers from GC since rb_str_buf_append may allocate.
|
||||
gen_save_sp(asm, ctx);
|
||||
// Guard buffers from GC since rb_str_buf_append may allocate. During the VM lock on GC,
|
||||
// other Ractors may trigger global invalidation, so we need ctx.clear_local_types().
|
||||
// PC is used on errors like Encoding::CompatibilityError raised by rb_str_buf_append.
|
||||
jit_prepare_routine_call(jit, ctx, asm);
|
||||
|
||||
let concat_arg = ctx.stack_pop(1);
|
||||
let recv = ctx.stack_pop(1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче