mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* compile.c (iseq_compile_each), gc.c (assign_heap_slot),
(gc_mark_children), parse.y (vtable_alloc, vtable_free, vtable_add), proc.c (proc_to_s), thread.c (terminate_i, rb_thread_terminate_all), (thread_start_func_2, blocking_region_begin, blocking_region_end), (rb_thread_kill), thread_pthread.c (native_thread_create), (ubf_pthread_cond_signal), vm.c (check_env, thread_free), vm_dump.c (vm_env_dump_raw, vm_stack_dump_each, vm_thread_dump_state), (vm_call0): use void pointer for %p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									3cde544d47
								
							
						
					
					
						commit
						541915b239
					
				
					 10 changed files with 44 additions and 34 deletions
				
			
		
							
								
								
									
										11
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,13 @@
 | 
			
		|||
Tue Dec  9 13:25:51 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
Tue Dec  9 13:33:53 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* compile.c (iseq_compile_each), gc.c (assign_heap_slot),
 | 
			
		||||
	  (gc_mark_children), parse.y (vtable_alloc, vtable_free, vtable_add),
 | 
			
		||||
	  proc.c (proc_to_s), thread.c (terminate_i, rb_thread_terminate_all),
 | 
			
		||||
	  (thread_start_func_2, blocking_region_begin, blocking_region_end),
 | 
			
		||||
	  (rb_thread_kill), thread_pthread.c (native_thread_create),
 | 
			
		||||
	  (ubf_pthread_cond_signal), vm.c (check_env, thread_free), vm_dump.c
 | 
			
		||||
	  (vm_env_dump_raw, vm_stack_dump_each, vm_thread_dump_state),
 | 
			
		||||
	  (vm_call0): use void pointer for %p.
 | 
			
		||||
 | 
			
		||||
	* cont.c (fiber_status), template/insns.inc.tmpl (ruby_vminsn_type),
 | 
			
		||||
	  vm_insnhelper.h (BOP): ISO C forbids comma at end of enumerator
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4629,7 +4629,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
 | 
			
		|||
	LABEL *lfin = NEW_LABEL(nd_line(node));
 | 
			
		||||
	LABEL *ltrue = NEW_LABEL(nd_line(node));
 | 
			
		||||
	VALUE key = rb_sprintf("flipflag/%s-%p-%d",
 | 
			
		||||
			       RSTRING_PTR(iseq->name), iseq,
 | 
			
		||||
			       RSTRING_PTR(iseq->name), (void *)iseq,
 | 
			
		||||
			       iseq->compile_data->flip_cnt++);
 | 
			
		||||
 | 
			
		||||
	iseq_add_mark_object_compile_time(iseq, key);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								gc.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								gc.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -819,7 +819,7 @@ assign_heap_slot(rb_objspace_t *objspace)
 | 
			
		|||
	    hi = mid;
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	    rb_bug("same heap slot is allocated: %p at %"PRIuVALUE, membase, (VALUE)mid);
 | 
			
		||||
	    rb_bug("same heap slot is allocated: %p at %"PRIuVALUE, (void *)membase, (VALUE)mid);
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
    if (hi < heaps_used) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1563,7 +1563,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
 | 
			
		|||
 | 
			
		||||
      default:
 | 
			
		||||
	rb_bug("rb_gc_mark(): unknown data type 0x%lx(%p) %s",
 | 
			
		||||
	       BUILTIN_TYPE(obj), obj,
 | 
			
		||||
	       BUILTIN_TYPE(obj), (void *)obj,
 | 
			
		||||
	       is_pointer_to_heap(objspace, obj) ? "corrupted object" : "non object");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								parse.y
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -129,14 +129,14 @@ vtable_alloc(struct vtable *prev)
 | 
			
		|||
    tbl->capa = 8;
 | 
			
		||||
    tbl->tbl = ALLOC_N(ID, tbl->capa);
 | 
			
		||||
    tbl->prev = prev;
 | 
			
		||||
    if (VTBL_DEBUG) printf("vtable_alloc: %p\n", tbl);
 | 
			
		||||
    if (VTBL_DEBUG) printf("vtable_alloc: %p\n", (void *)tbl);
 | 
			
		||||
    return tbl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vtable_free(struct vtable *tbl)
 | 
			
		||||
{
 | 
			
		||||
    if (VTBL_DEBUG)printf("vtable_free: %p\n", tbl);
 | 
			
		||||
    if (VTBL_DEBUG)printf("vtable_free: %p\n", (void *)tbl);
 | 
			
		||||
    if (POINTER_P(tbl)) {
 | 
			
		||||
        if (tbl->tbl) {
 | 
			
		||||
            xfree(tbl->tbl);
 | 
			
		||||
| 
						 | 
				
			
			@ -149,9 +149,9 @@ static void
 | 
			
		|||
vtable_add(struct vtable *tbl, ID id)
 | 
			
		||||
{
 | 
			
		||||
    if (!POINTER_P(tbl)) {
 | 
			
		||||
        rb_bug("vtable_add: vtable is not allocated (%p)", tbl);
 | 
			
		||||
        rb_bug("vtable_add: vtable is not allocated (%p)", (void *)tbl);
 | 
			
		||||
    }
 | 
			
		||||
    if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", tbl, rb_id2name(id));
 | 
			
		||||
    if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", (void *)tbl, rb_id2name(id));
 | 
			
		||||
 | 
			
		||||
    if (tbl->pos == tbl->capa) {
 | 
			
		||||
        tbl->capa = tbl->capa * 2;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								proc.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								proc.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -781,7 +781,7 @@ proc_to_s(VALUE self)
 | 
			
		|||
			 line_no, is_lambda);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	str = rb_sprintf("#<%s:%p%s>", cname, proc->block.iseq,
 | 
			
		||||
	str = rb_sprintf("#<%s:%p%s>", cname, (void *)proc->block.iseq,
 | 
			
		||||
			 is_lambda);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										23
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								thread.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -270,13 +270,13 @@ terminate_i(st_data_t key, st_data_t val, rb_thread_t *main_thread)
 | 
			
		|||
    GetThreadPtr(thval, th);
 | 
			
		||||
 | 
			
		||||
    if (th != main_thread) {
 | 
			
		||||
	thread_debug("terminate_i: %p\n", th);
 | 
			
		||||
	thread_debug("terminate_i: %p\n", (void *)th);
 | 
			
		||||
	rb_thread_interrupt(th);
 | 
			
		||||
	th->thrown_errinfo = eTerminateSignal;
 | 
			
		||||
	th->status = THREAD_TO_KILL;
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	thread_debug("terminate_i: main thread (%p)\n", th);
 | 
			
		||||
	thread_debug("terminate_i: main thread (%p)\n", (void *)th);
 | 
			
		||||
    }
 | 
			
		||||
    return ST_CONTINUE;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -298,7 +298,8 @@ rb_thread_terminate_all(void)
 | 
			
		|||
    rb_thread_t *th = GET_THREAD(); /* main thread */
 | 
			
		||||
    rb_vm_t *vm = th->vm;
 | 
			
		||||
    if (vm->main_thread != th) {
 | 
			
		||||
	rb_bug("rb_thread_terminate_all: called by child thread (%p, %p)", vm->main_thread, th);
 | 
			
		||||
	rb_bug("rb_thread_terminate_all: called by child thread (%p, %p)",
 | 
			
		||||
	       (void *)vm->main_thread, (void *)th);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* unlock all locking mutexes */
 | 
			
		||||
| 
						 | 
				
			
			@ -306,7 +307,7 @@ rb_thread_terminate_all(void)
 | 
			
		|||
	rb_mutex_unlock_all(th->keeping_mutexes);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    thread_debug("rb_thread_terminate_all (main thread: %p)\n", th);
 | 
			
		||||
    thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
 | 
			
		||||
    st_foreach(vm->living_threads, terminate_i, (st_data_t)th);
 | 
			
		||||
 | 
			
		||||
    while (!rb_thread_alone()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -365,11 +366,11 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
 | 
			
		|||
#ifdef __ia64
 | 
			
		||||
    th->machine_register_stack_start = register_stack_start;
 | 
			
		||||
#endif
 | 
			
		||||
    thread_debug("thread start: %p\n", th);
 | 
			
		||||
    thread_debug("thread start: %p\n", (void *)th);
 | 
			
		||||
 | 
			
		||||
    native_mutex_lock(&th->vm->global_vm_lock);
 | 
			
		||||
    {
 | 
			
		||||
	thread_debug("thread start (get lock): %p\n", th);
 | 
			
		||||
	thread_debug("thread start (get lock): %p\n", (void *)th);
 | 
			
		||||
	rb_thread_set_current(th);
 | 
			
		||||
 | 
			
		||||
	TH_PUSH_TAG(th);
 | 
			
		||||
| 
						 | 
				
			
			@ -413,7 +414,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	th->status = THREAD_KILLED;
 | 
			
		||||
	thread_debug("thread end: %p\n", th);
 | 
			
		||||
	thread_debug("thread end: %p\n", (void *)th);
 | 
			
		||||
 | 
			
		||||
	main_th = th->vm->main_thread;
 | 
			
		||||
	if (th != main_th) {
 | 
			
		||||
| 
						 | 
				
			
			@ -427,7 +428,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
 | 
			
		|||
	/* locking_mutex must be Qfalse */
 | 
			
		||||
	if (th->locking_mutex != Qfalse) {
 | 
			
		||||
	    rb_bug("thread_start_func_2: locking_mutex must not be set (%p:%"PRIxVALUE")",
 | 
			
		||||
		   th, th->locking_mutex);
 | 
			
		||||
		   (void *)th, th->locking_mutex);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* unlock all locking mutexes */
 | 
			
		||||
| 
						 | 
				
			
			@ -949,7 +950,7 @@ blocking_region_begin(rb_thread_t *th, struct rb_blocking_region_buffer *region,
 | 
			
		|||
    region->prev_status = th->status;
 | 
			
		||||
    set_unblock_function(th, func, arg, ®ion->oldubf);
 | 
			
		||||
    th->status = THREAD_STOPPED;
 | 
			
		||||
    thread_debug("enter blocking region (%p)\n", th);
 | 
			
		||||
    thread_debug("enter blocking region (%p)\n", (void *)th);
 | 
			
		||||
    rb_gc_save_machine_context(th);
 | 
			
		||||
    native_mutex_unlock(&th->vm->global_vm_lock);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -959,7 +960,7 @@ blocking_region_end(rb_thread_t *th, struct rb_blocking_region_buffer *region)
 | 
			
		|||
{
 | 
			
		||||
    native_mutex_lock(&th->vm->global_vm_lock);
 | 
			
		||||
    rb_thread_set_current(th);
 | 
			
		||||
    thread_debug("leave blocking region (%p)\n", th);
 | 
			
		||||
    thread_debug("leave blocking region (%p)\n", (void *)th);
 | 
			
		||||
    remove_signal_thread_list(th);
 | 
			
		||||
    reset_unblock_function(th, ®ion->oldubf);
 | 
			
		||||
    if (th->status == THREAD_STOPPED) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1276,7 +1277,7 @@ rb_thread_kill(VALUE thread)
 | 
			
		|||
	rb_exit(EXIT_SUCCESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    thread_debug("rb_thread_kill: %p (%p)\n", th, (void *)th->thread_id);
 | 
			
		||||
    thread_debug("rb_thread_kill: %p (%p)\n", (void *)th, (void *)th->thread_id);
 | 
			
		||||
 | 
			
		||||
    rb_thread_interrupt(th);
 | 
			
		||||
    th->thrown_errinfo = eKillSignal;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -461,7 +461,7 @@ native_thread_create(rb_thread_t *th)
 | 
			
		|||
    int err = 0;
 | 
			
		||||
 | 
			
		||||
    if (use_cached_thread(th)) {
 | 
			
		||||
	thread_debug("create (use cached thread): %p\n", th);
 | 
			
		||||
	thread_debug("create (use cached thread): %p\n", (void *)th);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	pthread_attr_t attr;
 | 
			
		||||
| 
						 | 
				
			
			@ -494,7 +494,7 @@ native_thread_create(rb_thread_t *th)
 | 
			
		|||
	CHECK_ERR(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED));
 | 
			
		||||
 | 
			
		||||
	err = pthread_create(&th->thread_id, &attr, thread_start_func_1, th);
 | 
			
		||||
	thread_debug("create: %p (%d)", th, err);
 | 
			
		||||
	thread_debug("create: %p (%d)", (void *)th, err);
 | 
			
		||||
	CHECK_ERR(pthread_attr_destroy(&attr));
 | 
			
		||||
 | 
			
		||||
	if (!err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -553,7 +553,7 @@ static void
 | 
			
		|||
ubf_pthread_cond_signal(void *ptr)
 | 
			
		||||
{
 | 
			
		||||
    rb_thread_t *th = (rb_thread_t *)ptr;
 | 
			
		||||
    thread_debug("ubf_pthread_cond_signal (%p)\n", th);
 | 
			
		||||
    thread_debug("ubf_pthread_cond_signal (%p)\n", (void *)th);
 | 
			
		||||
    pthread_cond_signal(&th->native_thread_data.sleep_cond);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								vm.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								vm.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -205,15 +205,15 @@ static int
 | 
			
		|||
check_env(rb_env_t * const env)
 | 
			
		||||
{
 | 
			
		||||
    printf("---\n");
 | 
			
		||||
    printf("envptr: %p\n", &env->block.dfp[0]);
 | 
			
		||||
    printf("envptr: %p\n", (void *)&env->block.dfp[0]);
 | 
			
		||||
    printf("orphan: %p\n", (void *)env->block.dfp[1]);
 | 
			
		||||
    printf("inheap: %p\n", (void *)env->block.dfp[2]);
 | 
			
		||||
    printf("envval: %10p ", (void *)env->block.dfp[3]);
 | 
			
		||||
    dp(env->block.dfp[3]);
 | 
			
		||||
    printf("penvv : %10p ", (void *)env->block.dfp[4]);
 | 
			
		||||
    dp(env->block.dfp[4]);
 | 
			
		||||
    printf("lfp:    %10p\n", env->block.lfp);
 | 
			
		||||
    printf("dfp:    %10p\n", env->block.dfp);
 | 
			
		||||
    printf("lfp:    %10p\n", (void *)env->block.lfp);
 | 
			
		||||
    printf("dfp:    %10p\n", (void *)env->block.dfp);
 | 
			
		||||
    if (env->block.dfp[4]) {
 | 
			
		||||
	printf(">>\n");
 | 
			
		||||
	check_env_value(env->block.dfp[4]);
 | 
			
		||||
| 
						 | 
				
			
			@ -1464,10 +1464,10 @@ thread_free(void *ptr)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if (th->locking_mutex != Qfalse) {
 | 
			
		||||
	    rb_bug("thread_free: locking_mutex must be NULL (%p:%ld)", th, th->locking_mutex);
 | 
			
		||||
	    rb_bug("thread_free: locking_mutex must be NULL (%p:%ld)", (void *)th, th->locking_mutex);
 | 
			
		||||
	}
 | 
			
		||||
	if (th->keeping_mutexes != NULL) {
 | 
			
		||||
	    rb_bug("thread_free: keeping_mutexes must be NULL (%p:%ld)", th, th->locking_mutex);
 | 
			
		||||
	    rb_bug("thread_free: keeping_mutexes must be NULL (%p:%ld)", (void *)th, th->locking_mutex);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (th->local_storage) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								vm_dump.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								vm_dump.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -196,7 +196,7 @@ vm_env_dump_raw(rb_env_t *env, VALUE *lfp, VALUE *dfp)
 | 
			
		|||
	fprintf(stderr, "--\n");
 | 
			
		||||
	for (i = 0; i < env->env_size; i++) {
 | 
			
		||||
	    fprintf(stderr, "%04d: %08lx (%p)", -env->local_size + i, env->env[i],
 | 
			
		||||
		   &env->env[i]);
 | 
			
		||||
		   (void *)&env->env[i]);
 | 
			
		||||
	    if (&env->env[i] == lfp)
 | 
			
		||||
		fprintf(stderr, " <- lfp");
 | 
			
		||||
	    if (&env->env[i] == dfp)
 | 
			
		||||
| 
						 | 
				
			
			@ -295,12 +295,12 @@ vm_stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
 | 
			
		|||
	for (i = 0; i < argc; i++) {
 | 
			
		||||
	    rstr = rb_inspect(*ptr);
 | 
			
		||||
	    fprintf(stderr, "  arg   %2d: %8s (%p)\n", i, StringValueCStr(rstr),
 | 
			
		||||
		   ptr++);
 | 
			
		||||
		   (void *)ptr++);
 | 
			
		||||
	}
 | 
			
		||||
	for (; i < local_size - 1; i++) {
 | 
			
		||||
	    rstr = rb_inspect(*ptr);
 | 
			
		||||
	    fprintf(stderr, "  local %2d: %8s (%p)\n", i, StringValueCStr(rstr),
 | 
			
		||||
		   ptr++);
 | 
			
		||||
		   (void *)ptr++);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ptr = cfp->bp;
 | 
			
		||||
| 
						 | 
				
			
			@ -562,8 +562,8 @@ vm_thread_dump_state(VALUE self)
 | 
			
		|||
    cfp = th->cfp;
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr, "Thread state dump:\n");
 | 
			
		||||
    fprintf(stderr, "pc : %p, sp : %p\n", cfp->pc, cfp->sp);
 | 
			
		||||
    fprintf(stderr, "cfp: %p, lfp: %p, dfp: %p\n", cfp, cfp->lfp, cfp->dfp);
 | 
			
		||||
    fprintf(stderr, "pc : %p, sp : %p\n", (void *)cfp->pc, (void *)cfp->sp);
 | 
			
		||||
    fprintf(stderr, "cfp: %p, lfp: %p, dfp: %p\n", (void *)cfp, (void *)cfp->lfp, (void *)cfp->dfp);
 | 
			
		||||
 | 
			
		||||
    return Qnil;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ vm_call0(rb_thread_t * th, VALUE klass, VALUE recv, VALUE id, ID oid,
 | 
			
		|||
 | 
			
		||||
    if (0) printf("id: %s, nd: %s, argc: %d, passed: %p\n",
 | 
			
		||||
		  rb_id2name(id), ruby_node_name(nd_type(body)),
 | 
			
		||||
		  argc, th->passed_block);
 | 
			
		||||
		  argc, (void *)th->passed_block);
 | 
			
		||||
 | 
			
		||||
    if (th->passed_block) {
 | 
			
		||||
	blockptr = th->passed_block;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue