Chromium Code Reviews
DescriptionVM: Fix initialization of statics in presence of exceptions.
In a static- or top-level variable v
var v = expr
static v = expr
If the initializer expression expr throws, the VM throws a
CyclicInitializationError when loading v afterwards, even though
this has nothing to do with cyclic initialization.
I'm changing the way implicit static getters and static initializers are
compiled. Static initializers are invoked from static getters.
They look as follows:
get:v {
if (field.value === transition_sentinel) {
field.value = null;
throw new CyclicInitializationError();
}
if (field.value === sentinel) {
field.value = transition_sentinel;
init:v();
}
return field.value;
}
init:v {
try {
field.value = expr;
} catch {
if (field.value === transition_sentinel) {
field.value = null;
}
rethrow;
}
}
BUG=http://dartbug.com/5802
TEST=language/lazy_static3_test,
language/throwing_lazy_variable_test,
co19/Language/12_Expressions/30_Identifier_Reference_A08_t02
R=hausner@google.com
Committed: https://code.google.com/p/dart/source/detail?r=29797
Patch Set 1 #Patch Set 2 : #
Total comments: 1
Patch Set 3 : rebased #Patch Set 4 : #
Messages
Total messages: 6 (0 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||