* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
iseq.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: 04/01/01 23:36:57 JST
|
|
|
|
|
|
|
|
Copyright (C) 2004-2008 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2015-09-19 04:48:48 +03:00
|
|
|
#ifndef RUBY_ISEQ_H
|
|
|
|
#define RUBY_ISEQ_H 1
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
2018-10-13 19:21:06 +03:00
|
|
|
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])
|
2015-12-08 16:58:50 +03:00
|
|
|
|
2015-09-19 04:53:34 +03:00
|
|
|
#ifndef rb_iseq_t
|
|
|
|
typedef struct rb_iseq_struct rb_iseq_t;
|
|
|
|
#define rb_iseq_t rb_iseq_t
|
|
|
|
#endif
|
|
|
|
|
2019-04-11 13:36:36 +03:00
|
|
|
extern const ID rb_iseq_shared_exc_local_tbl[];
|
|
|
|
|
2015-08-13 11:43:32 +03:00
|
|
|
static inline size_t
|
|
|
|
rb_call_info_kw_arg_bytes(int keyword_len)
|
|
|
|
{
|
2019-10-07 10:56:08 +03:00
|
|
|
return rb_size_mul_add_or_raise(
|
|
|
|
keyword_len - 1, sizeof(VALUE), sizeof(struct rb_call_info_kw_arg),
|
|
|
|
rb_eRuntimeError);
|
2015-08-13 11:43:32 +03:00
|
|
|
}
|
|
|
|
|
2018-03-19 21:21:54 +03:00
|
|
|
#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
|
|
|
|
#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
|
2017-09-03 17:26:06 +03:00
|
|
|
#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)
|
2015-12-02 16:58:07 +03:00
|
|
|
|
2018-10-20 13:45:48 +03:00
|
|
|
#define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex
|
|
|
|
#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h)
|
|
|
|
|
2018-03-19 21:21:54 +03:00
|
|
|
#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count
|
2015-12-08 16:58:50 +03:00
|
|
|
|
2018-03-19 21:21:54 +03:00
|
|
|
static inline rb_snum_t
|
2015-12-02 16:58:07 +03:00
|
|
|
ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-03-19 21:21:54 +03:00
|
|
|
rb_snum_t cnt = iseq->body->variable.flip_count;
|
|
|
|
iseq->body->variable.flip_count += 1;
|
2015-12-02 16:58:07 +03:00
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE *
|
|
|
|
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-05-09 08:42:06 +03:00
|
|
|
return iseq->body->variable.original_iseq;
|
2015-12-02 16:58:07 +03:00
|
|
|
}
|
|
|
|
|
2017-11-14 15:58:36 +03:00
|
|
|
static inline void
|
|
|
|
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-05-09 08:42:06 +03:00
|
|
|
void *ptr = iseq->body->variable.original_iseq;
|
|
|
|
iseq->body->variable.original_iseq = NULL;
|
|
|
|
if (ptr) {
|
|
|
|
ruby_xfree(ptr);
|
|
|
|
}
|
2017-11-14 15:58:36 +03:00
|
|
|
}
|
|
|
|
|
2015-12-02 16:58:07 +03:00
|
|
|
static inline VALUE *
|
|
|
|
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
|
|
|
|
{
|
2018-05-09 08:42:06 +03:00
|
|
|
return iseq->body->variable.original_iseq =
|
2019-10-07 10:56:08 +03:00
|
|
|
ALLOC_N(VALUE, size);
|
2015-12-02 16:58:07 +03:00
|
|
|
}
|
|
|
|
|
2017-11-18 12:39:41 +03:00
|
|
|
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
|
|
|
|
RUBY_EVENT_CLASS | \
|
|
|
|
RUBY_EVENT_END | \
|
|
|
|
RUBY_EVENT_CALL | \
|
|
|
|
RUBY_EVENT_RETURN| \
|
|
|
|
RUBY_EVENT_B_CALL| \
|
2018-08-22 14:09:47 +03:00
|
|
|
RUBY_EVENT_B_RETURN| \
|
2018-10-20 13:45:55 +03:00
|
|
|
RUBY_EVENT_COVERAGE_LINE| \
|
|
|
|
RUBY_EVENT_COVERAGE_BRANCH)
|
2017-11-18 12:39:41 +03:00
|
|
|
|
|
|
|
#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
|
|
|
|
#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
|
2018-03-19 21:21:54 +03:00
|
|
|
#define ISEQ_TRANSLATED IMEMO_FL_USER3
|
|
|
|
#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
|
2017-11-18 12:39:41 +03:00
|
|
|
|
2018-12-06 13:52:27 +03:00
|
|
|
#define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW((iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)
|
|
|
|
|
2017-11-18 12:39:41 +03:00
|
|
|
struct iseq_compile_data {
|
|
|
|
/* GC is needed */
|
|
|
|
const VALUE err_info;
|
|
|
|
const VALUE catch_table_ary; /* Array */
|
|
|
|
|
|
|
|
/* GC is not needed */
|
|
|
|
struct iseq_label_data *start_label;
|
|
|
|
struct iseq_label_data *end_label;
|
|
|
|
struct iseq_label_data *redo_label;
|
|
|
|
const rb_iseq_t *current_block;
|
|
|
|
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
|
2019-09-13 01:21:18 +03:00
|
|
|
struct {
|
|
|
|
struct iseq_compile_data_storage *storage_head;
|
|
|
|
struct iseq_compile_data_storage *storage_current;
|
|
|
|
} node;
|
|
|
|
struct {
|
|
|
|
struct iseq_compile_data_storage *storage_head;
|
|
|
|
struct iseq_compile_data_storage *storage_current;
|
|
|
|
} insn;
|
2018-07-29 04:32:37 +03:00
|
|
|
int loopval_popped; /* used by NODE_BREAK */
|
2017-11-18 12:39:41 +03:00
|
|
|
int last_line;
|
|
|
|
int label_no;
|
|
|
|
int node_level;
|
|
|
|
unsigned int ci_index;
|
|
|
|
unsigned int ci_kw_index;
|
|
|
|
const rb_compile_option_t *option;
|
|
|
|
struct rb_id_table *ivar_cache_table;
|
2019-11-07 10:58:00 +03:00
|
|
|
const struct rb_builtin_function *builtin_function_table;
|
2019-09-03 15:08:07 +03:00
|
|
|
#if OPT_SUPPORT_JOKE
|
2017-11-18 12:39:41 +03:00
|
|
|
st_table *labels_table;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct iseq_compile_data *
|
|
|
|
ISEQ_COMPILE_DATA(const rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
|
|
|
|
return iseq->aux.compile_data;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ISEQ_COMPILE_DATA_ALLOC(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
|
2018-12-06 13:52:27 +03:00
|
|
|
iseq->flags |= ISEQ_USE_COMPILE_DATA;
|
2017-11-18 12:39:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
|
|
|
|
iseq->aux.compile_data = NULL;
|
|
|
|
}
|
2015-12-08 16:58:50 +03:00
|
|
|
|
|
|
|
static inline rb_iseq_t *
|
|
|
|
iseq_imemo_alloc(void)
|
|
|
|
{
|
|
|
|
return (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:59:25 +03:00
|
|
|
VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
|
|
|
|
void rb_ibf_load_iseq_complete(rb_iseq_t *iseq);
|
|
|
|
const rb_iseq_t *rb_iseq_ibf_load(VALUE str);
|
2019-11-08 10:16:25 +03:00
|
|
|
const rb_iseq_t *rb_iseq_ibf_load_bytes(const char *cstr, size_t);
|
2018-09-13 16:59:25 +03:00
|
|
|
VALUE rb_iseq_ibf_load_extra_data(VALUE str);
|
|
|
|
void rb_iseq_init_trace(rb_iseq_t *iseq);
|
2018-11-26 23:16:14 +03:00
|
|
|
int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line);
|
2018-11-26 21:16:39 +03:00
|
|
|
int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
|
2018-12-06 16:42:32 +03:00
|
|
|
const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
|
2018-08-23 07:12:14 +03:00
|
|
|
|
2018-06-13 07:51:43 +03:00
|
|
|
#if VM_INSN_INFO_TABLE_IMPL == 2
|
2018-04-05 10:04:39 +03:00
|
|
|
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
|
2018-06-13 07:51:43 +03:00
|
|
|
#endif
|
2015-12-02 11:20:35 +03:00
|
|
|
|
2013-04-05 14:29:38 +04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-22 01:38:25 +04:00
|
|
|
|
2008-12-05 06:35:48 +03:00
|
|
|
/* compile.c */
|
2017-10-27 15:00:38 +03:00
|
|
|
VALUE rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node);
|
2019-08-26 08:25:53 +03:00
|
|
|
VALUE rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func * ifunc);
|
2015-07-22 01:52:59 +03:00
|
|
|
VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
|
|
|
|
void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
|
|
|
|
VALUE locals, VALUE args,
|
|
|
|
VALUE exception, VALUE body);
|
2019-09-17 03:19:44 +03:00
|
|
|
void rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *arena);
|
2008-12-05 06:35:48 +03:00
|
|
|
|
|
|
|
/* iseq.c */
|
* iseq.c (rb_iseq_load): renamed from ruby_iseq_load, since it is
for C extensions or the ruby core. [ruby-core:21407]
Index: compile.c
===================================================================
--- compile.c (revision 21649)
+++ compile.c (working copy)
@@ -5078,5 +5078,5 @@ iseq_build_exception(rb_iseq_t *iseq, st
}
else {
- eiseqval = ruby_iseq_load(ptr[1], iseq->self, Qnil);
+ eiseqval = rb_iseq_load(ptr[1], iseq->self, Qnil);
}
@@ -5162,5 +5162,5 @@ iseq_build_body(rb_iseq_t *iseq, LINK_AN
if (op != Qnil) {
if (TYPE(op) == T_ARRAY) {
- argv[j] = ruby_iseq_load(op, iseq->self, Qnil);
+ argv[j] = rb_iseq_load(op, iseq->self, Qnil);
}
else if (CLASS_OF(op) == rb_cISeq) {
Index: iseq.c
===================================================================
--- iseq.c (revision 21649)
+++ iseq.c (working copy)
@@ -448,5 +448,5 @@ iseq_s_load(int argc, VALUE *argv, VALUE
VALUE
-ruby_iseq_load(VALUE data, VALUE parent, VALUE opt)
+rb_iseq_load(VALUE data, VALUE parent, VALUE opt)
{
return iseq_load(rb_cISeq, data, parent, opt);
Index: iseq.h
===================================================================
--- iseq.h (revision 21649)
+++ iseq.h (working copy)
@@ -21,5 +21,5 @@ VALUE ruby_iseq_build_from_ary(rb_iseq_t
/* iseq.c */
-VALUE ruby_iseq_load(VALUE data, VALUE parent, VALUE opt);
+VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
struct st_table *ruby_insn_make_insn_table(void);
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-18 22:05:15 +03:00
|
|
|
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 02:43:38 +04:00
|
|
|
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
|
2011-08-24 10:31:15 +04:00
|
|
|
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
|
2017-11-17 09:24:55 +03:00
|
|
|
void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
|
2017-11-14 15:58:36 +03:00
|
|
|
void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
|
2018-01-09 17:05:23 +03:00
|
|
|
void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
2015-07-22 01:52:59 +03:00
|
|
|
VALUE rb_iseqw_new(const rb_iseq_t *iseq);
|
|
|
|
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
|
|
|
|
|
2017-06-01 03:05:33 +03:00
|
|
|
VALUE rb_iseq_absolute_path(const rb_iseq_t *iseq); /* obsolete */
|
2015-07-22 01:52:59 +03:00
|
|
|
VALUE rb_iseq_label(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_base_label(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
|
2018-01-09 11:45:35 +03:00
|
|
|
void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
|
2012-11-30 21:00:30 +04:00
|
|
|
|
2018-08-22 13:22:02 +03:00
|
|
|
void rb_iseq_remove_coverage_all(void);
|
2018-08-22 08:24:50 +03:00
|
|
|
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 05:54:57 +04:00
|
|
|
/* proc.c */
|
2015-05-21 12:01:44 +03:00
|
|
|
const rb_iseq_t *rb_method_iseq(VALUE body);
|
|
|
|
const rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 05:54:57 +04:00
|
|
|
|
2010-10-31 04:42:54 +03:00
|
|
|
struct rb_compile_option_struct {
|
2016-03-10 10:06:39 +03:00
|
|
|
unsigned int inline_const_cache: 1;
|
|
|
|
unsigned int peephole_optimization: 1;
|
|
|
|
unsigned int tailcall_optimization: 1;
|
|
|
|
unsigned int specialized_instruction: 1;
|
|
|
|
unsigned int operands_unification: 1;
|
|
|
|
unsigned int instructions_unification: 1;
|
|
|
|
unsigned int stack_caching: 1;
|
|
|
|
unsigned int frozen_string_literal: 1;
|
|
|
|
unsigned int debug_frozen_string_literal: 1;
|
2016-03-10 11:34:18 +03:00
|
|
|
unsigned int coverage_enabled: 1;
|
2010-10-31 04:42:54 +03:00
|
|
|
int debug_level;
|
|
|
|
};
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
2017-11-09 09:57:24 +03:00
|
|
|
struct iseq_insn_info_entry {
|
|
|
|
int line_no;
|
2017-11-14 15:58:36 +03:00
|
|
|
rb_event_flag_t events;
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iseq_catch_table_entry {
|
2010-10-31 04:42:54 +03:00
|
|
|
enum catch_type {
|
2012-12-03 14:03:25 +04:00
|
|
|
CATCH_TYPE_RESCUE = INT2FIX(1),
|
|
|
|
CATCH_TYPE_ENSURE = INT2FIX(2),
|
|
|
|
CATCH_TYPE_RETRY = INT2FIX(3),
|
|
|
|
CATCH_TYPE_BREAK = INT2FIX(4),
|
|
|
|
CATCH_TYPE_REDO = INT2FIX(5),
|
|
|
|
CATCH_TYPE_NEXT = INT2FIX(6)
|
2010-10-31 04:42:54 +03:00
|
|
|
} type;
|
2017-06-08 07:13:52 +03:00
|
|
|
|
2017-06-08 07:13:51 +03:00
|
|
|
/*
|
|
|
|
* iseq type:
|
|
|
|
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
|
|
|
* use iseq as continuation.
|
|
|
|
*
|
|
|
|
* CATCH_TYPE_BREAK (iter):
|
|
|
|
* use iseq as key.
|
|
|
|
*
|
|
|
|
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
|
|
|
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
|
|
|
* NULL.
|
|
|
|
*/
|
2019-04-20 04:19:47 +03:00
|
|
|
rb_iseq_t *iseq;
|
2017-06-08 07:13:51 +03:00
|
|
|
|
2014-07-14 11:08:55 +04:00
|
|
|
unsigned int start;
|
|
|
|
unsigned int end;
|
|
|
|
unsigned int cont;
|
|
|
|
unsigned int sp;
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
};
|
|
|
|
|
2014-07-14 11:06:26 +04:00
|
|
|
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
|
2015-07-25 00:44:14 +03:00
|
|
|
unsigned int size;
|
2018-01-13 15:44:17 +03:00
|
|
|
struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
|
2014-07-14 11:06:26 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
iseq_catch_table_bytes(int n)
|
|
|
|
{
|
2014-07-17 20:54:59 +04:00
|
|
|
enum {
|
2018-01-14 14:19:18 +03:00
|
|
|
catch_table_entry_size = sizeof(struct iseq_catch_table_entry),
|
|
|
|
catch_table_entries_max = (INT_MAX - offsetof(struct iseq_catch_table, entries)) / catch_table_entry_size
|
2014-07-17 20:54:59 +04:00
|
|
|
};
|
|
|
|
if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
|
2018-01-14 14:19:18 +03:00
|
|
|
return (int)(offsetof(struct iseq_catch_table, entries) +
|
|
|
|
n * catch_table_entry_size);
|
2014-07-14 11:06:26 +04:00
|
|
|
}
|
|
|
|
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
|
|
|
|
|
|
|
|
struct iseq_compile_data_storage {
|
|
|
|
struct iseq_compile_data_storage *next;
|
2014-07-26 11:57:44 +04:00
|
|
|
unsigned int pos;
|
|
|
|
unsigned int size;
|
2018-01-13 15:44:17 +03:00
|
|
|
char buff[FLEX_ARY_LEN];
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* defined? */
|
2010-10-31 04:42:54 +03:00
|
|
|
|
|
|
|
enum defined_type {
|
2018-01-19 08:18:18 +03:00
|
|
|
DEFINED_NOT_DEFINED,
|
2012-09-24 12:36:53 +04:00
|
|
|
DEFINED_NIL = 1,
|
|
|
|
DEFINED_IVAR,
|
|
|
|
DEFINED_LVAR,
|
2010-10-31 04:42:54 +03:00
|
|
|
DEFINED_GVAR,
|
|
|
|
DEFINED_CVAR,
|
|
|
|
DEFINED_CONST,
|
|
|
|
DEFINED_METHOD,
|
|
|
|
DEFINED_YIELD,
|
|
|
|
DEFINED_ZSUPER,
|
2012-09-24 12:36:53 +04:00
|
|
|
DEFINED_SELF,
|
|
|
|
DEFINED_TRUE,
|
|
|
|
DEFINED_FALSE,
|
|
|
|
DEFINED_ASGN,
|
|
|
|
DEFINED_EXPR,
|
|
|
|
DEFINED_IVAR2,
|
|
|
|
DEFINED_REF,
|
2019-11-06 09:47:32 +03:00
|
|
|
DEFINED_FUNC,
|
|
|
|
DEFINED_CONST_FROM
|
2010-10-31 04:42:54 +03:00
|
|
|
};
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
2012-09-24 12:36:53 +04:00
|
|
|
VALUE rb_iseq_defined_string(enum defined_type type);
|
|
|
|
|
2015-12-08 08:27:10 +03:00
|
|
|
/* vm.c */
|
|
|
|
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
|
|
|
|
|
2013-04-05 14:29:38 +04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-22 01:38:25 +04:00
|
|
|
|
2015-09-19 04:48:48 +03:00
|
|
|
#endif /* RUBY_ISEQ_H */
|