Skip to content

Commit bb04061

Browse files
lauraharkercopybara-github
authored andcommitted
Decrease peak memory usage during property collapsing
PiperOrigin-RevId: 551277400
1 parent d34529b commit bb04061

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/com/google/javascript/jscomp/InlineAndCollapseProperties.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,25 @@ private void performMinimalInliningAndModuleExportCollapsing(Node externs, Node
237237
// and reuse that one instead.
238238
namespace = new GlobalNamespace(decisionsLog, compiler, root);
239239
new CollapseProperties().process(externs, root);
240+
241+
namespace = null; // free up memory before PropagateConstantPropertyOverVars
242+
// This shouldn't be necessary, this pass should already be setting new constants as
243+
// constant.
244+
// TODO(b/64256754): Investigate.
245+
new PropagateConstantPropertyOverVars(compiler, false).process(externs, root);
240246
}
241247

242248
private void performAggressiveInliningAndCollapsing(Node externs, Node root) {
243249
new ConcretizeStaticInheritanceForInlining(compiler).process(externs, root);
244250
new AggressiveInlineAliases().process(externs, root);
251+
245252
new CollapseProperties().process(externs, root);
253+
254+
namespace = null; // free up memory before PropagateConstantPropertyOverVars
255+
// This shouldn't be necessary, this pass should already be setting new constants as
256+
// constant.
257+
// TODO(b/64256754): Investigate.
258+
new PropagateConstantPropertyOverVars(compiler, false).process(externs, root);
246259
}
247260

248261
private void performAggressiveInliningForTest(Node externs, Node root) {
@@ -1297,11 +1310,6 @@ public void process(Node externs, Node root) {
12971310
// invalidating the node ancestry stored with each reference.
12981311
collapseDeclarationOfNameAndDescendants(name, name.getBaseName(), escaped);
12991312
}
1300-
1301-
// This shouldn't be necessary, this pass should already be setting new constants as
1302-
// constant.
1303-
// TODO(b/64256754): Investigate.
1304-
new PropagateConstantPropertyOverVars(compiler, false).process(externs, root);
13051313
}
13061314

13071315
private boolean canCollapse(Name name) {

0 commit comments

Comments
 (0)