ruby-internal 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/bin/ruby-internal-node-dump +1 -1
  2. data/bin/ruby-internal-obfuscate +1 -1
  3. data/ext/internal/method/extconf.rb +4 -0
  4. data/ext/internal/method/internal_method.h +65 -0
  5. data/ext/internal/method/{method.h.rpp → internal_method.h.rpp} +21 -0
  6. data/ext/internal/method/method.c +69 -13
  7. data/ext/internal/module/classpath.c +12 -14
  8. data/ext/internal/module/extconf.rb +3 -2
  9. data/ext/internal/module/module.c +36 -15
  10. data/ext/internal/node/block.h.rpp +1 -0
  11. data/ext/internal/node/extconf.rb +0 -22
  12. data/ext/internal/node/global_entry.h +45 -3
  13. data/ext/internal/node/global_entry.h.rpp +12 -3
  14. data/ext/internal/node/node.c +42 -15
  15. data/ext/internal/node/node_type_descrip.c +16 -20
  16. data/ext/internal/node/node_type_descrip.c.rpp +1 -0
  17. data/ext/internal/node/nodeinfo.c +133 -281
  18. data/ext/internal/node/nodeinfo.c.rpp +8 -4
  19. data/ext/internal/node/nodeinfo.h.rpp +2 -1
  20. data/ext/internal/noex/noex.c +4 -0
  21. data/ext/internal/proc/proc.c +2 -2
  22. data/ext/internal/vm/constants/constants.c +2 -0
  23. data/ext/internal/vm/constants/extconf.rb +2 -0
  24. data/ext/internal/vm/control_frame/control_frame.c +21 -3
  25. data/ext/internal/vm/control_frame/extconf.rb +4 -0
  26. data/ext/internal/vm/inline_cache/inline_cache.c +12 -5
  27. data/ext/internal/vm/instruction/insns_info.c +141 -64
  28. data/ext/internal/vm/instruction/insns_info.c.rpp +3 -0
  29. data/ext/internal/vm/instruction/insns_info.h +80 -71
  30. data/ext/internal/vm/iseq/iseq.c +6 -6
  31. data/ext/internal/vm/iseq/iseq_load.inc.rpp +6 -3
  32. data/ext/mkmf-ruby-internal.rb +21 -1
  33. data/ext/ruby_source_dir.rb +6 -2
  34. data/post-setup.rb +1 -0
  35. data/pre-config.rb +9 -0
  36. data/run_tests.rb +1 -0
  37. data/test/test_method.rb +1 -1
  38. data/test/test_module.rb +1 -1
  39. metadata +309 -321
  40. data/ext/internal/method/method.h +0 -20
  41. data/ext/internal/yarv-headers/debug.h +0 -36
  42. data/ext/internal/yarv-headers/dln.h +0 -41
  43. data/ext/internal/yarv-headers/encdb.h +0 -147
  44. data/ext/internal/yarv-headers/eval_intern.h +0 -215
  45. data/ext/internal/yarv-headers/gc.h +0 -75
  46. data/ext/internal/yarv-headers/id.h +0 -163
  47. data/ext/internal/yarv-headers/iseq.h +0 -103
  48. data/ext/internal/yarv-headers/node.h +0 -516
  49. data/ext/internal/yarv-headers/parse.h +0 -188
  50. data/ext/internal/yarv-headers/regenc.h +0 -207
  51. data/ext/internal/yarv-headers/regint.h +0 -842
  52. data/ext/internal/yarv-headers/regparse.h +0 -351
  53. data/ext/internal/yarv-headers/revision.h +0 -1
  54. data/ext/internal/yarv-headers/thread_pthread.h +0 -24
  55. data/ext/internal/yarv-headers/thread_win32.h +0 -33
  56. data/ext/internal/yarv-headers/transcode_data.h +0 -106
  57. data/ext/internal/yarv-headers/transdb.h +0 -147
  58. data/ext/internal/yarv-headers/version.h +0 -54
  59. data/ext/internal/yarv-headers/vm_core.h +0 -646
  60. data/ext/internal/yarv-headers/vm_exec.h +0 -184
  61. data/ext/internal/yarv-headers/vm_insnhelper.h +0 -195
  62. data/ext/internal/yarv-headers/vm_opts.h +0 -51
  63. data/ext/rubypp.rb +0 -97
