Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5642279

Browse files
authored
Malloc branch entries (#112)
* Malloc branch entries * Add ASM comment for stack overflow check * WIP * Fix branch GC code. Add rb_darray_remove_unordered(). * Fix block end_pos after branch rewriting. Remove dst_patched bits.
1 parent e42fa19 commit 5642279

File tree

5 files changed

+176
-152
lines changed

5 files changed

+176
-152
lines changed

darray.h

+10
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,20 @@
5151
1 \
5252
) : 0)
5353

54+
// Last element of the array
55+
//
56+
#define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
57+
5458
// Remove the last element of the array.
5559
//
5660
#define rb_darray_pop_back(ary) ((ary)->meta.size--)
5761

62+
// Remove element at idx and replace it by the last element
63+
#define rb_darray_remove_unordered(ary, idx) do { \
64+
rb_darray_set(ary, idx, rb_darray_back(ary)); \
65+
rb_darray_pop_back(ary); \
66+
} while (0);
67+
5868
// Iterate over items of the array in a for loop
5969
//
6070
#define rb_darray_foreach(ary, idx_name, elem_ptr_var) \

yjit_codegen.c

+9
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ jit_jump_to_next_insn(jitstate_t *jit, const ctx_t *current_context)
300300

301301
// Generate the jump instruction
302302
gen_direct_jump(
303+
jit->block,
303304
&reset_depth,
304305
jump_block
305306
);
@@ -721,6 +722,7 @@ jit_chain_guard(enum jcc_kinds jcc, jitstate_t *jit, const ctx_t *ctx, uint8_t d
721722
deeper.chain_depth++;
722723

723724
gen_branch(
725+
jit->block,
724726
ctx,
725727
(blockid_t) { jit->iseq, jit->insn_idx },
726728
&deeper,
@@ -1333,6 +1335,7 @@ gen_branchif(jitstate_t* jit, ctx_t* ctx)
13331335

13341336
// Generate the branch instructions
13351337
gen_branch(
1338+
jit->block,
13361339
ctx,
13371340
jump_block,
13381341
ctx,
@@ -1386,6 +1389,7 @@ gen_branchunless(jitstate_t* jit, ctx_t* ctx)
13861389

13871390
// Generate the branch instructions
13881391
gen_branch(
1392+
jit->block,
13891393
ctx,
13901394
jump_block,
13911395
ctx,
@@ -1411,6 +1415,7 @@ gen_jump(jitstate_t* jit, ctx_t* ctx)
14111415

14121416
// Generate the jump instruction
14131417
gen_direct_jump(
1418+
jit->block,
14141419
ctx,
14151420
jump_block
14161421
);
@@ -1726,6 +1731,7 @@ gen_oswb_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
17261731

17271732
// Stack overflow check
17281733
// #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin)
1734+
ADD_COMMENT(cb, "stack overflow check");
17291735
lea(cb, REG0, ctx_sp_opnd(ctx, sizeof(VALUE) * (num_locals + iseq->body->stack_max) + sizeof(rb_control_frame_t)));
17301736
cmp(cb, REG_CFP, REG0);
17311737
jle_ptr(cb, COUNTED_EXIT(side_exit, oswb_se_cf_overflow));
@@ -1802,6 +1808,7 @@ gen_oswb_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
18021808

18031809
// Write the JIT return address on the callee frame
18041810
gen_branch(
1811+
jit->block,
18051812
ctx,
18061813
return_block,
18071814
&return_ctx,
@@ -1818,6 +1825,7 @@ gen_oswb_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
18181825

18191826
// Directly jump to the entry point of the callee
18201827
gen_direct_jump(
1828+
jit->block,
18211829
&callee_ctx,
18221830
(blockid_t){ iseq, 0 }
18231831
);
@@ -2049,6 +2057,7 @@ gen_opt_getinlinecache(jitstate_t *jit, ctx_t *ctx)
20492057
// Jump over the code for filling the cache
20502058
uint32_t jump_idx = jit_next_insn_idx(jit) + (int32_t)jump_offset;
20512059
gen_direct_jump(
2060+
jit->block,
20522061
ctx,
20532062
(blockid_t){ .iseq = jit->iseq, .idx = jump_idx }
20542063
);

0 commit comments

Comments
 (0)