Skip to content

Commit db8d71d

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm/aot] Discard Code objects of entry points
Calls from C++ to Dart entry points are currently performed by calling via Function::entry_point() in AOT mode (with --use_bare_instructions). Such calls no longer use Code objects, so Code objects can be discarded even if they belong to a Function which is used as an entry point. TEST=ci Issue: dart-lang/sdk#44852 Change-Id: Iaf9dd67392780ef4344fc518865ffbe30648762e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196720 Reviewed-by: Tess Strickland <sstrickl@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
1 parent 8a08015 commit db8d71d

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

runtime/vm/compiler/aot/precompiler.cc

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ Precompiler::Precompiler(Thread* thread)
359359
pending_functions_(
360360
GrowableObjectArray::Handle(GrowableObjectArray::New())),
361361
sent_selectors_(),
362-
entry_point_functions_(
363-
HashTables::New<FunctionSet>(/*initial_capacity=*/128)),
364362
functions_called_dynamically_(
365363
HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
366364
seen_functions_(HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
@@ -384,7 +382,6 @@ Precompiler::Precompiler(Thread* thread)
384382

385383
Precompiler::~Precompiler() {
386384
// We have to call Release() in DEBUG mode.
387-
entry_point_functions_.Release();
388385
functions_called_dynamically_.Release();
389386
seen_functions_.Release();
390387
possibly_retained_functions_.Release();
@@ -1464,7 +1461,6 @@ void Precompiler::AddAnnotatedRoots() {
14641461
if (type == EntryPointPragma::kAlways ||
14651462
type == EntryPointPragma::kCallOnly) {
14661463
AddFunction(function, RetainReasons::kEntryPointPragma);
1467-
entry_point_functions_.Insert(function);
14681464
}
14691465

14701466
if ((type == EntryPointPragma::kAlways ||
@@ -1473,12 +1469,10 @@ void Precompiler::AddAnnotatedRoots() {
14731469
!function.IsSetterFunction()) {
14741470
function2 = function.ImplicitClosureFunction();
14751471
AddFunction(function2, RetainReasons::kEntryPointPragma);
1476-
entry_point_functions_.Insert(function2);
14771472
}
14781473

14791474
if (function.IsGenerativeConstructor()) {
14801475
AddInstantiatedClass(cls);
1481-
entry_point_functions_.Insert(function);
14821476
}
14831477
}
14841478
if (function.kind() == UntaggedFunction::kImplicitGetter &&
@@ -1487,7 +1481,6 @@ void Precompiler::AddAnnotatedRoots() {
14871481
field ^= implicit_getters.At(i);
14881482
if (function.accessor_field() == field.ptr()) {
14891483
AddFunction(function, RetainReasons::kImplicitGetter);
1490-
entry_point_functions_.Insert(function);
14911484
}
14921485
}
14931486
}
@@ -1497,7 +1490,6 @@ void Precompiler::AddAnnotatedRoots() {
14971490
field ^= implicit_setters.At(i);
14981491
if (function.accessor_field() == field.ptr()) {
14991492
AddFunction(function, RetainReasons::kImplicitSetter);
1500-
entry_point_functions_.Insert(function);
15011493
}
15021494
}
15031495
}
@@ -1507,7 +1499,6 @@ void Precompiler::AddAnnotatedRoots() {
15071499
field ^= implicit_static_getters.At(i);
15081500
if (function.accessor_field() == field.ptr()) {
15091501
AddFunction(function, RetainReasons::kImplicitStaticGetter);
1510-
entry_point_functions_.Insert(function);
15111502
}
15121503
}
15131504
}
@@ -2717,7 +2708,6 @@ void Precompiler::DiscardCodeObjects() {
27172708
public:
27182709
DiscardCodeVisitor(Zone* zone,
27192710
const FunctionSet& functions_to_retain,
2720-
const FunctionSet& entry_point_functions,
27212711
const FunctionSet& functions_called_dynamically)
27222712
: zone_(zone),
27232713
function_(Function::Handle(zone)),
@@ -2730,7 +2720,6 @@ void Precompiler::DiscardCodeObjects() {
27302720
targets_of_calls_via_code_(
27312721
GrowableObjectArray::Handle(zone, GrowableObjectArray::New())),
27322722
functions_to_retain_(functions_to_retain),
2733-
entry_point_functions_(entry_point_functions),
27342723
functions_called_dynamically_(functions_called_dynamically) {}
27352724

27362725
// Certain static calls (e.g. between different loading units) are
@@ -2794,20 +2783,13 @@ void Precompiler::DiscardCodeObjects() {
27942783
return;
27952784
}
27962785

2797-
// Retain Code objects for entry points.
2798-
if (entry_point_functions_.ContainsKey(function_)) {
2799-
++codes_with_entry_point_function_;
2800-
return;
2801-
}
2802-
28032786
// Retain Code objects corresponding to dynamically
28042787
// called functions.
28052788
if (functions_called_dynamically_.ContainsKey(function_)) {
28062789
++codes_with_dynamically_called_function_;
28072790
return;
28082791
}
28092792
} else {
2810-
ASSERT(!entry_point_functions_.ContainsKey(function_));
28112793
ASSERT(!functions_called_dynamically_.ContainsKey(function_));
28122794
}
28132795

@@ -2857,8 +2839,6 @@ void Precompiler::DiscardCodeObjects() {
28572839
codes_with_native_function_);
28582840
THR_Print(" %8" Pd " Codes with async closure functions\n",
28592841
codes_with_async_closure_function_);
2860-
THR_Print(" %8" Pd " Codes with entry point functions\n",
2861-
codes_with_entry_point_function_);
28622842
THR_Print(" %8" Pd " Codes with dynamically called functions\n",
28632843
codes_with_dynamically_called_function_);
28642844
THR_Print(" %8" Pd " Codes with deferred functions\n",
@@ -2882,7 +2862,6 @@ void Precompiler::DiscardCodeObjects() {
28822862
Code& call_target_;
28832863
GrowableObjectArray& targets_of_calls_via_code_;
28842864
const FunctionSet& functions_to_retain_;
2885-
const FunctionSet& entry_point_functions_;
28862865
const FunctionSet& functions_called_dynamically_;
28872866

28882867
// Statistics
@@ -2893,7 +2872,6 @@ void Precompiler::DiscardCodeObjects() {
28932872
intptr_t codes_with_invisible_function_ = 0;
28942873
intptr_t codes_with_native_function_ = 0;
28952874
intptr_t codes_with_async_closure_function_ = 0;
2896-
intptr_t codes_with_entry_point_function_ = 0;
28972875
intptr_t codes_with_dynamically_called_function_ = 0;
28982876
intptr_t codes_with_deferred_function_ = 0;
28992877
intptr_t codes_with_ffi_trampoline_function_ = 0;
@@ -2909,7 +2887,7 @@ void Precompiler::DiscardCodeObjects() {
29092887
return;
29102888
}
29112889

2912-
DiscardCodeVisitor visitor(Z, functions_to_retain_, entry_point_functions_,
2890+
DiscardCodeVisitor visitor(Z, functions_to_retain_,
29132891
functions_called_dynamically_);
29142892
ProgramVisitor::WalkProgram(Z, IG, &visitor);
29152893
visitor.RetainCodeObjectsUsedAsCallTargets();

runtime/vm/compiler/aot/precompiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ class Precompiler : public ValueObject {
374374
GrowableObjectArray& libraries_;
375375
const GrowableObjectArray& pending_functions_;
376376
SymbolSet sent_selectors_;
377-
FunctionSet entry_point_functions_;
378377
FunctionSet functions_called_dynamically_;
379378
FunctionSet seen_functions_;
380379
FunctionSet possibly_retained_functions_;

0 commit comments

Comments
 (0)