@samitouri / QOS-React / commits / 40a85432ed

[hir] Move inference logic to Env.reference

Sathya Gunasekaran committed Feb 10, 2023 at 17:26 UTC 40a85432ed87d45ad9b91921bc96cc07286e6acd
1 file changed +4 -12
compiler/forget/src/Inference/InferReferenceEffects.ts
+4 -12
@@ -293,15 +293,13 @@ class Environment {
293 break;
294 }
295 case Effect.Store: {
296 - // TODO(gsn): Uncomment the invariant once
297 - // https://github.com/facebook/react-forget/pull/908#discussion_r1054294337
298 - // is fixed.
296 + // TODO(gsn): This should be bailout once we add bailout infra.
297 //
298 // invariant(
299 // valueKind === ValueKind.Mutable,
300 // `expected valueKind to be 'Mutable' but found to be '${valueKind}'`
301 // );
304 - effect = Effect.Store;
302 + effect = isObjectType(place.identifier) ? Effect.Store : Effect.Mutate;
303 break;
304 }
305 case Effect.Capture: {
@@ -666,11 +664,8 @@ function inferBlock(env: Environment, block: BasicBlock) {
664 continue;
665 }
666 case "PropertyStore": {
669 - const effect = isObjectType(instrValue.object.identifier)
670 - ? Effect.Store
671 - : Effect.Mutate;
667 env.reference(instrValue.value, Effect.Capture);
673 - env.reference(instrValue.object, effect);
668 + env.reference(instrValue.object, Effect.Store);
669
670 const lvalue = instr.lvalue;
671 env.alias(lvalue.place, instrValue.value);
@@ -697,12 +692,9 @@ function inferBlock(env: Environment, block: BasicBlock) {
692 continue;
693 }
694 case "ComputedStore": {
700 - const effect = isObjectType(instrValue.object.identifier)
701 - ? Effect.Store
702 - : Effect.Mutate;
695 env.reference(instrValue.value, Effect.Capture);
696 env.reference(instrValue.property, Effect.Capture);
705 - env.reference(instrValue.object, effect);
697 + env.reference(instrValue.object, Effect.Store);
698
699 const lvalue = instr.lvalue;
700 env.alias(lvalue.place, instrValue.value);