summaryrefslogtreecommitdiff
path: root/yjit/src/codegen.rs
diff options
context:
space:
mode:
authorNARUSE, Yui <[email protected]>2023-03-07 19:48:32 +0900
committerNARUSE, Yui <[email protected]>2023-03-07 19:48:32 +0900
commit4d75035e1762a23d38c5192b30bb47f40b752bee (patch)
tree192c44ecea4b99cf57f82e91e3a71881debc0ed2 /yjit/src/codegen.rs
parentf1cde05d99898f491c8e302ae74029468fdb6eb9 (diff)
merge revision(s) c178926fbe879045fa711444a1fd9e906af23e3b,a4b7ec12298c78392797e5ba7704076550e4f100: [Backport #19444]
YJIT: jit_prepare_routine_call() for String#+@ missing We saw SEGVs due to this when running with StackProf, which needs a correct PC for RUBY_INTERNAL_EVENT_NEWOBJ, the same event used for ObjectSpace allocation tracing. [Bug #19444] --- test/ruby/test_yjit.rb | 27 +++++++++++++++++++++++++++ yjit/src/codegen.rs | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) YJIT: Fix false assumption that String#+@ => ::String Could return a subclass. [Bug #19444] --- test/ruby/test_yjit.rb | 17 +++++++++++++++++ yjit/src/codegen.rs | 10 +++++++--- 2 files changed, 24 insertions(+), 3 deletions(-)
Diffstat (limited to 'yjit/src/codegen.rs')
-rw-r--r--yjit/src/codegen.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 2b2543b37a..8c5b413286 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -4047,17 +4047,24 @@ fn jit_rb_int_equal(
/// If string is frozen, duplicate it to get a non-frozen string. Otherwise, return it.
fn jit_rb_str_uplus(
- _jit: &mut JITState,
+ jit: &mut JITState,
ctx: &mut Context,
asm: &mut Assembler,
_ocb: &mut OutlinedCb,
_ci: *const rb_callinfo,
_cme: *const rb_callable_method_entry_t,
_block: Option<IseqPtr>,
- _argc: i32,
+ argc: i32,
_known_recv_class: *const VALUE,
) -> bool
{
+ if argc != 0 {
+ return false;
+ }
+
+ // We allocate when we dup the string
+ jit_prepare_routine_call(jit, ctx, asm);
+
asm.comment("Unary plus on string");
let recv_opnd = asm.load(ctx.stack_pop(1));
let flags_opnd = asm.load(Opnd::mem(64, recv_opnd, RUBY_OFFSET_RBASIC_FLAGS));
@@ -4065,8 +4072,8 @@ fn jit_rb_str_uplus(
let ret_label = asm.new_label("stack_ret");
- // We guard for the receiver being a ::String, so the return value is too
- let stack_ret = ctx.stack_push(Type::CString);
+ // String#+@ can only exist on T_STRING
+ let stack_ret = ctx.stack_push(Type::TString);
// If the string isn't frozen, we just return it.
asm.mov(stack_ret, recv_opnd);