@@ -38,20 +38,29 @@ namespace rubinius {
38
38
return Integer::from (state, ip_);
39
39
}
40
40
41
- Object* CallSite::empty_cache_custom (STATE, CallSite* call_site, CallFrame* call_frame,
42
- Arguments& args)
41
+ Object* CallSite::empty_cache_custom (STATE, CallSite* call_site,
42
+ CallFrame* call_frame, Arguments& args)
43
43
{
44
44
Object* const recv = args.recv ();
45
45
46
- Array* ary = Array::create (state, args.total () + 2 );
46
+ Array* ary = Array::create (state, args.total () + 2 );
47
47
ary->set (state, 0 , recv);
48
48
ary->set (state, 1 , call_site->name_ );
49
49
50
50
for (size_t i = 0 ; i < args.total (); i++) {
51
51
ary->set (state, i + 2 , args.get_argument (i));
52
52
}
53
53
54
- Object* ret = G (rubinius)->send (state, call_frame, state->symbol (" bind_call" ), ary);
54
+ Object* ret;
55
+
56
+ {
57
+ /* The references in args are not visible to the GC and
58
+ * there's not a simple mechanism to manage that now.
59
+ */
60
+ ObjectMemory::GCInhibit inhibitor (state);
61
+
62
+ ret = G (rubinius)->send (state, call_frame, state->symbol (" bind_call" ), ary);
63
+ }
55
64
56
65
if (CallUnit* cu = try_as<CallUnit>(ret)) {
57
66
CallCustomCache* cache = CallCustomCache::create (state, call_site, cu);
@@ -63,28 +72,28 @@ namespace rubinius {
63
72
}
64
73
}
65
74
66
- Object* CallSite::empty_cache (STATE, CallSite* call_site, CallFrame* call_frame,
67
- Arguments& args)
75
+ Object* CallSite::empty_cache (STATE, CallSite* call_site,
76
+ CallFrame* call_frame, Arguments& args)
68
77
{
69
78
Object* const recv = args.recv ();
70
79
Class* const recv_class = recv->direct_class (state);
71
80
72
81
LookupData lookup (call_frame->self (), recv->lookup_begin (state), G (sym_public));
73
- Dispatch dis (call_site->name ());
82
+ Dispatch dispatch (call_site->name ());
74
83
75
- if (!dis .resolve (state, call_site->name (), lookup)) {
84
+ if (!dispatch .resolve (state, call_site->name (), lookup)) {
76
85
if (!lookup_method_missing (state, call_frame, args,
77
- dis , call_frame->self (), recv->lookup_begin (state))) {
86
+ dispatch , call_frame->self (), recv->lookup_begin (state))) {
78
87
return NULL ;
79
88
}
80
89
}
81
90
82
91
state->vm ()->metrics ().machine .methods_invoked ++;
83
92
84
- call_site->update (state, recv_class, dis );
93
+ call_site->update (state, recv_class, dispatch );
85
94
86
- Executable* meth = dis .method ;
87
- Module* mod = dis .module ;
95
+ Executable* meth = dispatch .method ;
96
+ Module* mod = dispatch .module ;
88
97
89
98
if (meth->custom_call_site_p ()) {
90
99
CallSiteInformation info (call_site->executable (), call_site->ip ());
@@ -104,21 +113,21 @@ namespace rubinius {
104
113
Class* const recv_class = recv->direct_class (state);
105
114
106
115
LookupData lookup (call_frame->self (), recv->lookup_begin (state), G (sym_private));
107
- Dispatch dis (call_site->name ());
116
+ Dispatch dispatch (call_site->name ());
108
117
109
- if (!dis .resolve (state, dis .name , lookup)) {
118
+ if (!dispatch .resolve (state, dispatch .name , lookup)) {
110
119
if (!lookup_method_missing (state, call_frame, args,
111
- dis , call_frame->self (), recv->lookup_begin (state))) {
120
+ dispatch , call_frame->self (), recv->lookup_begin (state))) {
112
121
return NULL ;
113
122
}
114
123
}
115
124
116
125
state->vm ()->metrics ().machine .methods_invoked ++;
117
126
118
- call_site->update (state, recv_class, dis );
127
+ call_site->update (state, recv_class, dispatch );
119
128
120
- Executable* meth = dis .method ;
121
- Module* mod = dis .module ;
129
+ Executable* meth = dispatch .method ;
130
+ Module* mod = dispatch .module ;
122
131
123
132
if (meth->custom_call_site_p ()) {
124
133
CallSiteInformation info (call_site->executable (), call_site->ip ());
@@ -139,22 +148,22 @@ namespace rubinius {
139
148
Class* const recv_class = recv->direct_class (state);
140
149
141
150
LookupData lookup (call_frame->self (), recv->lookup_begin (state), G (sym_private));
142
- Dispatch dis (call_site->name ());
151
+ Dispatch dispatch (call_site->name ());
143
152
144
- if (!dis .resolve (state, call_site->name (), lookup)) {
145
- dis .method_missing = eVCall;
153
+ if (!dispatch .resolve (state, call_site->name (), lookup)) {
154
+ dispatch .method_missing = eVCall;
146
155
if (!lookup_method_missing (state, call_frame, args,
147
- dis , call_frame->self (), recv->lookup_begin (state))) {
156
+ dispatch , call_frame->self (), recv->lookup_begin (state))) {
148
157
return NULL ;
149
158
}
150
159
}
151
160
152
161
state->vm ()->metrics ().machine .methods_invoked ++;
153
162
154
- call_site->update (state, recv_class, dis );
163
+ call_site->update (state, recv_class, dispatch );
155
164
156
- Executable* meth = dis .method ;
157
- Module* mod = dis .module ;
165
+ Executable* meth = dispatch .method ;
166
+ Module* mod = dispatch .module ;
158
167
159
168
if (meth->custom_call_site_p ()) {
160
169
CallSiteInformation info (call_site->executable (), call_site->ip ());
@@ -181,14 +190,15 @@ namespace rubinius {
181
190
Module* const start = call_frame->module ()->superclass ();
182
191
183
192
LookupData lookup (call_frame->self (), start, G (sym_private));
184
- Dispatch dis (call_site->name ());
193
+ Dispatch dispatch (call_site->name ());
185
194
186
- if (start->nil_p () || !dis .resolve (state, call_site->name (), lookup)) {
195
+ if (start->nil_p () || !dispatch .resolve (state, call_site->name (), lookup)) {
187
196
188
- LookupData missing_lookup (call_frame->self (), recv->lookup_begin (state), G (sym_private));
189
- Dispatch missing_dis (G (sym_method_missing));
197
+ LookupData missing_lookup (call_frame->self (),
198
+ recv->lookup_begin (state), G (sym_private));
199
+ Dispatch missing_dispatch (G (sym_method_missing));
190
200
191
- if (!missing_dis .resolve (state, G (sym_method_missing), missing_lookup)) {
201
+ if (!missing_dispatch .resolve (state, G (sym_method_missing), missing_lookup)) {
192
202
std::ostringstream msg;
193
203
msg << " no method_missing for " ;
194
204
msg << recv_class->to_string (state);
@@ -199,19 +209,19 @@ namespace rubinius {
199
209
}
200
210
201
211
args.unshift (state, call_site->name ());
202
- dis .method = missing_dis .method ;
203
- dis .module = missing_dis .module ;
204
- dis .method_missing = eSuper;
205
- state->vm ()->set_method_missing_reason (dis .method_missing );
212
+ dispatch .method = missing_dispatch .method ;
213
+ dispatch .module = missing_dispatch .module ;
214
+ dispatch .method_missing = eSuper;
215
+ state->vm ()->set_method_missing_reason (dispatch .method_missing );
206
216
state->vm ()->global_cache ()->add_seen (state, call_site->name ());
207
217
}
208
218
209
219
state->vm ()->metrics ().machine .methods_invoked ++;
210
220
211
- call_site->update (state, recv_class, dis );
221
+ call_site->update (state, recv_class, dispatch );
212
222
213
- Executable* meth = dis .method ;
214
- Module* mod = dis .module ;
223
+ Executable* meth = dispatch .method ;
224
+ Module* mod = dispatch .module ;
215
225
216
226
if (meth->custom_call_site_p ()) {
217
227
CallSiteInformation info (call_site->executable (), call_site->ip ());
@@ -245,34 +255,37 @@ namespace rubinius {
245
255
}
246
256
247
257
LookupData lookup (call_frame->self (), recv->lookup_begin (state), G (sym_public));
248
- Dispatch dis (name_);
258
+ Dispatch dispatch (name_);
249
259
250
- if (dis .resolve (state, name_, lookup)) {
251
- update (state, recv_class, dis );
252
- return dis .method ->serial ()->to_native () == serial;
260
+ if (dispatch .resolve (state, name_, lookup)) {
261
+ update (state, recv_class, dispatch );
262
+ return dispatch .method ->serial ()->to_native () == serial;
253
263
}
254
264
return false ;
255
265
}
256
266
257
- bool CallSite::lookup_method_missing (STATE, CallFrame* call_frame, Arguments& args, Dispatch& dis, Object* self, Module* begin) {
267
+ bool CallSite::lookup_method_missing (STATE, CallFrame* call_frame,
268
+ Arguments& args, Dispatch& dispatch, Object* self, Module* begin)
269
+ {
258
270
LookupData missing_lookup (self, begin, G (sym_private));
259
- Dispatch missing_dis (G (sym_method_missing));
271
+ Dispatch missing_dispatch (G (sym_method_missing));
260
272
261
- if (!missing_dis .resolve (state, G (sym_method_missing), missing_lookup)) {
273
+ if (!missing_dispatch .resolve (state, G (sym_method_missing), missing_lookup)) {
262
274
std::ostringstream msg;
263
275
msg << " no method_missing for " ;
264
276
msg << begin->to_string (state);
265
- msg << " #" << dis .name ->to_string (state);
277
+ msg << " #" << dispatch .name ->to_string (state);
266
278
267
279
Exception::internal_error (state, call_frame, msg.str ().c_str ());
268
280
return false ;
269
281
}
270
282
271
- args.unshift (state, dis.name );
272
- dis.method = missing_dis.method ;
273
- dis.module = missing_dis.module ;
274
- state->vm ()->set_method_missing_reason (dis.method_missing );
275
- state->vm ()->global_cache ()->add_seen (state, dis.name );
283
+ args.unshift (state, dispatch.name );
284
+ dispatch.method = missing_dispatch.method ;
285
+ dispatch.module = missing_dispatch.module ;
286
+ state->vm ()->set_method_missing_reason (dispatch.method_missing );
287
+ state->vm ()->global_cache ()->add_seen (state, dispatch.name );
288
+
276
289
return true ;
277
290
}
278
291
0 commit comments