Skip to content

Commit ad3202b

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/compiler] Add Function::PrologueNeedsArgumentsDescriptor and use 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]>
1 parent 089d6fc commit ad3202b

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

runtime/vm/compiler/backend/il_deserializer.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,9 +2138,8 @@ bool FlowGraphDeserializer::ParseCanonicalName(SExpSymbol* sym, Object* obj) {
21382138
return false;
21392139
}
21402140
if (is_forwarder) {
2141-
// Go back four characters to start at the 'dyn:' we stripped earlier.
2142-
tmp_string_ = String::FromUTF8(
2143-
reinterpret_cast<const uint8_t*>(func_start - 4), name_len + 4);
2141+
tmp_string_ = name_function_.name();
2142+
tmp_string_ = Function::CreateDynamicInvocationForwarderName(tmp_string_);
21442143
name_function_ =
21452144
name_function_.GetDynamicInvocationForwarder(tmp_string_);
21462145
}

runtime/vm/object.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9223,7 +9223,7 @@ bool Function::NeedsMonomorphicCheckedEntry(Zone* zone) const {
92239223
// monomorphic entry).
92249224
//
92259225
// See runtime_entry.cc:DEFINE_RUNTIME_ENTRY(UnlinkedCall)
9226-
if (HasOptionalParameters() || IsGeneric()) {
9226+
if (PrologueNeedsArgumentsDescriptor()) {
92279227
return false;
92289228
}
92299229

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

9251+
bool Function::PrologueNeedsArgumentsDescriptor() const {
9252+
// The prologue of those functions need to examine the arg descriptor for
9253+
// various purposes.
9254+
return IsGeneric() || HasOptionalParameters();
9255+
}
9256+
92519257
bool Function::MayHaveUncheckedEntryPoint() const {
92529258
return FLAG_enable_multiple_entrypoints &&
92539259
(NeedsArgumentTypeChecks() || IsImplicitClosureFunction());

runtime/vm/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,7 @@ class Function : public Object {
28962896
}
28972897

28982898
bool NeedsMonomorphicCheckedEntry(Zone* zone) const;
2899+
bool PrologueNeedsArgumentsDescriptor() const;
28992900

29002901
bool MayHaveUncheckedEntryPoint() const;
29012902

runtime/vm/runtime_entry.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,7 @@ static void TrySwitchInstanceCall(const ICData& ic_data,
12071207
// A call site in the monomorphic state does not load the arguments
12081208
// descriptor, so do not allow transition to this state if the callee
12091209
// needs it.
1210-
if (target_function.HasOptionalParameters() ||
1211-
target_function.IsGeneric()) {
1210+
if (target_function.PrologueNeedsArgumentsDescriptor()) {
12121211
return;
12131212
}
12141213

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

18971896
if ((number_of_checks == 0) &&
18981897
(!FLAG_precompiled_mode || ic_data.receiver_cannot_be_smi()) &&
1899-
!target_function.HasOptionalParameters() &&
1900-
!target_function.IsGeneric()) {
1898+
!target_function.PrologueNeedsArgumentsDescriptor()) {
19011899
// This call site is unlinked: transition to a monomorphic direct call.
19021900
// Note we cannot do this if the target has optional parameters because
19031901
// the monomorphic direct call does not load the arguments descriptor.

0 commit comments

Comments
 (0)