[vm] Simplify closure instantiation

When instantiating a closure, allocate a new closure object in
the same boostrap native method as checking bounds.

This simplifies code generation and prepares for variable-length
closure objects by removing the only place where closure of unknown
length was allocated in the generated code.

TEST=ci

Change-Id: I9ac51c862081612bca2160699ebe24526d4fc915
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov
2026-03-25 06:59:41 -07:00
committed by Commit Queue
parent f62c82aaf8
commit 17e6648fe0
9 changed files with 54 additions and 158 deletions
@@ -148,9 +148,7 @@ void matchIL$testCSE3(FlowGraph graph) {
'b_bar' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.MoveArgument('b_bar'),
match.MoveArgument(match.any),
match.StaticCall(), // _boundsCheckForPartialInstantiation
'b_bar_int' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.StoreField('b_bar_int', match.any),
'b_bar_int' << match.StaticCall(), // _instantiateClosure
match.MoveArgument('b_bar_int'),
match.StaticCall(),
'cond' << match.LoadStaticField(),
@@ -164,9 +162,7 @@ void matchIL$testCSE3(FlowGraph graph) {
match.block('Target', [
match.MoveArgument('b_bar'),
match.MoveArgument(match.any),
match.StaticCall(), // _boundsCheckForPartialInstantiation
'b_bar_num' << match.AllocateClosure(match.any, 'b', 'b_type_args'),
match.StoreField('b_bar_num', match.any),
'b_bar_num' << match.StaticCall(), // _instantiateClosure
match.MoveArgument('b_bar_num'),
match.StaticCall(),
match.Goto('B5'),