Skip to content

Commit 6ff0b84

Browse files
committed
docs: centralised documentation todos
1 parent 5826ae9 commit 6ff0b84

12 files changed

Lines changed: 52 additions & 36 deletions

File tree

‎docs-old/output-api.md‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,3 @@ PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
130130
PHP_OUTPUT_HANDLER_HOOK_DISABLE
131131
the second arg is ignored; marks the output handler as disabled
132132
```
133-
134-
## Open questions
135-
136-
- Should the userland API be adjusted and unified?
137-
138-
Many bits of the manual (and very first implementation) do not comply with the
139-
behaviour of the current (to be obsoleted) code, thus should the manual or the
140-
behaviour be adjusted?

‎docs/source/conf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'sphinx_design',
2020
'sphinx.ext.autosectionlabel',
2121
]
22+
exclude_patterns = ['**/*TODO.md']
2223
myst_enable_extensions = [
2324
'alert',
2425
'gfm_autolink',

‎docs/source/core/TODO.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Core TODO
2+
3+
Pages to add:
4+
5+
- Parser and AST: grammar generation, AST representation, compilation boundaries,
6+
and important extension points.
7+
- Virtual Machine: opcode execution, operands, call frames, and VM variants.
8+
- Object Handlers: handler contracts, object storage, and common ownership traps.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Data Structures TODO
2+
3+
- Add a HashTable page covering ownership, iteration, mutation, and common APIs.
4+
- Expand the zval macro table and document the remaining internal zval types.

‎docs/source/core/data-structures/reference-counting.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ they reference each other. This is called a reference cycle.
144144
PHP implements a cycle collector that detects such cycles and frees values that are only reachable
145145
through their own references. The cycle collector will record values that may be involved in a
146146
cycle, and run when this buffer becomes full. It is also possible to invoke it explicitly by calling
147-
the `gc_collect_cycles()` function. The cycle collectors design is described in the <a
148-
href="todo">Cycle collector</a> chapter.
147+
the `gc_collect_cycles()` function.
149148

150149
## GC flags
151150

@@ -171,8 +170,7 @@ again.
171170
172171
The `GC_PERSISTENT` flag indicates that the value was allocated using `malloc`, instead of PHPs
173172
own allocator. Usually, such values are alive for the entire lifetime of the process, instead of
174-
being freed at the end of the request. See the <a href="todo">Zend allocator</a> chapter for more
175-
information.
173+
being freed at the end of the request.
176174
177175
The `GC_PERSISTENT_LOCAL` flag indicates that a `GC_PERSISTENT` value is only accessible in one
178176
thread, and is thus still safe to modify. This flag is only used in debug builds to satisfy an

‎docs/source/core/data-structures/zend_string.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct _zend_string {
2121
};
2222
```
2323

24-
The `gc` field is used for {doc}`./reference-counting`. The `h` field contains a hash value,
25-
which is used for <a href="todo">hash table</a> lookups. The `len` field stores the length of the string
26-
in bytes, and the `val` field contains the actual string data.
24+
The `gc` field is used for {doc}`./reference-counting`. The `h` field contains a hash value, which is
25+
used for hash table lookups. The `len` field stores the length of the string in bytes, and the `val`
26+
field contains the actual string data.
2727

