Skip to content

Commit

Permalink
[vm/compiler] Add Function::PrologueNeedsArgumentsDescriptor and use …
Browse files Browse the repository at this point in the history
…it in all places (to avoid code duplication)

Change-Id: Id7d168578eca13cd03377237a430b95ab49d5e78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153984
Commit-Queue: Martin Kustermann <[email protected]>
Reviewed-by: Tess Strickland <[email protected]>
  • Loading branch information
mkustermann authored and [email protected] committed Jul 10, 2020
1 parent 089d6fc commit ad3202b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 2 additions & 3 deletions runtime/vm/compiler/backend/il_deserializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2138,9 +2138,8 @@ bool FlowGraphDeserializer::ParseCanonicalName(SExpSymbol* sym, Object* obj) {
return false;
}
if (is_forwarder) {
// Go back four characters to start at the 'dyn:' we stripped earlier.
tmp_string_ = String::FromUTF8(
reinterpret_cast<const uint8_t*>(func_start - 4), name_len + 4);
tmp_string_ = name_function_.name();
tmp_string_ = Function::CreateDynamicInvocationForwarderName(tmp_string_);
name_function_ =
name_function_.GetDynamicInvocationForwarder(tmp_string_);
}
Expand Down
8 changes: 7 additions & 1 deletion runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9223,7 +9223,7 @@ bool Function::NeedsMonomorphicCheckedEntry(Zone* zone) const {
// monomorphic entry).
//
// See runtime_entry.cc:DEFINE_RUNTIME_ENTRY(UnlinkedCall)
if (HasOptionalParameters() || IsGeneric()) {
if (PrologueNeedsArgumentsDescriptor()) {
return false;
}

Expand All @@ -9248,6 +9248,12 @@ bool Function::NeedsMonomorphicCheckedEntry(Zone* zone) const {
#endif
}

bool Function::PrologueNeedsArgumentsDescriptor() const {
// The prologue of those functions need to examine the arg descriptor for
// various purposes.
return IsGeneric() || HasOptionalParameters();
}

bool Function::MayHaveUncheckedEntryPoint() const {
return FLAG_enable_multiple_entrypoints &&
(NeedsArgumentTypeChecks() || IsImplicitClosureFunction());
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,7 @@ class Function : public Object {
}

bool NeedsMonomorphicCheckedEntry(Zone* zone) const;
bool PrologueNeedsArgumentsDescriptor() const;

bool MayHaveUncheckedEntryPoint() const;

Expand Down
10 changes: 4 additions & 6 deletions runtime/vm/runtime_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,7 @@ static void TrySwitchInstanceCall(const ICData& ic_data,
// A call site in the monomorphic state does not load the arguments
// descriptor, so do not allow transition to this state if the callee
// needs it.
if (target_function.HasOptionalParameters() ||
target_function.IsGeneric()) {
if (target_function.PrologueNeedsArgumentsDescriptor()) {
return;
}

Expand Down Expand Up @@ -1643,8 +1642,8 @@ void SwitchableCallHandler::DoUnlinkedCall(const UnlinkedCall& unlinked,
//
// Because of this we also don't generate monomorphic checks for those
// functions.
if (!target_function.IsNull() && !target_function.HasOptionalParameters() &&
!target_function.IsGeneric()) {
if (!target_function.IsNull() &&
!target_function.PrologueNeedsArgumentsDescriptor()) {
// Patch to monomorphic call.
ASSERT(target_function.HasCode());
const Code& target_code =
Expand Down Expand Up @@ -1896,8 +1895,7 @@ void SwitchableCallHandler::DoICDataMiss(const ICData& ic_data,

if ((number_of_checks == 0) &&
(!FLAG_precompiled_mode || ic_data.receiver_cannot_be_smi()) &&
!target_function.HasOptionalParameters() &&
!target_function.IsGeneric()) {
!target_function.PrologueNeedsArgumentsDescriptor()) {
// This call site is unlinked: transition to a monomorphic direct call.
// Note we cannot do this if the target has optional parameters because
// the monomorphic direct call does not load the arguments descriptor.
Expand Down

0 comments on commit ad3202b

Please sign in to comment.