Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from facebook:main #52

Merged
merged 4 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import {validateNoJSXInTryStatement} from '../Validation/ValidateNoJSXInTryState
import {propagateScopeDependenciesHIR} from '../HIR/PropagateScopeDependenciesHIR';
import {outlineJSX} from '../Optimization/OutlineJsx';
import {optimizePropsMethodCalls} from '../Optimization/OptimizePropsMethodCalls';
import {transformFire} from '../Transform';

export type CompilerPipelineValue =
| {kind: 'ast'; name: string; value: CodegenFunction}
Expand Down Expand Up @@ -197,6 +198,11 @@ function runWithEnvironment(
validateHooksUsage(hir);
}

if (env.config.enableFire) {
transformFire(hir);
log({kind: 'hir', name: 'TransformFire', value: hir});
}

if (env.config.validateNoCapitalizedCalls) {
validateNoCapitalizedCalls(hir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,14 @@ export function compileProgram(
if (environment.enableChangeDetectionForDebugging != null) {
externalFunctions.push(environment.enableChangeDetectionForDebugging);
}

const hasFireRewrite = compiledFns.some(c => c.compiledFn.hasFireRewrite);
if (environment.enableFire && hasFireRewrite) {
externalFunctions.push({
source: getReactCompilerRuntimeModule(pass.opts),
importSpecifierName: 'useFire',
});
}
} catch (err) {
handleError(err, pass, null);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ export class Environment {
fnType: ReactFunctionType;
useMemoCacheIdentifier: string;
hasLoweredContextAccess: boolean;
hasFireRewrite: boolean;

#contextIdentifiers: Set<t.Identifier>;
#hoistedIdentifiers: Set<t.Identifier>;
Expand All @@ -811,6 +812,7 @@ export class Environment {
this.#shapes = new Map(DEFAULT_SHAPES);
this.#globals = new Map(DEFAULT_GLOBALS);
this.hasLoweredContextAccess = false;
this.hasFireRewrite = false;

if (
config.disableMemoizationForDebugging &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,14 @@ export function printSourceLocation(loc: SourceLocation): string {
}
}

export function printSourceLocationLine(loc: SourceLocation): string {
if (typeof loc === 'symbol') {
return 'generated';
} else {
return `${loc.start.line}:${loc.end.line}`;
}
}

export function printAliases(aliases: DisjointSet<Identifier>): string {
const aliasSets = aliases.buildSets();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export type CodegenFunction = {
* This is true if the compiler has the lowered useContext calls.
*/
hasLoweredContextAccess: boolean;

/**
* This is true if the compiler has compiled a fire to a useFire call
*/
hasFireRewrite: boolean;
};

export function codegenFunction(
Expand Down Expand Up @@ -355,6 +360,7 @@ function codegenReactiveFunction(
prunedMemoValues: countMemoBlockVisitor.prunedMemoValues,
outlined: [],
hasLoweredContextAccess: fn.env.hasLoweredContextAccess,
hasFireRewrite: fn.env.hasFireRewrite,
});
}

Expand Down
Loading
Loading