Skip to content

Commit b6ecdf5

Browse files
committed
th->ec: rb_threadptr_reset_raised()
* thread.c (rb_threadptr_reset_raised): rename to `rb_ec_reset_raised` and accepts `ec`. * vm_trace.c: the following functions accept `ec` instead of `th` * exec_hooks_body * exec_hooks_precheck * exec_hooks_unprotected * exec_hooks_protected git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent aa07918 commit b6ecdf5

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

eval.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
524524
rb_ivar_set(mesg, idBt_locations, at);
525525
set_backtrace(mesg, at);
526526
}
527-
rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
527+
rb_ec_reset_raised(ec);
528528
}
529529
EC_POP_TAG();
530530
if (state) goto fatal;
@@ -563,15 +563,15 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
563563
ec->errinfo = mesg;
564564
}
565565
else if (state) {
566-
rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
566+
rb_ec_reset_raised(ec);
567567
EC_JUMP_TAG(ec, state);
568568
}
569569
}
570570

571571
if (rb_threadptr_set_raised(rb_ec_thread_ptr(ec))) {
572572
fatal:
573573
ec->errinfo = exception_error;
574-
rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
574+
rb_ec_reset_raised(ec);
575575
EC_JUMP_TAG(ec, TAG_FATAL);
576576
}
577577

eval_error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,6 @@ error_handle(int ex)
324324
unknown_longjmp_status(ex);
325325
break;
326326
}
327-
rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
327+
rb_ec_reset_raised(ec);
328328
return status;
329329
}

eval_intern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ enum {
281281
RAISED_NOMEMORY = 4
282282
};
283283
int rb_threadptr_set_raised(rb_thread_t *th);
284-
int rb_threadptr_reset_raised(rb_thread_t *th);
285284
#define rb_thread_raised_set(th, f) ((th)->ec->raised_flag |= (f))
286285
#define rb_thread_raised_reset(th, f) ((th)->ec->raised_flag &= ~(f))
287286
#define rb_thread_raised_p(th, f) (((th)->ec->raised_flag & (f)) != 0)
288287
#define rb_thread_raised_clear(th) ((th)->ec->raised_flag = 0)
288+
int rb_ec_reset_raised(rb_execution_context_t *th);
289289
int rb_ec_stack_check(rb_execution_context_t *ec);
290290

291291
VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self);

thread.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,12 +2177,12 @@ rb_threadptr_set_raised(rb_thread_t *th)
21772177
}
21782178

21792179
int
2180-
rb_threadptr_reset_raised(rb_thread_t *th)
2180+
rb_ec_reset_raised(rb_execution_context_t *ec)
21812181
{
2182-
if (!(th->ec->raised_flag & RAISED_EXCEPTION)) {
2182+
if (!(ec->raised_flag & RAISED_EXCEPTION)) {
21832183
return 0;
21842184
}
2185-
th->ec->raised_flag &= ~RAISED_EXCEPTION;
2185+
ec->raised_flag &= ~RAISED_EXCEPTION;
21862186
return 1;
21872187
}
21882188

vm_trace.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ clean_hooks(rb_hook_list_t *list)
238238
}
239239

