[vm] Remove overlap between Function and FunctionType.

Previously there were several pieces of information shared between
both FunctionType and Function, mostly in the packed fields, but
named argument names were also kept in both places.

Now the FunctionType is the primary source for this information, with
the Function only keeping the names of positional arguments, which are
discarded in AOT snapshots.

This does mean extra work to access this information via the function
object, but for the most part, this information is only accessed in the
compiler or during dynamic lookups or checks in the runtime.

After adding the count of type parameters to the packed information
in FunctionType, the packed information has been split into two pieces:
one for parameter counts, another for type parameter counts. This
split does not increase the size of UntaggedFunctionType, as there
were 2 bytes available in the existing padding.

Changes on flutter gallery in release mode:

* ARM7 code size: total -0.91%, readonly -0.22%, isolate -4.32%
* ARM7 heap size: total -2.00%
* ARM8 code size: total -0.93%, readonly -0.22%, isolate -4.32%
* ARM8 heap size: total -2.12%

Changes on flutter gallery in release-sizeopt mode:

* ARM7 code size: total -0.24%, readonly -0.08%, isolate -1.49%
* ARM7 heap size: total -0.88%
* ARM8 code size: total -0.26%, readonly -0.11%, isolate -1.49%
* ARM8 heap size: total -1.01%

TEST=Refactoring, so existing tests.

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try
Change-Id: Ic4d59a7b4acca039a5647f9163e716f6019163f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203241
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
This commit is contained in:
Tess Strickland 2021-07-02 14:26:04 +00:00 committed by commit-bot@chromium.org
parent 42164cc140
commit cf63eaed4d
26 changed files with 885 additions and 730 deletions

View file

@ -96,7 +96,9 @@ static void EnsureConstructorsAreCompiled(const Function& func) {
static InstancePtr CreateParameterMirrorList(const Function& func,
const FunctionType& signature,
const Instance& owner_mirror) {
HANDLESCOPE(Thread::Current());
Thread* const T = Thread::Current();
Zone* const Z = T->zone();
HANDLESCOPE(T);
const intptr_t implicit_param_count = signature.num_implicit_parameters();
const intptr_t non_implicit_param_count =
signature.NumParameters() - implicit_param_count;
@ -104,15 +106,15 @@ static InstancePtr CreateParameterMirrorList(const Function& func,
non_implicit_param_count - signature.NumOptionalParameters();
const intptr_t index_of_first_named_param =
non_implicit_param_count - signature.NumOptionalNamedParameters();
const Array& results = Array::Handle(Array::New(non_implicit_param_count));
const Array& args = Array::Handle(Array::New(9));
const Array& results = Array::Handle(Z, Array::New(non_implicit_param_count));
const Array& args = Array::Handle(Z, Array::New(9));
Smi& pos = Smi::Handle();
String& name = String::Handle();
Instance& param = Instance::Handle();
Bool& is_final = Bool::Handle();
Object& default_value = Object::Handle();
Object& metadata = Object::Handle();
Smi& pos = Smi::Handle(Z);
String& name = String::Handle(Z);
Instance& param = Instance::Handle(Z);
Bool& is_final = Bool::Handle(Z);
Object& default_value = Object::Handle(Z);
Object& metadata = Object::Handle(Z);
// We force compilation of constructors to ensure the types of initializing
// formals have been corrected. We do not force the compilation of all types
@ -156,10 +158,17 @@ static InstancePtr CreateParameterMirrorList(const Function& func,
for (intptr_t i = 0; i < non_implicit_param_count; i++) {
pos = Smi::New(i);
if (!func.IsNull()) {
if (i >= index_of_first_named_param) {
// Named parameters are stored in the signature.
name = signature.ParameterNameAt(implicit_param_count + i);
} else if (!func.IsNull()) {
// Positional parameters are stored in the function.
name = func.ParameterNameAt(implicit_param_count + i);
} else {
name = signature.ParameterNameAt(implicit_param_count + i);
// We were not given a function, only the type, so create placeholder
// names for the positional parameters.
const char* const placeholder = OS::SCreate(Z, ":param%" Pd "", i);
name = String::New(placeholder);
}
if (has_extra_parameter_info) {
is_final ^= param_descriptor.At(i * Parser::kParameterEntrySize +

View file

@ -958,7 +958,7 @@ void ClassFinalizer::FinalizeMemberTypes(const Class& cls) {
// Remove this finalization code?
signature = function.signature();
signature ^= FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
}
}
// Finalize function signatures and check for conflicts in super classes and
@ -969,7 +969,7 @@ void ClassFinalizer::FinalizeMemberTypes(const Class& cls) {
function ^= array.At(i);
signature = function.signature();
signature ^= FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
if (function.IsSetterFunction() || function.IsImplicitSetterFunction()) {
continue;
}

View file

@ -960,6 +960,9 @@ class FunctionSerializationCluster : public SerializationCluster {
s->Push(func->untag()->code());
s->Push(func->untag()->ic_data_array());
}
if (kind != Snapshot::kFullAOT) {
NOT_IN_PRECOMPILED(s->Push(func->untag()->positional_parameter_names()));
}
}
void WriteAlloc(Serializer* s) {
@ -987,6 +990,8 @@ class FunctionSerializationCluster : public SerializationCluster {
}
if (kind != Snapshot::kFullAOT) {
NOT_IN_PRECOMPILED(
WriteCompressedField(func, positional_parameter_names));
s->WriteTokenPosition(func->untag()->token_pos_);
s->WriteTokenPosition(func->untag()->end_token_pos_);
s->Write<uint32_t>(func->untag()->kernel_offset_);
@ -1061,6 +1066,8 @@ class FunctionDeserializationCluster : public DeserializationCluster {
#if !defined(DART_PRECOMPILED_RUNTIME)
if (kind != Snapshot::kFullAOT) {
func->untag()->positional_parameter_names_ =
static_cast<ArrayPtr>(d->ReadRef());
func->untag()->token_pos_ = d->ReadTokenPosition();
func->untag()->end_token_pos_ = d->ReadTokenPosition();
func->untag()->kernel_offset_ = d->Read<uint32_t>();
@ -3971,7 +3978,8 @@ class FunctionTypeSerializationCluster
ASSERT_EQUAL(type->untag()->type_state_, combined >> kNullabilityBitSize);
ASSERT_EQUAL(type->untag()->nullability_, combined & kNullabilityBitMask);
s->Write<uint8_t>(combined);
s->Write<uint32_t>(type->untag()->packed_fields_);
s->Write<uint32_t>(type->untag()->packed_parameter_counts_);
s->Write<uint16_t>(type->untag()->packed_type_parameter_counts_);
}
};
#endif // !DART_PRECOMPILED_RUNTIME
@ -4001,7 +4009,8 @@ class FunctionTypeDeserializationCluster
const uint8_t combined = d->Read<uint8_t>();
type->untag()->type_state_ = combined >> kNullabilityBitSize;
type->untag()->nullability_ = combined & kNullabilityBitMask;
type->untag()->packed_fields_ = d->Read<uint32_t>();
type->untag()->packed_parameter_counts_ = d->Read<uint32_t>();
type->untag()->packed_type_parameter_counts_ = d->Read<uint16_t>();
}
}
@ -6255,6 +6264,10 @@ bool Serializer::CreateArtificialNodeIfNeeded(ObjectPtr obj) {
name = String::ToCString(thread(), lib->untag()->url());
break;
}
case kFunctionTypeCid: {
type = "FunctionType";
break;
};
default:
FATAL("Request to create artificial node for object with cid %d", cid);
}

View file

@ -151,6 +151,22 @@ struct RetainReasons : public AllStatic {
static constexpr const char* kEntryPointPragma = "entry point pragma";
// The function is a target of FFI callback.
static constexpr const char* kFfiCallbackTarget = "ffi callback target";
// The signature is used in a closure function.
static constexpr const char* kClosureSignature = "closure signature";
// The signature is used in an FFI trampoline.
static constexpr const char* kFfiTrampolineSignature =
"FFI trampoline signature";
// The signature is used in a native function.
static constexpr const char* kNativeSignature = "native function signature";
// The signature has required named parameters.
static constexpr const char* kRequiredNamedParameters =
"signature has required named parameters";
// The signature is used in a function that has dynamic calls.
static constexpr const char* kDynamicallyCalledSignature =
"signature of dynamically called function";
// The signature is used in a function with an entry point pragma.
static constexpr const char* kEntryPointPragmaSignature =
"signature of entry point function";
};
class RetainedReasonsWriter : public ValueObject {
@ -267,6 +283,9 @@ class RetainedReasonsWriter : public ValueObject {
if (key->IsClass()) {
return Utils::WordHash(Class::Cast(*key).id());
}
if (key->IsAbstractType()) {
return AbstractType::Cast(*key).Hash();
}
return Utils::WordHash(key->GetClassId());
}
@ -286,6 +305,11 @@ class RetainedReasonsWriter : public ValueObject {
writer_.PrintProperty("kind",
UntaggedFunction::KindToCString(function.kind()));
return;
} else if (obj.IsFunctionType()) {
writer_.PrintProperty("type", "FunctionType");
const auto& sig = FunctionType::Cast(obj);
writer_.PrintProperty("name", sig.ToCString());
return;
}
FATAL("Unexpected object %s", obj.ToCString());
}
@ -375,6 +399,8 @@ Precompiler::Precompiler(Thread* thread)
sent_selectors_(),
functions_called_dynamically_(
HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
functions_with_entry_point_pragmas_(
HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
seen_functions_(HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
possibly_retained_functions_(
HashTables::New<FunctionSet>(/*initial_capacity=*/1024)),
@ -401,6 +427,7 @@ Precompiler::Precompiler(Thread* thread)
Precompiler::~Precompiler() {
// We have to call Release() in DEBUG mode.
functions_called_dynamically_.Release();
functions_with_entry_point_pragmas_.Release();
seen_functions_.Release();
possibly_retained_functions_.Release();
functions_to_retain_.Release();
@ -1501,6 +1528,7 @@ void Precompiler::AddAnnotatedRoots() {
if (type == EntryPointPragma::kAlways ||
type == EntryPointPragma::kCallOnly) {
functions_with_entry_point_pragmas_.Insert(function);
AddFunction(function, RetainReasons::kEntryPointPragma);
}
@ -1509,6 +1537,7 @@ void Precompiler::AddAnnotatedRoots() {
function.kind() != UntaggedFunction::kConstructor &&
!function.IsSetterFunction()) {
function2 = function.ImplicitClosureFunction();
functions_with_entry_point_pragmas_.Insert(function2);
AddFunction(function2, RetainReasons::kEntryPointPragma);
}
@ -1521,6 +1550,7 @@ void Precompiler::AddAnnotatedRoots() {
for (intptr_t i = 0; i < implicit_getters.Length(); ++i) {
field ^= implicit_getters.At(i);
if (function.accessor_field() == field.ptr()) {
functions_with_entry_point_pragmas_.Insert(function);
AddFunction(function, RetainReasons::kImplicitGetter);
}
}
@ -1530,6 +1560,7 @@ void Precompiler::AddAnnotatedRoots() {
for (intptr_t i = 0; i < implicit_setters.Length(); ++i) {
field ^= implicit_setters.At(i);
if (function.accessor_field() == field.ptr()) {
functions_with_entry_point_pragmas_.Insert(function);
AddFunction(function, RetainReasons::kImplicitSetter);
}
}
@ -1539,6 +1570,7 @@ void Precompiler::AddAnnotatedRoots() {
for (intptr_t i = 0; i < implicit_static_getters.Length(); ++i) {
field ^= implicit_static_getters.At(i);
if (function.accessor_field() == field.ptr()) {
functions_with_entry_point_pragmas_.Insert(function);
AddFunction(function, RetainReasons::kImplicitStaticGetter);
}
}
@ -2051,6 +2083,51 @@ void Precompiler::DropFunctions() {
Code& code = Code::Handle(Z);
Object& owner = Object::Handle(Z);
GrowableObjectArray& retained_functions = GrowableObjectArray::Handle(Z);
auto& sig = FunctionType::Handle(Z);
auto& ref = Object::Handle(Z);
auto trim_function = [&](const Function& function) {
sig = function.signature();
// In the AOT runtime, most calls are direct or through the dispatch table,
// not resolved via dynamic lookup. Thus, we only need to retain the
// function signature in the following cases:
if (function.IsClosureFunction()) {
// Dynamic calls to closures go through dynamic closure call dispatchers,
// which need the signature.
return AddRetainReason(sig, RetainReasons::kClosureSignature);
}
if (function.IsFfiTrampoline()) {
// FFI trampolines may be dynamically called.
return AddRetainReason(sig, RetainReasons::kFfiTrampolineSignature);
}
if (function.is_native()) {
return AddRetainReason(sig, RetainReasons::kNativeSignature);
}
if (function.HasRequiredNamedParameters()) {
// Required named parameters must be checked, so a NoSuchMethod exception
// can be thrown if they are not provided.
return AddRetainReason(sig, RetainReasons::kRequiredNamedParameters);
}
if (functions_called_dynamically_.ContainsKey(function)) {
// Dynamic resolution of these functions checks for valid arguments.
return AddRetainReason(sig, RetainReasons::kDynamicallyCalledSignature);
}
if (functions_with_entry_point_pragmas_.ContainsKey(function)) {
// Dynamic resolution of entry points also checks for valid arguments.
return AddRetainReason(sig, RetainReasons::kEntryPointPragmaSignature);
}
if (FLAG_trace_precompiler) {
THR_Print("Clearing signature for function %s\n",
function.ToLibNamePrefixedQualifiedCString());
}
// Other functions not listed here may end up in dynamic resolution via
// UnlinkedCalls. However, since it is not a dynamic invocation and has
// been type checked at compile time, we already know the arguments are
// valid. Thus, we can skip checking arguments for functions with dropped
// signatures in ResolveDynamicForReceiverClassWithCustomLookup.
ref = WeakSerializationReference::New(sig, Object::null_function_type());
function.set_signature(ref);
};
auto drop_function = [&](const Function& function) {
if (function.HasCode()) {
@ -2088,6 +2165,7 @@ void Precompiler::DropFunctions() {
function ^= functions.At(j);
function.DropUncompiledImplicitClosureFunction();
if (functions_to_retain_.ContainsKey(function)) {
trim_function(function);
retained_functions.Add(function);
} else {
drop_function(function);
@ -2113,6 +2191,7 @@ void Precompiler::DropFunctions() {
if (functions_to_retain_.ContainsKey(function)) {
retained_functions.Add(name);
retained_functions.Add(desc);
trim_function(function);
retained_functions.Add(function);
} else {
drop_function(function);
@ -2135,6 +2214,7 @@ void Precompiler::DropFunctions() {
retained_functions = GrowableObjectArray::New();
ClosureFunctionsCache::ForAllClosureFunctions([&](const Function& function) {
if (functions_to_retain_.ContainsKey(function)) {
trim_function(function);
retained_functions.Add(function);
} else {
drop_function(function);

View file

@ -376,6 +376,7 @@ class Precompiler : public ValueObject {
const GrowableObjectArray& pending_functions_;
SymbolSet sent_selectors_;
FunctionSet functions_called_dynamically_;
FunctionSet functions_with_entry_point_pragmas_;
FunctionSet seen_functions_;
FunctionSet possibly_retained_functions_;
FieldSet fields_to_retain_;

View file

@ -2801,7 +2801,7 @@ void LoadFieldInstr::InferRange(RangeAnalysis* analysis, Range* range) {
case Slot::Kind::kClosure_instantiator_type_arguments:
case Slot::Kind::kFunction_data:
case Slot::Kind::kFunction_signature:
case Slot::Kind::kFunctionType_parameter_names:
case Slot::Kind::kFunctionType_named_parameter_names:
case Slot::Kind::kFunctionType_parameter_types:
case Slot::Kind::kFunctionType_type_parameters:
case Slot::Kind::kPointerBase_data_field:

View file

@ -226,7 +226,7 @@ bool Slot::IsImmutableLengthSlot() const {
case Slot::Kind::kDartField:
case Slot::Kind::kFunction_data:
case Slot::Kind::kFunction_signature:
case Slot::Kind::kFunctionType_parameter_names:
case Slot::Kind::kFunctionType_named_parameter_names:
case Slot::Kind::kFunctionType_parameter_types:
case Slot::Kind::kFunctionType_type_parameters:
case Slot::Kind::kPointerBase_data_field:

View file

@ -59,9 +59,9 @@ class ParsedFunction;
FINAL) \
V(Closure, UntaggedClosure, delayed_type_arguments, TypeArguments, FINAL) \
V(Closure, UntaggedClosure, function_type_arguments, TypeArguments, FINAL) \
V(Type, UntaggedType, arguments, TypeArguments, FINAL) \
V(FunctionType, UntaggedFunctionType, type_parameters, TypeParameters, \
FINAL) \
V(Type, UntaggedType, arguments, TypeArguments, FINAL) \
V(TypeParameters, UntaggedTypeParameters, flags, Array, FINAL) \
V(TypeParameters, UntaggedTypeParameters, bounds, TypeArguments, FINAL) \
V(TypeParameters, UntaggedTypeParameters, defaults, TypeArguments, FINAL) \
@ -87,7 +87,7 @@ class ParsedFunction;
V(Closure, UntaggedClosure, context, Context, FINAL) \
V(Closure, UntaggedClosure, hash, Context, VAR) \
V(Function, UntaggedFunction, data, Dynamic, FINAL) \
V(FunctionType, UntaggedFunctionType, parameter_names, Array, FINAL) \
V(FunctionType, UntaggedFunctionType, named_parameter_names, Array, FINAL) \
V(FunctionType, UntaggedFunctionType, parameter_types, Array, FINAL) \
V(GrowableObjectArray, UntaggedGrowableObjectArray, length, Smi, VAR) \
V(GrowableObjectArray, UntaggedGrowableObjectArray, data, Array, VAR) \
@ -145,7 +145,10 @@ class ParsedFunction;
V(Function, UntaggedFunction, entry_point, Uword, FINAL) \
V(Function, UntaggedFunction, kind_tag, Uint32, FINAL) \
V(Function, UntaggedFunction, packed_fields, Uint32, FINAL) \
V(FunctionType, UntaggedFunctionType, packed_fields, Uint32, FINAL) \
V(FunctionType, UntaggedFunctionType, packed_parameter_counts, Uint32, \
FINAL) \
V(FunctionType, UntaggedFunctionType, packed_type_parameter_counts, Uint16, \
FINAL) \
V(Pointer, UntaggedPointer, data_field, FfiIntPtr, FINAL) \
V(TypedDataBase, UntaggedTypedDataBase, data_field, IntPtr, VAR) \
V(TypeParameter, UntaggedTypeParameter, flags, Uint8, FINAL)

View file

@ -32,28 +32,27 @@ FunctionPtr TrampolineFunction(const FunctionType& dart_signature,
/*is_native=*/false, owner_class,
TokenPosition::kMinSource));
function.set_is_debuggable(false);
function.set_num_fixed_parameters(dart_signature.num_fixed_parameters());
// Trampolines have no optional arguments.
const intptr_t num_fixed = dart_signature.num_fixed_parameters();
signature.set_num_fixed_parameters(num_fixed);
signature.set_result_type(
AbstractType::Handle(zone, dart_signature.result_type()));
signature.set_parameter_types(
Array::Handle(zone, dart_signature.parameter_types()));
// The signature function won't have any names for the parameters. We need to
// assign unique names for scope building and error messages.
signature.CreateNameArrayIncludingFlags(Heap::kOld);
const intptr_t num_params = dart_signature.num_fixed_parameters();
for (intptr_t i = 0; i < num_params; ++i) {
if (i == 0) {
name = Symbols::ClosureParameter().ptr();
} else {
// Create unique names for the parameters, as they are used in scope building
// and error messages.
if (num_fixed > 0) {
function.CreateNameArray();
function.SetParameterNameAt(0, Symbols::ClosureParameter());
for (intptr_t i = 1; i < num_fixed; i++) {
name = Symbols::NewFormatted(thread, ":ffi_param%" Pd, i);
function.SetParameterNameAt(i, name);
}
signature.SetParameterNameAt(i, name);
}
signature.FinalizeNameArrays(function);
function.SetFfiCSignature(c_signature);
signature ^= ClassFinalizer::FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
function.SetFfiIsLeaf(is_leaf);

View file

@ -28,15 +28,15 @@ FunctionPtr NativeCallbackFunction(const FunctionType& c_signature,
String::Handle(zone, dart_target.name())));
const Library& lib = Library::Handle(zone, Library::FfiLibrary());
const Class& owner_class = Class::Handle(zone, lib.toplevel_class());
const Function& function =
Function::Handle(zone, Function::New(Object::null_function_type(), name,
UntaggedFunction::kFfiTrampoline,
/*is_static=*/true,
/*is_const=*/false,
/*is_abstract=*/false,
/*is_external=*/false,
/*is_native=*/false, owner_class,
TokenPosition::kNoSource));
auto& signature = FunctionType::Handle(zone, FunctionType::New());
const Function& function = Function::Handle(
zone, Function::New(signature, name, UntaggedFunction::kFfiTrampoline,
/*is_static=*/true,
/*is_const=*/false,
/*is_abstract=*/false,
/*is_external=*/false,
/*is_native=*/false, owner_class,
TokenPosition::kNoSource));
function.set_is_debuggable(false);
// Set callback-specific fields which the flow-graph builder needs to generate
@ -60,6 +60,16 @@ FunctionPtr NativeCallbackFunction(const FunctionType& c_signature,
function.SetFfiCallbackExceptionalReturn(exceptional_return);
}
// The dart type of the FfiCallback has no arguments or type arguments and
// has a result type of dynamic, as the callback is never invoked via Dart,
// only via native calls that do not use this information. Having no Dart
// arguments ensures the scope builder does not add inappropriate parameter
// variables.
signature.set_result_type(Object::dynamic_type());
// Finalize (and thus canonicalize) the signature.
signature ^= ClassFinalizer::FinalizeType(signature);
function.SetSignature(signature);
return function.ptr();
}

View file

@ -5365,7 +5365,7 @@ Fragment StreamingFlowGraphBuilder::BuildFunctionNode(
// Finalize function type.
FunctionType& signature = FunctionType::Handle(Z, function.signature());
signature ^= ClassFinalizer::FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
ClosureFunctionsCache::AddClosureFunctionLocked(function);
break;

View file

@ -2097,7 +2097,7 @@ struct FlowGraphBuilder::ClosureCallInfo {
LocalVariable* num_opt_params = nullptr;
LocalVariable* num_max_params = nullptr;
LocalVariable* has_named_params = nullptr;
LocalVariable* parameter_names = nullptr;
LocalVariable* named_parameter_names = nullptr;
LocalVariable* parameter_types = nullptr;
LocalVariable* type_parameters = nullptr;
LocalVariable* num_type_parameters = nullptr;
@ -2136,30 +2136,23 @@ Fragment FlowGraphBuilder::TestClosureFunctionNamedParameterRequired(
if (!IG->use_strict_null_safety_checks()) return not_set;
Fragment check_required;
// First, we convert the index to be in terms of the number of optional
// parameters, not total parameters (to calculate the flag index and shift).
// We calculate the index to dereference in the parameter names array.
check_required += LoadLocal(info.vars->current_param_index);
check_required += LoadLocal(info.num_fixed_params);
check_required += SmiBinaryOp(Token::kSUB, /*is_truncating=*/true);
LocalVariable* opt_index = MakeTemporary("opt_index"); // Read-only.
// Next, we calculate the index to dereference in the parameter names array.
check_required += LoadLocal(opt_index);
check_required +=
IntConstant(compiler::target::kNumParameterFlagsPerElementLog2);
check_required += SmiBinaryOp(Token::kSHR);
check_required += LoadLocal(info.num_max_params);
check_required += LoadLocal(info.num_opt_params);
check_required += SmiBinaryOp(Token::kADD);
LocalVariable* flags_index = MakeTemporary("flags_index"); // Read-only.
// Two read-only stack values (opt_index, flag_index) that must be dropped
// One read-only stack value (flag_index) that must be dropped
// after we rejoin at after_check.
JoinEntryInstr* after_check = BuildJoinEntry();
// Now we check to see if the flags index is within the bounds of the
// parameters names array. If not, it cannot be required.
check_required += LoadLocal(flags_index);
check_required += LoadLocal(info.parameter_names);
check_required += LoadLocal(info.named_parameter_names);
check_required += LoadNativeField(Slot::Array_length());
check_required += SmiRelationalOp(Token::kLT);
TargetEntryInstr* valid_index;
@ -2174,11 +2167,11 @@ Fragment FlowGraphBuilder::TestClosureFunctionNamedParameterRequired(
// the flag slots are non-null, so after loading we can immediate check
// the required flag bit for the given named parameter.
check_required.current = valid_index;
check_required += LoadLocal(info.parameter_names);
check_required += LoadLocal(info.named_parameter_names);
check_required += LoadLocal(flags_index);
check_required += LoadIndexed(
kArrayCid, /*index_scale*/ compiler::target::kCompressedWordSize);
check_required += LoadLocal(opt_index);
check_required += LoadLocal(info.vars->current_param_index);
check_required +=
IntConstant(compiler::target::kNumParameterFlagsPerElement - 1);
check_required += SmiBinaryOp(Token::kBIT_AND);
@ -2206,7 +2199,6 @@ Fragment FlowGraphBuilder::TestClosureFunctionNamedParameterRequired(
// After rejoining, drop the introduced temporaries.
check_required.current = after_check;
check_required += DropTemporary(&flags_index);
check_required += DropTemporary(&opt_index);
return check_required;
}
@ -2328,8 +2320,8 @@ Fragment FlowGraphBuilder::BuildClosureCallNamedArgumentsCheck(
// for named parameters. If this changes, we'll need to check each flag
// entry appropriately for any set required bits.
Fragment has_any;
has_any += LoadLocal(info.num_max_params);
has_any += LoadLocal(info.parameter_names);
has_any += LoadLocal(info.num_opt_params);
has_any += LoadLocal(info.named_parameter_names);
has_any += LoadNativeField(Slot::Array_length());
TargetEntryInstr* no_required;
TargetEntryInstr* has_required;
@ -2356,14 +2348,14 @@ Fragment FlowGraphBuilder::BuildClosureCallNamedArgumentsCheck(
check_names += IntConstant(0);
check_names += StoreLocal(info.vars->current_num_processed);
check_names += Drop();
check_names += LoadLocal(info.num_fixed_params);
check_names += IntConstant(0);
check_names += StoreLocal(info.vars->current_param_index);
check_names += Drop();
check_names += Goto(loop);
Fragment loop_check(loop);
loop_check += LoadLocal(info.vars->current_param_index);
loop_check += LoadLocal(info.num_max_params);
loop_check += LoadLocal(info.num_opt_params);
loop_check += SmiRelationalOp(Token::kLT);
TargetEntryInstr* no_more;
TargetEntryInstr* more;
@ -2373,7 +2365,7 @@ Fragment FlowGraphBuilder::BuildClosureCallNamedArgumentsCheck(
Fragment loop_body(more);
// First load the name we need to check against.
loop_body += LoadLocal(info.parameter_names);
loop_body += LoadLocal(info.named_parameter_names);
loop_body += LoadLocal(info.vars->current_param_index);
loop_body += LoadIndexed(
kArrayCid, /*index_scale*/ compiler::target::kCompressedWordSize);
@ -2398,6 +2390,8 @@ Fragment FlowGraphBuilder::BuildClosureCallNamedArgumentsCheck(
// arguments. (No need to check the required bit for provided parameters.)
Fragment matched(match);
matched += LoadLocal(info.vars->current_param_index);
matched += LoadLocal(info.num_fixed_params);
matched += SmiBinaryOp(Token::kADD, /*is_truncating=*/true);
matched += StoreLocal(info.vars->named_argument_parameter_indices.At(i));
matched += Drop();
matched += LoadLocal(info.vars->current_num_processed);
@ -2460,9 +2454,10 @@ Fragment FlowGraphBuilder::BuildClosureCallArgumentsValidCheck(
TargetEntryInstr* not_null;
check_type_args_length += BranchIfNull(&null, &not_null);
check_type_args_length.current = not_null; // Continue in non-error case.
check_type_args_length += LoadLocal(info.type_parameters);
check_type_args_length += LoadNativeField(Slot::TypeParameters_names());
check_type_args_length += LoadNativeField(Slot::Array_length());
check_type_args_length += LoadLocal(info.signature);
check_type_args_length += BuildExtractUnboxedSlotBitFieldIntoSmi<
UntaggedFunctionType::PackedNumTypeParameters>(
Slot::FunctionType_packed_type_parameter_counts());
check_type_args_length += IntConstant(info.descriptor.TypeArgsLen());
TargetEntryInstr* equal;
TargetEntryInstr* not_equal;
@ -2749,13 +2744,13 @@ Fragment FlowGraphBuilder::BuildDynamicClosureCallChecks(
body += LoadLocal(info.signature);
body += BuildExtractUnboxedSlotBitFieldIntoSmi<
FunctionType::PackedNumFixedParameters>(
Slot::FunctionType_packed_fields());
Slot::FunctionType_packed_parameter_counts());
info.num_fixed_params = MakeTemporary("num_fixed_params");
body += LoadLocal(info.signature);
body += BuildExtractUnboxedSlotBitFieldIntoSmi<
FunctionType::PackedNumOptionalParameters>(
Slot::FunctionType_packed_fields());
Slot::FunctionType_packed_parameter_counts());
info.num_opt_params = MakeTemporary("num_opt_params");
body += LoadLocal(info.num_fixed_params);
@ -2766,15 +2761,15 @@ Fragment FlowGraphBuilder::BuildDynamicClosureCallChecks(
body += LoadLocal(info.signature);
body += BuildExtractUnboxedSlotBitFieldIntoSmi<
FunctionType::PackedHasNamedOptionalParameters>(
Slot::FunctionType_packed_fields());
Slot::FunctionType_packed_parameter_counts());
body += IntConstant(0);
body += StrictCompare(Token::kNE_STRICT);
info.has_named_params = MakeTemporary("has_named_params");
body += LoadLocal(info.signature);
body += LoadNativeField(Slot::FunctionType_parameter_names());
info.parameter_names = MakeTemporary("parameter_names");
body += LoadNativeField(Slot::FunctionType_named_parameter_names());
info.named_parameter_names = MakeTemporary("named_parameter_names");
body += LoadLocal(info.signature);
body += LoadNativeField(Slot::FunctionType_parameter_types());
@ -2814,13 +2809,14 @@ Fragment FlowGraphBuilder::BuildDynamicClosureCallChecks(
generic += LoadLocal(info.signature);
generic += BuildExtractUnboxedSlotBitFieldIntoSmi<
UntaggedFunctionType::PackedNumParentTypeArguments>(
Slot::FunctionType_packed_fields());
Slot::FunctionType_packed_type_parameter_counts());
info.num_parent_type_args = MakeTemporary("num_parent_type_args");
// Hoist number of type parameters.
generic += LoadLocal(info.type_parameters);
generic += LoadNativeField(Slot::TypeParameters_names());
generic += LoadNativeField(Slot::Array_length());
generic += LoadLocal(info.signature);
generic += BuildExtractUnboxedSlotBitFieldIntoSmi<
UntaggedFunctionType::PackedNumTypeParameters>(
Slot::FunctionType_packed_type_parameter_counts());
info.num_type_parameters = MakeTemporary("num_type_parameters");
// Hoist type parameter flags.
@ -2877,7 +2873,7 @@ Fragment FlowGraphBuilder::BuildDynamicClosureCallChecks(
body += DropTemporary(&info.instantiator_type_args);
body += DropTemporary(&info.type_parameters);
body += DropTemporary(&info.parameter_types);
body += DropTemporary(&info.parameter_names);
body += DropTemporary(&info.named_parameter_names);
body += DropTemporary(&info.has_named_params);
body += DropTemporary(&info.num_max_params);
body += DropTemporary(&info.num_opt_params);

View file

@ -735,26 +735,25 @@ void TranslationHelper::SetupFieldAccessorFunction(
intptr_t parameter_count = (is_method ? 1 : 0) + (is_setter ? 1 : 0);
const FunctionType& signature = FunctionType::Handle(Z, function.signature());
function.SetNumOptionalParameters(0, false);
function.set_num_fixed_parameters(parameter_count);
signature.SetNumOptionalParameters(0, false);
signature.set_num_fixed_parameters(parameter_count);
if (parameter_count > 0) {
signature.set_parameter_types(
Array::Handle(Z, Array::New(parameter_count, Heap::kOld)));
}
signature.CreateNameArrayIncludingFlags(Heap::kOld);
function.CreateNameArray();
intptr_t pos = 0;
if (is_method) {
signature.SetParameterTypeAt(pos, GetDeclarationType(klass));
signature.SetParameterNameAt(pos, Symbols::This());
function.SetParameterNameAt(pos, Symbols::This());
pos++;
}
if (is_setter) {
signature.SetParameterTypeAt(pos, field_type);
signature.SetParameterNameAt(pos, Symbols::Value());
function.SetParameterNameAt(pos, Symbols::Value());
pos++;
}
signature.FinalizeNameArrays(function);
}
void TranslationHelper::ReportError(const char* format, ...) {
@ -3182,16 +3181,14 @@ void TypeTranslator::BuildFunctionType(bool simple) {
signature.set_parameter_types(Array::Handle(
Z, Array::New(kImplicitClosureParam + all_count, Heap::kOld)));
signature.CreateNameArrayIncludingFlags(Heap::kOld);
signature.CreateNameArrayIncludingFlags();
intptr_t pos = 0;
signature.SetParameterTypeAt(pos, AbstractType::dynamic_type());
signature.SetParameterNameAt(pos, H.DartSymbolPlain("_receiver_"));
++pos;
for (intptr_t i = 0; i < positional_count; ++i, ++pos) {
BuildTypeInternal(); // read ith positional parameter.
signature.SetParameterTypeAt(pos, result_);
signature.SetParameterNameAt(pos, H.DartSymbolPlain("noname"));
}
if (!simple) {
@ -3209,7 +3206,7 @@ void TypeTranslator::BuildFunctionType(bool simple) {
}
}
}
signature.TruncateUnusedParameterFlags();
signature.FinalizeNameArray();
if (!simple) {
helper_->SkipOptionalDartType(); // read typedef type.
@ -3415,10 +3412,7 @@ void TypeTranslator::LoadAndSetupTypeParameters(
parameterized_class.set_type_parameters(type_parameters);
} else {
ASSERT(parameterized_signature.type_parameters() == TypeParameters::null());
parameterized_signature.set_type_parameters(type_parameters);
if (!function.IsNull()) {
function.SetNumTypeParameters(type_parameter_count);
}
parameterized_signature.SetTypeParameters(type_parameters);
}
const Library& lib = Library::Handle(Z, active_class->klass->library());
@ -3658,12 +3652,12 @@ void TypeTranslator::SetupFunctionParameters(
intptr_t named_parameter_count =
total_parameter_count - positional_parameter_count;
function.set_num_fixed_parameters(extra_parameters +
required_parameter_count);
signature.set_num_fixed_parameters(extra_parameters +
required_parameter_count);
if (named_parameter_count > 0) {
function.SetNumOptionalParameters(named_parameter_count, false);
signature.SetNumOptionalParameters(named_parameter_count, false);
} else {
function.SetNumOptionalParameters(
signature.SetNumOptionalParameters(
positional_parameter_count - required_parameter_count, true);
}
intptr_t parameter_count = extra_parameters + total_parameter_count;
@ -3672,19 +3666,20 @@ void TypeTranslator::SetupFunctionParameters(
if (parameter_count > 0) {
signature.set_parameter_types(
Array::Handle(Z, Array::New(parameter_count, Heap::kOld)));
signature.CreateNameArrayIncludingFlags(Heap::kOld);
function.CreateNameArray();
signature.CreateNameArrayIncludingFlags();
if (is_method) {
ASSERT(!klass.IsNull());
signature.SetParameterTypeAt(pos, H.GetDeclarationType(klass));
signature.SetParameterNameAt(pos, Symbols::This());
function.SetParameterNameAt(pos, Symbols::This());
pos++;
} else if (is_closure) {
signature.SetParameterTypeAt(pos, AbstractType::dynamic_type());
signature.SetParameterNameAt(pos, Symbols::ClosureParameter());
function.SetParameterNameAt(pos, Symbols::ClosureParameter());
pos++;
} else if (is_factory) {
signature.SetParameterTypeAt(pos, AbstractType::dynamic_type());
signature.SetParameterNameAt(pos, Symbols::TypeArgumentsParameter());
function.SetParameterNameAt(pos, Symbols::TypeArgumentsParameter());
pos++;
}
} else {
@ -3705,8 +3700,7 @@ void TypeTranslator::SetupFunctionParameters(
}
signature.SetParameterTypeAt(pos, type);
signature.SetParameterNameAt(pos,
H.DartIdentifier(lib, helper.name_index_));
function.SetParameterNameAt(pos, H.DartIdentifier(lib, helper.name_index_));
}
intptr_t named_parameter_count_check =
@ -3729,7 +3723,7 @@ void TypeTranslator::SetupFunctionParameters(
signature.SetIsRequiredAt(pos);
}
}
signature.FinalizeNameArrays(function);
signature.FinalizeNameArray();
function_node_helper->SetJustRead(FunctionNodeHelper::kNamedParameters);

View file

@ -418,7 +418,8 @@ ScopeBuildingResult* ScopeBuilder::BuildScopes() {
AbstractType::ZoneHandle(Z, function.IsFfiTrampoline()
? function.ParameterTypeAt(i)
: Object::dynamic_type().ptr()));
scope_->InsertParameterAt(i, variable);
bool added = scope_->InsertParameterAt(i, variable);
ASSERT(added);
}
break;
}

View file

@ -699,8 +699,9 @@ class FunctionType : public AllStatic {
public:
static word hash_offset();
static word type_state_offset();
static word packed_fields_offset();
static word parameter_names_offset();
static word packed_parameter_counts_offset();
static word packed_type_parameter_counts_offset();
static word named_parameter_names_offset();
static word parameter_types_offset();
static word type_parameters_offset();
static word nullability_offset();

View file

@ -19,7 +19,7 @@
#if defined(TARGET_ARCH_ARM) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
76;
72;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 16;
static constexpr dart::compiler::target::word Array_elements_start_offset = 12;
@ -159,14 +159,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
24;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 54;
static constexpr dart::compiler::target::word Function_code_offset = 36;
static constexpr dart::compiler::target::word Function_data_offset = 28;
static constexpr dart::compiler::target::word Function_code_offset = 32;
static constexpr dart::compiler::target::word Function_data_offset = 24;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
4, 8};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 64;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
68;
static constexpr dart::compiler::target::word Function_signature_offset = 24;
83;
static constexpr dart::compiler::target::word Function_signature_offset = 20;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
4;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -419,11 +419,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 24;
static constexpr dart::compiler::target::word Type_nullability_offset = 25;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 32;
FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 24;
FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -557,7 +559,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_X64) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
116;
112;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
@ -699,14 +701,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
48;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 82;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 90;
static constexpr dart::compiler::target::word Function_code_offset = 72;
static constexpr dart::compiler::target::word Function_data_offset = 56;
static constexpr dart::compiler::target::word Function_code_offset = 64;
static constexpr dart::compiler::target::word Function_data_offset = 48;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 104;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
108;
static constexpr dart::compiler::target::word Function_signature_offset = 48;
123;
static constexpr dart::compiler::target::word Function_signature_offset = 40;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -964,11 +966,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 48;
static constexpr dart::compiler::target::word Type_nullability_offset = 49;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 64;
FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 48;
FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -1104,7 +1108,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_IA32) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
76;
72;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 16;
static constexpr dart::compiler::target::word Array_elements_start_offset = 12;
@ -1244,14 +1248,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
24;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 54;
static constexpr dart::compiler::target::word Function_code_offset = 36;
static constexpr dart::compiler::target::word Function_data_offset = 28;
static constexpr dart::compiler::target::word Function_code_offset = 32;
static constexpr dart::compiler::target::word Function_data_offset = 24;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
4, 8};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 64;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
68;
static constexpr dart::compiler::target::word Function_signature_offset = 24;
83;
static constexpr dart::compiler::target::word Function_signature_offset = 20;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
4;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -1504,11 +1508,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 24;
static constexpr dart::compiler::target::word Type_nullability_offset = 25;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 32;
FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 24;
FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -1639,7 +1645,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_ARM64) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
116;
112;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
@ -1781,14 +1787,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
48;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 82;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 90;
static constexpr dart::compiler::target::word Function_code_offset = 72;
static constexpr dart::compiler::target::word Function_data_offset = 56;
static constexpr dart::compiler::target::word Function_code_offset = 64;
static constexpr dart::compiler::target::word Function_data_offset = 48;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 104;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
108;
static constexpr dart::compiler::target::word Function_signature_offset = 48;
123;
static constexpr dart::compiler::target::word Function_signature_offset = 40;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -2046,11 +2052,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 48;
static constexpr dart::compiler::target::word Type_nullability_offset = 49;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 64;
FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 48;
FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -2187,7 +2195,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_X64) && defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
84;
80;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 16;
@ -2327,14 +2335,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
28;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 50;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 58;
static constexpr dart::compiler::target::word Function_code_offset = 48;
static constexpr dart::compiler::target::word Function_data_offset = 40;
static constexpr dart::compiler::target::word Function_code_offset = 44;
static constexpr dart::compiler::target::word Function_data_offset = 36;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
76;
static constexpr dart::compiler::target::word Function_signature_offset = 36;
91;
static constexpr dart::compiler::target::word Function_signature_offset = 32;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -2592,11 +2600,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 32;
static constexpr dart::compiler::target::word Type_nullability_offset = 33;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 40;
FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 32;
FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -2732,7 +2742,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_ARM64) && defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
84;
80;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 16;
@ -2872,14 +2882,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
28;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 50;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 58;
static constexpr dart::compiler::target::word Function_code_offset = 48;
static constexpr dart::compiler::target::word Function_data_offset = 40;
static constexpr dart::compiler::target::word Function_code_offset = 44;
static constexpr dart::compiler::target::word Function_data_offset = 36;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
76;
static constexpr dart::compiler::target::word Function_signature_offset = 36;
91;
static constexpr dart::compiler::target::word Function_signature_offset = 32;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -3137,11 +3147,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 32;
static constexpr dart::compiler::target::word Type_nullability_offset = 33;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 40;
FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 32;
FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -3280,7 +3292,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_ARM) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
76;
72;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 16;
static constexpr dart::compiler::target::word Array_elements_start_offset = 12;
@ -3415,14 +3427,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
24;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 54;
static constexpr dart::compiler::target::word Function_code_offset = 36;
static constexpr dart::compiler::target::word Function_data_offset = 28;
static constexpr dart::compiler::target::word Function_code_offset = 32;
static constexpr dart::compiler::target::word Function_data_offset = 24;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
4, 8};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 64;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
68;
static constexpr dart::compiler::target::word Function_signature_offset = 24;
83;
static constexpr dart::compiler::target::word Function_signature_offset = 20;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
4;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -3674,11 +3686,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 24;
static constexpr dart::compiler::target::word Type_nullability_offset = 25;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 32;
FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 24;
FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -3812,7 +3826,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_X64) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
116;
112;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
@ -3949,14 +3963,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
48;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 82;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 90;
static constexpr dart::compiler::target::word Function_code_offset = 72;
static constexpr dart::compiler::target::word Function_data_offset = 56;
static constexpr dart::compiler::target::word Function_code_offset = 64;
static constexpr dart::compiler::target::word Function_data_offset = 48;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 104;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
108;
static constexpr dart::compiler::target::word Function_signature_offset = 48;
123;
static constexpr dart::compiler::target::word Function_signature_offset = 40;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -4213,11 +4227,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 48;
static constexpr dart::compiler::target::word Type_nullability_offset = 49;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 64;
FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 48;
FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -4353,7 +4369,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_IA32) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
76;
72;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 16;
static constexpr dart::compiler::target::word Array_elements_start_offset = 12;
@ -4488,14 +4504,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
24;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 54;
static constexpr dart::compiler::target::word Function_code_offset = 36;
static constexpr dart::compiler::target::word Function_data_offset = 28;
static constexpr dart::compiler::target::word Function_code_offset = 32;
static constexpr dart::compiler::target::word Function_data_offset = 24;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
4, 8};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 64;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
68;
static constexpr dart::compiler::target::word Function_signature_offset = 24;
83;
static constexpr dart::compiler::target::word Function_signature_offset = 20;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
4;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -4747,11 +4763,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 24;
static constexpr dart::compiler::target::word Type_nullability_offset = 25;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 32;
FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 24;
FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -4882,7 +4900,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_ARM64) && !defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
116;
112;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
@ -5019,14 +5037,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
48;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 82;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 90;
static constexpr dart::compiler::target::word Function_code_offset = 72;
static constexpr dart::compiler::target::word Function_data_offset = 56;
static constexpr dart::compiler::target::word Function_code_offset = 64;
static constexpr dart::compiler::target::word Function_data_offset = 48;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 104;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
108;
static constexpr dart::compiler::target::word Function_signature_offset = 48;
123;
static constexpr dart::compiler::target::word Function_signature_offset = 40;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -5283,11 +5301,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 48;
static constexpr dart::compiler::target::word Type_nullability_offset = 49;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 64;
FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 48;
FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -5424,7 +5444,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_X64) && defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
84;
80;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 16;
@ -5559,14 +5579,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
28;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 50;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 58;
static constexpr dart::compiler::target::word Function_code_offset = 48;
static constexpr dart::compiler::target::word Function_data_offset = 40;
static constexpr dart::compiler::target::word Function_code_offset = 44;
static constexpr dart::compiler::target::word Function_data_offset = 36;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
76;
static constexpr dart::compiler::target::word Function_signature_offset = 36;
91;
static constexpr dart::compiler::target::word Function_signature_offset = 32;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -5823,11 +5843,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 32;
static constexpr dart::compiler::target::word Type_nullability_offset = 33;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 40;
FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 32;
FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -5963,7 +5985,7 @@ static constexpr dart::compiler::target::word
#if defined(TARGET_ARCH_ARM64) && defined(DART_COMPRESSED_POINTERS)
static constexpr dart::compiler::target::word Function_usage_counter_offset =
84;
80;
static constexpr dart::compiler::target::word
ICData_receivers_static_type_offset = 32;
static constexpr dart::compiler::target::word Array_elements_start_offset = 16;
@ -6098,14 +6120,14 @@ static constexpr dart::compiler::target::word Field_guarded_list_length_offset =
28;
static constexpr dart::compiler::target::word Field_is_nullable_offset = 50;
static constexpr dart::compiler::target::word Field_kind_bits_offset = 58;
static constexpr dart::compiler::target::word Function_code_offset = 48;
static constexpr dart::compiler::target::word Function_data_offset = 40;
static constexpr dart::compiler::target::word Function_code_offset = 44;
static constexpr dart::compiler::target::word Function_data_offset = 36;
static constexpr dart::compiler::target::word Function_entry_point_offset[] = {
8, 16};
static constexpr dart::compiler::target::word Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word Function_packed_fields_offset =
76;
static constexpr dart::compiler::target::word Function_signature_offset = 36;
91;
static constexpr dart::compiler::target::word Function_signature_offset = 32;
static constexpr dart::compiler::target::word FutureOr_type_arguments_offset =
8;
static constexpr dart::compiler::target::word GrowableObjectArray_data_offset =
@ -6362,11 +6384,13 @@ static constexpr dart::compiler::target::word Type_type_state_offset = 32;
static constexpr dart::compiler::target::word Type_nullability_offset = 33;
static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
FunctionType_packed_fields_offset = 40;
FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
FunctionType_parameter_names_offset = 32;
FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -6656,15 +6680,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 24;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 42;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 46;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 36;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 28;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 32;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {4, 8};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 44;
AOT_Function_packed_fields_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
24;
20;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
@ -6948,11 +6972,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 24;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 25;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 32;
AOT_FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 24;
AOT_FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -7034,7 +7060,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 48;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 48;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 44;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 8;
@ -7261,15 +7287,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 48;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 74;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 78;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 72;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 56;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 80;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 84;
AOT_Function_packed_fields_offset = 76;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
48;
40;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -7554,11 +7580,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 64;
AOT_FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 48;
AOT_FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -7642,7 +7670,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
72;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -7872,15 +7900,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 48;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 74;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 78;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 72;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 56;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 80;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 84;
AOT_Function_packed_fields_offset = 76;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
48;
40;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -8165,11 +8193,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 64;
AOT_FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 48;
AOT_FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -8254,7 +8284,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
72;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -8480,15 +8510,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 28;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 50;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 48;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 56;
AOT_Function_packed_fields_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
36;
32;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -8773,11 +8803,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 40;
AOT_FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 32;
AOT_FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -8861,7 +8893,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -9087,15 +9119,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 28;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 50;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 48;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 56;
AOT_Function_packed_fields_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
36;
32;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -9380,11 +9412,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 40;
AOT_FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 32;
AOT_FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -9469,7 +9503,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -9692,15 +9726,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 24;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 42;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 46;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 36;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 28;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 32;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {4, 8};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 44;
AOT_Function_packed_fields_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
24;
20;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
@ -9982,11 +10016,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 24;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 25;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 32;
AOT_FunctionType_packed_parameter_counts_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 20;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 24;
AOT_FunctionType_named_parameter_names_offset = 24;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
@ -10068,7 +10104,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 48;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 48;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 44;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 8;
@ -10290,15 +10326,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 48;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 74;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 78;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 72;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 56;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 80;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 84;
AOT_Function_packed_fields_offset = 76;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
48;
40;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -10581,11 +10617,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 64;
AOT_FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 48;
AOT_FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -10669,7 +10707,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
72;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -10894,15 +10932,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 48;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 74;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 78;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 72;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 56;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 80;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 84;
AOT_Function_packed_fields_offset = 76;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
48;
40;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -11185,11 +11223,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 64;
AOT_FunctionType_packed_parameter_counts_offset = 64;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 68;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 48;
AOT_FunctionType_named_parameter_names_offset = 48;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
@ -11274,7 +11314,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
72;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -11495,15 +11535,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 28;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 50;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 48;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 56;
AOT_Function_packed_fields_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
36;
32;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -11786,11 +11826,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 40;
AOT_FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 32;
AOT_FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -11874,7 +11916,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
@ -12095,15 +12137,15 @@ static constexpr dart::compiler::target::word
AOT_Field_guarded_list_length_offset = 28;
static constexpr dart::compiler::target::word AOT_Field_is_nullable_offset = 46;
static constexpr dart::compiler::target::word AOT_Field_kind_bits_offset = 50;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 48;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 40;
static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
static constexpr dart::compiler::target::word
AOT_Function_entry_point_offset[] = {8, 16};
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
static constexpr dart::compiler::target::word
AOT_Function_packed_fields_offset = 56;
AOT_Function_packed_fields_offset = 52;
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
36;
32;
static constexpr dart::compiler::target::word
AOT_FutureOr_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
@ -12386,11 +12428,13 @@ static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_fields_offset = 40;
AOT_FunctionType_packed_parameter_counts_offset = 40;
static constexpr dart::compiler::target::word
AOT_FunctionType_packed_type_parameter_counts_offset = 44;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
AOT_FunctionType_parameter_names_offset = 32;
AOT_FunctionType_named_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
@ -12475,7 +12519,7 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word AOT_Field_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;

View file

@ -290,9 +290,10 @@
FIELD(Type, type_state_offset) \
FIELD(Type, nullability_offset) \
FIELD(FunctionType, hash_offset) \
FIELD(FunctionType, packed_fields_offset) \
FIELD(FunctionType, packed_parameter_counts_offset) \
FIELD(FunctionType, packed_type_parameter_counts_offset) \
FIELD(FunctionType, parameter_types_offset) \
FIELD(FunctionType, parameter_names_offset) \
FIELD(FunctionType, named_parameter_names_offset) \
FIELD(FunctionType, type_parameters_offset) \
FIELD(TypeParameter, parameterized_class_id_offset) \
FIELD(TypeParameter, index_offset) \

View file

@ -801,7 +801,7 @@ ObjectPtr KernelLoader::LoadExpressionEvaluationFunction(
signature.SetParameterTypeAt(0, Object::dynamic_type());
}
signature ^= ClassFinalizer::FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
return function.ptr();
}
@ -1729,7 +1729,7 @@ void KernelLoader::FinishClassLoading(const Class& klass,
// must be finalized here, since finalization of member types will not be
// called anymore.
signature ^= ClassFinalizer::FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
}
functions_.Add(&function);
@ -2404,14 +2404,13 @@ FunctionPtr CreateFieldInitializerFunction(Thread* thread,
false, // is_native
initializer_owner, TokenPosition::kNoSource));
if (!field.is_static()) {
initializer_fun.set_num_fixed_parameters(1);
signature.set_num_fixed_parameters(1);
signature.set_parameter_types(
Array::Handle(zone, Array::New(1, Heap::kOld)));
signature.CreateNameArrayIncludingFlags(Heap::kOld);
signature.SetParameterTypeAt(
0, AbstractType::Handle(zone, field_owner.DeclarationType()));
signature.SetParameterNameAt(0, Symbols::This());
signature.FinalizeNameArrays(initializer_fun);
initializer_fun.CreateNameArray();
initializer_fun.SetParameterNameAt(0, Symbols::This());
}
signature.set_result_type(AbstractType::Handle(zone, field.type()));
initializer_fun.set_is_reflectable(false);
@ -2423,7 +2422,7 @@ FunctionPtr CreateFieldInitializerFunction(Thread* thread,
initializer_fun.set_is_extension_member(field.is_extension_member());
signature ^= ClassFinalizer::FinalizeType(signature);
initializer_fun.set_signature(signature);
initializer_fun.SetSignature(signature);
field.SetInitializerFunction(initializer_fun);
return initializer_fun.ptr();

View file

@ -205,6 +205,7 @@ static void AppendSubString(BaseTextBuffer* buffer,
#endif
PRECOMPILER_WSR_FIELD_DEFINITION(ClosureData, Function, parent_function)
PRECOMPILER_WSR_FIELD_DEFINITION(Function, FunctionType, signature)
#undef PRECOMPILER_WSR_FIELD_DEFINITION
@ -3647,26 +3648,41 @@ FunctionPtr Class::CreateInvocationDispatcher(
false, // Not native.
*this, TokenPosition::kMinSource));
ArgumentsDescriptor desc(args_desc);
if (desc.TypeArgsLen() > 0) {
const intptr_t type_args_len = desc.TypeArgsLen();
if (type_args_len > 0) {
// Make dispatcher function generic, since type arguments are passed.
invocation.SetNumTypeParameters(desc.TypeArgsLen());
const auto& type_parameters =
TypeParameters::Handle(zone, TypeParameters::New(type_args_len));
// Allow any type, as any type checking is compiled into the dispatcher.
auto& bound = Type::Handle(
zone, IsolateGroup::Current()->object_store()->nullable_object_type());
for (intptr_t i = 0; i < type_args_len; i++) {
// The name of the type parameter does not matter, as a type error using
// it should never be thrown.
type_parameters.SetNameAt(i, Symbols::OptimizedOut());
type_parameters.SetBoundAt(i, bound);
// Type arguments will always be provided, so the default is not used.
type_parameters.SetDefaultAt(i, Object::dynamic_type());
}
signature.SetTypeParameters(type_parameters);
}
invocation.set_num_fixed_parameters(desc.PositionalCount());
invocation.SetNumOptionalParameters(desc.NamedCount(),
false); // Not positional.
signature.set_num_fixed_parameters(desc.PositionalCount());
signature.SetNumOptionalParameters(desc.NamedCount(),
false); // Not positional.
signature.set_parameter_types(
Array::Handle(zone, Array::New(desc.Count(), Heap::kOld)));
signature.CreateNameArrayIncludingFlags(Heap::kOld);
invocation.CreateNameArray();
signature.CreateNameArrayIncludingFlags();
// Receiver.
signature.SetParameterTypeAt(0, Object::dynamic_type());
signature.SetParameterNameAt(0, Symbols::This());
invocation.SetParameterNameAt(0, Symbols::This());
// Remaining positional parameters.
for (intptr_t i = 1; i < desc.PositionalCount(); i++) {
signature.SetParameterTypeAt(i, Object::dynamic_type());
char name[64];
Utils::SNPrint(name, 64, ":p%" Pd, i);
signature.SetParameterNameAt(
invocation.SetParameterNameAt(
i, String::Handle(zone, Symbols::New(thread, name)));
}
@ -3677,7 +3693,7 @@ FunctionPtr Class::CreateInvocationDispatcher(
signature.SetParameterTypeAt(param_index, Object::dynamic_type());
signature.SetParameterNameAt(param_index, param_name);
}
signature.FinalizeNameArrays(invocation);
signature.FinalizeNameArray();
signature.set_result_type(Object::dynamic_type());
invocation.set_is_debuggable(false);
invocation.set_is_visible(false);
@ -3685,7 +3701,7 @@ FunctionPtr Class::CreateInvocationDispatcher(
invocation.set_saved_args_desc(args_desc);
signature ^= ClassFinalizer::FinalizeType(signature);
invocation.set_signature(signature);
invocation.SetSignature(signature);
return invocation.ptr();
}
@ -3718,11 +3734,12 @@ FunctionPtr Function::CreateMethodExtractor(const String& getter_name) const {
// Initialize signature: receiver is a single fixed parameter.
const intptr_t kNumParameters = 1;
extractor.set_num_fixed_parameters(kNumParameters);
extractor.SetNumOptionalParameters(0, false);
signature.set_num_fixed_parameters(kNumParameters);
signature.SetNumOptionalParameters(0, false);
signature.set_parameter_types(Object::extractor_parameter_types());
signature.set_parameter_names(Object::extractor_parameter_names());
extractor.SetParameterNamesFrom(signature);
#if !defined(DART_PRECOMPILED_RUNTIME)
extractor.set_positional_parameter_names(Object::extractor_parameter_names());
#endif
signature.set_result_type(Object::dynamic_type());
extractor.InheritKernelOffsetFrom(*this);
@ -3732,7 +3749,7 @@ FunctionPtr Function::CreateMethodExtractor(const String& getter_name) const {
extractor.set_is_visible(false);
signature ^= ClassFinalizer::FinalizeType(signature);
extractor.set_signature(signature);
extractor.SetSignature(signature);
owner.AddFunction(extractor);
@ -7724,20 +7741,17 @@ void Function::set_native_name(const String& value) const {
set_data(pair);
}
void Function::set_signature(const FunctionType& value) const {
// Signature may be reset to null in aot to save space.
untag()->set_signature(value.ptr());
if (!value.IsNull()) {
ASSERT(NumImplicitParameters() == value.num_implicit_parameters());
if (IsClosureFunction() && value.IsGeneric()) {
const TypeParameters& type_params =
TypeParameters::Handle(value.type_parameters());
const TypeArguments& defaults =
TypeArguments::Handle(type_params.defaults());
auto kind = DefaultTypeArgumentsKindFor(defaults);
ASSERT(kind != DefaultTypeArgumentsKind::kInvalid);
set_default_type_arguments_kind(kind);
}
void Function::SetSignature(const FunctionType& value) const {
set_signature(value);
ASSERT(NumImplicitParameters() == value.num_implicit_parameters());
if (IsClosureFunction() && value.IsGeneric()) {
const TypeParameters& type_params =
TypeParameters::Handle(value.type_parameters());
const TypeArguments& defaults =
TypeArguments::Handle(type_params.defaults());
auto kind = DefaultTypeArgumentsKindFor(defaults);
ASSERT(kind != DefaultTypeArgumentsKind::kInvalid);
set_default_type_arguments_kind(kind);
}
}
@ -7761,9 +7775,8 @@ void FunctionType::set_result_type(const AbstractType& value) const {
}
AbstractTypePtr Function::ParameterTypeAt(intptr_t index) const {
const Array& parameter_types =
Array::Handle(untag()->signature()->untag()->parameter_types());
return AbstractType::RawCast(parameter_types.At(index));
const Array& types = Array::Handle(parameter_types());
return AbstractType::RawCast(types.At(index));
}
AbstractTypePtr FunctionType::ParameterTypeAt(intptr_t index) const {
@ -7778,73 +7791,129 @@ void FunctionType::SetParameterTypeAt(intptr_t index,
parameter_types.SetAt(index, value);
}
void Function::set_parameter_types(const Array& value) const {
ASSERT(value.IsNull() || value.Length() > 0);
untag()->signature()->untag()->set_parameter_types(value.ptr());
}
void FunctionType::set_parameter_types(const Array& value) const {
ASSERT(value.IsNull() || value.Length() > 0);
untag()->set_parameter_types(value.ptr());
}
StringPtr Function::ParameterNameAt(intptr_t index) const {
const Array& parameter_names = Array::Handle(untag()->parameter_names());
return String::RawCast(parameter_names.At(index));
#if defined(DART_PRECOMPILED_RUNTIME)
if (signature() == FunctionType::null()) {
// Without the signature, we're guaranteed not to have any name information.
return Symbols::OptimizedOut().ptr();
}
#endif
const intptr_t num_fixed = num_fixed_parameters();
if (HasOptionalNamedParameters() && index >= num_fixed) {
const Array& parameter_names =
Array::Handle(signature()->untag()->named_parameter_names());
return String::RawCast(parameter_names.At(index - num_fixed));
}
#if defined(DART_PRECOMPILED_RUNTIME)
return Symbols::OptimizedOut().ptr();
#else
const Array& names = Array::Handle(untag()->positional_parameter_names());
return String::RawCast(names.At(index));
#endif
}
void Function::SetParameterNamesFrom(const FunctionType& signature) const {
untag()->set_parameter_names(signature.parameter_names());
void Function::SetParameterNameAt(intptr_t index, const String& value) const {
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
ASSERT(!value.IsNull() && value.IsSymbol());
if (HasOptionalNamedParameters() && index >= num_fixed_parameters()) {
// These should be set on the signature, not the function.
UNREACHABLE();
}
const Array& parameter_names =
Array::Handle(untag()->positional_parameter_names());
parameter_names.SetAt(index, value);
#endif
}
#if !defined(DART_PRECOMPILED_RUNTIME)
void Function::set_positional_parameter_names(const Array& value) const {
ASSERT(value.ptr() == Object::empty_array().ptr() || value.Length() > 0);
untag()->set_positional_parameter_names(value.ptr());
}
#endif
StringPtr FunctionType::ParameterNameAt(intptr_t index) const {
const Array& parameter_names = Array::Handle(untag()->parameter_names());
return String::RawCast(parameter_names.At(index));
const intptr_t num_fixed = num_fixed_parameters();
if (!HasOptionalNamedParameters() || index < num_fixed) {
// The positional parameter names are stored on the function, not here.
UNREACHABLE();
}
const Array& parameter_names =
Array::Handle(untag()->named_parameter_names());
return String::RawCast(parameter_names.At(index - num_fixed));
}
void FunctionType::SetParameterNameAt(intptr_t index,
const String& value) const {
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
ASSERT(!value.IsNull() && value.IsSymbol());
const Array& parameter_names = Array::Handle(untag()->parameter_names());
parameter_names.SetAt(index, value);
const intptr_t num_fixed = num_fixed_parameters();
if (!HasOptionalNamedParameters() || index < num_fixed) {
UNREACHABLE();
}
const Array& parameter_names =
Array::Handle(untag()->named_parameter_names());
parameter_names.SetAt(index - num_fixed, value);
#endif
}
void Function::set_parameter_names(const Array& value) const {
ASSERT(value.IsNull() || value.Length() > 0);
untag()->set_parameter_names(value.ptr());
void FunctionType::set_named_parameter_names(const Array& value) const {
ASSERT(value.ptr() == Object::empty_array().ptr() || value.Length() > 0);
untag()->set_named_parameter_names(value.ptr());
}
void FunctionType::set_parameter_names(const Array& value) const {
ASSERT(value.IsNull() || value.Length() > 0);
untag()->set_parameter_names(value.ptr());
void Function::CreateNameArray(Heap::Space space) const {
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
const intptr_t num_positional_params =
num_fixed_parameters() + NumOptionalPositionalParameters();
if (num_positional_params == 0) {
set_positional_parameter_names(Object::empty_array());
} else {
set_positional_parameter_names(
Array::Handle(Array::New(num_positional_params, space)));
}
#endif
}
void FunctionType::CreateNameArrayIncludingFlags(Heap::Space space) const {
// Currently, we only store flags for named parameters that are required.
const intptr_t num_parameters = NumParameters();
if (num_parameters == 0) return;
intptr_t num_total_slots = num_parameters;
if (HasOptionalNamedParameters()) {
const intptr_t last_index = (NumOptionalNamedParameters() - 1) /
compiler::target::kNumParameterFlagsPerElement;
const intptr_t num_flag_slots = last_index + 1;
num_total_slots += num_flag_slots;
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
const intptr_t num_named_parameters = NumOptionalNamedParameters();
if (num_named_parameters == 0) {
return set_named_parameter_names(Object::empty_array());
}
// Currently, we only store flags for named parameters.
const intptr_t last_index = (num_named_parameters - 1) /
compiler::target::kNumParameterFlagsPerElement;
const intptr_t num_flag_slots = last_index + 1;
intptr_t num_total_slots = num_named_parameters + num_flag_slots;
auto& array = Array::Handle(Array::New(num_total_slots, space));
if (num_total_slots > num_parameters) {
// Set flag slots to Smi 0 before handing off.
auto& empty_flags_smi = Smi::Handle(Smi::New(0));
for (intptr_t i = num_parameters; i < num_total_slots; i++) {
array.SetAt(i, empty_flags_smi);
}
// Set flag slots to Smi 0 before handing off.
auto& empty_flags_smi = Smi::Handle(Smi::New(0));
for (intptr_t i = num_named_parameters; i < num_total_slots; i++) {
array.SetAt(i, empty_flags_smi);
}
set_parameter_names(array);
set_named_parameter_names(array);
#endif
}
intptr_t FunctionType::GetRequiredFlagIndex(intptr_t index,
intptr_t* flag_mask) const {
// If these calculations change, also change
// FlowGraphBuilder::BuildClosureCallHasRequiredNamedArgumentsCheck.
ASSERT(HasOptionalNamedParameters());
ASSERT(flag_mask != nullptr);
ASSERT(index >= num_fixed_parameters());
index -= num_fixed_parameters();
@ -7852,50 +7921,50 @@ intptr_t FunctionType::GetRequiredFlagIndex(intptr_t index,
<< ((static_cast<uintptr_t>(index) %
compiler::target::kNumParameterFlagsPerElement) *
compiler::target::kNumParameterFlags);
return NumParameters() +
return NumOptionalNamedParameters() +
index / compiler::target::kNumParameterFlagsPerElement;
}
bool Function::HasRequiredNamedParameters() const {
const FunctionType& sig = FunctionType::Handle(signature());
#if defined(DART_PRECOMPILED_RUNTIME)
if (sig.IsNull()) {
if (signature() == FunctionType::null()) {
// Signature is not dropped in aot when any named parameter is required.
return false;
}
#else
ASSERT(!sig.IsNull());
#endif
const Array& parameter_names = Array::Handle(sig.parameter_names());
if (!HasOptionalNamedParameters()) {
return false;
}
const FunctionType& sig = FunctionType::Handle(signature());
const Array& parameter_names = Array::Handle(sig.named_parameter_names());
if (parameter_names.IsNull()) {
return false;
}
return parameter_names.Length() > NumParameters();
return parameter_names.Length() > NumOptionalNamedParameters();
}
bool Function::IsRequiredAt(intptr_t index) const {
if (index < num_fixed_parameters() + NumOptionalPositionalParameters()) {
return false;
}
const FunctionType& sig = FunctionType::Handle(signature());
#if defined(DART_PRECOMPILED_RUNTIME)
if (sig.IsNull()) {
if (signature() == FunctionType::null()) {
// Signature is not dropped in aot when any named parameter is required.
return false;
}
#else
ASSERT(!sig.IsNull());
#endif
if (!HasOptionalNamedParameters() || index < num_fixed_parameters()) {
return false;
}
const FunctionType& sig = FunctionType::Handle(signature());
return sig.IsRequiredAt(index);
}
bool FunctionType::IsRequiredAt(intptr_t index) const {
if (index < num_fixed_parameters() + NumOptionalPositionalParameters()) {
if (!HasOptionalNamedParameters() || index < num_fixed_parameters()) {
return false;
}
intptr_t flag_mask;
const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
const Array& parameter_names = Array::Handle(untag()->parameter_names());
const Array& parameter_names =
Array::Handle(untag()->named_parameter_names());
if (flag_index >= parameter_names.Length()) {
return false;
}
@ -7905,56 +7974,40 @@ bool FunctionType::IsRequiredAt(intptr_t index) const {
}
void FunctionType::SetIsRequiredAt(intptr_t index) const {
#if defined(DART_PRECOMPILER_RUNTIME)
UNREACHABLE();
#else
intptr_t flag_mask;
const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
const Array& parameter_names = Array::Handle(untag()->parameter_names());
const Array& parameter_names =
Array::Handle(untag()->named_parameter_names());
ASSERT(flag_index < parameter_names.Length());
const intptr_t flags =
Smi::Value(Smi::RawCast(parameter_names.At(flag_index)));
parameter_names.SetAt(flag_index, Smi::Handle(Smi::New(flags | flag_mask)));
#endif
}
void FunctionType::TruncateUnusedParameterFlags() const {
const intptr_t num_params = NumParameters();
if (num_params == 0) return;
const Array& parameter_names = Array::Handle(untag()->parameter_names());
if (parameter_names.Length() == num_params) {
// No flag slots to truncate.
void FunctionType::FinalizeNameArray() const {
#if defined(DART_PRECOMPILER_RUNTIME)
UNREACHABLE();
#else
const intptr_t num_named_parameters = NumOptionalNamedParameters();
if (num_named_parameters == 0) {
ASSERT(untag()->named_parameter_names() == Object::empty_array().ptr());
return;
}
const Array& parameter_names =
Array::Handle(untag()->named_parameter_names());
// Truncate the parameter names array to remove unused flags from the end.
intptr_t last_used = parameter_names.Length() - 1;
for (; last_used >= num_params; --last_used) {
for (; last_used >= num_named_parameters; --last_used) {
if (Smi::Value(Smi::RawCast(parameter_names.At(last_used))) != 0) {
break;
}
}
parameter_names.Truncate(last_used + 1);
}
void FunctionType::FinalizeNameArrays(const Function& function) const {
TruncateUnusedParameterFlags();
if (!function.IsNull()) {
function.SetParameterNamesFrom(*this);
// Unless the function is a dispatcher, its number of type parameters
// must match the number of type parameters in its signature.
ASSERT(function.kind() == UntaggedFunction::kNoSuchMethodDispatcher ||
function.kind() == UntaggedFunction::kInvokeFieldDispatcher ||
function.kind() == UntaggedFunction::kDynamicInvocationForwarder ||
function.NumTypeParameters() == NumTypeParameters());
}
}
void FunctionType::set_type_parameters(const TypeParameters& value) const {
untag()->set_type_parameters(value.ptr());
}
static void ReportTooManyTypeParameters(const Function& function) {
Report::MessageF(Report::kError, Script::Handle(), TokenPosition::kNoSource,
Report::AtLocation,
"too many type parameters declared in function '%s'",
function.UserVisibleNameCString());
UNREACHABLE();
#endif
}
static void ReportTooManyTypeParameters(const FunctionType& sig) {
@ -7966,39 +8019,24 @@ static void ReportTooManyTypeParameters(const FunctionType& sig) {
UNREACHABLE();
}
void FunctionType::SetTypeParameters(const TypeParameters& value) const {
untag()->set_type_parameters(value.ptr());
const intptr_t count = value.Length();
if (!UntaggedFunctionType::PackedNumTypeParameters::is_valid(count)) {
ReportTooManyTypeParameters(*this);
}
untag()->packed_type_parameter_counts_.Update<PackedNumTypeParameters>(count);
}
void FunctionType::SetNumParentTypeArguments(intptr_t value) const {
ASSERT(value >= 0);
if (!Utils::IsUint(UntaggedFunctionType::kMaxParentTypeArgumentsBits,
value)) {
if (!PackedNumParentTypeArguments::is_valid(value)) {
ReportTooManyTypeParameters(*this);
}
const uint32_t* original = &untag()->packed_fields_;
StoreNonPointer(original,
UntaggedFunctionType::PackedNumParentTypeArguments::update(
value, *original));
}
void Function::SetNumTypeParameters(intptr_t value) const {
ASSERT(value >= 0);
if (!Utils::IsUint(UntaggedFunction::kMaxTypeParametersBits, value)) {
ReportTooManyTypeParameters(*this);
}
untag()->packed_fields_.Update<UntaggedFunction::PackedNumTypeParameters>(
untag()->packed_type_parameter_counts_.Update<PackedNumParentTypeArguments>(
value);
}
intptr_t FunctionType::NumTypeParameters(Thread* thread) const {
if (type_parameters() == TypeParameters::null()) {
return 0;
}
REUSABLE_TYPE_PARAMETERS_HANDLESCOPE(thread);
TypeParameters& type_params = thread->TypeParametersHandle();
type_params = type_parameters();
// We require null to represent a non-generic signature.
ASSERT(type_params.Length() != 0);
return type_params.Length();
}
intptr_t Function::NumParentTypeArguments() const {
// Don't allocate handle in cases where we know it is 0.
if (!IsClosureFunction()) return 0;
@ -8720,7 +8758,7 @@ AbstractTypePtr FunctionType::InstantiateFrom(
num_free_fun_type_params, space, trail);
}
sig_type_params.set_defaults(type_args);
sig.set_type_parameters(sig_type_params);
sig.SetTypeParameters(sig_type_params);
}
}
@ -8756,7 +8794,7 @@ AbstractTypePtr FunctionType::InstantiateFrom(
}
sig.SetParameterTypeAt(i, type);
}
sig.set_parameter_names(Array::Handle(zone, parameter_names()));
sig.set_named_parameter_names(Array::Handle(zone, named_parameter_names()));
if (delete_type_parameters) {
ASSERT(sig.IsInstantiated(kFunctions));
@ -8795,11 +8833,10 @@ bool FunctionType::IsContravariantParameter(intptr_t parameter_position,
bool FunctionType::HasSameTypeParametersAndBounds(const FunctionType& other,
TypeEquality kind,
TrailPtr trail) const {
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
Zone* const zone = Thread::Current()->zone();
const intptr_t num_type_params = NumTypeParameters(thread);
if (num_type_params != other.NumTypeParameters(thread)) {
const intptr_t num_type_params = NumTypeParameters();
if (num_type_params != other.NumTypeParameters()) {
return false;
}
if (num_type_params > 0) {
@ -8996,6 +9033,7 @@ FunctionPtr Function::New(const FunctionType& signature,
TokenPosition token_pos,
Heap::Space space) {
ASSERT(!owner.IsNull());
ASSERT(!signature.IsNull());
const Function& result = Function::Handle(Function::New(space));
result.set_kind_tag(0);
result.set_packed_fields(0);
@ -9051,12 +9089,10 @@ FunctionPtr Function::New(const FunctionType& signature,
if (result.ForceOptimize()) {
result.set_is_debuggable(false);
}
if (!signature.IsNull()) {
signature.set_num_implicit_parameters(result.NumImplicitParameters());
result.set_signature(signature);
} else {
ASSERT(kind == UntaggedFunction::kFfiTrampoline);
}
signature.set_num_implicit_parameters(result.NumImplicitParameters());
result.SetSignature(signature);
NOT_IN_PRECOMPILED(
result.set_positional_parameter_names(Object::empty_array()));
return result.ptr();
}
@ -9159,9 +9195,8 @@ FunctionPtr Function::ImplicitClosureFunction() const {
// This function cannot be local, therefore it has no generic parent.
// Its implicit closure function therefore has no generic parent function
// either. That is why it is safe to simply copy the type parameters.
closure_signature.set_type_parameters(
closure_signature.SetTypeParameters(
TypeParameters::Handle(zone, type_parameters()));
closure_function.SetNumTypeParameters(NumTypeParameters());
// Set closure function's result type to this result type.
closure_signature.set_result_type(AbstractType::Handle(zone, result_type()));
@ -9183,27 +9218,38 @@ FunctionPtr Function::ImplicitClosureFunction() const {
const int num_opt_params = NumOptionalParameters();
const bool has_opt_pos_params = HasOptionalPositionalParameters();
const int num_params = num_fixed_params + num_opt_params;
closure_function.set_num_fixed_parameters(num_fixed_params);
closure_function.SetNumOptionalParameters(num_opt_params, has_opt_pos_params);
const int num_pos_params = has_opt_pos_params ? num_params : num_fixed_params;
closure_signature.set_num_fixed_parameters(num_fixed_params);
closure_signature.SetNumOptionalParameters(num_opt_params,
has_opt_pos_params);
closure_signature.set_parameter_types(
Array::Handle(zone, Array::New(num_params, Heap::kOld)));
closure_signature.CreateNameArrayIncludingFlags(Heap::kOld);
closure_function.CreateNameArray();
closure_signature.CreateNameArrayIncludingFlags();
AbstractType& param_type = AbstractType::Handle(zone);
String& param_name = String::Handle(zone);
// Add implicit closure object parameter.
param_type = Type::DynamicType();
closure_signature.SetParameterTypeAt(0, param_type);
closure_signature.SetParameterNameAt(0, Symbols::ClosureParameter());
for (int i = kClosure; i < num_params; i++) {
closure_function.SetParameterNameAt(0, Symbols::ClosureParameter());
for (int i = kClosure; i < num_pos_params; i++) {
param_type = ParameterTypeAt(has_receiver - kClosure + i);
closure_signature.SetParameterTypeAt(i, param_type);
param_name = ParameterNameAt(has_receiver - kClosure + i);
// Set the name in the function for positional parameters.
closure_function.SetParameterNameAt(i, param_name);
}
for (int i = num_pos_params; i < num_params; i++) {
param_type = ParameterTypeAt(has_receiver - kClosure + i);
closure_signature.SetParameterTypeAt(i, param_type);
param_name = ParameterNameAt(has_receiver - kClosure + i);
// Set the name in the signature for named parameters.
closure_signature.SetParameterNameAt(i, param_name);
if (IsRequiredAt(has_receiver - kClosure + i)) {
closure_signature.SetIsRequiredAt(i);
}
}
closure_signature.FinalizeNameArrays(closure_function);
closure_signature.FinalizeNameArray();
closure_function.InheritKernelOffsetFrom(*this);
// Change covariant parameter types to either Object? for an opted-in implicit
@ -9230,7 +9276,7 @@ FunctionPtr Function::ImplicitClosureFunction() const {
}
ASSERT(!closure_signature.IsFinalized());
closure_signature ^= ClassFinalizer::FinalizeType(closure_signature);
closure_function.set_signature(closure_signature);
closure_function.SetSignature(closure_signature);
set_implicit_closure_function(closure_function);
ASSERT(closure_function.IsImplicitClosureFunction());
return closure_function.ptr();
@ -9247,6 +9293,11 @@ void Function::DropUncompiledImplicitClosureFunction() const {
}
StringPtr Function::InternalSignature() const {
#if defined(DART_PRECOMPILED_RUNTIME)
if (signature() == FunctionType::null()) {
return String::null();
}
#endif
Thread* thread = Thread::Current();
ZoneTextBuffer printer(thread->zone());
const FunctionType& sig = FunctionType::Handle(signature());
@ -9255,6 +9306,11 @@ StringPtr Function::InternalSignature() const {
}
StringPtr Function::UserVisibleSignature() const {
#if defined(DART_PRECOMPILED_RUNTIME)
if (signature() == FunctionType::null()) {
return String::null();
}
#endif
Thread* thread = Thread::Current();
ZoneTextBuffer printer(thread->zone());
const FunctionType& sig = FunctionType::Handle(signature());
@ -10140,8 +10196,14 @@ const char* Function::ToCString() const {
return buffer.buffer();
}
void FunctionType::set_packed_fields(uint32_t packed_fields) const {
StoreNonPointer(&untag()->packed_fields_, packed_fields);
void FunctionType::set_packed_parameter_counts(
uint32_t packed_parameter_counts) const {
untag()->packed_parameter_counts_ = packed_parameter_counts;
}
void FunctionType::set_packed_type_parameter_counts(
uint16_t packed_type_parameter_counts) const {
untag()->packed_type_parameter_counts_ = packed_type_parameter_counts;
}
intptr_t FunctionType::NumParameters() const {
@ -10150,12 +10212,7 @@ intptr_t FunctionType::NumParameters() const {
void FunctionType::set_num_implicit_parameters(intptr_t value) const {
ASSERT(value >= 0);
ASSERT(
Utils::IsUint(UntaggedFunctionType::kMaxImplicitParametersBits, value));
const uint32_t* original = &untag()->packed_fields_;
StoreNonPointer(original,
UntaggedFunctionType::PackedNumImplicitParameters::update(
value, *original));
untag()->packed_parameter_counts_.Update<PackedNumImplicitParameters>(value);
}
ClosureData::DefaultTypeArgumentsKind ClosureData::default_type_arguments_kind()
@ -10195,36 +10252,9 @@ const char* ClosureData::ToCString() const {
return buffer.buffer();
}
void Function::set_num_fixed_parameters(intptr_t value) const {
ASSERT(value >= 0);
ASSERT(Utils::IsUint(UntaggedFunction::kMaxFixedParametersBits, value));
untag()->packed_fields_.Update<UntaggedFunction::PackedNumFixedParameters>(
value);
// Also store in signature.
FunctionType::Handle(signature()).set_num_fixed_parameters(value);
}
void FunctionType::set_num_fixed_parameters(intptr_t value) const {
ASSERT(value >= 0);
ASSERT(Utils::IsUint(UntaggedFunctionType::kMaxFixedParametersBits, value));
const uint32_t* original = &untag()->packed_fields_;
StoreNonPointer(
original,
UntaggedFunctionType::PackedNumFixedParameters::update(value, *original));
}
void Function::SetNumOptionalParameters(intptr_t value,
bool are_optional_positional) const {
ASSERT(Utils::IsUint(UntaggedFunction::kMaxOptionalParametersBits, value));
untag()
->packed_fields_
.Update<UntaggedFunction::PackedHasNamedOptionalParameters>(
(value > 0) && !are_optional_positional);
untag()->packed_fields_.Update<UntaggedFunction::PackedNumOptionalParameters>(
value);
// Also store in signature.
FunctionType::Handle(signature())
.SetNumOptionalParameters(value, are_optional_positional);
untag()->packed_parameter_counts_.Update<PackedNumFixedParameters>(value);
}
void FfiTrampolineData::set_callback_target(const Function& value) const {
@ -10234,15 +10264,9 @@ void FfiTrampolineData::set_callback_target(const Function& value) const {
void FunctionType::SetNumOptionalParameters(
intptr_t value,
bool are_optional_positional) const {
ASSERT(
Utils::IsUint(UntaggedFunctionType::kMaxOptionalParametersBits, value));
uint32_t packed_fields = untag()->packed_fields_;
packed_fields =
UntaggedFunctionType::PackedHasNamedOptionalParameters::update(
(value > 0) && !are_optional_positional, packed_fields);
packed_fields = UntaggedFunctionType::PackedNumOptionalParameters::update(
value, packed_fields);
StoreNonPointer(&untag()->packed_fields_, packed_fields);
untag()->packed_parameter_counts_.Update<PackedHasNamedOptionalParameters>(
(value > 0) && !are_optional_positional);
untag()->packed_parameter_counts_.Update<PackedNumOptionalParameters>(value);
}
FunctionTypePtr FunctionType::New(Heap::Space space) {
@ -10258,10 +10282,10 @@ FunctionTypePtr FunctionType::New(intptr_t num_parent_type_arguments,
Zone* Z = Thread::Current()->zone();
const FunctionType& result =
FunctionType::Handle(Z, FunctionType::New(space));
result.set_packed_fields(0);
result.set_packed_parameter_counts(0);
result.set_packed_type_parameter_counts(0);
result.set_named_parameter_names(Object::empty_array());
result.SetNumParentTypeArguments(num_parent_type_arguments);
result.set_num_fixed_parameters(0);
result.SetNumOptionalParameters(0, false);
result.set_nullability(nullability);
result.SetHash(0);
result.StoreNonPointer(&result.untag()->type_state_,
@ -20712,8 +20736,10 @@ bool FunctionType::IsEquivalent(const Instance& other,
return false;
}
const FunctionType& other_type = FunctionType::Cast(other);
if (packed_fields() != other_type.packed_fields()) {
// Different number of parent type arguments or of parameters.
if ((packed_parameter_counts() != other_type.packed_parameter_counts()) ||
(packed_type_parameter_counts() !=
other_type.packed_type_parameter_counts())) {
// Different number of type parameters or parameters.
return false;
}
Nullability this_type_nullability = nullability();
@ -20773,17 +20799,15 @@ bool FunctionType::IsEquivalent(const Instance& other,
return false;
}
}
// Check the names and types of optional named parameters.
if (!HasOptionalNamedParameters()) {
ASSERT(!other_type.HasOptionalNamedParameters()); // Same packed_fields.
return true;
}
for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
if (ParameterNameAt(i) != other_type.ParameterNameAt(i)) {
return false;
}
if (IsRequiredAt(i) != other_type.IsRequiredAt(i)) {
return false;
if (HasOptionalNamedParameters()) {
ASSERT(other_type.HasOptionalNamedParameters()); // Same packed counts.
for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
if (ParameterNameAt(i) != other_type.ParameterNameAt(i)) {
return false;
}
if (IsRequiredAt(i) != other_type.IsRequiredAt(i)) {
return false;
}
}
}
return true;
@ -21040,7 +21064,8 @@ uword Type::ComputeHash() const {
uword FunctionType::ComputeHash() const {
ASSERT(IsFinalized());
uint32_t result = packed_fields();
uint32_t result =
CombineHashes(packed_parameter_counts(), packed_type_parameter_counts());
// A legacy type should have the same hash as its non-nullable version to be
// consistent with the definition of type equality in Dart code.
Nullability type_nullability = nullability();
@ -21242,7 +21267,7 @@ AbstractTypePtr FunctionType::Canonicalize(Thread* thread,
ASSERT(type.IsOld());
ASSERT(type.IsCanonical());
ASSERT(Array::Handle(zone, parameter_types()).IsOld());
ASSERT(Array::Handle(zone, parameter_names()).IsOld());
ASSERT(Array::Handle(zone, named_parameter_names()).IsOld());
const intptr_t num_params = NumParameters();
for (intptr_t i = 0; i < num_params; i++) {
type = ParameterTypeAt(i);
@ -21291,7 +21316,7 @@ AbstractTypePtr FunctionType::Canonicalize(Thread* thread,
SetHash(0);
}
ASSERT(Array::Handle(zone, parameter_types()).IsOld());
ASSERT(Array::Handle(zone, parameter_names()).IsOld());
ASSERT(Array::Handle(zone, named_parameter_names()).IsOld());
const intptr_t num_params = NumParameters();
for (intptr_t i = 0; i < num_params; i++) {
type = ParameterTypeAt(i);

View file

@ -2587,8 +2587,8 @@ class Function : public Object {
void SetFfiCallbackExceptionalReturn(const Instance& value) const;
// Return the signature of this function.
FunctionTypePtr signature() const { return untag()->signature(); }
void set_signature(const FunctionType& value) const;
PRECOMPILER_WSR_FIELD_DECLARATION(FunctionType, signature);
void SetSignature(const FunctionType& value) const;
static intptr_t signature_offset() {
return OFFSET_OF(UntaggedFunction, signature_);
}
@ -2637,7 +2637,7 @@ class Function : public Object {
void set_native_name(const String& name) const;
AbstractTypePtr result_type() const {
return untag()->signature()->untag()->result_type();
return signature()->untag()->result_type();
}
// The parameters, starting with NumImplicitParameters() parameters which are
@ -2645,33 +2645,37 @@ class Function : public Object {
// Note that type checks exclude implicit parameters.
AbstractTypePtr ParameterTypeAt(intptr_t index) const;
ArrayPtr parameter_types() const {
return untag()->signature()->untag()->parameter_types();
return signature()->untag()->parameter_types();
}
// Parameter names are valid for all valid parameter indices, and are not
// limited to named optional parameters. If there are parameter flags (eg
// required) they're stored at the end of this array, so the size of this
// array isn't necessarily NumParameters(), but the first NumParameters()
// elements are the names.
// Outside of the AOT runtime, functions store the names for their positional
// parameters, and delegate storage of the names for named parameters to
// their signature. These methods handle fetching the name from and
// setting the name to the correct location.
StringPtr ParameterNameAt(intptr_t index) const;
ArrayPtr parameter_names() const { return untag()->parameter_names(); }
void SetParameterNamesFrom(const FunctionType& signature) const;
// Only valid for positional parameter indexes, as this should be called
// explicitly on the signature for named parameters.
void SetParameterNameAt(intptr_t index, const String& value) const;
// Creates an appropriately sized array in the function to hold positional
// parameter names, using the positional parameter count in the signature.
// Uses same default space as Function::New.
void CreateNameArray(Heap::Space space = Heap::kOld) const;
// The required flags are stored at the end of the parameter_names. The flags
// are packed into SMIs, but omitted if they're 0.
// Delegates to the signature, which stores the named parameter flags.
bool IsRequiredAt(intptr_t index) const;
// The formal type parameters, their bounds, and defaults, are specified as an
// object of type TypeParameters stored in the signature.
TypeParametersPtr type_parameters() const {
return untag()->signature()->untag()->type_parameters();
return signature()->untag()->type_parameters();
}
intptr_t NumTypeParameters() const {
return UntaggedFunction::PackedNumTypeParameters::decode(
untag()->packed_fields_);
return signature()
->untag()
->packed_type_parameter_counts_
.Read<UntaggedFunctionType::PackedNumTypeParameters>();
}
void SetNumTypeParameters(intptr_t value) const;
// Return the cumulative number of type arguments in all parent functions.
intptr_t NumParentTypeArguments() const;
@ -2993,33 +2997,38 @@ class Function : public Object {
}
intptr_t num_fixed_parameters() const {
return UntaggedFunction::PackedNumFixedParameters::decode(
untag()->packed_fields_);
return signature()
->untag()
->packed_parameter_counts_
.Read<UntaggedFunctionType::PackedNumFixedParameters>();
}
void set_num_fixed_parameters(intptr_t value) const;
bool HasOptionalParameters() const {
return UntaggedFunction::PackedNumOptionalParameters::decode(
untag()->packed_fields_) > 0;
return signature()
->untag()
->packed_parameter_counts_
.Read<UntaggedFunctionType::PackedNumOptionalParameters>() > 0;
}
bool HasOptionalNamedParameters() const {
return HasOptionalParameters() &&
UntaggedFunction::PackedHasNamedOptionalParameters::decode(
untag()->packed_fields_);
signature()
->untag()
->packed_parameter_counts_
.Read<UntaggedFunctionType::PackedHasNamedOptionalParameters>();
}
bool HasRequiredNamedParameters() const;
bool HasOptionalPositionalParameters() const {
return HasOptionalParameters() && !HasOptionalNamedParameters();
}
intptr_t NumOptionalParameters() const {
return UntaggedFunction::PackedNumOptionalParameters::decode(
untag()->packed_fields_);
return signature()
->untag()
->packed_parameter_counts_
.Read<UntaggedFunctionType::PackedNumOptionalParameters>();
}
intptr_t NumOptionalPositionalParameters() const {
return HasOptionalPositionalParameters() ? NumOptionalParameters() : 0;
}
void SetNumOptionalParameters(intptr_t num_optional_parameters,
bool are_optional_positional) const;
intptr_t NumOptionalNamedParameters() const {
return HasOptionalNamedParameters() ? NumOptionalParameters() : 0;
@ -3781,8 +3790,6 @@ class Function : public Object {
DefaultTypeArgumentsKind DefaultTypeArgumentsKindFor(
const TypeArguments& defaults) const;
void set_parameter_names(const Array& value) const;
void set_parameter_types(const Array& value) const;
void set_ic_data_array(const Array& value) const;
void set_name(const String& value) const;
void set_kind(UntaggedFunction::Kind value) const;
@ -3796,6 +3803,13 @@ class Function : public Object {
void set_num_optional_parameters(intptr_t value) const; // Encoded value.
void set_kind_tag(uint32_t value) const;
#if !defined(DART_PRECOMPILED_RUNTIME)
ArrayPtr positional_parameter_names() const {
return untag()->positional_parameter_names();
}
void set_positional_parameter_names(const Array& value) const;
#endif
ObjectPtr data() const { return untag()->data<std::memory_order_acquire>(); }
void set_data(const Object& value) const;
@ -8365,6 +8379,19 @@ class Type : public AbstractType {
// of parameters, but includes the names of optional named parameters.
class FunctionType : public AbstractType {
public:
// Reexported so they can be used by the flow graph builders.
using PackedNumParentTypeArguments =
UntaggedFunctionType::PackedNumParentTypeArguments;
using PackedNumTypeParameters = UntaggedFunctionType::PackedNumTypeParameters;
using PackedHasNamedOptionalParameters =
UntaggedFunctionType::PackedHasNamedOptionalParameters;
using PackedNumImplicitParameters =
UntaggedFunctionType::PackedNumImplicitParameters;
using PackedNumFixedParameters =
UntaggedFunctionType::PackedNumFixedParameters;
using PackedNumOptionalParameters =
UntaggedFunctionType::PackedNumOptionalParameters;
static intptr_t type_state_offset() {
return OFFSET_OF(UntaggedFunctionType, type_state_);
}
@ -8421,41 +8448,46 @@ class FunctionType : public AbstractType {
// Return the number of type arguments in enclosing signature.
intptr_t NumParentTypeArguments() const {
return UntaggedFunctionType::PackedNumParentTypeArguments::decode(
untag()->packed_fields_);
return untag()
->packed_type_parameter_counts_.Read<PackedNumParentTypeArguments>();
}
void SetNumParentTypeArguments(intptr_t value) const;
intptr_t NumTypeParameters() const {
return PackedNumTypeParameters::decode(
untag()->packed_type_parameter_counts_);
}
intptr_t NumTypeArguments() const {
return NumParentTypeArguments() + NumTypeParameters();
}
intptr_t num_implicit_parameters() const {
return UntaggedFunctionType::PackedNumImplicitParameters::decode(
untag()->packed_fields_);
return untag()
->packed_parameter_counts_.Read<PackedNumImplicitParameters>();
}
void set_num_implicit_parameters(intptr_t value) const;
intptr_t num_fixed_parameters() const {
return UntaggedFunctionType::PackedNumFixedParameters::decode(
untag()->packed_fields_);
return untag()->packed_parameter_counts_.Read<PackedNumFixedParameters>();
}
void set_num_fixed_parameters(intptr_t value) const;
bool HasOptionalParameters() const {
return UntaggedFunctionType::PackedNumOptionalParameters::decode(
untag()->packed_fields_) > 0;
return untag()
->packed_parameter_counts_.Read<PackedNumOptionalParameters>() >
0;
}
bool HasOptionalNamedParameters() const {
return HasOptionalParameters() &&
UntaggedFunctionType::PackedHasNamedOptionalParameters::decode(
untag()->packed_fields_);
untag()
->packed_parameter_counts_
.Read<PackedHasNamedOptionalParameters>();
}
bool HasOptionalPositionalParameters() const {
return HasOptionalParameters() && !HasOptionalNamedParameters();
}
intptr_t NumOptionalParameters() const {
return UntaggedFunctionType::PackedNumOptionalParameters::decode(
untag()->packed_fields_);
return untag()
->packed_parameter_counts_.Read<PackedNumOptionalParameters>();
}
void SetNumOptionalParameters(intptr_t num_optional_parameters,
bool are_optional_positional) const;
@ -8467,21 +8499,21 @@ class FunctionType : public AbstractType {
intptr_t NumOptionalNamedParameters() const {
return HasOptionalNamedParameters() ? NumOptionalParameters() : 0;
}
uint32_t packed_fields() const { return untag()->packed_fields_; }
void set_packed_fields(uint32_t packed_fields) const;
static intptr_t packed_fields_offset() {
return OFFSET_OF(UntaggedFunctionType, packed_fields_);
}
// Reexported so they can be used by the flow graph builders.
using PackedNumParentTypeArguments =
UntaggedFunctionType::PackedNumParentTypeArguments;
using PackedHasNamedOptionalParameters =
UntaggedFunctionType::PackedHasNamedOptionalParameters;
using PackedNumFixedParameters =
UntaggedFunctionType::PackedNumFixedParameters;
using PackedNumOptionalParameters =
UntaggedFunctionType::PackedNumOptionalParameters;
uint32_t packed_parameter_counts() const {
return untag()->packed_parameter_counts_;
}
void set_packed_parameter_counts(uint32_t packed_parameter_counts) const;
static intptr_t packed_parameter_counts_offset() {
return OFFSET_OF(UntaggedFunctionType, packed_parameter_counts_);
}
uint16_t packed_type_parameter_counts() const {
return untag()->packed_type_parameter_counts_;
}
void set_packed_type_parameter_counts(uint16_t packed_parameter_counts) const;
static intptr_t packed_type_parameter_counts_offset() {
return OFFSET_OF(UntaggedFunctionType, packed_type_parameter_counts_);
}
// Return the type parameter declared at index.
TypeParameterPtr TypeParameterAt(
@ -8501,20 +8533,24 @@ class FunctionType : public AbstractType {
static intptr_t parameter_types_offset() {
return OFFSET_OF(UntaggedFunctionType, parameter_types_);
}
// Parameter names are valid for all valid parameter indices, and are not
// limited to named optional parameters. However, they are meaningless after
// canonicalization of the function type. Any particular signature may be
// selected as the canonical represent as the names are not part of the type.
// Parameter names are only stored for named parameters. If there are no named
// parameters, named_parameter_names() is null.
// If there are parameter flags (eg required) they're stored at the end of
// this array, so the size of this array isn't necessarily NumParameters(),
// but the first NumParameters() elements are the names.
StringPtr ParameterNameAt(intptr_t index) const;
void SetParameterNameAt(intptr_t index, const String& value) const;
ArrayPtr parameter_names() const { return untag()->parameter_names(); }
void set_parameter_names(const Array& value) const;
static intptr_t parameter_names_offset() {
return OFFSET_OF(UntaggedFunctionType, parameter_names_);
// this array, so the size of this array isn't necessarily
// NumOptionalNamedParameters(), but the first NumOptionalNamedParameters()
// elements are the names.
ArrayPtr named_parameter_names() const {
return untag()->named_parameter_names();
}
void set_named_parameter_names(const Array& value) const;
static intptr_t named_parameter_names_offset() {
return OFFSET_OF(UntaggedFunctionType, named_parameter_names_);
}
// The index for these operations is the absolute index of the parameter, not
// the index relative to the start of the named parameters (if any).
StringPtr ParameterNameAt(intptr_t index) const;
// Only valid for absolute indexes of named parameters.
void SetParameterNameAt(intptr_t index, const String& value) const;
// The required flags are stored at the end of the parameter_names. The flags
// are packed into SMIs, but omitted if they're 0.
@ -8523,20 +8559,16 @@ class FunctionType : public AbstractType {
// Sets up the signature's parameter name array, including appropriate space
// for any possible parameter flags. This may be an overestimate if some
// parameters don't have flags, and so TruncateUnusedParameterFlags() should
// parameters don't have flags, and so FinalizeNameArray() should
// be called after all parameter flags have been appropriately set.
//
// Assumes that the number of fixed and optional parameters for the signature
// has already been set.
void CreateNameArrayIncludingFlags(Heap::Space space) const;
// has already been set. Uses same default space as FunctionType::New.
void CreateNameArrayIncludingFlags(Heap::Space space = Heap::kOld) const;
// Truncate the parameter names array to remove any unused flag slots. Make
// sure to only do this after calling SetIsRequiredAt as necessary.
void TruncateUnusedParameterFlags() const;
// Finalize the name arrays by truncating the parameter name array and copying
// the names in the given function.
void FinalizeNameArrays(const Function& function) const;
void FinalizeNameArray() const;
// Returns the length of the parameter names array that is required to store
// all the names plus all their flags. This may be an overestimate if some
@ -8548,14 +8580,10 @@ class FunctionType : public AbstractType {
TypeParametersPtr type_parameters() const {
return untag()->type_parameters();
}
void set_type_parameters(const TypeParameters& value) const;
void SetTypeParameters(const TypeParameters& value) const;
static intptr_t type_parameters_offset() {
return OFFSET_OF(UntaggedFunctionType, type_parameters_);
}
intptr_t NumTypeParameters(Thread* thread) const;
intptr_t NumTypeParameters() const {
return NumTypeParameters(Thread::Current());
}
// Returns true if this function type has the same number of type parameters
// with equal bounds as the other function type. Type parameter names and
@ -8565,7 +8593,7 @@ class FunctionType : public AbstractType {
TrailPtr trail = nullptr) const;
// Return true if this function type declares type parameters.
bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; }
bool IsGeneric() const { return NumTypeParameters() > 0; }
// Return true if any enclosing signature of this signature is generic.
bool HasGenericParent() const { return NumParentTypeArguments() > 0; }
@ -11071,9 +11099,16 @@ class Closure : public Instance {
return OFFSET_OF(UntaggedClosure, function_);
}
#if defined(DART_PRECOMPILER)
FunctionTypePtr signature() const {
return FunctionType::RawCast(WeakSerializationReference::Unwrap(
untag()->function()->untag()->signature()));
}
#else
FunctionTypePtr signature() const {
return untag()->function()->untag()->signature();
}
#endif
ContextPtr context() const { return untag()->context(); }
static intptr_t context_offset() {

View file

@ -96,9 +96,9 @@ ISOLATE_UNIT_TEST_CASE(Class) {
const int kNumFixedParameters = 2;
const int kNumOptionalParameters = 3;
const bool kAreOptionalPositional = true;
function.set_num_fixed_parameters(kNumFixedParameters);
function.SetNumOptionalParameters(kNumOptionalParameters,
kAreOptionalPositional);
signature.set_num_fixed_parameters(kNumFixedParameters);
signature.SetNumOptionalParameters(kNumOptionalParameters,
kAreOptionalPositional);
functions.SetAt(1, function);
function_name = Symbols::New(thread, "baz");
@ -2599,7 +2599,7 @@ ISOLATE_UNIT_TEST_CASE(Closure) {
signature = function.signature();
signature.set_result_type(Object::dynamic_type());
signature ^= ClassFinalizer::FinalizeType(signature);
function.set_signature(signature);
function.SetSignature(signature);
const Closure& closure = Closure::Handle(
Closure::New(Object::null_type_arguments(), Object::null_type_arguments(),
function, context));

View file

@ -1105,64 +1105,20 @@ void ProgramVisitor::DedupLists(Zone* zone, IsolateGroup* isolate_group) {
}
void VisitFunction(const Function& function) {
list_ = PrepareParameterNames(function);
list_ = Dedup(list_);
function.set_parameter_names(list_);
// No need to dedup parameter types, as they are stored in the
// canonicalized function type of the function.
// However, the function type of the function is only needed in case of
// recompilation or if available to mirrors, or for copied types
// to lazily generated tear offs. Also avoid attempting to change
// read-only VM objects for de-duplication.
// We cannot check precisely if a function is an entry point here,
// because the metadata has been dropped already. However, we use the
// has_pragma flag on the function as a conservative approximation.
// Resolution requires the number of parameters (no signature needed) and
// their names if any named parameter is required (signature needed).
if (FLAG_precompiled_mode && !function.InVMIsolateHeap() &&
!function.IsClosureFunction() && !function.IsFfiTrampoline() &&
function.name() != Symbols::Call().ptr() && !function.is_native() &&
!function.HasRequiredNamedParameters() &&
!MayBeEntryPoint(function)) {
// Function type not needed for function type tests or resolution.
function.set_signature(Object::null_function_type());
// Don't bother dedupping the positional names in precompiled mode, as
// they'll be dropped anyway.
if (!FLAG_precompiled_mode) {
list_ = function.positional_parameter_names();
if (!list_.IsNull()) {
list_ = Dedup(list_);
function.set_positional_parameter_names(list_);
}
}
}
private:
bool IsCorrectType(const Object& obj) const { return obj.IsArray(); }
ArrayPtr PrepareParameterNames(const Function& function) {
list_ = function.parameter_names();
// Preserve parameter names in case of recompilation for the JIT. Also
// avoid attempting to change read-only VM objects for de-duplication.
if (FLAG_precompiled_mode && !list_.IsNull() &&
!list_.InVMIsolateHeap() && !function.HasOptionalNamedParameters()) {
// Parameter names not needed for resolution.
ASSERT(list_.Length() == function.NumParameters());
for (intptr_t i = 0; i < list_.Length(); i++) {
list_.SetAt(i, Symbols::OptimizedOut());
}
}
return list_.ptr();
}
bool MayBeEntryPoint(const Function& function) {
// Metadata has been dropped already.
// Use presence of pragma as conservative approximation.
if (function.has_pragma()) return true;
auto kind = function.kind();
if ((kind == UntaggedFunction::kImplicitGetter) ||
(kind == UntaggedFunction::kImplicitSetter) ||
(kind == UntaggedFunction::kImplicitStaticGetter) ||
(kind == UntaggedFunction::kFieldInitializer)) {
field_ = function.accessor_field();
if (!field_.IsNull() && field_.has_pragma()) return true;
}
return false;
}
Array& list_;
Field& field_;
};

View file

@ -265,6 +265,8 @@ class UntaggedObject {
public:
Tags() : tags_(0) {}
using ContentType = T;
operator T() const { return tags_.load(std::memory_order_relaxed); }
T operator=(T tags) {
tags_.store(tags, std::memory_order_relaxed);
@ -1360,8 +1362,7 @@ class UntaggedFunction : public UntaggedObject {
VISIT_FROM(name)
// Class or patch class or mixin class where this function is defined.
COMPRESSED_POINTER_FIELD(ObjectPtr, owner)
COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_names)
COMPRESSED_POINTER_FIELD(FunctionTypePtr, signature)
WSR_COMPRESSED_POINTER_FIELD(FunctionTypePtr, signature)
// Additional data specific to the function kind. See Function::set_data()
// for details.
COMPRESSED_POINTER_FIELD(ObjectPtr, data)
@ -1384,52 +1385,21 @@ class UntaggedFunction : public UntaggedObject {
COMPRESSED_POINTER_FIELD(ArrayPtr, ic_data_array);
// Currently active code. Accessed from generated code.
COMPRESSED_POINTER_FIELD(CodePtr, code);
// Unoptimized code, keep it after optimization.
NOT_IN_PRECOMPILED(COMPRESSED_POINTER_FIELD(CodePtr, unoptimized_code));
#if defined(DART_PRECOMPILED_RUNTIME)
VISIT_TO(code);
#else
// Positional parameter names are not needed in the AOT runtime.
COMPRESSED_POINTER_FIELD(ArrayPtr, positional_parameter_names);
// Unoptimized code, keep it after optimization.
COMPRESSED_POINTER_FIELD(CodePtr, unoptimized_code);
VISIT_TO(unoptimized_code);
UnboxedParameterBitmap unboxed_parameters_info_;
TokenPosition token_pos_;
TokenPosition end_token_pos_;
#endif
NOT_IN_PRECOMPILED(UnboxedParameterBitmap unboxed_parameters_info_);
NOT_IN_PRECOMPILED(TokenPosition token_pos_);
NOT_IN_PRECOMPILED(TokenPosition end_token_pos_);
Tags<uint32_t> kind_tag_; // See Function::KindTagBits.
Tags<uint32_t> packed_fields_;
// TODO(regis): Split packed_fields_ in 2 uint32_t if max values are too low.
static constexpr intptr_t kMaxOptimizableBits = 1;
static constexpr intptr_t kMaxTypeParametersBits = 7;
static constexpr intptr_t kMaxHasNamedOptionalParametersBits = 1;
static constexpr intptr_t kMaxFixedParametersBits = 10;
static constexpr intptr_t kMaxOptionalParametersBits = 10;
typedef BitField<uint32_t, bool, 0, kMaxOptimizableBits> PackedOptimizable;
typedef BitField<uint32_t,
uint8_t,
PackedOptimizable::kNextBit,
kMaxTypeParametersBits>
PackedNumTypeParameters;
typedef BitField<uint32_t,
bool,
PackedNumTypeParameters::kNextBit,
kMaxHasNamedOptionalParametersBits>
PackedHasNamedOptionalParameters;
typedef BitField<uint32_t,
uint16_t,
PackedHasNamedOptionalParameters::kNextBit,
kMaxFixedParametersBits>
PackedNumFixedParameters;
typedef BitField<uint32_t,
uint16_t,
PackedNumFixedParameters::kNextBit,
kMaxOptionalParametersBits>
PackedNumOptionalParameters;
static_assert(PackedNumOptionalParameters::kNextBit <=
kBitsPerByte * sizeof(decltype(packed_fields_)),
"UntaggedFunction::packed_fields_ bitfields don't fit.");
#define JIT_FUNCTION_COUNTERS(F) \
F(intptr_t, int32_t, usage_counter) \
@ -1448,7 +1418,14 @@ class UntaggedFunction : public UntaggedObject {
#endif // !defined(DART_PRECOMPILED_RUNTIME)
friend class UntaggedFunctionType; // To use same constants for packing.
Tags<uint8_t> packed_fields_;
static constexpr intptr_t kMaxOptimizableBits = 1;
using PackedOptimizable = BitField<decltype(packed_fields_)::ContentType,
bool,
0,
kMaxOptimizableBits>;
};
class UntaggedClosureData : public UntaggedObject {
@ -2682,49 +2659,46 @@ class UntaggedFunctionType : public UntaggedAbstractType {
COMPRESSED_POINTER_FIELD(TypeParametersPtr, type_parameters)
COMPRESSED_POINTER_FIELD(AbstractTypePtr, result_type)
COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_types)
COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_names);
COMPRESSED_POINTER_FIELD(ArrayPtr, named_parameter_names);
COMPRESSED_POINTER_FIELD(SmiPtr, hash)
VISIT_TO(hash)
uint32_t packed_fields_; // Number of parent type args and own parameters.
Tags<uint32_t> packed_parameter_counts_;
Tags<uint16_t> packed_type_parameter_counts_;
uint8_t type_state_;
uint8_t nullability_;
static constexpr intptr_t kMaxParentTypeArgumentsBits = 8;
static constexpr intptr_t kMaxImplicitParametersBits = 1;
static constexpr intptr_t kMaxHasNamedOptionalParametersBits =
UntaggedFunction::kMaxHasNamedOptionalParametersBits;
static constexpr intptr_t kMaxFixedParametersBits =
UntaggedFunction::kMaxFixedParametersBits;
static constexpr intptr_t kMaxOptionalParametersBits =
UntaggedFunction::kMaxOptionalParametersBits;
// The bit fields are public for use in kernel_to_il.cc.
public:
typedef BitField<uint32_t, uint8_t, 0, kMaxParentTypeArgumentsBits>
PackedNumParentTypeArguments;
typedef BitField<uint32_t,
uint8_t,
PackedNumParentTypeArguments::kNextBit,
kMaxImplicitParametersBits>
PackedNumImplicitParameters;
typedef BitField<uint32_t,
bool,
PackedNumImplicitParameters::kNextBit,
kMaxHasNamedOptionalParametersBits>
PackedHasNamedOptionalParameters;
typedef BitField<uint32_t,
uint16_t,
PackedHasNamedOptionalParameters::kNextBit,
kMaxFixedParametersBits>
PackedNumFixedParameters;
typedef BitField<uint32_t,
uint16_t,
PackedNumFixedParameters::kNextBit,
kMaxOptionalParametersBits>
PackedNumOptionalParameters;
static_assert(PackedNumOptionalParameters::kNextBit <=
kBitsPerByte * sizeof(decltype(packed_fields_)),
"UntaggedFunctionType::packed_fields_ bitfields don't fit.");
// For packed_type_parameter_counts_.
using PackedNumParentTypeArguments =
BitField<decltype(packed_type_parameter_counts_)::ContentType,
uint8_t,
0,
8>;
using PackedNumTypeParameters =
BitField<decltype(packed_type_parameter_counts_)::ContentType,
uint8_t,
PackedNumParentTypeArguments::kNextBit,
8>;
// For packed_parameter_counts_.
using PackedNumImplicitParameters =
BitField<decltype(packed_parameter_counts_)::ContentType, uint8_t, 0, 1>;
using PackedHasNamedOptionalParameters =
BitField<decltype(packed_parameter_counts_)::ContentType,
bool,
PackedNumImplicitParameters::kNextBit,
1>;
using PackedNumFixedParameters =
BitField<decltype(packed_parameter_counts_)::ContentType,
uint16_t,
PackedHasNamedOptionalParameters::kNextBit,
14>;
using PackedNumOptionalParameters =
BitField<decltype(packed_parameter_counts_)::ContentType,
uint16_t,
PackedNumFixedParameters::kNextBit,
14>;
static_assert(PackedNumOptionalParameters::kNextBit <=
compiler::target::kSmiBits,
"In-place mask for number of optional parameters cannot fit in "

View file

@ -28,7 +28,6 @@ namespace dart {
F(PatchClass, library_kernel_data_) \
F(Function, name_) \
F(Function, owner_) \
F(Function, parameter_names_) \
F(Function, signature_) \
F(Function, data_) \
F(Function, ic_data_array_) \
@ -137,7 +136,7 @@ namespace dart {
F(FunctionType, hash_) \
F(FunctionType, result_type_) \
F(FunctionType, parameter_types_) \
F(FunctionType, parameter_names_) \
F(FunctionType, named_parameter_names_) \
F(FunctionType, type_parameters_) \
F(TypeRef, type_test_stub_) \
F(TypeRef, type_) \
@ -214,6 +213,7 @@ namespace dart {
F(Code, deopt_info_array_) \
F(Code, static_calls_target_table_) \
F(ICData, receivers_static_type_) \
F(Function, positional_parameter_names_) \
F(Function, unoptimized_code_) \
F(Field, type_test_cache_)

View file

@ -5537,24 +5537,23 @@ void CreateSpecializedFunction(Thread* thread,
// TODO(zerny): Share these arrays between all irregexp functions.
// TODO(regis): Better, share a common signature.
fn.set_num_fixed_parameters(kParamCount);
signature.set_num_fixed_parameters(kParamCount);
signature.set_parameter_types(
Array::Handle(zone, Array::New(kParamCount, Heap::kOld)));
signature.CreateNameArrayIncludingFlags(Heap::kOld);
fn.CreateNameArray();
signature.SetParameterTypeAt(RegExpMacroAssembler::kParamRegExpIndex,
Object::dynamic_type());
signature.SetParameterNameAt(RegExpMacroAssembler::kParamRegExpIndex,
Symbols::This());
fn.SetParameterNameAt(RegExpMacroAssembler::kParamRegExpIndex,
Symbols::This());
signature.SetParameterTypeAt(RegExpMacroAssembler::kParamStringIndex,
Object::dynamic_type());
signature.SetParameterNameAt(RegExpMacroAssembler::kParamStringIndex,
Symbols::string_param());
fn.SetParameterNameAt(RegExpMacroAssembler::kParamStringIndex,
Symbols::string_param());
signature.SetParameterTypeAt(RegExpMacroAssembler::kParamStartOffsetIndex,
Object::dynamic_type());
signature.SetParameterNameAt(RegExpMacroAssembler::kParamStartOffsetIndex,
Symbols::start_index_param());
fn.SetParameterNameAt(RegExpMacroAssembler::kParamStartOffsetIndex,
Symbols::start_index_param());
signature.set_result_type(Type::Handle(zone, Type::ArrayType()));
signature.FinalizeNameArrays(fn);
// Cache the result.
regexp.set_function(specialization_cid, sticky, fn);

View file

@ -121,6 +121,21 @@ static FunctionPtr ResolveDynamicForReceiverClassWithCustomLookup(
zone, ResolveDynamicAnyArgsWithCustomLookup(
zone, receiver_class, function_name, allow_add, lookup));
#if defined(DART_PRECOMPILED_RUNTIME)
if (!function.IsNull() && function.signature() == FunctionType::null()) {
// FfiTrampolines are the only functions that can still be called
// dynamically without going through a dynamic invocation forwarder.
RELEASE_ASSERT(!Function::IsDynamicInvocationForwarderName(function_name) &&
!function.IsFfiTrampoline());
// The signature for this function was dropped in the precompiler, which
// means it is not a possible target for a dynamic call in the program.
// That means we're resolving an UnlinkedCall for an InstanceCall to
// a known interface. Since there's no overloading in Dart, the type checker
// has already checked the validity of the arguments at compile time.
return function.ptr();
}
#endif
if (function.IsNull() || !function.AreValidArguments(args_desc, NULL)) {
// Return a null function to signal to the upper levels to dispatch to
// "noSuchMethod" function.