mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Update base for Update on "[compiler] Fix for PropertyStore object effect"
Fix for the issue in the previous PR. Long-term the ideal thing would be to make InferMutableRanges smarter about Store effects, and recognize that they are also transitive mutations of whatever was captured into the object. So in the following:
```
const x = {y: {z: {}}};
x.y.z.key = value;
```
That the `PropertyStore z . 'key' = value` is a transitive mutation of x and all three object expressions (x, x.y, x.y.z).
But for now it's simpler to stick to the original idea of Store only counting if we know that the type is an object.
[ghstack-poisoned]
This commit is contained in:
@@ -731,7 +731,7 @@ function isMutable(range: MutableRange): boolean {
|
||||
}
|
||||
|
||||
const DEBUG_MUTABLE_RANGES = false;
|
||||
function printMutableRange(identifier: Identifier): string {
|
||||
export function printMutableRange(identifier: Identifier): string {
|
||||
if (DEBUG_MUTABLE_RANGES) {
|
||||
// if debugging, print both the identifier and scope range if they differ
|
||||
const range = identifier.mutableRange;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import prettyFormat from 'pretty-format';
|
||||
import {HIRFunction, Identifier} from '../HIR/HIR';
|
||||
import DisjointSet from '../Utils/DisjointSet';
|
||||
import {inferAliasForUncalledFunctions} from './InerAliasForUncalledFunctions';
|
||||
@@ -16,6 +17,7 @@ import {inferMutableLifetimes} from './InferMutableLifetimes';
|
||||
import {inferMutableRangesForAlias} from './InferMutableRangesForAlias';
|
||||
import {inferMutableRangesForComutation} from './InferMutableRangesForComutation';
|
||||
import {inferTryCatchAliases} from './InferTryCatchAliases';
|
||||
import {printIdentifier, printMutableRange} from '../HIR/PrintHIR';
|
||||
|
||||
export function inferMutableRanges(ir: HIRFunction): DisjointSet<Identifier> {
|
||||
// Infer mutable ranges for non fields
|
||||
@@ -96,6 +98,20 @@ export function inferMutableRanges(ir: HIRFunction): DisjointSet<Identifier> {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
export function debugAliases(aliases: DisjointSet<Identifier>): void {
|
||||
console.log(
|
||||
prettyFormat(
|
||||
aliases
|
||||
.buildSets()
|
||||
.map(set =>
|
||||
[...set].map(
|
||||
ident => printIdentifier(ident) + printMutableRange(ident),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonicalizes the alias set and mutable range information calculated at the current time.
|
||||
* The returned value maps each identifier in the program to the root identifier of its alias
|
||||
|
||||
Reference in New Issue
Block a user