Revert "[vm,dart2bytecode,modular_aot] Variable-length closure objects"

This reverts commit 88496ba1c3.

Reason for revert: crashes on arm64c

Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
>  - delayed type arguments;
>  - instantiator type arguments;
>  - function type arguments;
>  - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/61572
> Issue: https://github.com/dart-lang/sdk/issues/61635
>
> Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I94c88f8922f6ea49251e942ba791fee714911e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494261
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov
2026-04-09 14:12:09 -07:00
committed by Commit Queue
parent 9fee4af302
commit 0dfaa16dc7
88 changed files with 1396 additions and 2797 deletions
@@ -59,12 +59,7 @@ main() async {
if (uri == '') {
// We don't verify non-user-visible objects.
} else if (uri.startsWith('dart') &&
[
'Array',
'Closure',
'List',
'Record',
].any((p) => klass.name.contains(p))) {
['Array', 'List', 'Record'].any((p) => klass.name.contains(p))) {
Expect.isTrue(fields.length <= object.references.length);
} else {
// For objects with vm-defined layouts, this fails if a new field is
@@ -34,7 +34,7 @@ void matchIL$main_testForIn(FlowGraph graph) {
match.block('Graph'),
match.block('Function', [
'v2' << match.Parameter(index: 0),
'v3' << match.LoadField('v2', slot: ':closure_element[0]'),
'v3' << match.LoadField('v2', slot: 'Closure.context'),
'v4' << match.LoadField('v3', slot: 'list'),
'v92' << match.LoadField('v4', slot: 'GrowableObjectArray.length'),
if (!is32BitConfiguration) 'v112' << match.UnboxInt64('v92'),
@@ -116,8 +116,7 @@ void matchIL$testCSE2(FlowGraph graph) {
'b' << match.Parameter(index: 0),
match.CheckStackOverflow(),
'b_type_args' << match.LoadField('b'),
'b_bar' << match.AllocateClosure(match.any, 'b'),
match.StoreField('b_bar', 'b_type_args', slot: ':closure_element[1]'),
'b_bar' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.MoveArgument('b_bar'),
match.StaticCall(),
'cond' << match.LoadStaticField(),
@@ -146,8 +145,7 @@ void matchIL$testCSE3(FlowGraph graph) {
'b' << match.Parameter(index: 0),
match.CheckStackOverflow(),
'b_type_args' << match.LoadField('b'),
'b_bar' << match.AllocateClosure(match.any, 'b'),
match.StoreField('b_bar', 'b_type_args', slot: ':closure_element[1]'),
'b_bar' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.MoveArgument('b_bar'),
match.MoveArgument(match.any),
'b_bar_int' << match.StaticCall(), // _instantiateClosure
@@ -214,8 +212,7 @@ void matchIL$testLICM2(FlowGraph graph) {
'b' << match.Parameter(index: 0),
match.CheckStackOverflow(),
'b_type_args' << match.LoadField('b'),
'b_bar' << match.AllocateClosure(match.any, 'b'),
match.StoreField('b_bar', 'b_type_args', slot: ':closure_element[1]'),
'b_bar' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.Goto('B5'),
]),
'B5' <<