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
Introduce TS_ISE operand
The `once` instruction uses an "inline storage entry".  This commit
introduces an inline storage entry specific operand.  Adding this
operand allows us to remove conditionals based on instruction type.
  • Loading branch information
tenderlove committed Feb 15, 2018
commit d6ca1ce34321552a73cef70060d51385384a37ed
16 changes: 14 additions & 2 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2052,9 +2052,17 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
}
generated_iseq[code_index + 1 + j] = (VALUE)ic;
if (BIN(once) == insn || BIN(trace_once) == insn) {
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
}
case TS_ISE: /* inline storage entry */
{
unsigned int ic_index = FIX2UINT(operands[j]);
IC ic = (IC)&iseq->body->is_entries[ic_index];
if (UNLIKELY(ic_index >= iseq->body->is_size)) {
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
}
generated_iseq[code_index + 1 + j] = (VALUE)ic;
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
}
case TS_CALLINFO: /* call info */
Expand Down Expand Up @@ -7299,6 +7307,7 @@ insn_data_to_s_detail(INSN *iobj)
break;
}
case TS_IC: /* inline cache */
case TS_ISE: /* inline storage entry */
rb_str_catf(str, "<ic:%d>", FIX2INT(OPERAND_AT(iobj, j)));
break;
case TS_CALLINFO: /* call info */
Expand Down Expand Up @@ -7684,6 +7693,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
break;
case TS_IC:
case TS_ISE:
argv[j] = op;
if (NUM2UINT(op) >= iseq->body->is_size) {
iseq->body->is_size = NUM2INT(op) + 1;
Expand Down Expand Up @@ -8289,6 +8299,7 @@ ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
code[code_index] = (VALUE)ibf_dump_iseq(dump, (const rb_iseq_t *)op);
break;
case TS_IC:
case TS_ISE:
{
unsigned int i;
for (i=0; i<iseq->body->is_size; i++) {
Expand Down Expand Up @@ -8354,6 +8365,7 @@ ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, const struct r
code[code_index] = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op);
break;
case TS_IC:
case TS_ISE:
code[code_index] = (VALUE)&is_entries[(int)op];
break;
case TS_CALLINFO:
Expand Down
4 changes: 2 additions & 2 deletions insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -971,11 +971,11 @@ setinlinecache
/* run iseq only once */
DEFINE_INSN
once
(ISEQ iseq, IC ic)
(ISEQ iseq, ISE ise)
()
(VALUE val)
{
val = vm_once_dispatch(ec, iseq, ic);
val = vm_once_dispatch(ec, iseq, ise);
}

/* case dispatcher, jump by table if possible */
Expand Down
8 changes: 5 additions & 3 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ iseq_extract_values(const VALUE *code, size_t pos, iseq_value_itr_t * func, void
}
break;
}
case TS_IC:
if (BIN(once) == insn || BIN(trace_once) == insn) {
case TS_ISE:
{
union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)code[pos + op_no + 1];
if (is->once.value) {
func(data, is->once.value);
}
break;
}
break;
default:
break;
}
Expand Down Expand Up @@ -1717,6 +1717,7 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break;

case TS_IC:
case TS_ISE:
ret = rb_sprintf("<is:%"PRIdPTRDIFF">", (union iseq_inline_storage_entry *)op - iseq->body->is_entries);
break;

Expand Down Expand Up @@ -2460,6 +2461,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
}
break;
case TS_IC:
case TS_ISE:
{
union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)*seq;
rb_ary_push(ary, INT2FIX(is - iseq->body->is_entries));
Expand Down
1 change: 1 addition & 0 deletions tool/ruby_vm/models/typemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"GENTRY" => %w[G TS_GENTRY],
"IC" => %w[K TS_IC],
"ID" => %w[I TS_ID],
"ISE" => %w[T TS_ISE],
"ISEQ" => %w[S TS_ISEQ],
"OFFSET" => %w[O TS_OFFSET],
"VALUE" => %w[V TS_VALUE],
Expand Down
1 change: 1 addition & 0 deletions vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ enum vm_svar_index {

/* inline cache */
typedef struct iseq_inline_cache_entry *IC;
typedef union iseq_inline_storage_entry *ISE;
typedef struct rb_call_info *CALL_INFO;
typedef struct rb_call_cache *CALL_CACHE;

Expand Down
3 changes: 1 addition & 2 deletions vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3285,11 +3285,10 @@ vm_ic_update(IC ic, VALUE val, const VALUE *reg_ep)
}

static VALUE
vm_once_dispatch(rb_execution_context_t *ec, ISEQ iseq, IC ic)
vm_once_dispatch(rb_execution_context_t *ec, ISEQ iseq, ISE is)
{
rb_thread_t *th = rb_ec_thread_ptr(ec);
rb_thread_t *const RUNNING_THREAD_ONCE_DONE = (rb_thread_t *)(0x1);
union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)ic;

again:
if (is->once.running_thread == RUNNING_THREAD_ONCE_DONE) {
Expand Down