did_you_mean 0.5.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -4
- data/Appraisals +6 -0
- data/Gemfile +14 -0
- data/README.md +69 -13
- data/Rakefile +47 -22
- data/did_you_mean.gemspec +3 -5
- data/docs/did_you_mean_example.png +0 -0
- data/ext/did_you_mean/extconf.rb +16 -11
- data/ext/did_you_mean/org/yukinishijima/ReceiverCapturer.java +58 -0
- data/ext/did_you_mean/ruby_headers/210/id.h +11 -9
- data/ext/did_you_mean/ruby_headers/210/version.h +6 -6
- data/ext/did_you_mean/ruby_headers/211/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/211/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/211/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/211/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/211/eval_intern.h +260 -0
- data/ext/did_you_mean/ruby_headers/211/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/211/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/211/internal.h +889 -0
- data/ext/did_you_mean/ruby_headers/211/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/211/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/211/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/211/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/211/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/211/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/211/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/211/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/211/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/211/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/211/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/211/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/211/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/211/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/211/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/211/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/211/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/211/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/211/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/211/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/211/vm_core.h +1043 -0
- data/ext/did_you_mean/ruby_headers/211/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/211/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/211/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/211/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/212/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/212/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/212/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/212/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/212/eval_intern.h +260 -0
- data/ext/did_you_mean/ruby_headers/212/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/212/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/212/internal.h +889 -0
- data/ext/did_you_mean/ruby_headers/212/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/212/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/212/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/212/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/212/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/212/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/212/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/212/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/212/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/212/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/212/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/212/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/212/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/212/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/212/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/212/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/212/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/212/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/212/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/212/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/212/vm_core.h +1043 -0
- data/ext/did_you_mean/ruby_headers/212/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/212/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/212/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/212/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/213/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/213/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/213/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/213/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/213/eval_intern.h +270 -0
- data/ext/did_you_mean/ruby_headers/213/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/213/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/213/internal.h +892 -0
- data/ext/did_you_mean/ruby_headers/213/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/213/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/213/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/213/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/213/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/213/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/213/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/213/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/213/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/213/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/213/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/213/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/213/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/213/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/213/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/213/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/213/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/213/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/213/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/213/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/213/vm_core.h +1052 -0
- data/ext/did_you_mean/ruby_headers/213/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/213/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/213/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/213/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/214/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/214/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/214/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/214/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/214/eval_intern.h +270 -0
- data/ext/did_you_mean/ruby_headers/214/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/214/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/214/internal.h +892 -0
- data/ext/did_you_mean/ruby_headers/214/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/214/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/214/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/214/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/214/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/214/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/214/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/214/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/214/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/214/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/214/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/214/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/214/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/214/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/214/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/214/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/214/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/214/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/214/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/214/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/214/vm_core.h +1055 -0
- data/ext/did_you_mean/ruby_headers/214/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/214/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/214/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/214/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/220/addr2line.h +1 -1
- data/ext/did_you_mean/ruby_headers/220/ccan/build_assert/build_assert.h +40 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/check_type/check_type.h +63 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/container_of/container_of.h +106 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/licenses/BSD-MIT +17 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/licenses/CC0 +28 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/list/list.h +602 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/str/str.h +16 -0
- data/ext/did_you_mean/ruby_headers/220/constant.h +10 -3
- data/ext/did_you_mean/ruby_headers/220/eval_intern.h +24 -5
- data/ext/did_you_mean/ruby_headers/220/gc.h +5 -0
- data/ext/did_you_mean/ruby_headers/220/id.h +11 -9
- data/ext/did_you_mean/ruby_headers/220/internal.h +116 -21
- data/ext/did_you_mean/ruby_headers/220/iseq.h +28 -7
- data/ext/did_you_mean/ruby_headers/220/method.h +0 -1
- data/ext/did_you_mean/ruby_headers/220/node.h +5 -4
- data/ext/did_you_mean/ruby_headers/220/regenc.h +18 -7
- data/ext/did_you_mean/ruby_headers/220/regint.h +72 -11
- data/ext/did_you_mean/ruby_headers/220/regparse.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/ruby_atomic.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/symbol.h +87 -0
- data/ext/did_you_mean/ruby_headers/220/thread_pthread.h +4 -6
- data/ext/did_you_mean/ruby_headers/220/thread_win32.h +0 -9
- data/ext/did_you_mean/ruby_headers/220/timev.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/version.h +3 -3
- data/ext/did_you_mean/ruby_headers/220/vm_core.h +200 -65
- data/ext/did_you_mean/ruby_headers/220/vm_insnhelper.h +0 -40
- data/gemfiles/activerecord_30.gemfile +14 -0
- data/gemfiles/activerecord_31.gemfile +14 -0
- data/gemfiles/activerecord_32.gemfile +14 -0
- data/gemfiles/activerecord_40.gemfile +14 -0
- data/gemfiles/activerecord_41.gemfile +14 -0
- data/gemfiles/activerecord_42.gemfile +21 -0
- data/gemfiles/activerecord_edge.gemfile +16 -0
- data/lib/did_you_mean.rb +14 -4
- data/lib/did_you_mean/core_ext/name_error.rb +11 -44
- data/lib/did_you_mean/finders.rb +31 -0
- data/lib/did_you_mean/finders/name_error_finders.rb +24 -0
- data/lib/did_you_mean/finders/name_error_finders/similar_class_finder.rb +50 -0
- data/lib/did_you_mean/finders/name_error_finders/similar_name_finder.rb +61 -0
- data/lib/did_you_mean/finders/similar_attribute_finder.rb +26 -0
- data/lib/did_you_mean/finders/similar_method_finder.rb +42 -0
- data/lib/did_you_mean/levenshtein.rb +49 -0
- data/lib/did_you_mean/test_helper.rb +11 -0
- data/lib/did_you_mean/version.rb +1 -1
- data/lib/did_you_mean/word_collection.rb +27 -0
- data/test/all_test.rb +16 -2
- data/test/name_error_extension_test.rb +24 -0
- data/test/no_method_error_extension_test.rb +20 -0
- data/test/null_finder_test.rb +19 -0
- data/test/similar_attribute_finder_test.rb +2 -6
- data/test/similar_class_finder_test.rb +85 -0
- data/test/similar_method_finder_test.rb +16 -35
- data/test/similar_name_finder_test.rb +31 -23
- data/test/test_helper.rb +19 -11
- metadata +168 -45
- data/docs/better_errors_example.png +0 -0
- data/docs/irb_example.png +0 -0
- data/docs/rspec_example.png +0 -0
- data/lib/did_you_mean/method_finder.rb +0 -24
- data/lib/did_you_mean/strategies.rb +0 -23
- data/lib/did_you_mean/strategies/similar_attribute_finder.rb +0 -41
- data/lib/did_you_mean/strategies/similar_method_finder.rb +0 -46
- data/lib/did_you_mean/strategies/similar_name_finder.rb +0 -57
- data/test.sh +0 -18
@@ -11,12 +11,12 @@
|
|
11
11
|
#ifndef RUBY_THREAD_PTHREAD_H
|
12
12
|
#define RUBY_THREAD_PTHREAD_H
|
13
13
|
|
14
|
-
#include <pthread.h>
|
15
14
|
#ifdef HAVE_PTHREAD_NP_H
|
16
15
|
#include <pthread_np.h>
|
17
16
|
#endif
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
|
19
|
+
#define RB_NATIVETHREAD_COND_INIT { PTHREAD_COND_INITIALIZER, }
|
20
20
|
|
21
21
|
typedef struct rb_thread_cond_struct {
|
22
22
|
pthread_cond_t cond;
|
@@ -30,8 +30,6 @@ typedef struct native_thread_data_struct {
|
|
30
30
|
rb_nativethread_cond_t sleep_cond;
|
31
31
|
} native_thread_data_t;
|
32
32
|
|
33
|
-
#include <semaphore.h>
|
34
|
-
|
35
33
|
#undef except
|
36
34
|
#undef try
|
37
35
|
#undef leave
|
@@ -40,7 +38,7 @@ typedef struct native_thread_data_struct {
|
|
40
38
|
typedef struct rb_global_vm_lock_struct {
|
41
39
|
/* fast path */
|
42
40
|
unsigned long acquired;
|
43
|
-
|
41
|
+
rb_nativethread_lock_t lock;
|
44
42
|
|
45
43
|
/* slow path */
|
46
44
|
volatile unsigned long waiting;
|
@@ -12,8 +12,6 @@
|
|
12
12
|
#ifndef RUBY_THREAD_WIN32_H
|
13
13
|
#define RUBY_THREAD_WIN32_H
|
14
14
|
|
15
|
-
#include <windows.h>
|
16
|
-
|
17
15
|
# ifdef __CYGWIN__
|
18
16
|
# undef _WIN32
|
19
17
|
# endif
|
@@ -21,13 +19,6 @@
|
|
21
19
|
WINBASEAPI BOOL WINAPI
|
22
20
|
TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
|
23
21
|
|
24
|
-
typedef HANDLE rb_nativethread_id_t;
|
25
|
-
|
26
|
-
typedef union rb_thread_lock_union {
|
27
|
-
HANDLE mutex;
|
28
|
-
CRITICAL_SECTION crit;
|
29
|
-
} rb_nativethread_lock_t;
|
30
|
-
|
31
22
|
typedef struct rb_thread_cond_struct {
|
32
23
|
struct cond_event_entry *next;
|
33
24
|
struct cond_event_entry *prev;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#ifndef RUBY_TIMEV_H
|
2
2
|
#define RUBY_TIMEV_H
|
3
3
|
|
4
|
-
struct vtm {
|
4
|
+
PACKED_STRUCT_UNALIGNED(struct vtm {
|
5
5
|
VALUE year; /* 2000 for example. Integer. */
|
6
6
|
VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
|
7
7
|
VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */
|
@@ -14,7 +14,7 @@ struct vtm {
|
|
14
14
|
uint8_t sec:6; /* 0..60 */
|
15
15
|
uint8_t wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
|
16
16
|
uint8_t isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
|
17
|
-
}
|
17
|
+
});
|
18
18
|
|
19
19
|
#define TIME_SCALE 1000000000
|
20
20
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#define RUBY_VERSION "2.2.0"
|
2
|
-
#define RUBY_RELEASE_DATE "2014-
|
2
|
+
#define RUBY_RELEASE_DATE "2014-11-09"
|
3
3
|
#define RUBY_PATCHLEVEL -1
|
4
4
|
#define RUBY_BRANCH_NAME "trunk"
|
5
5
|
|
6
6
|
#define RUBY_RELEASE_YEAR 2014
|
7
|
-
#define RUBY_RELEASE_MONTH
|
8
|
-
#define RUBY_RELEASE_DAY
|
7
|
+
#define RUBY_RELEASE_MONTH 11
|
8
|
+
#define RUBY_RELEASE_DAY 9
|
9
9
|
|
10
10
|
#include "ruby/version.h"
|
11
11
|
|
@@ -23,8 +23,14 @@
|
|
23
23
|
#include "id.h"
|
24
24
|
#include "method.h"
|
25
25
|
#include "ruby_atomic.h"
|
26
|
+
#include "ccan/list/list.h"
|
26
27
|
|
27
|
-
#include "thread_native.h"
|
28
|
+
#include "ruby/thread_native.h"
|
29
|
+
#if defined(_WIN32)
|
30
|
+
#include "thread_win32.h"
|
31
|
+
#elif defined(HAVE_PTHREAD_H)
|
32
|
+
#include "thread_pthread.h"
|
33
|
+
#endif
|
28
34
|
|
29
35
|
#ifndef ENABLE_VM_OBJSPACE
|
30
36
|
#ifdef _WIN32
|
@@ -121,7 +127,6 @@ union iseq_inline_storage_entry {
|
|
121
127
|
struct {
|
122
128
|
struct rb_thread_struct *running_thread;
|
123
129
|
VALUE value;
|
124
|
-
VALUE done;
|
125
130
|
} once;
|
126
131
|
struct iseq_inline_cache_entry cache;
|
127
132
|
};
|
@@ -130,13 +135,20 @@ union iseq_inline_storage_entry {
|
|
130
135
|
struct rb_thread_struct;
|
131
136
|
struct rb_control_frame_struct;
|
132
137
|
|
138
|
+
typedef struct rb_call_info_kw_arg_struct {
|
139
|
+
int keyword_len;
|
140
|
+
ID keywords[1];
|
141
|
+
} rb_call_info_kw_arg_t;
|
142
|
+
|
133
143
|
/* rb_call_info_t contains calling information including inline cache */
|
134
144
|
typedef struct rb_call_info_struct {
|
135
145
|
/* fixed at compile time */
|
136
146
|
ID mid;
|
137
|
-
|
147
|
+
|
148
|
+
unsigned int flag;
|
138
149
|
int orig_argc;
|
139
150
|
rb_iseq_t *blockiseq;
|
151
|
+
rb_call_info_kw_arg_t *kw_arg;
|
140
152
|
|
141
153
|
/* inline cache: keys */
|
142
154
|
rb_serial_t method_state;
|
@@ -148,12 +160,12 @@ typedef struct rb_call_info_struct {
|
|
148
160
|
VALUE defined_class;
|
149
161
|
|
150
162
|
/* temporary values for method calling */
|
151
|
-
int argc;
|
152
163
|
struct rb_block_struct *blockptr;
|
153
164
|
VALUE recv;
|
165
|
+
int argc;
|
154
166
|
union {
|
155
167
|
int opt_pc; /* used by iseq */
|
156
|
-
|
168
|
+
int index; /* used by ivar */
|
157
169
|
int missing_reason; /* used by method_missing */
|
158
170
|
int inc_sp; /* used by cfunc */
|
159
171
|
} aux;
|
@@ -177,7 +189,7 @@ typedef struct rb_iseq_location_struct {
|
|
177
189
|
const VALUE absolute_path;
|
178
190
|
const VALUE base_label;
|
179
191
|
const VALUE label;
|
180
|
-
|
192
|
+
VALUE first_lineno; /* TODO: may be unsigned short */
|
181
193
|
} rb_iseq_location_t;
|
182
194
|
|
183
195
|
struct rb_iseq_struct;
|
@@ -198,18 +210,22 @@ struct rb_iseq_struct {
|
|
198
210
|
ISEQ_TYPE_MAIN,
|
199
211
|
ISEQ_TYPE_DEFINED_GUARD
|
200
212
|
} type; /* instruction sequence type */
|
213
|
+
#if defined(WORDS_BIGENDIAN) && (SIZEOF_VALUE > SIZEOF_INT)
|
214
|
+
char dummy[SIZEOF_VALUE - SIZEOF_INT]; /* [Bug #10037][ruby-core:63721] */
|
215
|
+
#endif
|
216
|
+
int stack_max; /* for stack overflow check */
|
201
217
|
|
202
218
|
rb_iseq_location_t location;
|
203
219
|
|
204
|
-
VALUE *
|
205
|
-
|
206
|
-
unsigned
|
220
|
+
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
221
|
+
unsigned int iseq_size;
|
222
|
+
unsigned int line_info_size;
|
223
|
+
|
207
224
|
const VALUE mark_ary; /* Array: includes operands which should be GC marked */
|
208
225
|
const VALUE coverage; /* coverage array */
|
209
226
|
|
210
227
|
/* insn info, must be freed */
|
211
228
|
struct iseq_line_info_entry *line_info_table;
|
212
|
-
size_t line_info_size;
|
213
229
|
|
214
230
|
ID *local_table; /* must free */
|
215
231
|
int local_table_size;
|
@@ -220,56 +236,81 @@ struct rb_iseq_struct {
|
|
220
236
|
union iseq_inline_storage_entry *is_entries;
|
221
237
|
int is_size;
|
222
238
|
|
223
|
-
rb_call_info_t *callinfo_entries;
|
224
239
|
int callinfo_size;
|
240
|
+
rb_call_info_t *callinfo_entries;
|
225
241
|
|
226
242
|
/**
|
227
|
-
*
|
243
|
+
* parameter information
|
228
244
|
*
|
229
245
|
* def m(a1, a2, ..., aM, # mandatory
|
230
246
|
* b1=(...), b2=(...), ..., bN=(...), # optional
|
231
247
|
* *c, # rest
|
232
248
|
* d1, d2, ..., dO, # post
|
233
249
|
* e1:(...), e2:(...), ..., eK:(...), # keyword
|
234
|
-
* **f, #
|
250
|
+
* **f, # keyword_rest
|
235
251
|
* &g) # block
|
236
252
|
* =>
|
237
253
|
*
|
238
|
-
*
|
239
|
-
*
|
240
|
-
*
|
241
|
-
*
|
242
|
-
*
|
243
|
-
*
|
244
|
-
*
|
245
|
-
*
|
246
|
-
*
|
247
|
-
* arg_simple = 0 if not simple arguments.
|
248
|
-
* = 1 if no opt, rest, post, block.
|
249
|
-
* = 2 if ambiguous block parameter ({|a|}).
|
250
|
-
* arg_size = M+N+O+(*1)+K+(&1)+(**1) argument size.
|
254
|
+
* lead_num = M
|
255
|
+
* opt_num = N
|
256
|
+
* rest_start = M+N
|
257
|
+
* post_start = M+N+(*1)
|
258
|
+
* post_num = O
|
259
|
+
* keyword_num = K
|
260
|
+
* block_start = M+N+(*1)+O+K
|
261
|
+
* keyword_bits = M+N+(*1)+O+K+(&1)
|
262
|
+
* size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
|
251
263
|
*/
|
252
264
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
265
|
+
struct {
|
266
|
+
struct {
|
267
|
+
unsigned int has_lead : 1;
|
268
|
+
unsigned int has_opt : 1;
|
269
|
+
unsigned int has_rest : 1;
|
270
|
+
unsigned int has_post : 1;
|
271
|
+
unsigned int has_kw : 1;
|
272
|
+
unsigned int has_kwrest : 1;
|
273
|
+
unsigned int has_block : 1;
|
274
|
+
|
275
|
+
unsigned int ambiguous_param0 : 1; /* {|a|} */
|
276
|
+
} flags;
|
277
|
+
|
278
|
+
int size;
|
279
|
+
|
280
|
+
int lead_num;
|
281
|
+
int opt_num;
|
282
|
+
int rest_start;
|
283
|
+
int post_start;
|
284
|
+
int post_num;
|
285
|
+
int block_start;
|
286
|
+
|
287
|
+
VALUE *opt_table; /* (opt_num + 1) entries. */
|
288
|
+
/* opt_num and opt_table:
|
289
|
+
*
|
290
|
+
* def foo o1=e1, o2=e2, ..., oN=eN
|
291
|
+
* #=>
|
292
|
+
* # prologue code
|
293
|
+
* A1: e1
|
294
|
+
* A2: e2
|
295
|
+
* ...
|
296
|
+
* AN: eN
|
297
|
+
* AL: body
|
298
|
+
* opt_num = N
|
299
|
+
* opt_table = [A1, A2, ..., AN, AL]
|
300
|
+
*/
|
301
|
+
|
302
|
+
struct rb_iseq_param_keyword {
|
303
|
+
int num;
|
304
|
+
int required_num;
|
305
|
+
int bits_start;
|
306
|
+
int rest_start;
|
307
|
+
ID *table;
|
308
|
+
VALUE *default_values;
|
309
|
+
} *keyword;
|
310
|
+
} param;
|
269
311
|
|
270
312
|
/* catch table */
|
271
|
-
struct
|
272
|
-
int catch_table_size;
|
313
|
+
struct iseq_catch_table *catch_table;
|
273
314
|
|
274
315
|
/* for child iseq */
|
275
316
|
struct rb_iseq_struct *parent_iseq;
|
@@ -300,6 +341,10 @@ struct rb_iseq_struct {
|
|
300
341
|
|
301
342
|
/* used at compile time */
|
302
343
|
struct iseq_compile_data *compile_data;
|
344
|
+
|
345
|
+
/* original iseq, before encoding
|
346
|
+
* used for debug/dump (TODO: union with compile_data) */
|
347
|
+
VALUE *iseq;
|
303
348
|
};
|
304
349
|
|
305
350
|
enum ruby_special_exceptions {
|
@@ -310,6 +355,33 @@ enum ruby_special_exceptions {
|
|
310
355
|
ruby_special_error_count
|
311
356
|
};
|
312
357
|
|
358
|
+
enum ruby_basic_operators {
|
359
|
+
BOP_PLUS,
|
360
|
+
BOP_MINUS,
|
361
|
+
BOP_MULT,
|
362
|
+
BOP_DIV,
|
363
|
+
BOP_MOD,
|
364
|
+
BOP_EQ,
|
365
|
+
BOP_EQQ,
|
366
|
+
BOP_LT,
|
367
|
+
BOP_LE,
|
368
|
+
BOP_LTLT,
|
369
|
+
BOP_AREF,
|
370
|
+
BOP_ASET,
|
371
|
+
BOP_LENGTH,
|
372
|
+
BOP_SIZE,
|
373
|
+
BOP_EMPTY_P,
|
374
|
+
BOP_SUCC,
|
375
|
+
BOP_GT,
|
376
|
+
BOP_GE,
|
377
|
+
BOP_NOT,
|
378
|
+
BOP_NEQ,
|
379
|
+
BOP_MATCH,
|
380
|
+
BOP_FREEZE,
|
381
|
+
|
382
|
+
BOP_LAST_
|
383
|
+
};
|
384
|
+
|
313
385
|
#define GetVMPtr(obj, ptr) \
|
314
386
|
GetCoreDataFromValue((obj), rb_vm_t, (ptr))
|
315
387
|
|
@@ -333,7 +405,8 @@ typedef struct rb_vm_struct {
|
|
333
405
|
struct rb_thread_struct *main_thread;
|
334
406
|
struct rb_thread_struct *running_thread;
|
335
407
|
|
336
|
-
|
408
|
+
struct list_head living_threads;
|
409
|
+
size_t living_thread_num;
|
337
410
|
VALUE thgroup_default;
|
338
411
|
|
339
412
|
int running;
|
@@ -344,7 +417,7 @@ typedef struct rb_vm_struct {
|
|
344
417
|
/* object management */
|
345
418
|
VALUE mark_object_ary;
|
346
419
|
|
347
|
-
VALUE special_exceptions[ruby_special_error_count];
|
420
|
+
const VALUE special_exceptions[ruby_special_error_count];
|
348
421
|
|
349
422
|
/* load */
|
350
423
|
VALUE top_self;
|
@@ -393,6 +466,7 @@ typedef struct rb_vm_struct {
|
|
393
466
|
struct RArray at_exit;
|
394
467
|
|
395
468
|
VALUE *defined_strings;
|
469
|
+
st_table *frozen_strings;
|
396
470
|
|
397
471
|
/* params */
|
398
472
|
struct { /* size in byte */
|
@@ -401,6 +475,8 @@ typedef struct rb_vm_struct {
|
|
401
475
|
size_t fiber_vm_stack_size;
|
402
476
|
size_t fiber_machine_stack_size;
|
403
477
|
} default_params;
|
478
|
+
|
479
|
+
short redefined_flag[BOP_LAST_];
|
404
480
|
} rb_vm_t;
|
405
481
|
|
406
482
|
/* default values */
|
@@ -417,10 +493,27 @@ typedef struct rb_vm_struct {
|
|
417
493
|
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
|
418
494
|
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
|
419
495
|
|
496
|
+
/* optimize insn */
|
497
|
+
#define FIXNUM_REDEFINED_OP_FLAG (1 << 0)
|
498
|
+
#define FLOAT_REDEFINED_OP_FLAG (1 << 1)
|
499
|
+
#define STRING_REDEFINED_OP_FLAG (1 << 2)
|
500
|
+
#define ARRAY_REDEFINED_OP_FLAG (1 << 3)
|
501
|
+
#define HASH_REDEFINED_OP_FLAG (1 << 4)
|
502
|
+
#define BIGNUM_REDEFINED_OP_FLAG (1 << 5)
|
503
|
+
#define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
|
504
|
+
#define TIME_REDEFINED_OP_FLAG (1 << 7)
|
505
|
+
#define REGEXP_REDEFINED_OP_FLAG (1 << 8)
|
506
|
+
|
507
|
+
#define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((GET_VM()->redefined_flag[(op)]&(klass)) == 0))
|
508
|
+
|
420
509
|
#ifndef VM_DEBUG_BP_CHECK
|
421
510
|
#define VM_DEBUG_BP_CHECK 0
|
422
511
|
#endif
|
423
512
|
|
513
|
+
#ifndef VM_DEBUG_VERIFY_METHOD_CACHE
|
514
|
+
#define VM_DEBUG_VERIFY_METHOD_CACHE 0
|
515
|
+
#endif
|
516
|
+
|
424
517
|
typedef struct rb_control_frame_struct {
|
425
518
|
VALUE *pc; /* cfp[0] */
|
426
519
|
VALUE *sp; /* cfp[1] */
|
@@ -500,7 +593,12 @@ typedef struct rb_ensure_list {
|
|
500
593
|
struct rb_ensure_entry entry;
|
501
594
|
} rb_ensure_list_t;
|
502
595
|
|
596
|
+
typedef char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) * 2 + 3];
|
597
|
+
|
598
|
+
typedef struct rb_fiber_struct rb_fiber_t;
|
599
|
+
|
503
600
|
typedef struct rb_thread_struct {
|
601
|
+
struct list_node vmlt_node;
|
504
602
|
VALUE self;
|
505
603
|
rb_vm_t *vm;
|
506
604
|
|
@@ -521,7 +619,7 @@ typedef struct rb_thread_struct {
|
|
521
619
|
const rb_block_t *passed_block;
|
522
620
|
|
523
621
|
/* for bmethod */
|
524
|
-
const rb_method_entry_t *
|
622
|
+
const rb_method_entry_t *passed_bmethod_me;
|
525
623
|
|
526
624
|
/* for cfunc */
|
527
625
|
rb_call_info_t *passed_ci;
|
@@ -538,9 +636,13 @@ typedef struct rb_thread_struct {
|
|
538
636
|
|
539
637
|
/* thread control */
|
540
638
|
rb_nativethread_id_t thread_id;
|
639
|
+
#ifdef NON_SCALAR_THREAD_ID
|
640
|
+
rb_thread_id_string_t thread_id_string;
|
641
|
+
#endif
|
541
642
|
enum rb_thread_status status;
|
542
643
|
int to_kill;
|
543
644
|
int priority;
|
645
|
+
int mark_stack_len;
|
544
646
|
|
545
647
|
native_thread_data_t native_thread_data;
|
546
648
|
void *blocking_region_buffer;
|
@@ -558,8 +660,8 @@ typedef struct rb_thread_struct {
|
|
558
660
|
|
559
661
|
/* async errinfo queue */
|
560
662
|
VALUE pending_interrupt_queue;
|
561
|
-
int pending_interrupt_queue_checked;
|
562
663
|
VALUE pending_interrupt_mask_stack;
|
664
|
+
int pending_interrupt_queue_checked;
|
563
665
|
|
564
666
|
rb_atomic_t interrupt_flag;
|
565
667
|
unsigned long interrupt_mask;
|
@@ -607,7 +709,6 @@ typedef struct rb_thread_struct {
|
|
607
709
|
#endif
|
608
710
|
jmp_buf regs;
|
609
711
|
} machine;
|
610
|
-
int mark_stack_len;
|
611
712
|
|
612
713
|
/* statistics data for profiler */
|
613
714
|
VALUE stat_insn_usage;
|
@@ -617,8 +718,8 @@ typedef struct rb_thread_struct {
|
|
617
718
|
struct rb_trace_arg_struct *trace_arg; /* trace information */
|
618
719
|
|
619
720
|
/* fiber */
|
620
|
-
|
621
|
-
|
721
|
+
rb_fiber_t *fiber;
|
722
|
+
rb_fiber_t *root_fiber;
|
622
723
|
rb_jmpbuf_t root_jmpbuf;
|
623
724
|
|
624
725
|
/* ensure & callcc */
|
@@ -664,7 +765,7 @@ VALUE rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, rb_block_t *bas
|
|
664
765
|
VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt);
|
665
766
|
|
666
767
|
VALUE rb_iseq_disasm(VALUE self);
|
667
|
-
int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
|
768
|
+
int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
|
668
769
|
const char *ruby_node_name(int node);
|
669
770
|
|
670
771
|
RUBY_EXTERN VALUE rb_cISeq;
|
@@ -681,20 +782,20 @@ typedef struct {
|
|
681
782
|
|
682
783
|
VALUE envval; /* for GC mark */
|
683
784
|
VALUE blockprocval;
|
684
|
-
|
685
|
-
|
686
|
-
|
785
|
+
int8_t safe_level; /* 0..3 */
|
786
|
+
int8_t is_from_method; /* bool */
|
787
|
+
int8_t is_lambda; /* bool */
|
687
788
|
} rb_proc_t;
|
688
789
|
|
689
790
|
#define GetEnvPtr(obj, ptr) \
|
690
791
|
GetCoreDataFromValue((obj), rb_env_t, (ptr))
|
691
792
|
|
692
793
|
typedef struct {
|
693
|
-
VALUE *env;
|
694
794
|
int env_size;
|
695
795
|
int local_size;
|
696
796
|
VALUE prev_envval; /* for GC mark */
|
697
797
|
rb_block_t block;
|
798
|
+
VALUE env[1]; /* flexible array */
|
698
799
|
} rb_env_t;
|
699
800
|
|
700
801
|
extern const rb_data_type_t ruby_binding_data_type;
|
@@ -705,6 +806,7 @@ extern const rb_data_type_t ruby_binding_data_type;
|
|
705
806
|
typedef struct {
|
706
807
|
VALUE env;
|
707
808
|
VALUE path;
|
809
|
+
VALUE blockprocval; /* for GC mark */
|
708
810
|
unsigned short first_lineno;
|
709
811
|
} rb_binding_t;
|
710
812
|
|
@@ -726,7 +828,7 @@ enum vm_check_match_type {
|
|
726
828
|
#define VM_CALL_TAILCALL (0x01 << 5) /* located at tail position */
|
727
829
|
#define VM_CALL_SUPER (0x01 << 6) /* super */
|
728
830
|
#define VM_CALL_OPT_SEND (0x01 << 7) /* internal flag */
|
729
|
-
#define
|
831
|
+
#define VM_CALL_ARGS_SIMPLE (0x01 << 8) /* (ci->flag & (SPLAT|BLOCKARG)) && ci->blockiseq == NULL && ci->kw_arg == NULL */
|
730
832
|
|
731
833
|
enum vm_special_object_type {
|
732
834
|
VM_SPECIAL_OBJECT_VMCORE = 1,
|
@@ -743,15 +845,18 @@ enum vm_special_object_type {
|
|
743
845
|
#define VM_FRAME_MAGIC_IFUNC 0x81
|
744
846
|
#define VM_FRAME_MAGIC_EVAL 0x91
|
745
847
|
#define VM_FRAME_MAGIC_LAMBDA 0xa1
|
746
|
-
#define
|
747
|
-
#define
|
848
|
+
#define VM_FRAME_MAGIC_RESCUE 0xb1
|
849
|
+
#define VM_FRAME_MAGIC_MASK_BITS 8
|
850
|
+
#define VM_FRAME_MAGIC_MASK (~(~(VALUE)0<<VM_FRAME_MAGIC_MASK_BITS))
|
748
851
|
|
749
852
|
#define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
|
750
853
|
|
751
854
|
/* other frame flag */
|
752
|
-
#define VM_FRAME_FLAG_PASSED
|
753
|
-
#define VM_FRAME_FLAG_FINISH
|
754
|
-
#define
|
855
|
+
#define VM_FRAME_FLAG_PASSED 0x0100
|
856
|
+
#define VM_FRAME_FLAG_FINISH 0x0200
|
857
|
+
#define VM_FRAME_FLAG_BMETHOD 0x0400
|
858
|
+
#define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0)
|
859
|
+
#define VM_FRAME_TYPE_BMETHOD_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_BMETHOD) != 0)
|
755
860
|
|
756
861
|
#define RUBYVM_CFUNC_FRAME_P(cfp) \
|
757
862
|
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
|
@@ -817,7 +922,8 @@ rb_block_t *rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp);
|
|
817
922
|
|
818
923
|
/* VM related object allocate functions */
|
819
924
|
VALUE rb_thread_alloc(VALUE klass);
|
820
|
-
VALUE
|
925
|
+
VALUE rb_proc_wrap(VALUE klass, rb_proc_t *); /* may use with rb_proc_alloc */
|
926
|
+
VALUE rb_binding_alloc(VALUE klass);
|
821
927
|
|
822
928
|
/* for debug */
|
823
929
|
extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
|
@@ -826,7 +932,8 @@ extern void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp
|
|
826
932
|
|
827
933
|
#define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
|
828
934
|
#define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
|
829
|
-
void rb_vm_bugreport(void);
|
935
|
+
void rb_vm_bugreport(const void *);
|
936
|
+
NORETURN(void rb_bug_context(const void *, const char *fmt, ...));
|
830
937
|
|
831
938
|
/* functions about thread/vm execution */
|
832
939
|
RUBY_SYMBOL_EXPORT_BEGIN
|
@@ -838,8 +945,9 @@ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
|
|
838
945
|
VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
|
839
946
|
int argc, const VALUE *argv, const rb_block_t *blockptr);
|
840
947
|
VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
|
948
|
+
VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
|
841
949
|
VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
|
842
|
-
VALUE
|
950
|
+
VALUE rb_vm_env_local_variables(VALUE envval);
|
843
951
|
VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars);
|
844
952
|
void rb_vm_inc_const_missing_count(void);
|
845
953
|
void rb_vm_gvl_destroy(rb_vm_t *vm);
|
@@ -854,6 +962,27 @@ void rb_thread_stop_timer_thread(int);
|
|
854
962
|
void rb_thread_reset_timer_thread(void);
|
855
963
|
void rb_thread_wakeup_timer_thread(void);
|
856
964
|
|
965
|
+
static inline void
|
966
|
+
rb_vm_living_threads_init(rb_vm_t *vm)
|
967
|
+
{
|
968
|
+
list_head_init(&vm->living_threads);
|
969
|
+
vm->living_thread_num = 0;
|
970
|
+
}
|
971
|
+
|
972
|
+
static inline void
|
973
|
+
rb_vm_living_threads_insert(rb_vm_t *vm, rb_thread_t *th)
|
974
|
+
{
|
975
|
+
list_add(&vm->living_threads, &th->vmlt_node);
|
976
|
+
vm->living_thread_num++;
|
977
|
+
}
|
978
|
+
|
979
|
+
static inline void
|
980
|
+
rb_vm_living_threads_remove(rb_vm_t *vm, rb_thread_t *th)
|
981
|
+
{
|
982
|
+
list_del(&th->vmlt_node);
|
983
|
+
vm->living_thread_num--;
|
984
|
+
}
|
985
|
+
|
857
986
|
int ruby_thread_has_gvl_p(void);
|
858
987
|
typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
|
859
988
|
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, const rb_control_frame_t *cfp);
|
@@ -863,6 +992,9 @@ VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method);
|
|
863
992
|
void rb_vm_stack_to_heap(rb_thread_t *th);
|
864
993
|
void ruby_thread_init_stack(rb_thread_t *th);
|
865
994
|
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
|
995
|
+
void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
|
996
|
+
|
997
|
+
void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg);
|
866
998
|
|
867
999
|
void rb_gc_mark_machine_stack(rb_thread_t *th);
|
868
1000
|
|
@@ -1009,6 +1141,9 @@ void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *tra
|
|
1009
1141
|
#define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \
|
1010
1142
|
EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1)
|
1011
1143
|
|
1144
|
+
VALUE rb_threadptr_reset_recursive_data(rb_thread_t *th);
|
1145
|
+
void rb_threadptr_restore_recursive_data(rb_thread_t *th, VALUE old);
|
1146
|
+
|
1012
1147
|
RUBY_SYMBOL_EXPORT_BEGIN
|
1013
1148
|
|
1014
1149
|
int rb_thread_check_trap_pending(void);
|