2828
You may wonder why the `val` field is declared as `char val[1]`. This is called the [struct
2929
hack](https://www.geeksforgeeks.org/struct-hack/) in C. It is used to create structs with a flexible size, namely by allowing the last element
@@ -45,7 +45,7 @@ zend_string_release(string);
4545
`ZSTR_INIT_LITERAL` creates a `zend_string` from a string literal. It is just a wrapper around
4646
`zend_string_init(char *string, size_t length, bool persistent)` that provides the length of the
4747
string at compile time. The `persistent` parameter indicates whether the string is allocated using
48-
`malloc` (`persistent == true`) or `emalloc`, <a href="todo">PHPs custom allocator</a> (`persistent == false`) that is emptied after each request.
48+
`malloc` (`persistent == true`) or `emalloc`, PHP's custom allocator (`persistent == false`) that is emptied after each request.
4949
5050
When you're done using the string, you must call `zend_string_release`, or the memory will leak.
5151
`zend_string_release` will automatically call `malloc` or `emalloc`, depending on how the
@@ -104,8 +104,8 @@ use.
104104
Programs use some strings many times. For example, if your program declares a class called
105105
`MyClass`, it would be wasteful to allocate a new string `"MyClass"` every time it is referenced
106106
within your program. Instead, when repeated strings are expected, php-src uses a technique called
107-
string interning. Essentially, this is just a simple <a href="todo">HashTable</a> where existing interned
108-
strings are stored. When creating a new interned string, php-src first checks the interned string
107+
string interning. Essentially, this is just a simple `HashTable` where existing interned strings are
108+
stored. When creating a new interned string, php-src first checks the interned string
109109
buffer. If it finds it there, it can return a pointer to the existing string. If it doesn't, it
110110
allocates a new string and adds it to the buffer.
111111

‎docs/source/core/data-structures/zval.md‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ member, but never both at the same time. However, it doesn't know which member i
6262
Remembering this is our job, and that's exactly what the `IS_*` constants are for.
6363

6464
The top members of `zend_value` mostly mirror the `IS_*` constants, with the exception of
65-
`counted`. `counted` polymorphically refers to any <a href="todo">reference counted</a> value, including
66-
strings, arrays, objects, resources and references. `null` and `bool` are missing from
65+
`counted`. `counted` polymorphically refers to any [reference-counted](reference-counting.md) value,
66+
including strings, arrays, objects, resources and references. `null` and `bool` are missing from
6767
`zend_value` because their types are self-contained.
6868

6969
The rest of the fields aren't important for now.
@@ -108,8 +108,8 @@ struct _zval_struct {
108108

109109
`zval.u1` stores the variable type, the given `IS_*` constant, along with some other flags. It's
110110
definition looks a bit complicated. You can think of the entire field as a 4 byte integer, split
111-
into 3 parts. `v.type` stores the actual variable type, `v.type_flags` is used for some <a
112-
href="todo">reference counting</a> flags, and `v.u.extra` is pretty much unused.
111+
into 3 parts. `v.type` stores the actual variable type, `v.type_flags` is used for some
112+
[reference-counting](reference-counting.md) flags, and `v.u.extra` is pretty much unused.
113113

114114
`zval.u2` defines some more storage for various contexts that is often unoccupied. It's there
115115
because the memory would otherwise be wasted due to padding, so we may as well make use of it. We'll
@@ -135,8 +135,6 @@ there's a `_P`-suffixed variant that performs the same operation on a pointer to
135135
| `ZVAL_COPY_VALUE(t, s)` | Copy one `zval` to another, including type and value. |
136136
| `ZVAL_COPY(t, s)` | Same as `ZVAL_COPY_VALUE`, but if the value is reference counted, increase the counter. |
137137

138-
<!-- _todo: There are many more. -->
139-
140138
## Other zval types
141139

142140
`zval`s are sometimes used internally with types that don't exist in userland.
@@ -153,16 +151,14 @@ there's a `_P`-suffixed variant that performs the same operation on a pointer to
153151
property/parameter initializers, etc.) before they are evaluated. The evaluation of a constant
154152
expression is not always possible during compilation, because they may contain references to values
155153
only available at runtime. Until that evaluation is possible, the constants contain the AST of the
156-
expression rather than the concrete values. Check the <a href="todo">parser</a> chapter for more information
157-
on ASTs. When this flag is set, the `zval.value.ast` union member is set accordingly.
154+
expression rather than the concrete values. When this flag is set, the `zval.value.ast` union member
155+
is set accordingly.
158156
159157
`IS_INDIRECT` indicates that the `zval.value.zv` member is populated. This field stores a
160158
pointer to some other `zval`. This type is mainly used in two situations, namely for intermediate
161159
values between `FETCH` and `ASSIGN` instructions, and for the sharing of variables in the symbol
162160
table.
163161
164-
<!-- _todo: There are many more. -->
165-
166162
`IS_PTR` is used for pointers to arbitrary data. Most commonly, this type is used internally for
167163
`HashTable`, as `HashTable` may only store `zval` values. For example, `EG(class_table)`
168164
represents the class table, which is a hash map of class names to the corresponding
@@ -173,8 +169,7 @@ Otherwise, it is essentially the same as `IS_PTR`. Arbitrary data is accessed th
173169
`zval.value.ptr`, and casted to the correct type depending on context. If `ptr` stores a class
174170
or function, the `zval.value.ce` or `zval.value.func` fields may be used, respectively.
175171
176-
`_IS_ERROR` is used as an error value for some <a href="todo">object handlers</a>. It is described in more
177-
detail in its own chapter.
172+
`_IS_ERROR` is used as an error value for some object handlers.
178173
179174
```c
180175
/* Fake types used only for type hinting.
@@ -192,7 +187,7 @@ detail in its own chapter.
192187
```
193188

194189
These flags are never actually stored in `zval.u1`. They are used for type hinting and in the
195-
<a href="todo">object handler</a> API.
190+
object handler API.
196191

197192
This only leaves the `zval.value.ww` field. In short, this field is used on 32-bit platforms when
198193
copying data from one `zval` to another. Normally, `zval.value.counted` is copied as a generic
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Memory Management TODO
2+
3+
The Reference Counting page contained TODOs for dedicated Cycle Collector and
4+
Zend Allocator pages; grouping them under Memory Management makes sense. Pages
5+
to be added:
6+
7+
- Cycle Collector:
8+
candidate buffering, collection phases, collectable types, and correct use of
9+
GC flags and macros.
10+
- Zend Allocator:
11+
allocator pairing, overflow-safe allocation, request/persistent lifetimes, and
12+
relevant arena cleanup.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Open Questions
2+
3+
- Should the userland API be adjusted and unified?
4+
5+
Many bits of the manual (and very first implementation) do not comply with the
6+
behaviour of the current (to be obsoleted) code, thus should the manual or the
7+
behaviour be adjusted?

‎docs/source/introduction/high-level-overview.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ Like with tokenization, we use a tool called `Bison` to generate the parser impl
9696
grammar specification. The grammar lives in the `Zend/zend_language_parser.y` file. Check the
9797
[Bison documentation](https://www.gnu.org/software/bison/manual/) for details. Luckily, the syntax is quite approachable.
9898

99-
Parsing is described in more detail in its <a href="todo">dedicated chapter</a>.
100-
10199
## Compilation
102100

103101
Computers don't understand human language, or even programming languages. They only understand
@@ -149,7 +147,7 @@ With these simple rules, we can see that the interpreter will `echo` only when `
149147
truthy, and skip over the `echo` otherwise.
150148

151149
That's it! This is how PHP works, fundamentally. Of course, we skipped over a ton of details. The VM
152-
is quite complex, and will be discussed separately in the <a href="todo">virtual machine</a> chapter.
150+
is quite complex.
153151

154152
## Opcache
155153

0 commit comments

Comments
 (0)