Martin Odersky 的演讲中 Scala 编译器的早期实现中的可重入性和静态数据。它们有什么关系?

Reentrancy and static data in an early implementation of the Scala compiler in Martin Odersky's talk. How are they related?

在 Martin Odersky 的演讲中:http://youtu.be/9PkxE_L_LMo,在第 49 分钟,他谈到了一个 "the compiler is not re-entrant" 由于静态数据引起的问题。

我基本了解 "reentrancy" 在 Java 中的含义(for example,如果我递归调用同步方法,那么我不会陷入死锁) , 但我还是不明白马丁在说什么。

如果第 49 分钟的代码是这样写的,为什么不能在同一个 JVM 中运行两个编译器?

他说的重入是什么样的?

我假设当他在演讲的第 49 分钟提到可重入时,他并不是指允许在 Java 中使用递归同步方法调用而不会陷入死锁的那种可重入。我对吗?我不知道。

他是否只是指当 on 具有从多个线程访问的可变静态数据时,程序将由于竞争条件而无法正常工作?

请赐教!

What kind of reentrancy is he talking about?

他说的是关于可重入者的一个计算机科学定义。除了 wikipedia article, this IBM developerWorks article 明确指出:

A reentrant function is one that can be used by more than one task concurrently without fear of data corruption. Conversely, a non-reentrant function is one that cannot be shared by more than one task unless mutual exclusion to the function is ensured either by using a semaphore or by disabling interrupts during critical sections of code. A reentrant function can be interrupted at any time and resumed at a later time without loss of data. Reentrant functions either use local variables or protect their data when global variables are used.

由于静态变量是全局变量的面向对象版本,Odersky 谈论的是不保护其全局变量的编译器。

Is he simply refering to the fact that when on [sic] has mutable static data accessed from several threads then the program will work incorrectly due to race conditions?

基本上,是的。编译器在并发调用时可能无法正常运行,因为它会混合有关多个程序的信息,从而可能导致损坏。