Project

General

Profile

Feature #3638 » macro_yarv.patch

wanabe (_ wanabe), 08/01/2010 07:44 AM

View differences:

eval.c
604 604
{
605 605
    rb_thread_t *th = GET_THREAD();
606 606

  
607
    if ((th->cfp->lfp[0] & 0x02) == 0 &&
608
	GC_GUARDED_PTR_REF(th->cfp->lfp[0])) {
607
    if (!IN_CLASS_DEF(th->cfp) && BLOCK_PTR_REF(th->cfp)) {
609 608
	return TRUE;
610 609
    }
611 610
    else {
......
980 979
    while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
981 980
	if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
982 981
	    if (cfp->iseq->type == ISEQ_TYPE_RESCUE) {
983
		return &cfp->dfp[-2];
982
		return &ERRINFO(cfp);
984 983
	    }
985 984
	    else if (cfp->iseq->type == ISEQ_TYPE_ENSURE &&
986
		     TYPE(cfp->dfp[-2]) != T_NODE &&
987
		     !FIXNUM_P(cfp->dfp[-2])) {
988
		return &cfp->dfp[-2];
985
		     TYPE(ERRINFO(cfp)) != T_NODE &&
986
		     !FIXNUM_P(ERRINFO(cfp))) {
987
		return &ERRINFO(cfp);
989 988
	    }
990 989
	}
991 990
	cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
eval_intern.h
5 5
#include "vm_core.h"
6 6

  
7 7
#define PASS_PASSED_BLOCK_TH(th) do { \
8
    (th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
8
    (th)->passed_block = BLOCK_PTR_REF((th)->cfp); \
9 9
    (th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
10 10
} while (0)
11 11

  
proc.c
384 384
    rb_control_frame_t *cfp = th->cfp;
385 385
    rb_block_t *block;
386 386

  
387
    if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0) {
387
    if (BLOCK_PTR_REF(cfp) != 0) {
388 388

  
389
	block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
389
	block = BLOCK_PTR_REF(cfp);
390 390
    }
391 391
    else {
392 392
	cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
393 393

  
394
	if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0) {
394
	if (BLOCK_PTR_REF(cfp) != 0) {
395 395

  
396
	    block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
396
	    block = BLOCK_PTR_REF(cfp);
397 397

  
398 398
	    if (is_lambda) {
399 399
		rb_warn("tried to create Proc object without a block");
vm.c
69 69
rb_vm_set_finish_env(rb_thread_t * th)
70 70
{
71 71
    vm_push_frame(th, 0, VM_FRAME_MAGIC_FINISH,
72
		  Qnil, th->cfp->lfp[0], 0,
72
		  Qnil, BLOCK_PTR_RAW(th->cfp), 0,
73 73
		  th->cfp->sp, 0, 1);
74 74
    th->cfp->pc = (VALUE *)&finish_insn_seq[0];
75 75
    return Qtrue;
......
109 109
		  th->cfp->sp, block->lfp, iseq->local_size);
110 110

  
111 111
    if (cref) {
112
	th->cfp->dfp[-1] = (VALUE)cref;
112
	CREF(th->cfp) = (VALUE)cref;
113 113
    }
114 114

  
115 115
    CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
......
476 476
	rb_bug("rb_vm_make_proc: Proc value is already created.");
477 477
    }
478 478

  
479
    if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
479
    if (BLOCK_PTR_REF(cfp)) {
480 480
	    rb_proc_t *p;
481 481

  
482 482
	    blockprocval = vm_make_proc_from_block(
......
551 551
	th->passed_me = 0;
552 552

  
553 553
	if (cref) {
554
	    th->cfp->dfp[-1] = (VALUE)cref;
554
	    CREF(th->cfp) = (VALUE)cref;
555 555
	}
556 556

  
557 557
	return vm_exec(th);
......
564 564
static inline const rb_block_t *
565 565
check_block(rb_thread_t *th)
566 566
{
567
    const rb_block_t *blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
567
    const rb_block_t *blockptr = BLOCK_PTR_REF(th->cfp);
568 568

  
569 569
    if (blockptr == 0) {
570 570
	rb_vm_localjump_error("no block given", Qnil, 0);
vm_core.h
707 707
#pragma GCC visibility pop
708 708
#endif
709 709

  
710
#define BLOCK_PTR_RAW(cfp) (cfp)->lfp[0]
711
#define BLOCK_PTR_REF(cfp) (GC_GUARDED_PTR_REF(BLOCK_PTR_RAW(cfp)))
712
#define IN_CLASS_DEF(cfp) (BLOCK_PTR_RAW(cfp) & 0x02)
713
#define SET_BLOCK_PTR(cfp, ptr) BLOCK_PTR_RAW(cfp) = GC_GUARDED_PTR(ptr)
714
#define ERRINFO(cfp) (cfp)->dfp[-2]
715
#define CREF(cfp) (cfp)->dfp[-1]
716
#define PREV_DFP_REF(cfp) GC_GUARDED_PTR_REF((cfp)->dfp[0])
717

  
710 718
#endif /* RUBY_VM_CORE_H */
vm_eval.c
845 845
		blockptr->proc = 0;
846 846
	    }
847 847
	    else {
848
		blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
848
		blockptr = BLOCK_PTR_REF(th->cfp);
849 849
	    }
850 850
	    th->passed_block = blockptr;
851 851
	}
......
1195 1195
    rb_block_t block, *blockptr;
1196 1196
    NODE *cref;
1197 1197

  
1198
    if ((blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0])) != 0) {
1198
    if ((blockptr = BLOCK_PTR_REF(th->cfp)) != 0) {
1199 1199
	block = *blockptr;
1200 1200
	block.self = self;
1201
	th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
1201
	SET_BLOCK_PTR(th->cfp, &block);
1202 1202
    }
1203 1203
    cref = vm_cref_push(th, under, NOEX_PUBLIC, blockptr);
1204 1204
    cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL;
......
1673 1673
	}
1674 1674
	if (cfp->lfp != cfp->dfp) {
1675 1675
	    /* block */
1676
	    VALUE *dfp = GC_GUARDED_PTR_REF(cfp->dfp[0]);
1676
	    VALUE *dfp = PREV_DFP_REF(cfp);
1677 1677

  
1678 1678
	    if (vm_collect_local_variables_in_heap(th, dfp, ary)) {
1679 1679
		break;
......
1721 1721
    cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
1722 1722

  
1723 1723
    if (cfp != 0 &&
1724
	(cfp->lfp[0] & 0x02) == 0 &&
1725
	GC_GUARDED_PTR_REF(cfp->lfp[0])) {
1724
	!IN_CLASS_DEF(cfp) &&
1725
	BLOCK_PTR_REF(cfp)) {
1726 1726
	return Qtrue;
1727 1727
    }
1728 1728
    else {