/* Copyright (C) 2009 Clozure Associates */ /* Copyright (C) 1994-2001 Digitool, Inc */ /* This file is part of Clozure CL. */ /* Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */ /* License , known as the LLGPL and distributed with Clozure CL as the */ /* file "LICENSE". The LLGPL consists of a preamble and the LGPL, */ /* which is distributed with Clozure CL as the file "LGPL". Where these */ /* conflict, the preamble takes precedence. */ /* Clozure CL is referenced in the preamble as the "LIBRARY." */ /* The LLGPL is also available online at */ /* http://opensource.franz.com/preamble.html */ nbits_in_word = 32 nbits_in_byte = 8 ntagbits = 3 /* But only 2 are significant to lisp */ nlisptagbits = 2 nfixnumtagbits = 2 num_subtag_bits = 8 fixnumshift = 2 fixnum_shift = 2 fulltagmask = 7 tagmask = 3 fixnummask = 3 subtag_mask = 0xff ncharcodebits = 24 /* arguably, we're only using the low 8 */ charcode_shift = nbits_in_word-ncharcodebits word_shift = 2 node_size = 4 dnode_size = 8 dnode_align_bits = 3 dnode_shift = dnode_align_bits bitmap_shift = 5 fixnumone = (1< 4 (so that code-vector entry-points can be branched to, since the low */ /* two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */ /* that share the same TAG. */ /* Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */ /* object that they see. */ fulltag_even_fixnum = 0 /* I suppose EVENP/ODDP might care; nothing else does. */ fulltag_nil = 1 /* NIL and nothing but. (Note that there's still a hidden NILSYM.) */ fulltag_nodeheader = 2 /* Header of heap_allocated object that contains lisp_object pointers */ fulltag_imm = 3 /* a "real" immediate object. Shares TAG with fulltag_immheader. */ fulltag_odd_fixnum = 4 /* */ fulltag_cons = 5 /* a real (non_null) cons. Shares TAG with fulltag_nil. */ fulltag_misc = 6 /* Pointer "real" tag_misc object. Shares TAG with fulltag_nodeheader. */ fulltag_immheader = 7 /* Header of heap-allocated object that contains unboxed data. */ nil_value = (0x04000000+fulltag_nil) misc_bias = fulltag_misc cons_bias = fulltag_cons unsigned_byte_24_mask = 0xe0000003 /* bits that should be clear in a boxed */ /* (UNSIGNED-BYTE 24) */ /* Functions are of (conceptually) unlimited size. */ _struct(_function,-misc_bias) _node(header) _node(entrypoint) /* codevector & ~tagmask */ _node(codevector) _ends _struct(tsp_frame,0) _node(backlink) _node(type) _struct_label(fixed_overhead) _struct_label(data_offset) _ends /* Order of CAR and CDR doesn't seem to matter much - there aren't */ /* too many tricks to be played with predecrement/preincrement addressing. */ /* Keep them in the confusing MCL 3.0 order, to avoid confusion. */ _struct(cons,-cons_bias) _node(cdr) _node(car) _ends misc_header_offset = -fulltag_misc misc_subtag_offset = misc_header_offset /* low byte of header */ misc_data_offset = misc_header_offset+4 /* first word of data */ misc_dfloat_offset = misc_header_offset+8 /* double-floats are doubleword-aligned */ max_64_bit_constant_index = ((0x0fff + misc_dfloat_offset)>>3) max_32_bit_constant_index = ((0x0fff + misc_data_offset)>>2) max_16_bit_constant_index = ((0x0fff + misc_data_offset)>>1) max_8_bit_constant_index = (0x0fff + misc_data_offset) max_1_bit_constant_index = ((0x0fff + misc_data_offset)<<5) /* T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */ /* two doublewords. The arithmetic difference between T and NIL is */ /* such that the least-significant bit and exactly one other bit is */ /* set in the result. */ t_offset = ((dnode_size-fulltag_nil)+fulltag_misc) t_value = nil_value+t_offset /* The order in which various header values are defined is significant in several ways: */ /* 1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */ /* 2) All subtags which denote CL arrays are preceded by those that don't, */ /* with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */ /* 3) The element-size of ivectors is determined by the ordering of ivector subtags. */ /* 4) All subtags are >= fulltag-immheader . */ define(`define_subtag',` subtag_$1 = $2|($3< than */ /* all non-CL-array subtags. So we start by defining the immediate subtags in decreasing order, starting */ /* with that subtag whose element size isn't an integral number of bits and ending with those whose */ /* element size - like all non-CL-array fulltag-immheader types - is 32 bits. */ define_imm_subtag(bit_vector,31) define_imm_subtag(double_float_vector,30) define_imm_subtag(s16_vector,29) define_imm_subtag(u16_vector,28) min_16_bit_ivector_subtag = subtag_u16_vector max_16_bit_ivector_subtag = subtag_s16_vector define_imm_subtag(s8_vector,26) define_imm_subtag(u8_vector,25) min_8_bit_ivector_subtag = subtag_u8_vector max_8_bit_ivector_subtag = fulltag_immheader|(27< max-numeric-subtag) & (n < min-array-subtag)) */ /* for various immediate/node object types. */ define_imm_subtag(macptr,3) define_imm_subtag(dead_macptr,4) define_imm_subtag(code_vector,5) define_imm_subtag(creole,6) max_non_array_imm_subtag = (18< -> unwind-protect, else catch */ _node(db_link) /* head of special-binding chain */ _node(xframe) /* exception frame chain */ _node(last_lisp_frame) /* from TCR */ _node(code_vector) /* of fn in lisp_frame, or 0 */ _endstructf _structf(macptr) _node(address) _node(domain) _node(type) _endstructf _structf(vectorH) _node(logsize) _node(physsize) _node(data_vector) _node(displacement) _node(flags) _endstructf _structf(arrayH) _node(rank) _node(physsize) _node(data_vector) _node(displacement) _node(flags) _struct_label(dim0) _endstructf _struct(lisp_frame,0) _node(marker) _node(savevsp) _node(savefn) _node(savelr) _ends _struct(vector,-fulltag_misc) _node(header) _struct_label(data) _ends _struct(binding,0) _node(link) _node(sym) _node(val) _ends /* Indices in %builtin-functions% */ _builtin_plus = 0 /* +-2 */ _builtin_minus = 1 /* --2 */ _builtin_times = 2 /* *-2 */ _builtin_div = 3 /* /-2 */ _builtin_eq = 4 /* =-2 */ _builtin_ne = 5 /* /-2 */ _builtin_gt = 6 /* >-2 */ _builtin_ge = 7 /* >=-2 */ _builtin_lt = 8 /* <-2 */ _builtin_le = 9 /* <=-2 */ _builtin_eql = 10 /* eql */ _builtin_length = 11 /* length */ _builtin_seqtype = 12 /* sequence-type */ _builtin_assq = 13 /* assq */ _builtin_memq = 14 /* memq */ _builtin_logbitp = 15 /* logbitp */ _builtin_logior = 16 /* logior-2 */ _builtin_logand = 17 /* logand-2 */ _builtin_ash = 18 /* ash */ _builtin_negate = 19 /* %negate */ _builtin_logxor = 20 /* logxor-2 */ _builtin_aref1 = 21 /* %aref1 */ _builtin_aset1 = 22 /* %aset1 */ nrs_origin = (dnode_size-fulltag_nil) nrs_symbol_fulltag = fulltag_misc lisp_globals_limit = -fulltag_nil include(lisp_globals.s) define(`def_header',` $1 = ($2<