什么是依赖触发执行?
What is dependency-triggered execution?
以下是 Doug Lea 的引述,可在 this link:
Even though computation may be parallel by default at the instruction level, in Local mode, the observable results of dependency-triggered execution are always equivalent to those of purely step-wise sequential execution, whether or not any allowed optimizations actually occur. The exact relationships between statement order and execution order that maintain the associated uniprocessor semantics don't matter, and cannot even be detected (except possibly by tools such as debuggers). There are no source-level programmer controls available to alter these relationships.
他所说的“依赖触发执行”是什么意思?
一些可能有帮助的上下文:
Plain mode applies to syntactic accesses of plain (non-volatile) object fields (as in int v = aPoint.x
), as well as statics and array elements. It also applies to default VarHandle
get
and set
access. Even though it behaves in the same way as always, its properties interact with new VarHandle
modes and operations in ways best explained in terms of a quick review of relevant aspects of processor and compiler design.
Plain mode extends the otherwise unnamed "Local" mode in which all accesses are to method-local arguments and variables; for example, the code for pure expressions and functions. Plain mode maintains local precedence order for accesses, which need not match source code statement order or machine instruction order, and is not in general even a total (sequential) order.
我将尝试回答,但这是我的看法。 IMO,你得反驳几句:
...the observable results of dependency-triggered execution.
在我看来,依赖触发执行是代码中的指令如何在它们之间具有“依赖性”。例如:
int xx = ...;
int yy = ...;
int getSum(){
int x = xx;
int y = yy;
return x + y;
}
优化器是否这样做并不重要:
int y = yy;
int x = xx;
return y + x;
即:它重新排序指令,甚至可能并行执行它们:
Even though computation may be parallel by default at the instruction level...
必须始终是:
... in Local mode, the observable results of dependency-triggered execution are always equivalent to those of purely step-wise sequential execution.
无论你观察到 来自 getSum
的内容总是 x + y
,无论它是如何优化的(例如 SSA 形式)甚至例如,如果整个方法主体在处理器级别并行执行。
可以找到包含一些依赖触发执行的更好示例here;我试图证明即使某些代码彼此之间存在依赖关系,只要根据 JMM
有效,优化器就可以自由地重新排序指令
以下是 Doug Lea 的引述,可在 this link:
Even though computation may be parallel by default at the instruction level, in Local mode, the observable results of dependency-triggered execution are always equivalent to those of purely step-wise sequential execution, whether or not any allowed optimizations actually occur. The exact relationships between statement order and execution order that maintain the associated uniprocessor semantics don't matter, and cannot even be detected (except possibly by tools such as debuggers). There are no source-level programmer controls available to alter these relationships.
他所说的“依赖触发执行”是什么意思?
一些可能有帮助的上下文:
Plain mode applies to syntactic accesses of plain (non-volatile) object fields (as in
int v = aPoint.x
), as well as statics and array elements. It also applies to defaultVarHandle
get
andset
access. Even though it behaves in the same way as always, its properties interact with newVarHandle
modes and operations in ways best explained in terms of a quick review of relevant aspects of processor and compiler design.
Plain mode extends the otherwise unnamed "Local" mode in which all accesses are to method-local arguments and variables; for example, the code for pure expressions and functions. Plain mode maintains local precedence order for accesses, which need not match source code statement order or machine instruction order, and is not in general even a total (sequential) order.
我将尝试回答,但这是我的看法。 IMO,你得反驳几句:
...the observable results of dependency-triggered execution.
在我看来,依赖触发执行是代码中的指令如何在它们之间具有“依赖性”。例如:
int xx = ...;
int yy = ...;
int getSum(){
int x = xx;
int y = yy;
return x + y;
}
优化器是否这样做并不重要:
int y = yy;
int x = xx;
return y + x;
即:它重新排序指令,甚至可能并行执行它们:
Even though computation may be parallel by default at the instruction level...
必须始终是:
... in Local mode, the observable results of dependency-triggered execution are always equivalent to those of purely step-wise sequential execution.
无论你观察到 来自 getSum
的内容总是 x + y
,无论它是如何优化的(例如 SSA 形式)甚至例如,如果整个方法主体在处理器级别并行执行。
可以找到包含一些依赖触发执行的更好示例here;我试图证明即使某些代码彼此之间存在依赖关系,只要根据 JMM