| 1 | /* |
| 2 | * Copyright (c) 2001, 2002 Michael J. Roberts. All Rights Reserved. |
| 3 | * |
| 4 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 5 | * on using and copying this software. |
| 6 | */ |
| 7 | /* |
| 8 | Name |
| 9 | vmparam.h - T3 Virtual Machine Initialization Parameters |
| 10 | Function |
| 11 | Defines a set of parameters that we use to initialize the VM during |
| 12 | program startup. These parameters are #define'd here if not already |
| 13 | #define'd elsewhere - this allows the system makefile to override |
| 14 | the parameters as desired for larger or smaller local limits. For |
| 15 | example, with a conventional Unix makefile, one could override the |
| 16 | stack size parameter like so: |
| 17 | |
| 18 | make -DVM_STACK_SIZE=4096 -funix/makefile |
| 19 | |
| 20 | Notes |
| 21 | |
| 22 | Modified |
| 23 | 10/07/01 MJRoberts - Creation |
| 24 | */ |
| 25 | |
| 26 | #ifndef VMPARAM_H |
| 27 | #define VMPARAM_H |
| 28 | |
| 29 | /* |
| 30 | * Error stack size. This is the number of bytes allocated per thread for |
| 31 | * our custom exception mechanism (see vmerr.h). err_throw() uses this |
| 32 | * space to store our custom exception structures and their parameters |
| 33 | * |
| 34 | * This limit doesn't affect exception handling for VM byte code, which |
| 35 | * uses the VM stack and VM objects. This parameter only affects our |
| 36 | * internal exception handling mechanism at the C++ level (err_try, |
| 37 | * err_catch, etc). It's unlikely that this will need to be modified for |
| 38 | * porting. |
| 39 | */ |
| 40 | #ifndef VM_ERR_STACK_SIZE |
| 41 | # define VM_ERR_STACK_BYTES 1024 |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | /* |
| 46 | * Name and os_exe_seek resource type of VM error message file. This file |
| 47 | * is optional; if present, it overrides the error message strings linked |
| 48 | * into the VM directly, to allow translated versions of the messages. |
| 49 | * These messages describe run-time exceptions. |
| 50 | */ |
| 51 | #ifndef VM_ERR_MSG_FNAME |
| 52 | # define VM_ERR_MSG_FNAME "T3_VM.msg" |
| 53 | #endif |
| 54 | #ifndef VM_ERR_MSG_RESTYPE |
| 55 | # define VM_ERR_MSG_RESTYPE "XMSG" |
| 56 | #endif |
| 57 | |
| 58 | |
| 59 | /* |
| 60 | * VM stack size, in elements. This is the number of slots allocated for |
| 61 | * the VM stack, which is used to store activation frames and intermediate |
| 62 | * calculation results during byte-code execution. On a typical 32-bit |
| 63 | * machine, each slot takes 8 bytes. |
| 64 | */ |
| 65 | #ifndef VM_STACK_SIZE |
| 66 | # define VM_STACK_SIZE 4096 |
| 67 | #endif |
| 68 | |
| 69 | /* |
| 70 | * VM stack reserve for stack overflow exception handling. This is the |
| 71 | * number of slots we allocate to process a stack overflow exception. This |
| 72 | * gives us a little space to work with in creating the exception object, |
| 73 | * so that the program can recover from the exception. |
| 74 | */ |
| 75 | #ifndef VM_STACK_RESERVE |
| 76 | # define VM_STACK_RESERVE 64 |
| 77 | #endif |
| 78 | |
| 79 | /* |
| 80 | * Debugger VM stack reserve size, in elements. This is the number of |
| 81 | * slots we allocate for emergency use by the debugger in recovering from a |
| 82 | * stack overflow exception. |
| 83 | * |
| 84 | * In debug builds only, this is used in lieu of the normal |
| 85 | * VM_STACK_RESERVE. This is usually a bit larger than the normal reserve, |
| 86 | * to create enough headroom that the user can evaluate expressions and |
| 87 | * otherwise carry on with interactive debugging activities while stopped |
| 88 | * at the point of the overflow. |
| 89 | */ |
| 90 | #ifndef VM_STACK_DBG_RESERVE |
| 91 | # define VM_STACK_DBG_RESERVE 256 |
| 92 | #endif |
| 93 | |
| 94 | |
| 95 | /* |
| 96 | * Undo record limit and savepoint limit. This controls the space |
| 97 | * allocated for the undo mechanism, which allows a snapshot of the |
| 98 | * machine state (called a "snapshot") to be taken such that the exact |
| 99 | * machine state as it was at the snapshot can be restored at a later |
| 100 | * time. Undo information is kept as deltas from the savepoint, so the |
| 101 | * amount of space needed is proportional to the number of changes made |
| 102 | * since the snapshot, and is not related to the total program size. |
| 103 | * |
| 104 | * The record limit specifies the maximum number of individual changes can |
| 105 | * be stored in the undo log. Each time a property, array element, or |
| 106 | * other individual scalar field of some object is changed, an undo record |
| 107 | * is consumed. Empirically, the standard library seems to use around 200 |
| 108 | * records per player turn, but this can vary substantially depending on |
| 109 | * what actions are performed, and a game with many daemons carrying on |
| 110 | * background operations could conceivably use a lot more space per turn. |
| 111 | * |
| 112 | * The savepoint limit specifies the maximum number of savepoints that can |
| 113 | * be created simultaneously. There is a hard upper limit of 255 |
| 114 | * savepoints. |
| 115 | * |
| 116 | * There is no visible error condition generated by exhausting the undo |
| 117 | * space - the undo mechanism simply discards the oldest savepoint or |
| 118 | * savepoints as needed to make room for new records. |
| 119 | * |
| 120 | * The default record limit is meant to allow about ten turns of undo to |
| 121 | * be saved. We choose a much higher savepoint limit because savepoints |
| 122 | * consume almost no space in the undo log, so there is no cost of making |
| 123 | * this limit high enough that the undo record limit is almost certain to |
| 124 | * dominate - in other words, since savepoints cost nothing, there is no |
| 125 | * point in artificially limiting them. |
| 126 | * |
| 127 | * An undo record takes up about 16 bytes (on a machine with 32-bit |
| 128 | * pointers and 32-bit alignment; this will obviously vary for hardware |
| 129 | * with different sizes or alignment requirements). |
| 130 | */ |
| 131 | #ifndef VM_UNDO_MAX_RECORDS |
| 132 | # define VM_UNDO_MAX_RECORDS 65536 |
| 133 | #endif |
| 134 | #ifndef VM_UNDO_MAX_SAVEPTS |
| 135 | # define VM_UNDO_MAX_SAVEPTS 255 |
| 136 | #endif |
| 137 | |
| 138 | #endif /* VMPARAM_H */ |