pline 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/README +134 -0
  2. data/ext/pline/depend +55 -0
  3. data/ext/pline/extconf.rb +14 -0
  4. data/ext/pline/iseq.c +124 -0
  5. data/ext/pline/minfo.c +167 -0
  6. data/ext/pline/pline.c.rb +68 -0
  7. data/ext/pline/profiler.c +125 -0
  8. data/ext/pline/ruby_source/1.9.2/debug.h +36 -0
  9. data/ext/pline/ruby_source/1.9.2/eval_intern.h +232 -0
  10. data/ext/pline/ruby_source/1.9.2/gc.h +77 -0
  11. data/ext/pline/ruby_source/1.9.2/id.h +170 -0
  12. data/ext/pline/ruby_source/1.9.2/insns.inc +179 -0
  13. data/ext/pline/ruby_source/1.9.2/insns_info.inc +695 -0
  14. data/ext/pline/ruby_source/1.9.2/iseq.h +104 -0
  15. data/ext/pline/ruby_source/1.9.2/manual_update.h +19 -0
  16. data/ext/pline/ruby_source/1.9.2/method.h +103 -0
  17. data/ext/pline/ruby_source/1.9.2/node.h +483 -0
  18. data/ext/pline/ruby_source/1.9.2/thread_pthread.h +27 -0
  19. data/ext/pline/ruby_source/1.9.2/thread_win32.h +33 -0
  20. data/ext/pline/ruby_source/1.9.2/vm_core.h +706 -0
  21. data/ext/pline/ruby_source/1.9.2/vm_exec.h +184 -0
  22. data/ext/pline/ruby_source/1.9.2/vm_insnhelper.c +1734 -0
  23. data/ext/pline/ruby_source/1.9.2/vm_insnhelper.h +208 -0
  24. data/ext/pline/ruby_source/1.9.2/vm_opts.h +51 -0
  25. data/ext/pline/ruby_source/1.9.3/atomic.h +56 -0
  26. data/ext/pline/ruby_source/1.9.3/constant.h +34 -0
  27. data/ext/pline/ruby_source/1.9.3/debug.h +41 -0
  28. data/ext/pline/ruby_source/1.9.3/eval_intern.h +234 -0
  29. data/ext/pline/ruby_source/1.9.3/gc.h +98 -0
  30. data/ext/pline/ruby_source/1.9.3/id.h +175 -0
  31. data/ext/pline/ruby_source/1.9.3/insns.inc +179 -0
  32. data/ext/pline/ruby_source/1.9.3/insns_info.inc +695 -0
  33. data/ext/pline/ruby_source/1.9.3/internal.h +227 -0
  34. data/ext/pline/ruby_source/1.9.3/iseq.h +125 -0
  35. data/ext/pline/ruby_source/1.9.3/manual_update.h +19 -0
  36. data/ext/pline/ruby_source/1.9.3/method.h +105 -0
  37. data/ext/pline/ruby_source/1.9.3/node.h +503 -0
  38. data/ext/pline/ruby_source/1.9.3/thread_pthread.h +51 -0
  39. data/ext/pline/ruby_source/1.9.3/thread_win32.h +40 -0
  40. data/ext/pline/ruby_source/1.9.3/vm_core.h +756 -0
  41. data/ext/pline/ruby_source/1.9.3/vm_exec.h +184 -0
  42. data/ext/pline/ruby_source/1.9.3/vm_insnhelper.c +1749 -0
  43. data/ext/pline/ruby_source/1.9.3/vm_insnhelper.h +220 -0
  44. data/ext/pline/ruby_source/1.9.3/vm_opts.h +51 -0
  45. data/ext/pline/sinfo.c +311 -0
  46. data/lib/pline.rb +11 -0
  47. data/lib/pline/minfo.rb +22 -0
  48. data/lib/pline/summarize.rb +127 -0
  49. data/lib/pline/util.rb +54 -0
  50. data/pline.gemspec +28 -0
  51. metadata +102 -0
