]> gitweb.factorcode.org Git - factor.git/blob - core/layouts/layouts-docs.factor
d330f52519e3fa362232ca62f5015414903002ee
[factor.git] / core / layouts / layouts-docs.factor
1 USING: generic help.markup help.syntax kernel math
2 memory namespaces sequences kernel.private classes
3 classes.builtin sequences.private ;
4 IN: layouts
5
6 HELP: tag-bits
7 { $var-description "Number of least significant bits reserved for a type tag in a tagged pointer." }
8 { $see-also tag } ;
9
10 HELP: tag-mask
11 { $var-description "Taking the bitwise and of a tagged pointer with this mask leaves the tag." } ;
12
13 HELP: num-types
14 { $var-description "Number of distinct built-in types. This is one more than the maximum value from the " { $link tag } " primitive." } ;
15
16 HELP: type-number
17 { $values { "class" class } { "n" "an integer or " { $link f } } }
18 { $description "Outputs the built-in type number instances of " { $link class } ". Will output " { $link f } " if this is not a built-in class." }
19 { $see-also builtin-class } ;
20
21 HELP: tag-fixnum
22 { $values { "n" integer } { "tagged" integer } }
23 { $description "Outputs a tagged fixnum." } ;
24
25 HELP: fixnum-bits
26 { $values { "n" "number of bits in a fixnum" } } ;
27
28 HELP: first-bignum
29 { $values { "n" "smallest positive integer not representable by a fixnum" } } ;
30
31 HELP: most-positive-fixnum
32 { $values { "n" "largest positive integer representable by a fixnum" } } ;
33
34 HELP: most-negative-fixnum
35 { $values { "n" "smallest negative integer representable by a fixnum" } } ;
36
37 HELP: bootstrap-first-bignum
38 { $values { "n" "smallest positive integer not representable by a fixnum" } }
39 { $description "Outputs the value for the target architecture when bootstrapping." } ;
40
41 HELP: bootstrap-most-positive-fixnum
42 { $values { "n" "largest positive integer representable by a fixnum" } }
43 { $description "Outputs the value for the target architecture when bootstrapping." } ;
44
45 HELP: bootstrap-most-negative-fixnum
46 { $values { "n" "smallest negative integer representable by a fixnum" } }
47 { $description "Outputs the value for the target architecture when bootstrapping." } ;
48
49 HELP: cell
50 { $values { "n" "a positive integer" } }
51 { $description "Outputs the pointer size in bytes of the current CPU architecture." } ;
52
53 HELP: cells
54 { $values { "m" integer } { "n" integer } }
55 { $description "Computes the number of bytes used by " { $snippet "m" } " CPU operand-sized cells." } ;
56
57 HELP: cell-bits
58 { $values { "n" integer } }
59 { $description "Outputs the number of bits in one CPU operand-sized cell." } ;
60
61 HELP: bootstrap-cell
62 { $values { "n" "a positive integer" } }
63 { $description "Outputs the pointer size in bytes for the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
64
65 HELP: bootstrap-cells
66 { $values { "m" integer } { "n" integer } }
67 { $description "Computes the number of bytes used by " { $snippet "m" } " cells in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
68
69 HELP: bootstrap-cell-bits
70 { $values { "n" integer } }
71 { $description "Outputs the number of bits in one cell in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
72
73 HELP: immediate
74 { $class-description "Union class of all values that the Factor VM can store immediately, all others are stored as references (pointer) to them." } ;
75
76 ARTICLE: "layouts-types" "Type numbers"
77 "Corresponding to every built-in class is a built-in type number. An object can be asked for its built-in type number:"
78 { $subsections tag }
79 "Built-in type numbers can be converted to classes, and vice versa:"
80 { $subsections
81     type>class
82     type-number
83     num-types
84 }
85 { $see-also "builtin-classes" } ;
86
87 ARTICLE: "layouts-tags" "Tagged pointers"
88 "Every pointer stored on the stack or in the heap has a " { $emphasis "tag" } ", which is a small integer identifying the type of the pointer. If the tag is not equal to one of the two special tags, the remaining bits contain the memory address of a heap-allocated object. The two special tags are the " { $link fixnum } " tag and the " { $link f } " tag."
89 $nl
90 "Words for working with tagged pointers:"
91 { $subsections
92     tag-bits
93     tag-mask
94 }
95 "The Factor VM does not actually expose any words for working with tagged pointers directly. The above words operate on integers; they are used in the bootstrap image generator and the optimizing compiler." ;
96
97 ARTICLE: "layouts-limits" "Sizes and limits"
98 "Processor cell size:"
99 { $subsections
100     cell
101     cells
102     cell-bits
103 }
104 "Range of integers representable by " { $link fixnum } "s:"
105 { $subsections
106     most-negative-fixnum
107     most-positive-fixnum
108 }
109 "Maximum array size:"
110 { $subsections max-array-capacity } ;
111
112 ARTICLE: "layouts-bootstrap" "Bootstrap support"
113 "Processor cell size for the target architecture:"
114 { $subsections
115     bootstrap-cell
116     bootstrap-cells
117     bootstrap-cell-bits
118 }
119 "Range of integers representable by " { $link fixnum } "s of the target architecture:"
120 { $subsections
121     bootstrap-most-negative-fixnum
122     bootstrap-most-positive-fixnum
123 }
124 "Maximum array size for the target architecture:"
125 { $subsections bootstrap-max-array-capacity } ;
126
127 ARTICLE: "layouts" "VM memory layouts"
128 "The words documented in this section do not ever need to be called by user code. They are documented for the benefit of those wishing to explore the internals of Factor's implementation."
129 { $subsections
130     "layouts-types"
131     "layouts-tags"
132     "layouts-limits"
133     "layouts-bootstrap"
134 } ;
135
136 ABOUT: "layouts"