stackprofx 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -0
- data/README.md +41 -0
- data/Rakefile +31 -0
- data/ext/extconf.rb +11 -0
- data/ext/ruby_headers/215/id.h +171 -0
- data/ext/ruby_headers/215/internal.h +889 -0
- data/ext/ruby_headers/215/iseq.h +136 -0
- data/ext/ruby_headers/215/method.h +142 -0
- data/ext/ruby_headers/215/node.h +543 -0
- data/ext/ruby_headers/215/ruby_atomic.h +170 -0
- data/ext/ruby_headers/215/thread_native.h +23 -0
- data/ext/ruby_headers/215/thread_pthread.h +56 -0
- data/ext/ruby_headers/215/thread_win32.h +45 -0
- data/ext/ruby_headers/215/vm_core.h +1042 -0
- data/ext/ruby_headers/215/vm_debug.h +37 -0
- data/ext/ruby_headers/215/vm_opts.h +56 -0
- data/ext/stackprofx.c +622 -0
- data/sample.rb +34 -0
- data/stackprofx.gemspec +20 -0
- data/test/test_stackprofx.rb +158 -0
- metadata +113 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
iseq.h -
|
4
|
+
|
5
|
+
$Author: ko1 $
|
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
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
16
|
+
|
17
|
+
/* compile.c */
|
18
|
+
VALUE rb_iseq_compile_node(VALUE self, NODE *node);
|
19
|
+
int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
|
20
|
+
VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
|
21
|
+
VALUE exception, VALUE body);
|
22
|
+
|
23
|
+
/* iseq.c */
|
24
|
+
void rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj);
|
25
|
+
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
|
26
|
+
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
|
27
|
+
struct st_table *ruby_insn_make_insn_table(void);
|
28
|
+
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
|
29
|
+
|
30
|
+
int rb_iseq_line_trace_each(VALUE iseqval, int (*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data);
|
31
|
+
VALUE rb_iseq_line_trace_all(VALUE iseqval);
|
32
|
+
VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set);
|
33
|
+
|
34
|
+
/* proc.c */
|
35
|
+
rb_iseq_t *rb_method_get_iseq(VALUE body);
|
36
|
+
rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
|
37
|
+
|
38
|
+
struct rb_compile_option_struct {
|
39
|
+
int inline_const_cache;
|
40
|
+
int peephole_optimization;
|
41
|
+
int tailcall_optimization;
|
42
|
+
int specialized_instruction;
|
43
|
+
int operands_unification;
|
44
|
+
int instructions_unification;
|
45
|
+
int stack_caching;
|
46
|
+
int trace_instruction;
|
47
|
+
int debug_level;
|
48
|
+
};
|
49
|
+
|
50
|
+
struct iseq_line_info_entry {
|
51
|
+
unsigned int position;
|
52
|
+
unsigned int line_no;
|
53
|
+
};
|
54
|
+
|
55
|
+
struct iseq_catch_table_entry {
|
56
|
+
enum catch_type {
|
57
|
+
CATCH_TYPE_RESCUE = INT2FIX(1),
|
58
|
+
CATCH_TYPE_ENSURE = INT2FIX(2),
|
59
|
+
CATCH_TYPE_RETRY = INT2FIX(3),
|
60
|
+
CATCH_TYPE_BREAK = INT2FIX(4),
|
61
|
+
CATCH_TYPE_REDO = INT2FIX(5),
|
62
|
+
CATCH_TYPE_NEXT = INT2FIX(6)
|
63
|
+
} type;
|
64
|
+
VALUE iseq;
|
65
|
+
unsigned long start;
|
66
|
+
unsigned long end;
|
67
|
+
unsigned long cont;
|
68
|
+
unsigned long sp;
|
69
|
+
};
|
70
|
+
|
71
|
+
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
|
72
|
+
|
73
|
+
struct iseq_compile_data_storage {
|
74
|
+
struct iseq_compile_data_storage *next;
|
75
|
+
unsigned long pos;
|
76
|
+
unsigned long size;
|
77
|
+
char *buff;
|
78
|
+
};
|
79
|
+
|
80
|
+
struct iseq_compile_data {
|
81
|
+
/* GC is needed */
|
82
|
+
const VALUE err_info;
|
83
|
+
VALUE mark_ary;
|
84
|
+
const VALUE catch_table_ary; /* Array */
|
85
|
+
|
86
|
+
/* GC is not needed */
|
87
|
+
struct iseq_label_data *start_label;
|
88
|
+
struct iseq_label_data *end_label;
|
89
|
+
struct iseq_label_data *redo_label;
|
90
|
+
VALUE current_block;
|
91
|
+
VALUE ensure_node;
|
92
|
+
VALUE for_iseq;
|
93
|
+
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
|
94
|
+
int loopval_popped; /* used by NODE_BREAK */
|
95
|
+
int cached_const;
|
96
|
+
struct iseq_compile_data_storage *storage_head;
|
97
|
+
struct iseq_compile_data_storage *storage_current;
|
98
|
+
int last_line;
|
99
|
+
int last_coverable_line;
|
100
|
+
int label_no;
|
101
|
+
int node_level;
|
102
|
+
const rb_compile_option_t *option;
|
103
|
+
#if SUPPORT_JOKE
|
104
|
+
st_table *labels_table;
|
105
|
+
#endif
|
106
|
+
};
|
107
|
+
|
108
|
+
/* defined? */
|
109
|
+
|
110
|
+
enum defined_type {
|
111
|
+
DEFINED_NIL = 1,
|
112
|
+
DEFINED_IVAR,
|
113
|
+
DEFINED_LVAR,
|
114
|
+
DEFINED_GVAR,
|
115
|
+
DEFINED_CVAR,
|
116
|
+
DEFINED_CONST,
|
117
|
+
DEFINED_METHOD,
|
118
|
+
DEFINED_YIELD,
|
119
|
+
DEFINED_ZSUPER,
|
120
|
+
DEFINED_SELF,
|
121
|
+
DEFINED_TRUE,
|
122
|
+
DEFINED_FALSE,
|
123
|
+
DEFINED_ASGN,
|
124
|
+
DEFINED_EXPR,
|
125
|
+
DEFINED_IVAR2,
|
126
|
+
DEFINED_REF,
|
127
|
+
DEFINED_FUNC
|
128
|
+
};
|
129
|
+
|
130
|
+
VALUE rb_iseq_defined_string(enum defined_type type);
|
131
|
+
|
132
|
+
#define DEFAULT_SPECIAL_VAR_COUNT 2
|
133
|
+
|
134
|
+
RUBY_SYMBOL_EXPORT_END
|
135
|
+
|
136
|
+
#endif /* RUBY_COMPILE_H */
|
@@ -0,0 +1,142 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
method.h -
|
4
|
+
|
5
|
+
$Author: tmm1 $
|
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
|
+
#include "internal.h"
|
15
|
+
|
16
|
+
#ifndef END_OF_ENUMERATION
|
17
|
+
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
18
|
+
# define END_OF_ENUMERATION(key)
|
19
|
+
# else
|
20
|
+
# define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
|
21
|
+
# endif
|
22
|
+
#endif
|
23
|
+
|
24
|
+
typedef enum {
|
25
|
+
NOEX_PUBLIC = 0x00,
|
26
|
+
NOEX_NOSUPER = 0x01,
|
27
|
+
NOEX_PRIVATE = 0x02,
|
28
|
+
NOEX_PROTECTED = 0x04,
|
29
|
+
NOEX_MASK = 0x06,
|
30
|
+
NOEX_BASIC = 0x08,
|
31
|
+
NOEX_UNDEF = NOEX_NOSUPER,
|
32
|
+
NOEX_MODFUNC = 0x12,
|
33
|
+
NOEX_SUPER = 0x20,
|
34
|
+
NOEX_VCALL = 0x40,
|
35
|
+
NOEX_RESPONDS = 0x80,
|
36
|
+
|
37
|
+
NOEX_BIT_WIDTH = 8,
|
38
|
+
NOEX_SAFE_SHIFT_OFFSET = ((NOEX_BIT_WIDTH+3)/4)*4 /* round up to nibble */
|
39
|
+
} rb_method_flag_t;
|
40
|
+
|
41
|
+
#define NOEX_SAFE(n) ((int)((n) >> NOEX_SAFE_SHIFT_OFFSET) & 0x0F)
|
42
|
+
#define NOEX_WITH(n, s) (((s) << NOEX_SAFE_SHIFT_OFFSET) | (n) | (ruby_running ? 0 : NOEX_BASIC))
|
43
|
+
#define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
|
44
|
+
|
45
|
+
/* method data type */
|
46
|
+
|
47
|
+
typedef enum {
|
48
|
+
VM_METHOD_TYPE_ISEQ,
|
49
|
+
VM_METHOD_TYPE_CFUNC,
|
50
|
+
VM_METHOD_TYPE_ATTRSET,
|
51
|
+
VM_METHOD_TYPE_IVAR,
|
52
|
+
VM_METHOD_TYPE_BMETHOD,
|
53
|
+
VM_METHOD_TYPE_ZSUPER,
|
54
|
+
VM_METHOD_TYPE_UNDEF,
|
55
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
56
|
+
VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
|
57
|
+
VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */
|
58
|
+
VM_METHOD_TYPE_REFINED,
|
59
|
+
|
60
|
+
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
61
|
+
} rb_method_type_t;
|
62
|
+
|
63
|
+
struct rb_call_info_struct;
|
64
|
+
|
65
|
+
typedef struct rb_method_cfunc_struct {
|
66
|
+
VALUE (*func)(ANYARGS);
|
67
|
+
VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
|
68
|
+
int argc;
|
69
|
+
} rb_method_cfunc_t;
|
70
|
+
|
71
|
+
typedef struct rb_method_attr_struct {
|
72
|
+
ID id;
|
73
|
+
const VALUE location;
|
74
|
+
} rb_method_attr_t;
|
75
|
+
|
76
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
77
|
+
|
78
|
+
typedef struct rb_method_definition_struct {
|
79
|
+
rb_method_type_t type; /* method type */
|
80
|
+
ID original_id;
|
81
|
+
union {
|
82
|
+
rb_iseq_t * const iseq; /* should be mark */
|
83
|
+
rb_method_cfunc_t cfunc;
|
84
|
+
rb_method_attr_t attr;
|
85
|
+
const VALUE proc; /* should be mark */
|
86
|
+
enum method_optimized_type {
|
87
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
88
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
89
|
+
|
90
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
91
|
+
} optimize_type;
|
92
|
+
struct rb_method_entry_struct *orig_me;
|
93
|
+
} body;
|
94
|
+
int alias_count;
|
95
|
+
} rb_method_definition_t;
|
96
|
+
|
97
|
+
typedef struct rb_method_entry_struct {
|
98
|
+
rb_method_flag_t flag;
|
99
|
+
char mark;
|
100
|
+
rb_method_definition_t *def;
|
101
|
+
ID called_id;
|
102
|
+
VALUE klass; /* should be mark */
|
103
|
+
} rb_method_entry_t;
|
104
|
+
|
105
|
+
struct unlinked_method_entry_list_entry {
|
106
|
+
struct unlinked_method_entry_list_entry *next;
|
107
|
+
rb_method_entry_t *me;
|
108
|
+
};
|
109
|
+
|
110
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
111
|
+
|
112
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
113
|
+
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
|
114
|
+
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
|
115
|
+
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
116
|
+
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
117
|
+
rb_method_entry_t *rb_resolve_refined_method(VALUE refinements,
|
118
|
+
const rb_method_entry_t *me,
|
119
|
+
VALUE *defined_class_ptr);
|
120
|
+
rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id,
|
121
|
+
VALUE *defined_class_ptr);
|
122
|
+
rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id,
|
123
|
+
VALUE *defined_class_ptr);
|
124
|
+
|
125
|
+
rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
|
126
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
|
127
|
+
|
128
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
129
|
+
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
130
|
+
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
131
|
+
|
132
|
+
VALUE rb_method_entry_location(rb_method_entry_t *me);
|
133
|
+
VALUE rb_mod_method_location(VALUE mod, ID id);
|
134
|
+
VALUE rb_obj_method_location(VALUE obj, ID id);
|
135
|
+
|
136
|
+
void rb_mark_method_entry(const rb_method_entry_t *me);
|
137
|
+
void rb_free_method_entry(rb_method_entry_t *me);
|
138
|
+
void rb_sweep_method_entry(void *vm);
|
139
|
+
void rb_free_m_tbl(st_table *tbl);
|
140
|
+
void rb_free_m_tbl_wrapper(struct method_table_wrapper *wrapper);
|
141
|
+
|
142
|
+
#endif /* METHOD_H */
|