comparison src/eval.c @ 3092:141c2920ea48

[xemacs-hg @ 2005-11-25 01:41:31 by crestani] Incremental Garbage Collector
author crestani
date Fri, 25 Nov 2005 01:42:08 +0000
parents facf3239ba30
children d674024a8674
comparison
equal deleted inserted replaced
3091:c22d8984148c 3092:141c2920ea48
2236 just to bomb out immediately. */ 2236 just to bomb out immediately. */
2237 stderr_out ("Error before initialization is complete!\n"); 2237 stderr_out ("Error before initialization is complete!\n");
2238 ABORT (); 2238 ABORT ();
2239 } 2239 }
2240 2240
2241 #ifndef NEW_GC
2241 assert (!gc_in_progress); 2242 assert (!gc_in_progress);
2243 #endif /* not NEW_GC */
2242 2244
2243 /* We abort if in_display and we are not protected, as garbage 2245 /* We abort if in_display and we are not protected, as garbage
2244 collections and non-local exits will invariably be fatal, but in 2246 collections and non-local exits will invariably be fatal, but in
2245 messy, difficult-to-debug ways. See enter_redisplay_critical_section(). 2247 messy, difficult-to-debug ways. See enter_redisplay_critical_section().
2246 */ 2248 */
3369 REGISTER int i = 0; 3371 REGISTER int i = 0;
3370 int max_non_rest_args = f->args_in_array - 1; 3372 int max_non_rest_args = f->args_in_array - 1;
3371 int bindargs = min (nargs, max_non_rest_args); 3373 int bindargs = min (nargs, max_non_rest_args);
3372 3374
3373 for (i = 0; i < bindargs; i++) 3375 for (i = 0; i < bindargs; i++)
3376 #ifdef NEW_GC
3377 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3378 args[i]);
3379 #else /* not NEW_GC */
3374 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3380 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3381 #endif /* not NEW_GC */
3375 for (i = bindargs; i < max_non_rest_args; i++) 3382 for (i = bindargs; i < max_non_rest_args; i++)
3383 #ifdef NEW_GC
3384 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3385 Qnil);
3386 #else /* not NEW_GC */
3376 SPECBIND_FAST_UNSAFE (f->args[i], Qnil); 3387 SPECBIND_FAST_UNSAFE (f->args[i], Qnil);
3388 #endif /* not NEW_GC */
3389 #ifdef NEW_GC
3390 SPECBIND_FAST_UNSAFE
3391 (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[max_non_rest_args],
3392 nargs > max_non_rest_args ?
3393 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) :
3394 Qnil);
3395 #else /* not NEW_GC */
3377 SPECBIND_FAST_UNSAFE 3396 SPECBIND_FAST_UNSAFE
3378 (f->args[max_non_rest_args], 3397 (f->args[max_non_rest_args],
3379 nargs > max_non_rest_args ? 3398 nargs > max_non_rest_args ?
3380 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) : 3399 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) :
3381 Qnil); 3400 Qnil);
3401 #endif /* not NEW_GC */
3382 } 3402 }
3383 3403
3384 /* Apply compiled-function object FUN to the NARGS evaluated arguments 3404 /* Apply compiled-function object FUN to the NARGS evaluated arguments
3385 in ARGS, and return the result of evaluation. */ 3405 in ARGS, and return the result of evaluation. */
3386 inline static Lisp_Object 3406 inline static Lisp_Object
3403 if (nargs == f->max_args) /* Optimize for the common case -- no unspecified 3423 if (nargs == f->max_args) /* Optimize for the common case -- no unspecified
3404 optional arguments. */ 3424 optional arguments. */
3405 { 3425 {
3406 #if 1 3426 #if 1
3407 for (i = 0; i < nargs; i++) 3427 for (i = 0; i < nargs; i++)
3428 #ifdef NEW_GC
3429 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3430 args[i]);
3431 #else /* not NEW_GC */
3408 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3432 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3433 #endif /* not NEW_GC */
3409 #else 3434 #else
3410 /* Here's an alternate way to write the loop that tries to further 3435 /* Here's an alternate way to write the loop that tries to further
3411 optimize funcalls for functions with few arguments by partially 3436 optimize funcalls for functions with few arguments by partially
3412 unrolling the loop. It's not clear whether this is a win since it 3437 unrolling the loop. It's not clear whether this is a win since it
3413 increases the size of the function and the possibility of L1 cache 3438 increases the size of the function and the possibility of L1 cache
3434 else if (nargs < f->min_args) 3459 else if (nargs < f->min_args)
3435 goto wrong_number_of_arguments; 3460 goto wrong_number_of_arguments;
3436 else if (nargs < f->max_args) 3461 else if (nargs < f->max_args)
3437 { 3462 {
3438 for (i = 0; i < nargs; i++) 3463 for (i = 0; i < nargs; i++)
3464 #ifdef NEW_GC
3465 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3466 args[i]);
3467 #else /* not NEW_GC */
3439 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3468 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3469 #endif /* not NEW_GC */
3440 for (i = nargs; i < f->max_args; i++) 3470 for (i = nargs; i < f->max_args; i++)
3471 #ifdef NEW_GC
3472 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3473 Qnil);
3474 #else /* not NEW_GC */
3441 SPECBIND_FAST_UNSAFE (f->args[i], Qnil); 3475 SPECBIND_FAST_UNSAFE (f->args[i], Qnil);
3476 #endif /* not NEW_GC */
3442 } 3477 }
3443 else if (f->max_args == MANY) 3478 else if (f->max_args == MANY)
3444 handle_compiled_function_with_and_rest (f, nargs, args); 3479 handle_compiled_function_with_and_rest (f, nargs, args);
3445 else 3480 else
3446 { 3481 {
3525 QUIT; 3560 QUIT;
3526 if (need_to_garbage_collect) 3561 if (need_to_garbage_collect)
3527 { 3562 {
3528 struct gcpro gcpro1; 3563 struct gcpro gcpro1;
3529 GCPRO1 (form); 3564 GCPRO1 (form);
3565 #ifdef NEW_GC
3566 gc_incremental ();
3567 #else /* not NEW_GC */
3530 garbage_collect_1 (); 3568 garbage_collect_1 ();
3569 #endif /* not NEW_GC */
3531 UNGCPRO; 3570 UNGCPRO;
3532 } 3571 }
3533 3572
3534 if (++lisp_eval_depth > max_lisp_eval_depth) 3573 if (++lisp_eval_depth > max_lisp_eval_depth)
3535 { 3574 {
3777 3816
3778 if (funcall_allocation_flag) 3817 if (funcall_allocation_flag)
3779 { 3818 {
3780 if (need_to_garbage_collect) 3819 if (need_to_garbage_collect)
3781 /* Callers should gcpro lexpr args */ 3820 /* Callers should gcpro lexpr args */
3821 #ifdef NEW_GC
3822 gc_incremental ();
3823 #else /* not NEW_GC */
3782 garbage_collect_1 (); 3824 garbage_collect_1 ();
3825 #endif /* not NEW_GC */
3783 if (need_to_check_c_alloca) 3826 if (need_to_check_c_alloca)
3784 { 3827 {
3785 if (++funcall_alloca_count >= MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP) 3828 if (++funcall_alloca_count >= MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP)
3786 { 3829 {
3787 xemacs_c_alloca (0); 3830 xemacs_c_alloca (0);
4303 4346
4304 if (!initialized || preparing_for_armageddon) 4347 if (!initialized || preparing_for_armageddon)
4305 /* We need to bail out of here pronto. */ 4348 /* We need to bail out of here pronto. */
4306 return Qnil; 4349 return Qnil;
4307 4350
4351 #ifndef NEW_GC
4308 /* Whenever gc_in_progress is true, preparing_for_armageddon 4352 /* Whenever gc_in_progress is true, preparing_for_armageddon
4309 will also be true unless something is really hosed. */ 4353 will also be true unless something is really hosed. */
4310 assert (!gc_in_progress); 4354 assert (!gc_in_progress);
4355 #endif /* not NEW_GC */
4311 4356
4312 sym = args[0]; 4357 sym = args[0];
4313 val = symbol_value_in_buffer (sym, wrap_buffer (buf)); 4358 val = symbol_value_in_buffer (sym, wrap_buffer (buf));
4314 ret = (cond == RUN_HOOKS_UNTIL_FAILURE ? Qt : Qnil); 4359 ret = (cond == RUN_HOOKS_UNTIL_FAILURE ? Qt : Qnil);
4315 4360