240240
static void
241-
exec_hooks_body(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
241+
exec_hooks_body(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
242242
{
243243
rb_event_hook_t *hook;
244244

@@ -255,10 +255,10 @@ exec_hooks_body(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *tra
255255
}
256256

257257
static int
258-
exec_hooks_precheck(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
258+
exec_hooks_precheck(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
259259
{
260260
if (UNLIKELY(list->need_clean != FALSE)) {
261-
if (th->vm->trace_running <= 1) { /* only running this hooks */
261+
if (rb_ec_vm_ptr(ec)->trace_running <= 1) { /* only running this hooks */
262262
clean_hooks(list);
263263
}
264264
}
@@ -267,32 +267,32 @@ exec_hooks_precheck(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t
267267
}
268268

269269
static void
270-
exec_hooks_unprotected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
270+
exec_hooks_unprotected(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
271271
{
272-
if (exec_hooks_precheck(th, list, trace_arg) == 0) return;
273-
exec_hooks_body(th, list, trace_arg);
272+
if (exec_hooks_precheck(ec, list, trace_arg) == 0) return;
273+
exec_hooks_body(ec, list, trace_arg);
274274
}
275275

276276
static int
277-
exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
277+
exec_hooks_protected(rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
278278
{
279279
enum ruby_tag_type state;
280280
volatile int raised;
281281

282-
if (exec_hooks_precheck(th, list, trace_arg) == 0) return 0;
282+
if (exec_hooks_precheck(ec, list, trace_arg) == 0) return 0;
283283

284-
raised = rb_threadptr_reset_raised(th);
284+
raised = rb_ec_reset_raised(ec);
285285

286286
/* TODO: Support !RUBY_EVENT_HOOK_FLAG_SAFE hooks */
287287

288-
EC_PUSH_TAG(th->ec);
288+
EC_PUSH_TAG(ec);
289289
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
290-
exec_hooks_body(th, list, trace_arg);
290+
exec_hooks_body(ec, list, trace_arg);
291291
}
292292
EC_POP_TAG();
293293

294294
if (raised) {
295-
rb_threadptr_set_raised(th);
295+
rb_threadptr_set_raised(rb_ec_thread_ptr(ec));
296296
}
297297

298298
return state;
@@ -302,8 +302,8 @@ static void
302302
rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
303303
{
304304
rb_execution_context_t *ec = trace_arg->ec;
305-
rb_thread_t *th = rb_ec_thread_ptr(ec);
306-
rb_vm_t *vm = th->vm;
305+
rb_vm_t *vm = rb_ec_vm_ptr(ec);
306+
rb_hook_list_t *th_event_hooks = &rb_ec_thread_ptr(ec)->event_hooks;
307307

308308
if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) {
309309
if (ec->trace_arg && (ec->trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) {
@@ -313,8 +313,8 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
313313
rb_trace_arg_t *prev_trace_arg = ec->trace_arg;
314314
vm->trace_running++;
315315
ec->trace_arg = trace_arg;
316-
exec_hooks_unprotected(th, &th->event_hooks, trace_arg);
317-
exec_hooks_unprotected(th, &vm->event_hooks, trace_arg);
316+
exec_hooks_unprotected(ec, th_event_hooks, trace_arg);
317+
exec_hooks_unprotected(ec, &vm->event_hooks, trace_arg);
318318
ec->trace_arg = prev_trace_arg;
319319
vm->trace_running--;
320320
}
@@ -333,11 +333,11 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
333333
ec->trace_arg = trace_arg;
334334
{
335335
/* thread local traces */
336-
state = exec_hooks_protected(th, &th->event_hooks, trace_arg);
336+
state = exec_hooks_protected(ec, th_event_hooks, trace_arg);
337337
if (state) goto terminate;
338338

339339
/* vm global traces */
340-
state = exec_hooks_protected(th, &vm->event_hooks, trace_arg);
340+
state = exec_hooks_protected(ec, &vm->event_hooks, trace_arg);
341341
if (state) goto terminate;
342342

343343
ec->errinfo = errinfo;
@@ -379,35 +379,35 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
379379
{
380380
volatile int raised;
381381
VALUE result = Qnil;
382-
rb_thread_t *volatile th = GET_THREAD();
382+
rb_execution_context_t *ec = GET_EC();
383383
enum ruby_tag_type state;
384-
const int volatile tracing = th->ec->trace_arg ? 1 : 0;
384+
const int volatile tracing = ec->trace_arg ? 1 : 0;
385385
rb_trace_arg_t dummy_trace_arg;
386386
dummy_trace_arg.event = 0;
387387

388-
if (!tracing) th->vm->trace_running++;
389-
if (!th->ec->trace_arg) th->ec->trace_arg = &dummy_trace_arg;
388+
if (!tracing) rb_ec_vm_ptr(ec)->trace_running++;
389+
if (!ec->trace_arg) ec->trace_arg = &dummy_trace_arg;
390390

391-
raised = rb_threadptr_reset_raised(th);
391+
raised = rb_ec_reset_raised(ec);
392392

393-
EC_PUSH_TAG(th->ec);
393+
EC_PUSH_TAG(ec);
394394
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
395395
result = (*func)(arg);
396396
}
397397
EC_POP_TAG();
398398

399399
if (raised) {
400-
rb_threadptr_set_raised(th);
400+
rb_ec_reset_raised(ec);
401401
}
402402

403-
if (th->ec->trace_arg == &dummy_trace_arg) th->ec->trace_arg = 0;
404-
if (!tracing) th->vm->trace_running--;
403+
if (ec->trace_arg == &dummy_trace_arg) ec->trace_arg = NULL;
404+
if (!tracing) rb_ec_vm_ptr(ec)->trace_running--;
405405

406406
if (state) {
407407
#if defined RUBY_USE_SETJMPEX && RUBY_USE_SETJMPEX
408408
RB_GC_GUARD(result);
409409
#endif
410-
EC_JUMP_TAG(th->ec, state);
410+
EC_JUMP_TAG(ec, state);
411411
}
412412

413413
return result;

0 commit comments

Comments
 (0)