Skip to content

Commit d0223e7

Browse files
committed
Add HACKING.md.
1 parent b60f3e9 commit d0223e7

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

HACKING.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
I accept small patches, but because this is my hobby project to
2+
learn about compilers, it's unlikely to accept large patches.
3+
That's in practice not going to be an issue, because
4+
if you are writing a large patch, that is your hobby project.
5+
You want to hack in your forked repository rather than
6+
taking time to send pull requests.
7+
8+
# Memory management
9+
10+
No memory management is a memory management scheme in 8cc.
11+
Memory regions allocated using malloc are never freed
12+
until the process terminates. That has greatly simplified
13+
the code and the APIs because 1) you can write code as if
14+
garbage collector were present, and 2) that design
15+
decision has eliminated use-after-free bugs entirely.
16+
17+
Modern computers have gigs of memory. 8cc consumes
18+
only about 100MB to compile 10K lines of C source file.
19+
Compiler is not a long-running process.
20+
It will never run out of memory unless you give an
21+
unrealistically large source file.
22+
23+
If we really need to free memory, we could use Boehm garbage
24+
collector. I don't see that need at this moment though.
25+
26+
# Backend
27+
28+
Backend is being rewritten. Once it's done, the current backend
29+
code will be discarded. The new backend models after the LLVM IR
30+
because the IR looks to be designed well. That's not going to be
31+
the same, though.

vector.c

-19
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,6 @@
33

44
/*
55
* Vectors are containers of void pointers that can change in size.
6-
*
7-
* Note on memory management:
8-
*
9-
* No memory management is a memory management scheme in 8cc.
10-
* Memory regions allocated using malloc are never freed
11-
* until the process terminates. That has greatly simplified
12-
* the code and the API because 1) when you want to write
13-
* a function returning a new heap-allocated value, you can
14-
* just malloc a new value and return that, and 2) that design
15-
* decision has eliminated use-after-free bugs entirely.
16-
*
17-
* Modern computers have gigs of memory. 8cc consumes
18-
* only about 100MB to compile 10K lines of C source file.
19-
* Compiler is not a long-running process.
20-
* It will never run out of memory unless you give an
21-
* unrealistically large source file.
22-
*
23-
* If we really need to free memory, we could use Boehm garbage
24-
* collector. I don't see that need at this moment though.
256
*/
267

278
#include <assert.h>

0 commit comments

Comments
 (0)