@@ -0,0 +1,227 @@
1
+ /**********************************************************************
2
+
3
+ internal.h -
4
+
5
+ $Author$
6
+ created at: Tue May 17 11:42:20 JST 2011
7
+
8
+ Copyright (C) 2011 Yukihiro Matsumoto
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_INTERNAL_H
13
+ #define RUBY_INTERNAL_H 1
14
+
15
+ #if defined(__cplusplus)
16
+ extern "C" {
17
+ #if 0
18
+ } /* satisfy cc-mode */
19
+ #endif
20
+ #endif
21
+
22
+ struct rb_deprecated_classext_struct {
23
+ char conflict[sizeof(VALUE) * 3];
24
+ };
25
+
26
+ struct rb_classext_struct {
27
+ VALUE super;
28
+ struct st_table *iv_tbl;
29
+ struct st_table *const_tbl;
30
+ };
31
+
32
+ #undef RCLASS_SUPER
33
+ #define RCLASS_EXT(c) (RCLASS(c)->ptr)
34
+ #define RCLASS_SUPER(c) (RCLASS_EXT(c)->super)
35
+ #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
36
+ #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
37
+ #define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
38
+ #define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
39
+
40
+ struct vtm; /* defined by timev.h */
41
+
42
+ /* array.c */
43
+ VALUE rb_ary_last(int, VALUE *, VALUE);
44
+
45
+ /* bignum.c */
46
+ VALUE rb_big_fdiv(VALUE x, VALUE y);
47
+ VALUE rb_big_uminus(VALUE x);
48
+
49
+ /* class.c */
50
+ VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
51
+ VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj);
52
+ VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj);
53
+ VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
54
+ int rb_obj_basic_to_s_p(VALUE);
55
+ void Init_class_hierarchy(void);
56
+
57
+ /* compile.c */
58
+ int rb_dvar_defined(ID);
59
+ int rb_local_defined(ID);
60
+ int rb_parse_in_eval(void);
61
+ int rb_parse_in_main(void);
62
+ VALUE rb_insns_name_array(void);
63
+
64
+ /* debug.c */
65
+ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
66
+
67
+ /* dmyext.c */
68
+ void Init_ext(void);
69
+
70
+ /* encoding.c */
71
+ ID rb_id_encoding(void);
72
+
73
+ /* encoding.c */
74
+ void rb_gc_mark_encodings(void);
75
+
76
+ /* error.c */
77
+ NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
78
+ VALUE rb_check_backtrace(VALUE);
79
+ NORETURN(void rb_async_bug_errno(const char *,int));
80
+
81
+ /* eval_error.c */
82
+ void ruby_error_print(void);
83
+ VALUE rb_get_backtrace(VALUE info);
84
+
85
+ /* eval_jump.c */
86
+ void rb_call_end_proc(VALUE data);
87
+
88
+ /* file.c */
89
+ VALUE rb_home_dir(const char *user, VALUE result);
90
+ VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
91
+ void Init_File(void);
92
+
93
+ /* gc.c */
94
+ void Init_heap(void);
95
+
96
+ /* inits.c */
97
+ void rb_call_inits(void);
98
+
99
+ /* io.c */
100
+ const char *ruby_get_inplace_mode(void);
101
+ void ruby_set_inplace_mode(const char *);
102
+ ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
103
+ void rb_stdio_set_default_encoding(void);
104
+
105
+ /* iseq.c */
106
+ VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, VALUE opt);
107
+ VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase);
108
+
109
+ /* load.c */
110
+ VALUE rb_get_load_path(void);
111
+
112
+ /* math.c */
113
+ VALUE rb_math_atan2(VALUE, VALUE);
114
+ VALUE rb_math_cos(VALUE);
115
+ VALUE rb_math_cosh(VALUE);
116
+ VALUE rb_math_exp(VALUE);
117
+ VALUE rb_math_hypot(VALUE, VALUE);
118
+ VALUE rb_math_log(int argc, VALUE *argv);
119
+ VALUE rb_math_sin(VALUE);
120
+ VALUE rb_math_sinh(VALUE);
121
+ VALUE rb_math_sqrt(VALUE);
122
+
123
+ /* newline.c */
124
+ void Init_newline(void);
125
+
126
+ /* numeric.c */
127
+ int rb_num_to_uint(VALUE val, unsigned int *ret);
128
+ int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
129
+
130
+ /* object.c */
131
+ VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
132
+
133
+ /* parse.y */
134
+ VALUE rb_parser_get_yydebug(VALUE);
135
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
136
+
137
+ /* proc.c */
138
+ VALUE rb_proc_location(VALUE self);
139
+
140
+ /* rational.c */
141
+ VALUE rb_lcm(VALUE x, VALUE y);
142
+ VALUE rb_rational_reciprocal(VALUE x);
143
+
144
+ /* re.c */
145
+ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
146
+ VALUE rb_reg_check_preprocess(VALUE);
147
+
148
+ /* signal.c */
149
+ int rb_get_next_signal(void);
150
+
151
+ /* strftime.c */
152
+ size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, struct timespec *ts, int gmt);
153
+
154
+ /* string.c */
155
+ int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
156
+
157
+ /* struct.c */
158
+ VALUE rb_struct_init_copy(VALUE copy, VALUE s);
159
+
160
+ /* time.c */
161
+ struct timeval rb_time_timeval(VALUE);
162
+
163
+ /* thread.c */
164
+ VALUE rb_obj_is_mutex(VALUE obj);
165
+ VALUE ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always);
166
+ void rb_thread_execute_interrupts(VALUE th);
167
+ void rb_clear_trace_func(void);
168
+ VALUE rb_thread_backtrace(VALUE thval);
169
+ VALUE rb_get_coverages(void);
170
+
171
+ /* thread_pthread.c, thread_win32.c */
172
+ void Init_native_thread(void);
173
+
174
+ /* vm.c */
175
+ VALUE rb_obj_is_thread(VALUE obj);
176
+ void rb_vm_mark(void *ptr);
177
+ void Init_BareVM(void);
178
+ VALUE rb_vm_top_self(void);
179
+ void rb_thread_recycle_stack_release(VALUE *);
180
+ void rb_vm_change_state(void);
181
+ void rb_vm_inc_const_missing_count(void);
182
+ void rb_thread_mark(void *th);
183
+ const void **rb_vm_get_insns_address_table(void);
184
+
185
+ /* vm_dump.c */
186
+ void rb_vm_bugreport(void);
187
+
188
+ /* vm_eval.c */
189
+ void Init_vm_eval(void);
190
+ VALUE rb_current_realfilepath(void);
191
+
192
+ /* vm_method.c */
193
+ void Init_eval_method(void);
194
+
195
+ /* miniprelude.c, prelude.c */
196
+ void Init_prelude(void);
197
+
198
+ #if defined __GNUC__ && __GNUC__ >= 4
199
+ #pragma GCC visibility push(default)
200
+ #endif
201
+ const char *rb_objspace_data_type_name(VALUE obj);
202
+
203
+ /* Temporary. This API will be removed (renamed). */
204
+ VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
205
+
206
+ /* experimental.
207
+ * These APIs can be changed on Ruby 1.9.4 or later.
208
+ * We will change these APIs (spac, name and so on) if there are something wrong.
209
+ * If you use these APIs, catch up future changes.
210
+ */
211
+ void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
212
+ VALUE rb_thread_call_without_gvl(
213
+ rb_blocking_function_t *func, void *data1,
214
+ rb_unblock_function_t *ubf, void *data2);
215
+
216
+ #if defined __GNUC__ && __GNUC__ >= 4
217
+ #pragma GCC visibility pop
218
+ #endif
219
+
220
+ #if defined(__cplusplus)
221
+ #if 0
222
+ { /* satisfy cc-mode */
223
+ #endif
224
+ } /* extern "C" { */
225
+ #endif
226
+
227
+ #endif /* RUBY_INTERNAL_H */
@@ -0,0 +1,125 @@
1
+ /**********************************************************************
2
+
3
+ iseq.h -
4
+
5
+ $Author$
6
+ created at: 04/01/01 23:36:57 JST
7
+
8
+ Copyright (C) 2004-2008 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_COMPILE_H
13
+ #define RUBY_COMPILE_H
14
+
15
+ #if defined __GNUC__ && __GNUC__ >= 4
16
+ #pragma GCC visibility push(default)
17
+ #endif
18
+
19
+ /* compile.c */
20
+ VALUE rb_iseq_compile_node(VALUE self, NODE *node);
21
+ int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
22
+ VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
23
+ VALUE exception, VALUE body);
24
+
25
+ /* iseq.c */
26
+ VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
27
+ VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
28
+ struct st_table *ruby_insn_make_insn_table(void);
29
+
30
+ /* proc.c */
31
+ rb_iseq_t *rb_method_get_iseq(VALUE body);
32
+ rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
33
+
34
+ struct rb_compile_option_struct {
35
+ int inline_const_cache;
36
+ int peephole_optimization;
37
+ int tailcall_optimization;
38
+ int specialized_instruction;
39
+ int operands_unification;
40
+ int instructions_unification;
41
+ int stack_caching;
42
+ int trace_instruction;
43
+ int debug_level;
44
+ };
45
+
46
+ struct iseq_insn_info_entry {
47
+ unsigned short position;
48
+ unsigned short line_no;
49
+ unsigned short sp;
50
+ };
51
+
52
+ struct iseq_catch_table_entry {
53
+ enum catch_type {
54
+ CATCH_TYPE_RESCUE,
55
+ CATCH_TYPE_ENSURE,
56
+ CATCH_TYPE_RETRY,
57
+ CATCH_TYPE_BREAK,
58
+ CATCH_TYPE_REDO,
59
+ CATCH_TYPE_NEXT
60
+ } type;
61
+ VALUE iseq;
62
+ unsigned long start;
63
+ unsigned long end;
64
+ unsigned long cont;
65
+ unsigned long sp;
66
+ };
67
+
68
+ #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
69
+
70
+ struct iseq_compile_data_storage {
71
+ struct iseq_compile_data_storage *next;
72
+ unsigned long pos;
73
+ unsigned long size;
74
+ char *buff;
75
+ };
76
+
77
+ struct iseq_compile_data {
78
+ /* GC is needed */
79
+ VALUE err_info;
80
+ VALUE mark_ary;
81
+ VALUE catch_table_ary; /* Array */
82
+
83
+ /* GC is not needed */
84
+ struct iseq_label_data *start_label;
85
+ struct iseq_label_data *end_label;
86
+ struct iseq_label_data *redo_label;
87
+ VALUE current_block;
88
+ VALUE ensure_node;
89
+ VALUE for_iseq;
90
+ struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
91
+ int loopval_popped; /* used by NODE_BREAK */
92
+ int cached_const;
93
+ struct iseq_compile_data_storage *storage_head;
94
+ struct iseq_compile_data_storage *storage_current;
95
+ int last_line;
96
+ int last_coverable_line;
97
+ int flip_cnt;
98
+ int label_no;
99
+ int node_level;
100
+ const rb_compile_option_t *option;
101
+ #if SUPPORT_JOKE
102
+ st_table *labels_table;
103
+ #endif
104
+ };
105
+
106
+ /* defined? */
107
+
108
+ enum defined_type {
109
+ DEFINED_IVAR = 1,
110
+ DEFINED_IVAR2,
111
+ DEFINED_GVAR,
112
+ DEFINED_CVAR,
113
+ DEFINED_CONST,
114
+ DEFINED_METHOD,
115
+ DEFINED_YIELD,
116
+ DEFINED_REF,
117
+ DEFINED_ZSUPER,
118
+ DEFINED_FUNC
119
+ };
120
+
121
+ #if defined __GNUC__ && __GNUC__ >= 4
122
+ #pragma GCC visibility pop
123
+ #endif
124
+
125
+ #endif /* RUBY_COMPILE_H */
@@ -0,0 +1,19 @@
1
+ /* ----- vm_method.c ----- */
2
+ static rb_method_entry_t*
3
+ search_method(VALUE klass, ID id)
4
+ {
5
+ st_data_t body;
6
+ if (!klass) {
7
+ return 0;
8
+ }
9
+
10
+ while (!st_lookup(RCLASS_M_TBL(klass), id, &body)) {
11
+ klass = RCLASS_SUPER(klass);
12
+ if (!klass) {
13
+ return 0;
14
+ }
15
+ }
16
+
17
+ return (rb_method_entry_t *)body;
18
+ }
19
+
@@ -0,0 +1,105 @@
1
+ /**********************************************************************
2
+
3
+ method.h -
4
+
5
+ $Author$
6
+ created at: Wed Jul 15 20:02:33 2009
7
+
8
+ Copyright (C) 2009 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+ #ifndef METHOD_H
12
+ #define METHOD_H
13
+
14
+ typedef enum {
15
+ NOEX_PUBLIC = 0x00,
16
+ NOEX_NOSUPER = 0x01,
17
+ NOEX_PRIVATE = 0x02,
18
+ NOEX_PROTECTED = 0x04,
19
+ NOEX_MASK = 0x06,
20
+ NOEX_BASIC = 0x08,
21
+ NOEX_UNDEF = NOEX_NOSUPER,
22
+ NOEX_MODFUNC = 0x12,
23
+ NOEX_SUPER = 0x20,
24
+ NOEX_VCALL = 0x40,
25
+ NOEX_RESPONDS = 0x80
26
+ } rb_method_flag_t;
27
+
28
+ #define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
29
+ #define NOEX_WITH(n, s) (((s) << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC))
30
+ #define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
31
+
32
+ /* method data type */
33
+
34
+ typedef enum {
35
+ VM_METHOD_TYPE_ISEQ,
36
+ VM_METHOD_TYPE_CFUNC,
37
+ VM_METHOD_TYPE_ATTRSET,
38
+ VM_METHOD_TYPE_IVAR,
39
+ VM_METHOD_TYPE_BMETHOD,
40
+ VM_METHOD_TYPE_ZSUPER,
41
+ VM_METHOD_TYPE_UNDEF,
42
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
43
+ VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
44
+ VM_METHOD_TYPE_MISSING /* wrapper for method_missing(id) */
45
+ } rb_method_type_t;
46
+
47
+ typedef struct rb_method_cfunc_struct {
48
+ VALUE (*func)(ANYARGS);
49
+ int argc;
50
+ } rb_method_cfunc_t;
51
+
52
+ typedef struct rb_method_attr_struct {
53
+ ID id;
54
+ VALUE location;
55
+ } rb_method_attr_t;
56
+
57
+ typedef struct rb_iseq_struct rb_iseq_t;
58
+
59
+ typedef struct rb_method_definition_struct {
60
+ rb_method_type_t type; /* method type */
61
+ ID original_id;
62
+ union {
63
+ rb_iseq_t *iseq; /* should be mark */
64
+ rb_method_cfunc_t cfunc;
65
+ rb_method_attr_t attr;
66
+ VALUE proc; /* should be mark */
67
+ enum method_optimized_type {
68
+ OPTIMIZED_METHOD_TYPE_SEND,
69
+ OPTIMIZED_METHOD_TYPE_CALL
70
+ } optimize_type;
71
+ } body;
72
+ int alias_count;
73
+ } rb_method_definition_t;
74
+
75
+ typedef struct rb_method_entry_struct {
76
+ rb_method_flag_t flag;
77
+ char mark;
78
+ rb_method_definition_t *def;
79
+ ID called_id;
80
+ VALUE klass; /* should be mark */
81
+ } rb_method_entry_t;
82
+
83
+ struct unlinked_method_entry_list_entry {
84
+ struct unlinked_method_entry_list_entry *next;
85
+ rb_method_entry_t *me;
86
+ };
87
+
88
+ #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
89
+
90
+ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
91
+ rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
92
+ rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
93
+
94
+ rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id);
95
+ rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
96
+
97
+ int rb_method_entry_arity(const rb_method_entry_t *me);
98
+ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
99
+
100
+ void rb_mark_method_entry(const rb_method_entry_t *me);
101
+ void rb_free_method_entry(rb_method_entry_t *me);
102
+ void rb_sweep_method_entry(void *vm);
103
+ void rb_free_m_table(st_table *tbl);
104
+
105
+ #endif /* METHOD_H */