@@ -372,11 +372,10 @@ inline bool canEmitSelectWithArms(Expression* ifTrue, Expression* ifFalse) {
372
372
return ifTrue->type .isSingle () && ifFalse->type .isSingle ();
373
373
}
374
374
375
- // An intrinsically-nondeterministic expression is one that can return different
376
- // results for the same inputs, and that difference is *not* explained by
377
- // other expressions that interact with this one. Hence the cause of
378
- // nondeterminism can be said to be "intrinsic" - it is internal and inherent in
379
- // the expression.
375
+ // A "generative" expression is one that can generate different results for the
376
+ // same inputs, and that difference is *not* explained by other expressions that
377
+ // interact with this one. This is an intrinsic/internal property of the
378
+ // expression.
380
379
//
381
380
// To see the issue more concretely, consider these:
382
381
//
@@ -396,26 +395,26 @@ inline bool canEmitSelectWithArms(Expression* ifTrue, Expression* ifFalse) {
396
395
// allocations, though, it doesn't matter what is in "..": there is nothing
397
396
// in the wasm that we can check to find out if the results are the same or
398
397
// not. (In fact, in this case they are always not the same.) So the
399
- // nondeterminism is "intrinsic."
398
+ // generativity is "intrinsic" to the expression and it is because each call to
399
+ // struct.new generates a new value.
400
400
//
401
- // Thus, loads are nondeterministic but not intrinsically so, while GC
402
- // allocations are actual examples of intrinsically nondeterministic
403
- // instructions. If wasm were to add "get current time" or "get a random number"
404
- // instructions then those would also be intrinsically nondeterministic.
401
+ // Thus, loads are nondeterministic but not generative, while GC allocations
402
+ // are in fact generative. Note that "generative" need not mean "allocation" as
403
+ // if wasm were to add "get current time" or "get a random number" instructions
404
+ // then those would also be generative - generating a new current time value or
405
+ // a new random number on each execution, respectively.
405
406
//
406
- // * Note that NaN nondeterminism is ignored here. Technically that allows e.g.
407
- // an f32.add to be nondeterministic, but it is a valid wasm implementation
408
- // to have deterministic NaN behavior, and we optimize under that assumption.
409
- // So NaN nondeterminism does not cause anything to be intrinsically
410
- // nondeterministic.
407
+ // * Note that NaN nondeterminism is ignored here. It is a valid wasm
408
+ // implementation to have deterministic NaN behavior, and we optimize under
409
+ // that simplifying assumption.
411
410
// * Note that calls are ignored here. In theory this concept could be defined
412
- // either way for them ( that is, we could potentially define them as either
413
- // intrinsically nondeterministic, or not, and each could make sense in its
414
- // own way). It is simpler to ignore them here, which means we only consider
415
- // the behavior of the expression provided here (including its chldren), and
416
- // not external code .
411
+ // either way for them - that is, we could potentially define them as
412
+ // generative, as they might contain such an instruction, or we could define
413
+ // this property as only looking at code in the current function. We choose
414
+ // the latter because calls are already handled best in other manners (using
415
+ // EffectAnalyzer) .
417
416
//
418
- bool isIntrinsicallyNondeterministic (Expression* curr, FeatureSet features);
417
+ bool isGenerative (Expression* curr, FeatureSet features);
419
418
420
419
} // namespace Properties
421
420
0 commit comments