File: stack.c

package info (click to toggle)
rscheme 0.7.2-1.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 10,672 kB
  • ctags: 12,430
  • sloc: lisp: 37,104; ansic: 29,763; cpp: 2,630; sh: 1,677; makefile: 568; yacc: 202; lex: 175; perl: 33
file content (55 lines) | stat: -rw-r--r-- 1,632 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-----------------------------------------------------------------*-C-*---
 * File:    handc/runtime/stack.c
 *
 *          Copyright (C)1997 Donovan Kolbly <d.kolbly@rscheme.org>
 *          as part of the RScheme project, licensed for free use.
 *          See <http://www.rscheme.org/> for the latest information.
 *
 * File version:     1.5
 * File mod date:    1997.11.29 23:10:49
 * System build:     v0.7.2, 97.12.21
 *
 * Purpose:          VM stack interface
 *------------------------------------------------------------------------*/

#include <rscheme/vinsns.h>

#ifndef STACK_CACHE

#ifndef INLINES
#include <rscheme/stack.ci>
#endif


/************************ Continuations ************************/

void push_cont( jump_addr label, unsigned reg_space )
{
obj pc = alloc( SLOT(CONT_FIXED+reg_space), partcont_class );
    
    gvec_write_init( pc, SLOT(0), envt_reg );
    gvec_write_init( pc, SLOT(1), literals_reg );
    gvec_write_init( pc, SLOT(2), dynamic_state_reg );
    gvec_write_init( pc, SLOT(3), continuation_reg );
    gvec_write_init_non_ptr( pc, SLOT(4), JUMP_ADDR_TO_OBJ(label) );
    continuation_reg = pc;
}

/*
    Restores a dynamically-determined number of
    argument-passing registers (ie, for use in the
    extremely rare cases when it cannot be determined
    statically -- nb, this only happens when compiling
    to closure-threaded code and on the occasion of
    interrupts) and the continuation register itself
*/

unsigned restore_arb( void )
{
unsigned n = (SIZEOF_PTR(continuation_reg) / sizeof(obj)) - CONT_FIXED;

    restore_cont( n );
    return n;
}

#endif /* STACK_CACHE */