Changeset 9150


Ignore:
Timestamp:
Apr 13, 2008, 4:40:15 AM (11 years ago)
Author:
rme
Message:

.SPstkconslist, .SPsave_values, .SPrecover_values, .SPspread_lexprz

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/lisp-kernel/x86-spentry32.s

    r9135 r9150  
    14441444_endsubp(conslist_star)
    14451445
    1446 /* We always have to create a tsp frame (even if nargs is 0), so the compiler   */
    1447 /* doesn't get confused.   */
     1446/* We always have to create a tsp frame (even if nargs is 0), so the compiler */
     1447/* doesn't get confused. */
    14481448_spentry(stkconslist)
    1449         __(int $3)
     1449        __(movl %ra0,%rcontext:tcr.save0)
     1450        __(movd %nargs,%mm0)
     1451        __(movl %nargs,%temp0)
     1452        __(addl %temp0,%temp0)
     1453        __(movl $nil_value,%arg_z)
     1454        __(dnode_align(%temp0,tsp_frame.fixed_overhead,%temp0))
     1455        __(TSP_Alloc_Var(%temp0,%imm0))
     1456        __(addl $fulltag_cons,%imm0)
     1457        __(test %nargs,%nargs)
     1458        __(jmp 2f)
     14591:      __(pop %arg_y)
     1460        __(_rplaca(%imm0,%arg_y))
     1461        __(_rplacd(%imm0,%arg_z))
     1462        __(movl %imm0,%arg_z)
     1463        __(add $cons.size,%imm0)
     1464        __(subl $node_size,%nargs)
     14652:      __(jne 1b)
     1466        __(movl %rcontext:tcr.save0,%ra0)
     1467        __(movl $0,%rcontext:tcr.save0)
     1468        __(jmp *%ra0)
    14501469_endsubp(stkconslist)
    14511470
     
    25052524
    25062525_spentry(save_values)
    2507         __(int $3)
     2526        __(movl %ra0,%rcontext:tcr.save0)
     2527        __(movd %rcontext:tcr.save_tsp,%mm1)
     2528/* common exit: nargs = values in this set, imm1 = ptr to tsp before call to save_values   */
     2529local_label(save_values_to_tsp):
     2530        __(movl %rcontext:tcr.save_tsp,%temp0)
     2531        __(dnode_align(%nargs,tsp_frame.fixed_overhead+(2*node_size),%imm0)) /* count, link   */
     2532        __(TSP_Alloc_Var(%imm0,%arg_z))
     2533        __(movl %rcontext:tcr.save_tsp,%imm0)
     2534        __(movd %mm1,(%imm0))
     2535        __(movl %nargs,(%arg_z))
     2536        __(movl %temp0,node_size(%arg_z))
     2537        __(leal 2*node_size(%arg_z,%nargs),%arg_y)
     2538        __(leal (%esp,%nargs),%imm0)
     2539        __(cmpl %imm0,%esp)
     2540        __(jmp 2f)
     25411:      __(subl $node_size,%imm0)
     2542        __(movl (%imm0),%arg_z)
     2543        __(subl $node_size,%arg_y)
     2544        __(cmpl %imm0,%esp)
     2545        __(movl %arg_z,(%arg_y))
     25462:      __(jne 1b)
     2547        __(addl %nargs,%esp)
     2548        __(movl %rcontext:tcr.save0,%ra0)
     2549        __(movl $0,%rcontext:tcr.save0)
     2550        __(jmp *%ra0)
    25082551_endsubp(save_values)
    25092552
     2553/* Add the multiple values that are on top of the vstack to the set  */
     2554/* saved in the top tsp frame, popping them off of the vstack in the  */
     2555/* process.  It is an error (a bad one) if the TSP contains something  */
     2556/* other than a previously saved set of multiple-values.  */
     2557/* Since adding to the TSP may cause a new TSP segment to be allocated,  */
     2558/* each add_values call adds another linked element to the list of  */
     2559/* values. This makes recover_values harder.   */
    25102560_spentry(add_values)
    25112561        __(int $3)
    25122562_endsubp(add_values)
    25132563
     2564/* push the values in the value set atop the sp, incrementing nargs.  */
     2565/* Discard the tsp frame; leave values atop the sp.   */
    25142566_spentry(recover_values)
    2515         __(int $3)
     2567        __(movl %ra0,%rcontext:tcr.save0) /* temp0 */
     2568        __(movd %nargs,%mm0)              /* temp1 */
     2569        /* First, walk the segments reversing the pointer to previous  */
     2570        /* segment pointers Can tell the end because that previous  */
     2571        /* segment pointer is the prev tsp pointer   */
     2572        __(movl %rcontext:tcr.save_tsp,%temp1)
     2573        __(movl %temp1,%temp0)  /* current segment   */
     2574        __(movl %temp1,%arg_y)  /* last segment   */
     2575        __(movl tsp_frame.backlink(%temp1),%arg_z)      /* previous tsp   */
     2576local_label(walkloop):
     2577        __(movl tsp_frame.fixed_overhead+node_size(%temp0),%imm0)
     2578        __(cmpl %imm0,%arg_z)   /* last segment ?   */
     2579        __(movl %arg_y,tsp_frame.fixed_overhead+node_size(%temp0))
     2580        __(movl %temp0,%arg_y)  /* last segment <- current segment   */
     2581        __(movl %imm0,%temp0)   /* current segment <- next segment   */
     2582        __(jne local_label(walkloop))
     2583
     2584        __(movl %temp1,%arg_z)
     2585        __(movd %mm0,%nargs)
     2586        /* the final segment pointer is now in %arg_y  */
     2587        /* walk backwards, pushing values on the stack and incrementing %nargs   */
     2588local_label(pushloop):
     2589        __(movl tsp_frame.data_offset(%arg_y),%imm0)    /* nargs in segment   */
     2590        __(test %imm0,%imm0)
     2591        __(leal tsp_frame.data_offset+(2*node_size)(%arg_y,%imm0),%temp0)
     2592        __(leal (%nargs,%imm0),%nargs)
     2593        __(jmp 2f)
     25941:      __(push -node_size(%temp0))
     2595        __(subl $node_size,%temp0)
     2596        __(subl $fixnum_one,%imm0)
     25972:      __(jne 1b)
     2598        __(cmpl %arg_y,%arg_z)
     2599        __(movl tsp_frame.data_offset+node_size(%arg_y),%arg_y)
     2600        __(jne local_label(pushloop))
     2601        __(movl (%arg_z),%arg_z)
     2602        __(movl %arg_z,%rcontext:tcr.save_tsp)
     2603        __(movl %arg_z,%rcontext:tcr.next_tsp)
     2604        __(movl %rcontext:tcr.save0,%ra0)
     2605        __(movl $0,%rcontext:tcr.save0)
     2606        __(jmp *%ra0)           
    25162607_endsubp(recover_values)
    25172608
     
    32913382_endsubp(ffcall_return_registers)
    32923383
     3384/* We need to reserve a frame here if (a) nothing else was already pushed
     3385/* and (b) we push something (e.g., more than 2 args in the lexpr) */
    32933386_spentry(spread_lexprz)
    32943387        __(int $3)
     3388        new_local_labels()
     3389        __(movl (%arg_z),%imm0) /* lexpr count */
     3390        __(leal node_size(%arg_z,%imm0),%arg_y)
     3391        __(movd %arg_y,%mm1)
     3392        __(test %nargs,%nargs) /* anything pushed by caller ? */
     3393        __(jne 0f)              /* yes, caller has already created frame. */
     3394        __(cmpl $(nargregs*node_size),%imm0) /* will we push anything ? */
     3395        __(jbe 0f)
     3396        __(push $reserved_frame_marker)
     3397        __(push $reserved_frame_marker)
     33980:      __(addl %imm0,%nargs)
     3399        __(cmpl $(1*node_size),%imm0)
     3400        __(ja 2f)
     3401        __(je 1f)
     3402        /* lexpr count was 0; vpop the args that */
     3403        /* were pushed by the caller */
     3404        __(test %nargs,%nargs)
     3405        __(je local_label(all_args_popped))
     3406        __(pop %arg_z)
     3407local_label(maybe_pop_y):
     3408        __(cmpl $(1*node_size),%nargs)
     3409        __(je local_label(all_args_popped))
     3410        __(pop %arg_y)
     3411local_label(all_args_popped):   
     3412        /* If all args fit in registers but some were pushed */
     3413        /* by the caller, discard the reserved frame that the caller */
     3414        /* pushed.         */
     3415        __(cmpl %imm0,%nargs)
     3416        __(je local_label(go))
     3417        __(cmpl $(nargregs*node_size),%nargs)
     3418        __(ja local_label(go))
     3419        __(addl $(2*node_size),%esp)
     3420local_label(go):
     3421        __(jmp *%ra0)
     3422
     3423        /* lexpr count is two or more: vpush args from the lexpr until */
     3424        /* we have only two left, then assign them to arg_y and arg_z */
     34252:      __(cmpl $(3*node_size),%imm0)
     3426        __(lea -1*node_size(%imm0),%imm0)
     3427        __(push -node_size(%arg_y))
     3428        __(lea -1*node_size(%arg_y),%arg_y)
     3429        __(jne 2b)
     3430        __(movl -node_size*2(%arg_y),%arg_z)
     3431        __(movl -node_size*1(%arg_y),%arg_y)
     3432        __(jmp *%ra0)
     3433        /* lexpr count is one: set arg_z from the lexpr, */
     3434        /* maybe vpop arg_y  */
     34351:      __(movl -node_size*1(%arg_y),%arg_z)
     3436        __(jmp local_label(maybe_pop_y))
    32953437_endsubp(spread_lexprz)
    32963438
Note: See TracChangeset for help on using the changeset viewer.