зеркало из https://github.com/github/ruby.git
Enable USE_ISEQ_NODE_ID by default
... which is formally called EXPERIMENTAL_ISEQ_NODE_ID.
See also ff69ef27b0
.
https://bugs.ruby-lang.org/issues/17930
This commit is contained in:
Родитель
dfba87cd62
Коммит
0a36cab1b5
4
ast.c
4
ast.c
|
@ -254,7 +254,7 @@ ast_node_type(rb_execution_context_t *ec, VALUE self)
|
|||
return rb_sym_intern_ascii_cstr(node_type_to_str(data->node));
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef DEBUG_ISEQ_NODE_ID
|
||||
static VALUE
|
||||
ast_node_node_id(VALUE self)
|
||||
{
|
||||
|
@ -725,7 +725,7 @@ Init_ast(void)
|
|||
rb_mAST = rb_define_module_under(rb_cRubyVM, "AbstractSyntaxTree");
|
||||
rb_cNode = rb_define_class_under(rb_mAST, "Node", rb_cObject);
|
||||
rb_undef_alloc_func(rb_cNode);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef DEBUG_ISEQ_NODE_ID
|
||||
rb_define_method(rb_cNode, "node_id", ast_node_node_id, 0);
|
||||
#endif
|
||||
}
|
||||
|
|
10
compile.c
10
compile.c
|
@ -2216,12 +2216,12 @@ add_insn_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions,
|
|||
{
|
||||
if (insns_info_index == 0 ||
|
||||
insns_info[insns_info_index-1].line_no != iobj->insn_info.line_no ||
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
insns_info[insns_info_index-1].node_id != iobj->insn_info.node_id ||
|
||||
#endif
|
||||
insns_info[insns_info_index-1].events != iobj->insn_info.events) {
|
||||
insns_info[insns_info_index].line_no = iobj->insn_info.line_no;
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
insns_info[insns_info_index].node_id = iobj->insn_info.node_id;
|
||||
#endif
|
||||
insns_info[insns_info_index].events = iobj->insn_info.events;
|
||||
|
@ -10059,7 +10059,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
|
|||
}
|
||||
|
||||
VALUE node_ids = Qfalse;
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
node_ids = rb_hash_aref(misc, ID2SYM(rb_intern("node_ids")));
|
||||
if (!RB_TYPE_P(node_ids, T_ARRAY)) {
|
||||
rb_raise(rb_eTypeError, "node_ids is not an array");
|
||||
|
@ -10940,7 +10940,7 @@ ibf_dump_insns_info_body(struct ibf_dump *dump, const rb_iseq_t *iseq)
|
|||
unsigned int i;
|
||||
for (i = 0; i < iseq->body->insns_info.size; i++) {
|
||||
ibf_dump_write_small_value(dump, entries[i].line_no);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
ibf_dump_write_small_value(dump, entries[i].node_id);
|
||||
#endif
|
||||
ibf_dump_write_small_value(dump, entries[i].events);
|
||||
|
@ -10958,7 +10958,7 @@ ibf_load_insns_info_body(const struct ibf_load *load, ibf_offset_t body_offset,
|
|||
unsigned int i;
|
||||
for (i = 0; i < size; i++) {
|
||||
entries[i].line_no = (int)ibf_load_small_value(load, &reading_pos);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
entries[i].node_id = (int)ibf_load_small_value(load, &reading_pos);
|
||||
#endif
|
||||
entries[i].events = (rb_event_flag_t)ibf_load_small_value(load, &reading_pos);
|
||||
|
|
8
iseq.c
8
iseq.c
|
@ -1840,7 +1840,7 @@ rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
int
|
||||
rb_iseq_node_id(const rb_iseq_t *iseq, size_t pos)
|
||||
{
|
||||
|
@ -2943,7 +2943,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
|
|||
/* make body with labels and insert line number */
|
||||
body = rb_ary_new();
|
||||
prev_insn_info = NULL;
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
VALUE node_ids = rb_ary_new();
|
||||
#endif
|
||||
|
||||
|
@ -2957,7 +2957,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
|
|||
}
|
||||
|
||||
info = get_insn_info(iseq, pos);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
rb_ary_push(node_ids, INT2FIX(info->node_id));
|
||||
#endif
|
||||
|
||||
|
@ -2997,7 +2997,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
|
|||
INT2FIX(iseq_body->location.code_location.beg_pos.column),
|
||||
INT2FIX(iseq_body->location.code_location.end_pos.lineno),
|
||||
INT2FIX(iseq_body->location.code_location.end_pos.column)));
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
rb_hash_aset(misc, ID2SYM(rb_intern("node_ids")), node_ids);
|
||||
#endif
|
||||
|
||||
|
|
8
iseq.h
8
iseq.h
|
@ -17,7 +17,9 @@ RUBY_EXTERN const int ruby_api_version[];
|
|||
#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
|
||||
#define ISEQ_MINOR_VERSION ((unsigned int)ruby_api_version[1])
|
||||
|
||||
//#define EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifndef USE_ISEQ_NODE_ID
|
||||
#define USE_ISEQ_NODE_ID 1
|
||||
#endif
|
||||
|
||||
#ifndef rb_iseq_t
|
||||
typedef struct rb_iseq_struct rb_iseq_t;
|
||||
|
@ -178,7 +180,7 @@ void rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *arena);
|
|||
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
|
||||
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
|
||||
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
int rb_iseq_node_id(const rb_iseq_t *iseq, size_t pos);
|
||||
#endif
|
||||
void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
|
||||
|
@ -218,7 +220,7 @@ struct rb_compile_option_struct {
|
|||
|
||||
struct iseq_insn_info_entry {
|
||||
int line_no;
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
int node_id;
|
||||
#endif
|
||||
rb_event_flag_t events;
|
||||
|
|
|
@ -47,7 +47,7 @@ calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id)
|
|||
return 0;
|
||||
}
|
||||
if (lineno) *lineno = FIX2INT(iseq->body->location.first_lineno);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
if (node_id) *node_id = -1;
|
||||
#endif
|
||||
return 1;
|
||||
|
@ -70,7 +70,7 @@ calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id)
|
|||
}
|
||||
#endif
|
||||
if (lineno) *lineno = rb_iseq_line_no(iseq, pos);
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
if (node_id) *node_id = rb_iseq_node_id(iseq, pos);
|
||||
#endif
|
||||
return 1;
|
||||
|
@ -85,7 +85,7 @@ calc_lineno(const rb_iseq_t *iseq, const VALUE *pc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
inline static int
|
||||
calc_node_id(const rb_iseq_t *iseq, const VALUE *pc)
|
||||
{
|
||||
|
@ -319,7 +319,7 @@ location_path_m(VALUE self)
|
|||
return location_path(location_ptr(self));
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
static int
|
||||
location_node_id(rb_backtrace_location_t *loc)
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ location_node_id(rb_backtrace_location_t *loc)
|
|||
void
|
||||
rb_frame_info_get(VALUE obj, VALUE *path, int *node_id)
|
||||
{
|
||||
#ifdef EXPERIMENTAL_ISEQ_NODE_ID
|
||||
#ifdef USE_ISEQ_NODE_ID
|
||||
rb_backtrace_location_t *loc = location_ptr(obj);
|
||||
*path = location_path(loc);
|
||||
*node_id = location_node_id(loc);
|
||||
|
|
Загрузка…
Ссылка в новой задаче