Skip to content

Commit 2f17c11

Browse files
alexmarkovCommit Bot
authored and
Commit Bot
committed
Revert "[vm] Cleanup old async/async*/sync* implementation from the VM"
This reverts commit bc8afad. Reason for revert: b/238653741 Original change's description: > [vm] Cleanup old async/async*/sync* implementation from the VM > > TEST=ci > > Issue: #48378 > Change-Id: I089ba4ed5613f30eec29f0db4ac6d5d8fbffd185 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249980 > Reviewed-by: Martin Kustermann <[email protected]> > Reviewed-by: Slava Egorov <[email protected]> > Commit-Queue: Alexander Markov <[email protected]> [email protected],[email protected],[email protected] Change-Id: I6437d2d7d3914eb7fb9fe397472e2a5f7ae0cd9e No-Presubmit: true No-Tree-Checks: true No-Try: true Issue: #48378 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251147 Bot-Commit: Rubber Stamper <[email protected]> Commit-Queue: Alexander Markov <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent 3efd79b commit 2f17c11

26 files changed

+1615
-465
lines changed

runtime/tests/vm/dart/regress_flutter51298_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// VMOptions=--optimization_counter_threshold=10 --deterministic
5+
// VMOptions=--async_igoto_threshold=0 --optimization_counter_threshold=10 --deterministic
66

77
// Regression test for https://github.com/flutter/flutter/issues/51298.
88
// This would cause a crash due to bad offsets causing entry to hit the pre-code

runtime/tests/vm/dart_2/regress_flutter51298_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// @dart = 2.9
66

7-
// VMOptions=--optimization_counter_threshold=10 --deterministic
7+
// VMOptions=--async_igoto_threshold=0 --optimization_counter_threshold=10 --deterministic
88

99
// Regression test for https://github.com/flutter/flutter/issues/51298.
1010
// This would cause a crash due to bad offsets causing entry to hit the pre-code

runtime/vm/code_descriptors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class ExceptionHandlerList : public ZoneAllocated {
7878

7979
explicit ExceptionHandlerList(const Function& function)
8080
: list_(),
81-
has_async_handler_(function.IsAsyncFunction() ||
82-
function.IsAsyncGenerator()) {}
81+
has_async_handler_(function.IsCompactAsyncFunction() ||
82+
function.IsCompactAsyncStarFunction()) {}
8383

8484
intptr_t Length() const { return list_.length(); }
8585

runtime/vm/compiler/aot/precompiler.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ void Precompiler::DoCompileAll() {
629629
IG->object_store()->set_simple_instance_of_true_function(null_function);
630630
IG->object_store()->set_simple_instance_of_false_function(
631631
null_function);
632+
IG->object_store()->set_async_star_move_next_helper(null_function);
633+
IG->object_store()->set_complete_on_async_return(null_function);
632634
IG->object_store()->set_async_star_stream_controller(null_class);
633635
DropMetadata();
634636
DropLibraryEntries();
@@ -1134,6 +1136,14 @@ void Precompiler::AddTypesOf(const Function& function) {
11341136
return;
11351137
}
11361138

1139+
// Preserve parents for generated bodies in async/async*/sync* functions,
1140+
// since predicates like Function::IsAsyncClosure(), etc. need that info.
1141+
if (function.is_generated_body()) {
1142+
AddRetainReason(parent_function, RetainReasons::kIsSyncAsyncFunction);
1143+
AddTypesOf(parent_function);
1144+
return;
1145+
}
1146+
11371147
// We're not retaining the parent due to this function, so wrap it with
11381148
// a weak serialization reference.
11391149
const auto& data = ClosureData::CheckedHandle(Z, function.data());
@@ -2973,6 +2983,10 @@ void Precompiler::DiscardCodeObjects() {
29732983
++codes_with_native_function_;
29742984
return;
29752985
}
2986+
if (function_.IsAsyncClosure() || function_.IsAsyncGenClosure()) {
2987+
++codes_with_async_closure_function_;
2988+
return;
2989+
}
29762990

29772991
// Retain Code objects corresponding to dynamically
29782992
// called functions.
@@ -3026,6 +3040,8 @@ void Precompiler::DiscardCodeObjects() {
30263040
codes_with_pc_descriptors_);
30273041
THR_Print(" %8" Pd " Codes with native functions\n",
30283042
codes_with_native_function_);
3043+
THR_Print(" %8" Pd " Codes with async closure functions\n",
3044+
codes_with_async_closure_function_);
30293045
THR_Print(" %8" Pd " Codes with dynamically called functions\n",
30303046
codes_with_dynamically_called_function_);
30313047
THR_Print(" %8" Pd " Codes with deferred functions\n",
@@ -3057,6 +3073,7 @@ void Precompiler::DiscardCodeObjects() {
30573073
intptr_t codes_with_exception_handlers_ = 0;
30583074
intptr_t codes_with_pc_descriptors_ = 0;
30593075
intptr_t codes_with_native_function_ = 0;
3076+
intptr_t codes_with_async_closure_function_ = 0;
30603077
intptr_t codes_with_dynamically_called_function_ = 0;
30613078
intptr_t codes_with_deferred_function_ = 0;
30623079
intptr_t codes_with_ffi_trampoline_function_ = 0;

runtime/vm/compiler/backend/il.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6836,7 +6836,7 @@ void RawStoreFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
68366836
const Code& ReturnInstr::GetReturnStub(FlowGraphCompiler* compiler) const {
68376837
const Function& function = compiler->parsed_function().function();
68386838
ASSERT(function.IsSuspendableFunction());
6839-
if (function.IsAsyncFunction()) {
6839+
if (function.IsCompactAsyncFunction()) {
68406840
if (!value()->Type()->CanBeFuture()) {
68416841
return Code::ZoneHandle(compiler->zone(),
68426842
compiler->isolate_group()
@@ -6846,11 +6846,11 @@ const Code& ReturnInstr::GetReturnStub(FlowGraphCompiler* compiler) const {
68466846
return Code::ZoneHandle(
68476847
compiler->zone(),
68486848
compiler->isolate_group()->object_store()->return_async_stub());
6849-
} else if (function.IsAsyncGenerator()) {
6849+
} else if (function.IsCompactAsyncStarFunction()) {
68506850
return Code::ZoneHandle(
68516851
compiler->zone(),
68526852
compiler->isolate_group()->object_store()->return_async_star_stub());
6853-
} else if (function.IsSyncGenerator()) {
6853+
} else if (function.IsCompactSyncStarFunction()) {
68546854
return Code::ZoneHandle(
68556855
compiler->zone(),
68566856
compiler->isolate_group()->object_store()->return_sync_star_stub());

0 commit comments

Comments
 (0)