summaryrefslogtreecommitdiff
path: root/iseq.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-18 09:39:41 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-18 09:39:41 +0000
commit26451ab3bab3aff8cee0113405b3c542c2d59b37 (patch)
tree034ea9f654a88f7a4ca99b889610c131b006e3a7 /iseq.h
parent4f83ca015d7131f0990ca03a295a9d0c816f0192 (diff)
introduce `trace_events' info for iseq.
* vm_core.h (rb_iseq_t::aux): add `trace_events` which represents which events are enabled on this iseq. With this information, we can skip useless trace-on changes for ISeqs. * vm_trace.c (RUBY_EVENTS_TRACE_BY_ISEQ): moved to iseq.h and rename it with ISEQ_TRACE_EVENTS. * iseq.h: introduce ISEQ_USE_COMPILE_DATA iseq (imemo) flag to represent COMPILE_DATA is available. In other words, iseq->aux.trace_events is not available when this flag is set. * ISEQ_COMPILE_DATA() is changed from a macro. * ISEQ_COMPILE_DATA_ALLOC() is added. * ISEQ_COMPILE_DATA_CLEAR() is added. * iseq.c: use them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r--iseq.h100
1 files changed, 66 insertions, 34 deletions
diff --git a/iseq.h b/iseq.h
index 8c8def5..7c1c385 100644
--- a/iseq.h
+++ b/iseq.h
@@ -85,7 +85,72 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
return (VALUE *)RSTRING_PTR(str);
}
-#define ISEQ_COMPILE_DATA(iseq) (iseq)->aux.compile_data
+#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
+ RUBY_EVENT_CLASS | \
+ RUBY_EVENT_END | \
+ RUBY_EVENT_CALL | \
+ RUBY_EVENT_RETURN| \
+ RUBY_EVENT_B_CALL| \
+ RUBY_EVENT_B_RETURN)
+
+#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
+#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
+
+struct iseq_compile_data {
+ /* GC is needed */
+ const VALUE err_info;
+ VALUE mark_ary;
+ 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;
+ VALUE ensure_node;
+ VALUE for_iseq;
+ struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
+ int loopval_popped; /* used by NODE_BREAK */
+ int cached_const;
+ struct iseq_compile_data_storage *storage_head;
+ struct iseq_compile_data_storage *storage_current;
+ int last_line;
+ int last_coverable_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;
+#if SUPPORT_JOKE
+ 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->flags |= ISEQ_USE_COMPILE_DATA;
+ iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
+}
+
+static inline void
+ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq)
+{
+ iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
+ iseq->aux.compile_data = NULL;
+}
static inline rb_iseq_t *
iseq_imemo_alloc(void)
@@ -93,8 +158,6 @@ iseq_imemo_alloc(void)
return (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
}
-#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
-
VALUE iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
void ibf_load_iseq_complete(rb_iseq_t *iseq);
const rb_iseq_t *iseq_ibf_load(VALUE str);
@@ -213,37 +276,6 @@ struct iseq_compile_data_storage {
#define SIZEOF_ISEQ_COMPILE_DATA_STORAGE \
(sizeof(struct iseq_compile_data_storage) - 1)
-struct iseq_compile_data {
- /* GC is needed */
- const VALUE err_info;
- VALUE mark_ary;
- 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;
- VALUE ensure_node;
- VALUE for_iseq;
- struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
- int loopval_popped; /* used by NODE_BREAK */
- int cached_const;
- struct iseq_compile_data_storage *storage_head;
- struct iseq_compile_data_storage *storage_current;
- int last_line;
- int last_coverable_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;
-#if SUPPORT_JOKE
- st_table *labels_table;
-#endif
-};
-
/* defined? */
enum defined_type {