[vm/aot] Do not generate monomorphic prologue for functions which need args descriptor

Functions which have optional parameters or which are generic need the
arguments descriptor to be passed. Since switchable call-sites do not
populate the arguments descriptor, such functions are always called via
a stub (i.e. the switchable calls transition never to monomorphic
state).

There is therefore no reason to generate the monomorphic prologues for
those functions.

Flutter Gallery size impact:

  armv8: -0.31% RX
  armv7: -0.226% RX

Change-Id: I7d6b554cbcdc90b85a278487c5541fed4e64b5bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120961
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2019-10-10 07:14:07 +00:00 committed by commit-bot@chromium.org
parent 7b9a26ee6f
commit f6477854cd
2 changed files with 18 additions and 1 deletions

View file

@ -4084,7 +4084,16 @@ void FunctionEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
// (As opposed to here where we don't check for the return value of
// [Intrinsify]).
const Function& function = compiler->parsed_function().function();
if (function.IsDynamicFunction()) {
// For functions which need an args descriptor the switchable call sites will
// transition directly to calling via a stub (and therefore never call the
// monomorphic entry).
//
// See runtime_entry.cc:DEFINE_RUNTIME_ENTRY(UnlinkedCall)
const bool needs_args_descriptor =
function.HasOptionalParameters() || function.IsGeneric();
if (function.IsDynamicFunction() && !needs_args_descriptor) {
compiler->SpecialStatsBegin(CombinedCodeStatistics::kTagCheckedEntry);
if (!FLAG_precompiled_mode) {
__ MonomorphicCheckedEntryJIT();

View file

@ -1567,6 +1567,14 @@ DEFINE_RUNTIME_ENTRY(UnlinkedCall, 3) {
ic_data.AddReceiverCheck(receiver.GetClassId(), target_function);
}
// If the target function has optional parameters or is generic, it's
// prologue requires ARGS_DESC_REG to be populated. Yet the switchable calls
// do not populate that on the call site, which is why we don't transition
// those call sites to monomorphic, but rather directly to call via stub
// (which will populate the ARGS_DESC_REG from the ICData).
//
// Because of this we also don't generate monomorphic checks for those
// functions.
if (!target_function.IsNull() && !target_function.HasOptionalParameters() &&
!target_function.IsGeneric()) {
// Patch to monomorphic call.