@@ -1,147 +0,0 @@
1
- rb_declare_transcoder("Big5", "UTF-8", "big5");
2
- rb_declare_transcoder("UTF-8", "Big5", "big5");
3
- rb_declare_transcoder("GB2312", "UTF-8", "chinese");
4
- rb_declare_transcoder("GB12345", "UTF-8", "chinese");
5
- rb_declare_transcoder("UTF-8", "GB2312", "chinese");
6
- rb_declare_transcoder("UTF-8", "GB12345", "chinese");
7
- rb_declare_transcoder("", "amp_escape", "escape");
8
- rb_declare_transcoder("", "xml_text_escape", "escape");
9
- rb_declare_transcoder("", "xml_attr_content_escape", "escape");
10
- rb_declare_transcoder("", "xml_attr_quote", "escape");
11
- rb_declare_transcoder("GB18030", "UTF-8", "gb18030");
12
- rb_declare_transcoder("UTF-8", "GB18030", "gb18030");
13
- rb_declare_transcoder("GBK", "UTF-8", "gbk");
14
- rb_declare_transcoder("UTF-8", "GBK", "gbk");
15
- rb_declare_transcoder("ISO-2022-JP", "stateless-ISO-2022-JP", "iso2022");
16
- rb_declare_transcoder("stateless-ISO-2022-JP", "ISO-2022-JP", "iso2022");
17
- rb_declare_transcoder("stateless-ISO-2022-JP", "EUC-JP", "iso2022");
18
- rb_declare_transcoder("EUC-JP", "stateless-ISO-2022-JP", "iso2022");
19
- rb_declare_transcoder("EUC-JP", "Shift_JIS", "japanese");
20
- rb_declare_transcoder("Shift_JIS", "EUC-JP", "japanese");
21
- rb_declare_transcoder("EUC-JP", "UTF-8", "japanese_euc");
22
- rb_declare_transcoder("eucJP-ms", "UTF-8", "japanese_euc");
23
- rb_declare_transcoder("CP51932", "UTF-8", "japanese_euc");
24
- rb_declare_transcoder("UTF-8", "EUC-JP", "japanese_euc");
25
- rb_declare_transcoder("UTF-8", "eucJP-ms", "japanese_euc");
26
- rb_declare_transcoder("UTF-8", "CP51932", "japanese_euc");
27
- rb_declare_transcoder("Shift_JIS", "UTF-8", "japanese_sjis");
28
- rb_declare_transcoder("Windows-31J", "UTF-8", "japanese_sjis");
29
- rb_declare_transcoder("UTF-8", "Shift_JIS", "japanese_sjis");
30
- rb_declare_transcoder("UTF-8", "Windows-31J", "japanese_sjis");
31
- rb_declare_transcoder("UTF-8", "EUC-KR", "korean");
32
- rb_declare_transcoder("EUC-KR", "UTF-8", "korean");
33
- rb_declare_transcoder("UTF-8", "CP949", "korean");
34
- rb_declare_transcoder("CP949", "UTF-8", "korean");
35
- rb_declare_transcoder("", "universal_newline", "newline");
36
- rb_declare_transcoder("", "crlf_newline", "newline");
37
- rb_declare_transcoder("", "cr_newline", "newline");
38
- rb_declare_transcoder("US-ASCII", "UTF-8", "single_byte");
39
- rb_declare_transcoder("UTF-8", "US-ASCII", "single_byte");
40
- rb_declare_transcoder("ASCII-8BIT", "UTF-8", "single_byte");
41
- rb_declare_transcoder("UTF-8", "ASCII-8BIT", "single_byte");
42
- rb_declare_transcoder("ISO-8859-1", "UTF-8", "single_byte");
43
- rb_declare_transcoder("UTF-8", "ISO-8859-1", "single_byte");
44
- rb_declare_transcoder("ISO-8859-2", "UTF-8", "single_byte");
45
- rb_declare_transcoder("UTF-8", "ISO-8859-2", "single_byte");
46
- rb_declare_transcoder("ISO-8859-3", "UTF-8", "single_byte");
47
- rb_declare_transcoder("UTF-8", "ISO-8859-3", "single_byte");
48
- rb_declare_transcoder("ISO-8859-4", "UTF-8", "single_byte");
49
- rb_declare_transcoder("UTF-8", "ISO-8859-4", "single_byte");
50
- rb_declare_transcoder("ISO-8859-5", "UTF-8", "single_byte");
51
- rb_declare_transcoder("UTF-8", "ISO-8859-5", "single_byte");
52
- rb_declare_transcoder("ISO-8859-6", "UTF-8", "single_byte");
53
- rb_declare_transcoder("UTF-8", "ISO-8859-6", "single_byte");
54
- rb_declare_transcoder("ISO-8859-7", "UTF-8", "single_byte");
55
- rb_declare_transcoder("UTF-8", "ISO-8859-7", "single_byte");
56
- rb_declare_transcoder("ISO-8859-8", "UTF-8", "single_byte");
57
- rb_declare_transcoder("UTF-8", "ISO-8859-8", "single_byte");
58
- rb_declare_transcoder("ISO-8859-9", "UTF-8", "single_byte");
59
- rb_declare_transcoder("UTF-8", "ISO-8859-9", "single_byte");
60
- rb_declare_transcoder("ISO-8859-10", "UTF-8", "single_byte");
61
- rb_declare_transcoder("UTF-8", "ISO-8859-10", "single_byte");
62
- rb_declare_transcoder("ISO-8859-11", "UTF-8", "single_byte");
63
- rb_declare_transcoder("UTF-8", "ISO-8859-11", "single_byte");
64
- rb_declare_transcoder("ISO-8859-13", "UTF-8", "single_byte");
65
- rb_declare_transcoder("UTF-8", "ISO-8859-13", "single_byte");
66
- rb_declare_transcoder("ISO-8859-14", "UTF-8", "single_byte");
67
- rb_declare_transcoder("UTF-8", "ISO-8859-14", "single_byte");
68
- rb_declare_transcoder("ISO-8859-15", "UTF-8", "single_byte");
69
- rb_declare_transcoder("UTF-8", "ISO-8859-15", "single_byte");
70
- rb_declare_transcoder("WINDOWS-874", "UTF-8", "single_byte");
71
- rb_declare_transcoder("UTF-8", "WINDOWS-874", "single_byte");
72
- rb_declare_transcoder("WINDOWS-1250", "UTF-8", "single_byte");
73
- rb_declare_transcoder("UTF-8", "WINDOWS-1250", "single_byte");
74
- rb_declare_transcoder("WINDOWS-1251", "UTF-8", "single_byte");
75
- rb_declare_transcoder("UTF-8", "WINDOWS-1251", "single_byte");
76
- rb_declare_transcoder("WINDOWS-1252", "UTF-8", "single_byte");
77
- rb_declare_transcoder("UTF-8", "WINDOWS-1252", "single_byte");
78
- rb_declare_transcoder("WINDOWS-1253", "UTF-8", "single_byte");
79
- rb_declare_transcoder("UTF-8", "WINDOWS-1253", "single_byte");
80
- rb_declare_transcoder("WINDOWS-1254", "UTF-8", "single_byte");
81
- rb_declare_transcoder("UTF-8", "WINDOWS-1254", "single_byte");
82
- rb_declare_transcoder("WINDOWS-1255", "UTF-8", "single_byte");
83
- rb_declare_transcoder("UTF-8", "WINDOWS-1255", "single_byte");
84
- rb_declare_transcoder("WINDOWS-1256", "UTF-8", "single_byte");
85
- rb_declare_transcoder("UTF-8", "WINDOWS-1256", "single_byte");
86
- rb_declare_transcoder("WINDOWS-1257", "UTF-8", "single_byte");
87
- rb_declare_transcoder("UTF-8", "WINDOWS-1257", "single_byte");
88
- rb_declare_transcoder("IBM437", "UTF-8", "single_byte");
89
- rb_declare_transcoder("UTF-8", "IBM437", "single_byte");
90
- rb_declare_transcoder("IBM775", "UTF-8", "single_byte");
91
- rb_declare_transcoder("UTF-8", "IBM775", "single_byte");
92
- rb_declare_transcoder("IBM852", "UTF-8", "single_byte");
93
- rb_declare_transcoder("UTF-8", "IBM852", "single_byte");
94
- rb_declare_transcoder("IBM855", "UTF-8", "single_byte");
95
- rb_declare_transcoder("UTF-8", "IBM855", "single_byte");
96
- rb_declare_transcoder("IBM857", "UTF-8", "single_byte");
97
- rb_declare_transcoder("UTF-8", "IBM857", "single_byte");
98
- rb_declare_transcoder("IBM860", "UTF-8", "single_byte");
99
- rb_declare_transcoder("UTF-8", "IBM860", "single_byte");
100
- rb_declare_transcoder("IBM861", "UTF-8", "single_byte");
101
- rb_declare_transcoder("UTF-8", "IBM861", "single_byte");
102
- rb_declare_transcoder("IBM862", "UTF-8", "single_byte");
103
- rb_declare_transcoder("UTF-8", "IBM862", "single_byte");
104
- rb_declare_transcoder("IBM863", "UTF-8", "single_byte");
105
- rb_declare_transcoder("UTF-8", "IBM863", "single_byte");
106
- rb_declare_transcoder("IBM865", "UTF-8", "single_byte");
107
- rb_declare_transcoder("UTF-8", "IBM865", "single_byte");
108
- rb_declare_transcoder("IBM866", "UTF-8", "single_byte");
109
- rb_declare_transcoder("UTF-8", "IBM866", "single_byte");
110
- rb_declare_transcoder("IBM869", "UTF-8", "single_byte");
111
- rb_declare_transcoder("UTF-8", "IBM869", "single_byte");
112
- rb_declare_transcoder("MACCROATIAN", "UTF-8", "single_byte");
113
- rb_declare_transcoder("UTF-8", "MACCROATIAN", "single_byte");
114
- rb_declare_transcoder("MACCYRILLIC", "UTF-8", "single_byte");
115
- rb_declare_transcoder("UTF-8", "MACCYRILLIC", "single_byte");
116
- rb_declare_transcoder("MACGREEK", "UTF-8", "single_byte");
117
- rb_declare_transcoder("UTF-8", "MACGREEK", "single_byte");
118
- rb_declare_transcoder("MACICELAND", "UTF-8", "single_byte");
119
- rb_declare_transcoder("UTF-8", "MACICELAND", "single_byte");
120
- rb_declare_transcoder("MACROMAN", "UTF-8", "single_byte");
121
- rb_declare_transcoder("UTF-8", "MACROMAN", "single_byte");
122
- rb_declare_transcoder("MACROMANIA", "UTF-8", "single_byte");
123
- rb_declare_transcoder("UTF-8", "MACROMANIA", "single_byte");
124
- rb_declare_transcoder("MACTURKISH", "UTF-8", "single_byte");
125
- rb_declare_transcoder("UTF-8", "MACTURKISH", "single_byte");
126
- rb_declare_transcoder("MACUKRAINE", "UTF-8", "single_byte");
127
- rb_declare_transcoder("UTF-8", "MACUKRAINE", "single_byte");
128
- rb_declare_transcoder("KOI8-U", "UTF-8", "single_byte");
129
- rb_declare_transcoder("UTF-8", "KOI8-U", "single_byte");
130
- rb_declare_transcoder("KOI8-R", "UTF-8", "single_byte");
131
- rb_declare_transcoder("UTF-8", "KOI8-R", "single_byte");
132
- rb_declare_transcoder("TIS-620", "UTF-8", "single_byte");
133
- rb_declare_transcoder("UTF-8", "TIS-620", "single_byte");
134
- rb_declare_transcoder("CP850", "UTF-8", "single_byte");
135
- rb_declare_transcoder("UTF-8", "CP850", "single_byte");
136
- rb_declare_transcoder("CP852", "UTF-8", "single_byte");
137
- rb_declare_transcoder("UTF-8", "CP852", "single_byte");
138
- rb_declare_transcoder("CP855", "UTF-8", "single_byte");
139
- rb_declare_transcoder("UTF-8", "CP855", "single_byte");
140
- rb_declare_transcoder("UTF-16BE", "UTF-8", "utf_16_32");
141
- rb_declare_transcoder("UTF-8", "UTF-16BE", "utf_16_32");
142
- rb_declare_transcoder("UTF-16LE", "UTF-8", "utf_16_32");
143
- rb_declare_transcoder("UTF-8", "UTF-16LE", "utf_16_32");
144
- rb_declare_transcoder("UTF-32BE", "UTF-8", "utf_16_32");
145
- rb_declare_transcoder("UTF-8", "UTF-32BE", "utf_16_32");
146
- rb_declare_transcoder("UTF-32LE", "UTF-8", "utf_16_32");
147
- rb_declare_transcoder("UTF-8", "UTF-32LE", "utf_16_32");
@@ -1,54 +0,0 @@
1
- #define RUBY_VERSION "1.9.1"
2
- #define RUBY_RELEASE_DATE "2009-07-16"
3
- #define RUBY_PATCHLEVEL 243
4
- #define RUBY_VERSION_MAJOR 1
5
- #define RUBY_VERSION_MINOR 9
6
- #define RUBY_VERSION_TEENY 1
7
- #define RUBY_RELEASE_YEAR 2009
8
- #define RUBY_RELEASE_MONTH 7
9
- #define RUBY_RELEASE_DAY 12
10
-
11
- #ifdef RUBY_EXTERN
12
- RUBY_EXTERN const char ruby_version[];
13
- RUBY_EXTERN const char ruby_release_date[];
14
- RUBY_EXTERN const char ruby_platform[];
15
- RUBY_EXTERN const int ruby_patchlevel;
16
- RUBY_EXTERN const char ruby_description[];
17
- RUBY_EXTERN const char ruby_copyright[];
18
- #endif
19
-
20
- #define RUBY_AUTHOR "Yukihiro Matsumoto"
21
- #define RUBY_BIRTH_YEAR 1993
22
- #define RUBY_BIRTH_MONTH 2
23
- #define RUBY_BIRTH_DAY 24
24
-
25
- #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL)
26
-
27
- #ifndef RUBY_REVISION
28
- # include "revision.h"
29
- #endif
30
- # ifndef RUBY_REVISION
31
- # define RUBY_REVISION 0
32
- #endif
33
-
34
- #if RUBY_REVISION
35
- # ifdef RUBY_BRANCH_NAME
36
- # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION)
37
- # else
38
- # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION)
39
- # endif
40
- #else
41
- # define RUBY_REVISION_STR ""
42
- #endif
43
-
44
- # define RUBY_DESCRIPTION \
45
- "ruby "RUBY_VERSION \
46
- RUBY_PATCHLEVEL_STR \
47
- " ("RUBY_RELEASE_DATE \
48
- RUBY_REVISION_STR") " \
49
- "["RUBY_PLATFORM"]"
50
- # define RUBY_COPYRIGHT \
51
- "ruby - Copyright (C) " \
52
- STRINGIZE(RUBY_BIRTH_YEAR)"-" \
53
- STRINGIZE(RUBY_RELEASE_YEAR)" " \
54
- RUBY_AUTHOR
@@ -1,646 +0,0 @@
1
- /**********************************************************************
2
-
3
- vm_core.h -
4
-
5
- $Author: yugui $
6
- created at: 04/01/01 19:41:38 JST
7
-
8
- Copyright (C) 2004-2007 Koichi Sasada
9
-
10
- **********************************************************************/
11
-
12
- #ifndef RUBY_VM_CORE_H
13
- #define RUBY_VM_CORE_H
14
-
15
- #define RUBY_VM_THREAD_MODEL 2
16
-
17
- #include "ruby/ruby.h"
18
- #include "ruby/st.h"
19
-
20
- #include "node.h"
21
- #include "debug.h"
22
- #include "vm_opts.h"
23
- #include "id.h"
24
-
25
- #if defined(_WIN32)
26
- #include "thread_win32.h"
27
- #elif defined(HAVE_PTHREAD_H)
28
- #include "thread_pthread.h"
29
- #else
30
- #error "unsupported thread type"
31
- #endif
32
-
33
- #include <setjmp.h>
34
- #include <signal.h>
35
-
36
- #ifndef NSIG
37
- # define NSIG (_SIGMAX + 1) /* For QNX */
38
- #endif
39
-
40
- #define RUBY_NSIG NSIG
41
-
42
- #ifdef HAVE_STDARG_PROTOTYPES
43
- #include <stdarg.h>
44
- #define va_init_list(a,b) va_start(a,b)
45
- #else
46
- #include <varargs.h>
47
- #define va_init_list(a,b) va_start(a)
48
- #endif
49
-
50
- /*****************/
51
- /* configuration */
52
- /*****************/
53
-
54
- /* gcc ver. check */
55
- #if defined(__GNUC__) && __GNUC__ >= 2
56
-
57
- #if OPT_TOKEN_THREADED_CODE
58
- #if OPT_DIRECT_THREADED_CODE
59
- #undef OPT_DIRECT_THREADED_CODE
60
- #endif
61
- #endif
62
-
63
- #else /* defined(__GNUC__) && __GNUC__ >= 2 */
64
-
65
- /* disable threaded code options */
66
- #if OPT_DIRECT_THREADED_CODE
67
- #undef OPT_DIRECT_THREADED_CODE
68
- #endif
69
- #if OPT_TOKEN_THREADED_CODE
70
- #undef OPT_TOKEN_THREADED_CODE
71
- #endif
72
- #endif
73
-
74
- /* call threaded code */
75
- #if OPT_CALL_THREADED_CODE
76
- #if OPT_DIRECT_THREADED_CODE
77
- #undef OPT_DIRECT_THREADED_CODE
78
- #endif /* OPT_DIRECT_THREADED_CODE */
79
- #if OPT_STACK_CACHING
80
- #undef OPT_STACK_CACHING
81
- #endif /* OPT_STACK_CACHING */
82
- #endif /* OPT_CALL_THREADED_CODE */
83
-
84
- /* likely */
85
- #if __GNUC__ >= 3
86
- #define LIKELY(x) (__builtin_expect((x), 1))
87
- #define UNLIKELY(x) (__builtin_expect((x), 0))
88
- #else /* __GNUC__ >= 3 */
89
- #define LIKELY(x) (x)
90
- #define UNLIKELY(x) (x)
91
- #endif /* __GNUC__ >= 3 */
92
-
93
- typedef unsigned long rb_num_t;
94
-
95
- struct iseq_compile_data_ensure_node_stack;
96
-
97
- typedef struct rb_compile_option_struct {
98
- int inline_const_cache;
99
- int peephole_optimization;
100
- int tailcall_optimization;
101
- int specialized_instruction;
102
- int operands_unification;
103
- int instructions_unification;
104
- int stack_caching;
105
- int trace_instruction;
106
- int debug_level;
107
- } rb_compile_option_t;
108
-
109
- #if 1
110
- #define GetCoreDataFromValue(obj, type, ptr) do { \
111
- ptr = (type*)DATA_PTR(obj); \
112
- } while (0)
113
- #else
114
- #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct(obj, type, ptr)
115
- #endif
116
-
117
- #define GetISeqPtr(obj, ptr) \
118
- GetCoreDataFromValue(obj, rb_iseq_t, ptr)
119
-
120
- struct rb_iseq_struct;
121
-
122
- struct rb_iseq_struct {
123
- /***************/
124
- /* static data */
125
- /***************/
126
-
127
- VALUE type; /* instruction sequence type */
128
- VALUE name; /* String: iseq name */
129
- VALUE filename; /* file information where this sequence from */
130
- VALUE *iseq; /* iseq (insn number and openrads) */
131
- VALUE *iseq_encoded; /* encoded iseq */
132
- unsigned long iseq_size;
133
- VALUE mark_ary; /* Array: includes operands which should be GC marked */
134
- VALUE coverage; /* coverage array */
135
-
136
- /* insn info, must be freed */
137
- struct iseq_insn_info_entry *insn_info_table;
138
- unsigned long insn_info_size;
139
-
140
- ID *local_table; /* must free */
141
- int local_table_size;
142
-
143
- /* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
144
- int local_size;
145
-
146
- /**
147
- * argument information
148
- *
149
- * def m(a1, a2, ..., aM, # mandatory
150
- * b1=(...), b2=(...), ..., bN=(...), # optinal
151
- * *c, # rest
152
- * d1, d2, ..., dO, # post
153
- * &e) # block
154
- * =>
155
- *
156
- * argc = M
157
- * arg_rest = M+N+1 // or -1 if no rest arg
158
- * arg_opts = N
159
- * arg_opts_tbl = [ (N entries) ]
160
- * arg_post_len = O // 0 if no post arguments
161
- * arg_post_start = M+N+2
162
- * arg_block = M+N + 1 + O + 1 // -1 if no block arg
163
- * arg_simple = 0 if not simple arguments.
164
- * = 1 if no opt, rest, post, block.
165
- * = 2 if ambiguos block parameter ({|a|}).
166
- * arg_size = argument size.
167
- */
168
-
169
- int argc;
170
- int arg_simple;
171
- int arg_rest;
172
- int arg_block;
173
- int arg_opts;
174
- int arg_post_len;
175
- int arg_post_start;
176
- int arg_size;
177
- VALUE *arg_opt_table;
178
-
179
- int stack_max; /* for stack overflow check */
180
-
181
- /* catch table */
182
- struct iseq_catch_table_entry *catch_table;
183
- int catch_table_size;
184
-
185
- /* for child iseq */
186
- struct rb_iseq_struct *parent_iseq;
187
- struct rb_iseq_struct *local_iseq;
188
-
189
- /****************/
190
- /* dynamic data */
191
- /****************/
192
-
193
- VALUE self;
194
- VALUE orig; /* non-NULL if its data have origin */
195
-
196
- /* block inlining */
197
- /*
198
- * NODE *node;
199
- * void *special_block_builder;
200
- * void *cached_special_block_builder;
201
- * VALUE cached_special_block;
202
- */
203
-
204
- /* klass/module nest information stack (cref) */
205
- NODE *cref_stack;
206
- VALUE klass;
207
-
208
- /* misc */
209
- ID defined_method_id; /* for define_method */
210
-
211
- /* used at compile time */
212
- struct iseq_compile_data *compile_data;
213
- };
214
-
215
- enum ruby_special_exceptions {
216
- ruby_error_reenter,
217
- ruby_error_nomemory,
218
- ruby_error_sysstack,
219
- ruby_special_error_count
220
- };
221
-
222
- typedef struct rb_iseq_struct rb_iseq_t;
223
-
224
- #define GetVMPtr(obj, ptr) \
225
- GetCoreDataFromValue(obj, rb_vm_t, ptr)
226
-
227
- typedef struct rb_vm_struct {
228
- VALUE self;
229
-
230
- rb_thread_lock_t global_vm_lock;
231
-
232
- struct rb_thread_struct *main_thread;
233
- struct rb_thread_struct *running_thread;
234
-
235
- st_table *living_threads;
236
- VALUE thgroup_default;
237
-
238
- int running;
239
- int thread_abort_on_exception;
240
- unsigned long trace_flag;
241
- volatile int sleeper;
242
-
243
- /* object management */
244
- VALUE mark_object_ary;
245
-
246
- VALUE special_exceptions[ruby_special_error_count];
247
-
248
- /* load */
249
- VALUE top_self;
250
- VALUE load_path;
251
- VALUE loaded_features;
252
- struct st_table *loading_table;
253
-
254
- /* signal */
255
- struct {
256
- VALUE cmd;
257
- int safe;
258
- } trap_list[RUBY_NSIG];
259
-
260
- /* hook */
261
- rb_event_hook_t *event_hooks;
262
-
263
- int src_encoding_index;
264
-
265
- VALUE verbose, debug, progname;
266
- VALUE coverages;
267
-
268
- #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
269
- struct rb_objspace *objspace;
270
- #endif
271
- } rb_vm_t;
272
-
273
- typedef struct {
274
- VALUE *pc; /* cfp[0] */
275
- VALUE *sp; /* cfp[1] */
276
- VALUE *bp; /* cfp[2] */
277
- rb_iseq_t *iseq; /* cfp[3] */
278
- VALUE flag; /* cfp[4] */
279
- VALUE self; /* cfp[5] / block[0] */
280
- VALUE *lfp; /* cfp[6] / block[1] */
281
- VALUE *dfp; /* cfp[7] / block[2] */
282
- rb_iseq_t *block_iseq; /* cfp[8] / block[3] */
283
- VALUE proc; /* cfp[9] / block[4] */
284
- ID method_id; /* cfp[10] saved in special case */
285
- VALUE method_class; /* cfp[11] saved in special case */
286
- } rb_control_frame_t;
287
-
288
- typedef struct rb_block_struct {
289
- VALUE self; /* share with method frame if it's only block */
290
- VALUE *lfp; /* share with method frame if it's only block */
291
- VALUE *dfp; /* share with method frame if it's only block */
292
- rb_iseq_t *iseq;
293
- VALUE proc;
294
- } rb_block_t;
295
-
296
- #define GetThreadPtr(obj, ptr) \
297
- GetCoreDataFromValue(obj, rb_thread_t, ptr)
298
-
299
- enum rb_thread_status {
300
- THREAD_TO_KILL,
301
- THREAD_RUNNABLE,
302
- THREAD_STOPPED,
303
- THREAD_STOPPED_FOREVER,
304
- THREAD_KILLED
305
- };
306
-
307
- typedef RUBY_JMP_BUF rb_jmpbuf_t;
308
-
309
- struct rb_vm_tag {
310
- rb_jmpbuf_t buf;
311
- VALUE tag;
312
- VALUE retval;
313
- struct rb_vm_tag *prev;
314
- };
315
-
316
- struct rb_vm_trap_tag {
317
- struct rb_vm_trap_tag *prev;
318
- };
319
-
320
- #define RUBY_VM_VALUE_CACHE_SIZE 0x1000
321
- #define USE_VALUE_CACHE 0
322
-
323
- struct rb_unblock_callback {
324
- rb_unblock_function_t *func;
325
- void *arg;
326
- };
327
-
328
- struct rb_mutex_struct;
329
-
330
- typedef struct rb_thread_struct
331
- {
332
- VALUE self;
333
- rb_vm_t *vm;
334
-
335
- /* execution information */
336
- VALUE *stack; /* must free, must mark */
337
- unsigned long stack_size;
338
- rb_control_frame_t *cfp;
339
- int safe_level;
340
- int raised_flag;
341
- VALUE last_status; /* $? */
342
-
343
- /* passing state */
344
- int state;
345
-
346
- /* for rb_iterate */
347
- rb_block_t *passed_block;
348
-
349
- /* for load(true) */
350
- VALUE top_self;
351
- VALUE top_wrapper;
352
-
353
- /* eval env */
354
- rb_block_t *base_block;
355
-
356
- VALUE *local_lfp;
357
- VALUE local_svar;
358
-
359
- /* thread control */
360
- rb_thread_id_t thread_id;
361
- enum rb_thread_status status;
362
- int priority;
363
- int slice;
364
-
365
- native_thread_data_t native_thread_data;
366
- void *blocking_region_buffer;
367
-
368
- VALUE thgroup;
369
- VALUE value;
370
-
371
- VALUE errinfo;
372
- VALUE thrown_errinfo;
373
- int exec_signal;
374
-
375
- int interrupt_flag;
376
- rb_thread_lock_t interrupt_lock;
377
- struct rb_unblock_callback unblock;
378
- VALUE locking_mutex;
379
- struct rb_mutex_struct *keeping_mutexes;
380
- int transition_for_lock;
381
-
382
- struct rb_vm_tag *tag;
383
- struct rb_vm_trap_tag *trap_tag;
384
-
385
- int parse_in_eval;
386
- int mild_compile_error;
387
-
388
- /* storage */
389
- st_table *local_storage;
390
- #if USE_VALUE_CACHE
391
- VALUE value_cache[RUBY_VM_VALUE_CACHE_SIZE + 1];
392
- VALUE *value_cache_ptr;
393
- #endif
394
-
395
- struct rb_thread_struct *join_list_next;
396
- struct rb_thread_struct *join_list_head;
397
-
398
- VALUE first_proc;
399
- VALUE first_args;
400
- VALUE (*first_func)(ANYARGS);
401
-
402
- /* for GC */
403
- VALUE *machine_stack_start;
404
- VALUE *machine_stack_end;
405
- size_t machine_stack_maxsize;
406
- #ifdef __ia64
407
- VALUE *machine_register_stack_start;
408
- VALUE *machine_register_stack_end;
409
- size_t machine_register_stack_maxsize;
410
- #endif
411
- jmp_buf machine_regs;
412
- int mark_stack_len;
413
-
414
- /* statistics data for profiler */
415
- VALUE stat_insn_usage;
416
-
417
- /* tracer */
418
- rb_event_hook_t *event_hooks;
419
- rb_event_flag_t event_flags;
420
- int tracing;
421
-
422
- /* fiber */
423
- VALUE fiber;
424
- VALUE root_fiber;
425
- rb_jmpbuf_t root_jmpbuf;
426
-
427
- /* misc */
428
- int method_missing_reason;
429
- int abort_on_exception;
430
- } rb_thread_t;
431
-
432
- /* iseq.c */
433
- VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
434
- VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent);
435
- VALUE rb_iseq_new_main(NODE *node, VALUE filename);
436
- VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE);
437
- VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
438
- VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
439
- VALUE rb_iseq_disasm(VALUE self);
440
- VALUE rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
441
- const char *ruby_node_name(int node);
442
- int rb_iseq_first_lineno(rb_iseq_t *iseq);
443
-
444
- RUBY_EXTERN VALUE rb_cISeq;
445
- RUBY_EXTERN VALUE rb_cRubyVM;
446
- RUBY_EXTERN VALUE rb_cEnv;
447
- RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
448
-
449
- /* each thread has this size stack : 128KB */
450
- #define RUBY_VM_THREAD_STACK_SIZE (128 * 1024)
451
-
452
- struct global_entry {
453
- struct global_variable *var;
454
- ID id;
455
- };
456
-
457
- #define GetProcPtr(obj, ptr) \
458
- GetCoreDataFromValue(obj, rb_proc_t, ptr)
459
-
460
- typedef struct {
461
- rb_block_t block;
462
-
463
- VALUE envval; /* for GC mark */
464
- VALUE blockprocval;
465
- int safe_level;
466
- int is_from_method;
467
- int is_lambda;
468
- } rb_proc_t;
469
-
470
- #define GetEnvPtr(obj, ptr) \
471
- GetCoreDataFromValue(obj, rb_env_t, ptr)
472
-
473
- typedef struct {
474
- VALUE *env;
475
- int env_size;
476
- int local_size;
477
- VALUE prev_envval; /* for GC mark */
478
- rb_block_t block;
479
- } rb_env_t;
480
-
481
- #define GetBindingPtr(obj, ptr) \
482
- GetCoreDataFromValue(obj, rb_binding_t, ptr)
483
-
484
- typedef struct {
485
- VALUE env;
486
- } rb_binding_t;
487
-
488
-
489
- /* used by compile time and send insn */
490
- #define VM_CALL_ARGS_SPLAT_BIT (0x01 << 1)
491
- #define VM_CALL_ARGS_BLOCKARG_BIT (0x01 << 2)
492
- #define VM_CALL_FCALL_BIT (0x01 << 3)
493
- #define VM_CALL_VCALL_BIT (0x01 << 4)
494
- #define VM_CALL_TAILCALL_BIT (0x01 << 5)
495
- #define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
496
- #define VM_CALL_SUPER_BIT (0x01 << 7)
497
- #define VM_CALL_SEND_BIT (0x01 << 8)
498
-
499
- #define VM_SPECIAL_OBJECT_VMCORE 0x01
500
- #define VM_SPECIAL_OBJECT_CBASE 0x02
501
-
502
- #define VM_FRAME_MAGIC_METHOD 0x11
503
- #define VM_FRAME_MAGIC_BLOCK 0x21
504
- #define VM_FRAME_MAGIC_CLASS 0x31
505
- #define VM_FRAME_MAGIC_TOP 0x41
506
- #define VM_FRAME_MAGIC_FINISH 0x51
507
- #define VM_FRAME_MAGIC_CFUNC 0x61
508
- #define VM_FRAME_MAGIC_PROC 0x71
509
- #define VM_FRAME_MAGIC_IFUNC 0x81
510
- #define VM_FRAME_MAGIC_EVAL 0x91
511
- #define VM_FRAME_MAGIC_LAMBDA 0xa1
512
- #define VM_FRAME_MAGIC_MASK_BITS 8
513
- #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
514
-
515
- #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
516
-
517
- /* other frame flag */
518
- #define VM_FRAME_FLAG_PASSED 0x0100
519
-
520
-
521
- #define RUBYVM_CFUNC_FRAME_P(cfp) \
522
- (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
523
-
524
-
525
- /* inline (method|const) cache */
526
- #define NEW_INLINE_CACHE_ENTRY() NEW_WHILE(Qundef, 0, 0)
527
- #define ic_class u1.value
528
- #define ic_method u2.node
529
- #define ic_value u2.value
530
- #define ic_vmstat u3.cnt
531
- typedef NODE *IC;
532
-
533
- void rb_vm_change_state(void);
534
-
535
- typedef VALUE CDHASH;
536
-
537
- #ifndef FUNC_FASTCALL
538
- #define FUNC_FASTCALL(x) x
539
- #endif
540
-
541
- typedef rb_control_frame_t *
542
- (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
543
-
544
- #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
545
- #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)p) & ~0x03))
546
- #define GC_GUARDED_PTR_P(p) (((VALUE)p) & 0x01)
547
-
548
- #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) (cfp+1)
549
- #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) (cfp-1)
550
- #define RUBY_VM_END_CONTROL_FRAME(th) \
551
- ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
552
- #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
553
- ((void *)(ecfp) > (void *)(cfp))
554
- #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
555
- (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
556
-
557
- #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
558
- #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
559
- (ptr && !RUBY_VM_IFUNC_P(ptr))
560
-
561
- #define RUBY_VM_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02)
562
-
563
- #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
564
- #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
565
- ((rb_control_frame_t *)((VALUE *)(b) - 5))
566
-
567
- /* VM related object allocate functions */
568
- VALUE rb_thread_alloc(VALUE klass);
569
- VALUE rb_proc_alloc(VALUE klass);
570
-
571
- /* for debug */
572
- extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
573
- #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
574
- #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
575
- void rb_vm_bugreport(void);
576
-
577
-
578
- /* functions about thread/vm execution */
579
-
580
- VALUE rb_iseq_eval(VALUE iseqval);
581
- VALUE rb_iseq_eval_main(VALUE iseqval);
582
- void rb_enable_interrupt(void);
583
- void rb_disable_interrupt(void);
584
- int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
585
-
586
- VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
587
- int argc, const VALUE *argv, rb_block_t *blockptr);
588
- VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
589
- VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
590
-
591
- void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
592
- int ruby_thread_has_gvl_p(void);
593
- rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
594
-
595
- NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
596
-
597
- #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
598
-
599
- /* for thread */
600
-
601
- #if RUBY_VM_THREAD_MODEL == 2
602
- RUBY_EXTERN rb_thread_t *ruby_current_thread;
603
- extern rb_vm_t *ruby_current_vm;
604
-
605
- #define GET_VM() ruby_current_vm
606
- #define GET_THREAD() ruby_current_thread
607
- #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
608
- #define rb_thread_set_current(th) do { \
609
- rb_thread_set_current_raw(th); \
610
- th->vm->running_thread = th; \
611
- } while (0)
612
-
613
- #else
614
- #error "unsupported thread model"
615
- #endif
616
-
617
- #define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02)
618
- #define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01)
619
- #define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04)
620
- #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
621
-
622
- void rb_thread_execute_interrupts(rb_thread_t *);
623
-
624
- #define RUBY_VM_CHECK_INTS_TH(th) do { \
625
- if (UNLIKELY(th->interrupt_flag)) { \
626
- rb_thread_execute_interrupts(th); \
627
- } \
628
- } while (0)
629
-
630
- #define RUBY_VM_CHECK_INTS() \
631
- RUBY_VM_CHECK_INTS_TH(GET_THREAD())
632
-
633
- /* tracer */
634
- void
635
- rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass);
636
-
637
- #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
638
- rb_event_flag_t wait_event__ = th->event_flags; \
639
- if (UNLIKELY(wait_event__)) { \
640
- if (wait_event__ & (flag | RUBY_EVENT_VM)) { \
641
- rb_threadptr_exec_event_hooks(th, flag, self, id, klass); \
642
- } \
643
- } \
644
- } while (0)
645
-
646
- #endif /* RUBY_VM_CORE_H */