Skip to content

Commit

Permalink
jit strfromcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ugexe committed Jun 9, 2019
1 parent b55658b commit 6053919
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/jit/core_templates.expr
Expand Up @@ -2247,6 +2247,12 @@
(carg (tc) ptr)
(carg $1 ptr)) int_sz))

(template: strfromcodes
(call (^func &MVM_unicode_codepoints_to_nfg_string)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) ptr_sz))

(template: eqatim_s
(call (^func &MVM_string_equal_at_ignore_mark)
(arglist
Expand Down
9 changes: 9 additions & 0 deletions src/jit/graph.c
Expand Up @@ -392,6 +392,7 @@ static void * op_to_func(MVMThreadContext *tc, MVMint16 opcode) {
case MVM_OP_decodeconf: return MVM_string_decode_from_buf_config;
case MVM_OP_decoderepconf: return MVM_string_decode_from_buf_config;
case MVM_OP_strfromname: return MVM_unicode_string_from_name;
case MVM_OP_strfromcodes: return MVM_unicode_codepoints_to_nfg_string;
case MVM_OP_callercode: return MVM_frame_caller_code;
case MVM_OP_stat: return MVM_file_stat;
case MVM_OP_lstat: return MVM_file_stat;
Expand Down Expand Up @@ -3839,6 +3840,14 @@ static MVMint32 consume_ins(MVMThreadContext *tc, MVMJitGraph *jg,
jg_append_call_c(tc, jg, op_to_func(tc, op), 2, args, MVM_JIT_RV_PTR, dst);
break;
}
case MVM_OP_strfromcodes: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 src = ins->operands[1].reg.orig;
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, { MVM_JIT_INTERP_TC } },
{ MVM_JIT_REG_VAL, { src } } };
jg_append_call_c(tc, jg, op_to_func(tc, op), 2, args, MVM_JIT_RV_PTR, dst);
break;
}
case MVM_OP_callercode: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, { MVM_JIT_INTERP_TC } } };
Expand Down

3 comments on commit 6053919

@lizmat
Copy link
Contributor

@lizmat lizmat commented on 6053919 Jun 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ perl6 -e 'use nqp; my uint32 @a = 65..127; nqp::strfromcodes(nqp::slice(@a,10,13)) for ^57251'
MVMArray: Slice index out of bounds

57251 is the first value on which this happens, 57250 works ok (well, for me)

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some extra debug info to the exception gives MVMArray: Slice index out of bounds: start = 10, end = 13, elems = 0, total_elems = 0 for use nqp; my uint32 @a = 65..127; nqp::strfromcodes(nqp::slice(@a,10,13)) for ^100000.

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timo reverting afd8f93 fixes the problem.

Please sign in to comment.