CoreCLR中超过3万行代码的gc.cpp文件的来源

时间:2022-01-03 15:54:52

在CoreCLR的开源代码中,GC的主要实现代码gc.cpp文件大小竟然有1.17MB,打开文件一看,竟然有35490行!第一次见到如此多行的单个代码文件。

CoreCLR中超过3万行代码的gc.cpp文件的来源

github都不让直接查看:https://github.com/dotnet/coreclr/blob/master/src/gc/gc.cpp

CoreCLR中超过3万行代码的gc.cpp文件的来源

为什么会有这么大的代码文件?微软的哪位大神在这样的代码海洋中游弋?不禁让人产生好奇。

在 Hacker News 的回复中发现了线索(CoreCLR is now open source):

> I guess it's no surprise that microsoft software has a human-edited source file that's over 35000 lines...

IIRC, it was originally machine-generated... from LISP code written by David Bacon, under contract from the then-GC owner Patrick Dussud.

也许是从LISP代码生成的C++代码。

接下来的回复中提供了一篇博客的链接:

http://blogs.msdn.com/b/patrick_dussud/archive/2006/11/21/how-it-all-started-aka-the-birth-of-the-clr.aspx

(How It All Started…AKA the Birth of the CLR)

文中的一段文字证实了这一点:

I designed the architecture of the runtime and wrote the Garbage Collector (and yes the GC prototype was was written in Common Lisp first and I wrote a translator to convert it to C++).

果然开始是用Lisp写的,然后转换为了C++代码。

而博文的作者Patrick Dussud就是他写了转换程序将Lisp代码转换为C++代码。