Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dc9ce32
test/ruby/test_optimization.rb: fix compile kwarg
Feb 14, 2018
7606806
compile.c: drop freezestring insn on String#-@
Feb 14, 2018
8df47f8
configure.ac: Use `pthread_create` to determine if pthread is available
mame Feb 15, 2018
50700c4
thread_pthread.c: Use `getpagesize()` when `pthread_attr_getguardsize…
mame Feb 15, 2018
b4b4b94
gc.c: force STACK_GROW_DIRECTION for emscripten
mame Feb 15, 2018
0efd8bb
test/io/console/test_io_console.rb (test_oflush): Avoid race condition
mame Feb 15, 2018
9a9a4e8
Benchmarks for Array#values_at
nobu Feb 15, 2018
41e9e19
Array#values_at optimization
nobu Feb 15, 2018
d6db2d9
Avoid using `@` in macro substitution that confuses FreeBSD make
knu Feb 15, 2018
80c850e
Iterate over the catch table, and mark iseq in the table
tenderlove Jan 12, 2018
881ea05
Disasm instruction sequences and mark things managed by the GC
tenderlove Jan 12, 2018
969ccfd
Only add objects to the compile time mark array
tenderlove Jan 12, 2018
aaaffa4
Only de-reference when we need to check the object type
tenderlove Jan 17, 2018
5fa1733
Private function should be static, no return in `void`
tenderlove Jan 18, 2018
d3f6c51
CDHASH needs to stay in the mark array until compilation finishes
tenderlove Jan 18, 2018
9bed499
Fix bug when marking iseq before instruction have been translated
tenderlove Jan 19, 2018
8aeb2b8
Directly mark `once` instruction values
tenderlove Feb 2, 2018
65c9fc9
stop using a mark array
tenderlove Feb 2, 2018
6649dc4
Set a compile time flag so iseq marking knows about markables
tenderlove Feb 5, 2018
d6ca1ce
Introduce TS_ISE operand
tenderlove Feb 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stop using a mark array
  • Loading branch information
tenderlove committed Feb 15, 2018
commit 65c9fc93a9cef2f41ccb74e908abe8d543044907
5 changes: 3 additions & 2 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -8644,7 +8644,8 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
dump_body.is_entries = NULL;
dump_body.ci_entries = ibf_dump_ci_entries(dump, iseq);
dump_body.cc_entries = NULL;
dump_body.mark_ary = ISEQ_FLIP_CNT(iseq);
dump_body.variable.coverage = Qnil;
dump_body.variable.original_iseq = Qnil;

return ibf_dump_write(dump, &dump_body, sizeof(dump_body));
}
Expand Down Expand Up @@ -8676,7 +8677,7 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
load_body->ci_kw_size = body->ci_kw_size;
load_body->insns_info.size = body->insns_info.size;

RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
iseq_mark_ary_create(iseq, (int)body->variable.flip_count);

{
VALUE realpath = Qnil, path = ibf_load_object(load, body->location.pathobj);
Expand Down
5 changes: 3 additions & 2 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ rb_iseq_mark(const rb_iseq_t *iseq)
const struct rb_iseq_constant_body *body = iseq->body;

rb_iseq_each_value(iseq, each_insn_value, NULL);
RUBY_MARK_UNLESS_NULL(body->mark_ary);
rb_gc_mark(body->variable.coverage);
rb_gc_mark(body->variable.original_iseq);
rb_gc_mark(body->location.label);
rb_gc_mark(body->location.base_label);
rb_gc_mark(body->location.pathobj);
Expand Down Expand Up @@ -427,7 +428,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
if (iseq != iseq->body->local_iseq) {
RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
}
RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, iseq_mark_ary_create(0));
iseq_mark_ary_create(iseq, 0);

ISEQ_COMPILE_DATA_ALLOC(iseq);
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err_info);
Expand Down
37 changes: 13 additions & 24 deletions iseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,48 @@ rb_call_info_kw_arg_bytes(int keyword_len)
return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
}

enum iseq_mark_ary_index {
ISEQ_MARK_ARY_COVERAGE,
ISEQ_MARK_ARY_FLIP_CNT,
ISEQ_MARK_ARY_ORIGINAL_ISEQ,
ISEQ_MARK_ARY_INITIAL_SIZE
};

static inline VALUE
iseq_mark_ary_create(int flip_cnt)
static inline void
iseq_mark_ary_create(rb_iseq_t *iseq, int flip_cnt)
{
VALUE ary = rb_ary_tmp_new(ISEQ_MARK_ARY_INITIAL_SIZE);
rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_COVERAGE */
rb_ary_push(ary, INT2FIX(flip_cnt)); /* ISEQ_MARK_ARY_FLIP_CNT */
rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_ORIGINAL_ISEQ */
return ary;
RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, Qnil);
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil);
iseq->body->variable.flip_count = flip_cnt;
}

#define ISEQ_MARK_ARY(iseq) (iseq)->body->mark_ary

#define ISEQ_COVERAGE(iseq) RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE)
#define ISEQ_COVERAGE_SET(iseq, cov) RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE, cov)
#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
#define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
#define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)

#define ISEQ_FLIP_CNT(iseq) FIX2INT(RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT))
#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count

static inline int
ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
{
int cnt = ISEQ_FLIP_CNT(iseq);
RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT, INT2FIX(cnt+1));
int cnt = iseq->body->variable.flip_count;
iseq->body->variable.flip_count += 1;
return cnt;
}

static inline VALUE *
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
{
VALUE str = RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ);
VALUE str = iseq->body->variable.original_iseq;
if (RTEST(str)) return (VALUE *)RSTRING_PTR(str);
return NULL;
}

static inline void
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
{
RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ, Qnil);
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil);
}

static inline VALUE *
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
{
VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ, str);
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, str);
return (VALUE *)RSTRING_PTR(str);
}

Expand Down
6 changes: 5 additions & 1 deletion vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ struct rb_iseq_constant_body {
*/
struct rb_call_cache *cc_entries; /* size is ci_size = ci_kw_size */

VALUE mark_ary; /* Array: includes operands which should be GC marked */
struct {
rb_num_t flip_count;
VALUE coverage;
VALUE original_iseq;
} variable;

unsigned int local_table_size;
unsigned int is_size;
Expand Down