Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::Function Class Reference

#include <object.h>

Inheritance diagram for dart::Function:
dart::Object

Classes

struct  AwaiterLink
 
struct  ICDataArrayIndices
 
class  KindBits
 
class  ModifierBits
 
class  RecognizedBits
 

Public Types

enum  StateBits
 
enum  KindTagBits {
  kKindTagPos = 0 , kKindTagSize = 5 , kRecognizedTagPos = kKindTagPos + kKindTagSize , kRecognizedTagSize = 9 ,
  kModifierPos = kRecognizedTagPos + kRecognizedTagSize , kModifierSize = 2 , kLastModifierBitPos = kModifierPos + (kModifierSize - 1) , kNumTagBits
}
 
- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 

Public Member Functions

StringPtr name () const
 
StringPtr UserVisibleName () const
 
const char * UserVisibleNameCString () const
 
const char * NameCString (NameVisibility name_visibility) const
 
void PrintName (const NameFormattingParams &params, BaseTextBuffer *printer) const
 
StringPtr QualifiedScrubbedName () const
 
const char * QualifiedScrubbedNameCString () const
 
StringPtr QualifiedUserVisibleName () const
 
const char * QualifiedUserVisibleNameCString () const
 
virtual StringPtr DictionaryName () const
 
StringPtr GetSource () const
 
void SetFfiCSignature (const FunctionType &sig) const
 
FunctionTypePtr FfiCSignature () const
 
bool FfiCSignatureContainsHandles () const
 
bool FfiCSignatureReturnsStruct () const
 
int32_t FfiCallbackId () const
 
void AssignFfiCallbackId (int32_t callback_id) const
 
bool FfiIsLeaf () const
 
FunctionPtr FfiCallbackTarget () const
 
void SetFfiCallbackTarget (const Function &target) const
 
InstancePtr FfiCallbackExceptionalReturn () const
 
void SetFfiCallbackExceptionalReturn (const Instance &value) const
 
FfiCallbackKind GetFfiCallbackKind () const
 
void SetFfiCallbackKind (FfiCallbackKind value) const
 
 PRECOMPILER_WSR_FIELD_DECLARATION (FunctionType, signature)
 
void SetSignature (const FunctionType &value) const
 
StringPtr InternalSignature () const
 
StringPtr UserVisibleSignature () const
 
bool HasInstantiatedSignature (Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
bool IsPrivate () const
 
ClassPtr Owner () const
 
void set_owner (const Object &value) const
 
ScriptPtr script () const
 
KernelProgramInfoPtr KernelProgramInfo () const
 
ObjectPtr RawOwner () const
 
RegExpPtr regexp () const
 
intptr_t string_specialization_cid () const
 
bool is_sticky_specialization () const
 
void SetRegExpData (const RegExp &regexp, intptr_t string_specialization_cid, bool sticky) const
 
StringPtr native_name () const
 
void set_native_name (const String &name) const
 
InstancePtr GetNativeAnnotation () const
 
bool is_ffi_native () const
 
bool is_old_native () const
 
AbstractTypePtr result_type () const
 
AbstractTypePtr ParameterTypeAt (intptr_t index) const
 
ArrayPtr parameter_types () const
 
StringPtr ParameterNameAt (intptr_t index) const
 
void SetParameterNameAt (intptr_t index, const String &value) const
 
void CreateNameArray (Heap::Space space=Heap::kOld) const
 
bool IsRequiredAt (intptr_t index) const
 
TypeParametersPtr type_parameters () const
 
intptr_t NumTypeParameters () const
 
intptr_t NumParentTypeArguments () const
 
intptr_t NumTypeArguments () const
 
bool IsGeneric () const
 
bool HasGenericParent () const
 
TypeParameterPtr TypeParameterAt (intptr_t index, Nullability nullability=Nullability::kNonNullable) const
 
void InstallOptimizedCode (const Code &code) const
 
void AttachCode (const Code &value) const
 
void SetInstructions (const Code &value) const
 
void SetInstructionsSafe (const Code &value) const
 
void ClearCode () const
 
void ClearCodeSafe () const
 
void SwitchToUnoptimizedCode () const
 
CodePtr EnsureHasCode () const
 
void SwitchToLazyCompiledUnoptimizedCode () const
 
void EnsureHasCompiledUnoptimizedCode () const
 
CodePtr CurrentCode () const
 
bool SafeToClosurize () const
 
CodePtr unoptimized_code () const
 
void set_unoptimized_code (const Code &value) const
 
bool HasCode () const
 
uword entry_point () const
 
virtual uword Hash () const
 
bool HasBreakpoint () const
 
ContextScopePtr context_scope () const
 
void set_context_scope (const ContextScope &value) const
 
AwaiterLink awaiter_link () const
 
void set_awaiter_link (AwaiterLink link) const
 
bool HasAwaiterLink () const
 
FunctionPtr parent_function () const
 
TypeArgumentsPtr DefaultTypeArguments (Zone *zone) const
 
InstantiationMode default_type_arguments_instantiation_mode () const
 
void set_default_type_arguments_instantiation_mode (InstantiationMode value) const
 
FunctionPtr GetOutermostFunction () const
 
void set_extracted_method_closure (const Function &function) const
 
FunctionPtr extracted_method_closure () const
 
void set_saved_args_desc (const Array &array) const
 
ArrayPtr saved_args_desc () const
 
bool HasSavedArgumentsDescriptor () const
 
void set_accessor_field (const Field &value) const
 
FieldPtr accessor_field () const
 
bool IsRegularFunction () const
 
bool IsMethodExtractor () const
 
bool IsNoSuchMethodDispatcher () const
 
bool IsRecordFieldGetter () const
 
bool IsInvokeFieldDispatcher () const
 
bool IsDynamicInvokeFieldDispatcher () const
 
bool IsDynamicClosureCallDispatcher () const
 
bool IsDynamicClosureCallDispatcher (Thread *thread) const
 
bool IsDynamicInvocationForwarder () const
 
bool IsImplicitGetterOrSetter () const
 
bool HasImplicitClosureFunction () const
 
FunctionPtr ImplicitClosureFunction () const
 
void DropUncompiledImplicitClosureFunction () const
 
ClosurePtr ImplicitStaticClosure () const
 
ClosurePtr ImplicitInstanceClosure (const Instance &receiver) const
 
FunctionPtr ImplicitClosureTarget (Zone *zone) const
 
FunctionPtr ForwardingTarget () const
 
void SetForwardingTarget (const Function &target) const
 
UntaggedFunction::Kind kind () const
 
UntaggedFunction::AsyncModifier modifier () const
 
bool IsConstructor () const
 
bool IsGenerativeConstructor () const
 
bool IsImplicitConstructor () const
 
bool IsFactory () const
 
bool HasThisParameter () const
 
bool IsDynamicFunction (bool allow_abstract=false) const
 
bool IsStaticFunction () const
 
bool NeedsTypeArgumentTypeChecks () const
 
bool NeedsArgumentTypeChecks () const
 
bool NeedsMonomorphicCheckedEntry (Zone *zone) const
 
bool HasDynamicCallers (Zone *zone) const
 
bool PrologueNeedsArgumentsDescriptor () const
 
bool MayHaveUncheckedEntryPoint () const
 
TokenPosition token_pos () const
 
void set_token_pos (TokenPosition value) const
 
TokenPosition end_token_pos () const
 
void set_end_token_pos (TokenPosition value) const
 
intptr_t SourceSize () const
 
uint32_t packed_fields () const
 
void set_packed_fields (uint32_t packed_fields) const
 
intptr_t num_fixed_parameters () const
 
bool HasOptionalParameters () const
 
bool HasOptionalNamedParameters () const
 
bool HasRequiredNamedParameters () const
 
bool HasOptionalPositionalParameters () const
 
intptr_t NumOptionalParameters () const
 
intptr_t NumOptionalPositionalParameters () const
 
intptr_t NumOptionalNamedParameters () const
 
intptr_t NumParameters () const
 
intptr_t NumImplicitParameters () const
 
bool MakesCopyOfParameters () const
 
intptr_t MaxNumberOfParametersInRegisters (Zone *zone) const
 
intptr_t kernel_offset () const
 
void set_kernel_offset (intptr_t value) const
 
void InheritKernelOffsetFrom (const Function &src) const
 
void InheritKernelOffsetFrom (const Field &src) const
 
void SetOptimizedInstructionCountClamped (uintptr_t value) const
 
void SetOptimizedCallSiteCountClamped (uintptr_t value) const
 
void SetKernelLibraryAndEvalScript (const Script &script, const class KernelProgramInfo &kernel_program_info, intptr_t index) const
 
intptr_t KernelLibraryOffset () const
 
intptr_t KernelLibraryIndex () const
 
TypedDataViewPtr KernelLibrary () const
 
bool IsOptimizable () const
 
void SetIsOptimizable (bool value) const
 
bool ForceOptimize () const
 
bool IsPreferInline () const
 
bool IsIdempotent () const
 
bool IsCachableIdempotent () const
 
bool RecognizedKindForceOptimize () const
 
bool CanBeInlined () const
 
MethodRecognizer::Kind recognized_kind () const
 
void set_recognized_kind (MethodRecognizer::Kind value) const
 
bool IsRecognized () const
 
bool HasOptimizedCode () const
 
bool AreValidArgumentCounts (intptr_t num_type_arguments, intptr_t num_arguments, intptr_t num_named_arguments, String *error_message) const
 
ObjectPtr DoArgumentTypesMatch (const Array &args, const ArgumentsDescriptor &arg_names) const
 
ObjectPtr DoArgumentTypesMatch (const Array &args, const ArgumentsDescriptor &arg_names, const TypeArguments &instantiator_type_args) const
 
ObjectPtr DoArgumentTypesMatch (const Array &args, const ArgumentsDescriptor &arg_names, const TypeArguments &instantiator_type_args, const TypeArguments &function_type_args) const
 
bool AreValidArguments (intptr_t num_type_arguments, intptr_t num_arguments, const Array &argument_names, String *error_message) const
 
bool AreValidArguments (const ArgumentsDescriptor &args_desc, String *error_message) const
 
const char * ToFullyQualifiedCString () const
 
const char * ToLibNamePrefixedQualifiedCString () const
 
const char * ToQualifiedCString () const
 
void reset_unboxed_parameters_and_return () const
 
void set_unboxed_integer_parameter_at (intptr_t index) const
 
void set_unboxed_double_parameter_at (intptr_t index) const
 
void set_unboxed_integer_return () const
 
void set_unboxed_double_return () const
 
void set_unboxed_record_return () const
 
bool is_unboxed_parameter_at (intptr_t index) const
 
bool is_unboxed_integer_parameter_at (intptr_t index) const
 
bool is_unboxed_double_parameter_at (intptr_t index) const
 
bool has_unboxed_return () const
 
bool has_unboxed_integer_return () const
 
bool has_unboxed_double_return () const
 
bool has_unboxed_record_return () const
 
bool HasUnboxedParameters () const
 
bool HasUnboxedReturnValue () const
 
bool IsDispatcherOrImplicitAccessor () const
 
bool IsGetterFunction () const
 
bool IsImplicitGetterFunction () const
 
bool IsImplicitStaticGetterFunction () const
 
bool IsSetterFunction () const
 
bool IsImplicitSetterFunction () const
 
bool IsFieldInitializer () const
 
bool IsClosureFunction () const
 
bool IsIrregexpFunction () const
 
bool IsImplicitClosureFunction () const
 
bool IsNonImplicitClosureFunction () const
 
bool IsImplicitStaticClosureFunction () const
 
bool IsImplicitInstanceClosureFunction () const
 
bool HasParent () const
 
bool IsLocalFunction () const
 
bool IsFfiCallbackTrampoline () const
 
bool IsFfiCallClosure () const
 
InstancePtr GetFfiCallClosurePragmaValue () const
 
bool IsSuspendableFunction () const
 
bool IsAsyncFunction () const
 
bool IsSyncGenerator () const
 
bool IsAsyncGenerator () const
 
bool IsTypedDataViewFactory () const
 
bool IsUnmodifiableTypedDataViewFactory () const
 
DART_WARN_UNUSED_RESULT ErrorPtr VerifyCallEntryPoint () const
 
DART_WARN_UNUSED_RESULT ErrorPtr VerifyClosurizedEntryPoint () const
 
FunctionPtr CreateMethodExtractor (const String &getter_name) const
 
FunctionPtr GetMethodExtractor (const String &getter_name) const
 
FunctionPtr CreateDynamicInvocationForwarder (const String &mangled_name) const
 
FunctionPtr GetDynamicInvocationForwarder (const String &mangled_name) const
 
int32_t SourceFingerprint () const
 
bool CheckSourceFingerprint (int32_t fp, const char *kind=nullptr) const
 
void SaveICDataMap (const ZoneGrowableArray< const ICData * > &deopt_id_to_ic_data, const Array &edge_counters_array, const Array &coverage_array) const
 
void RestoreICDataMap (ZoneGrowableArray< const ICData * > *deopt_id_to_ic_data, bool clone_ic_data) const
 
ArrayPtr ic_data_array () const
 
void ClearICDataArray () const
 
ICDataPtr FindICData (intptr_t deopt_id) const
 
ArrayPtr GetCoverageArray () const
 
void AddFunctionServiceId (const JSONObject &obj) const
 
void SetDeoptReasonForAll (intptr_t deopt_id, ICData::DeoptReasonId reason)
 
void set_modifier (UntaggedFunction::AsyncModifier value) const
 
void SetUsageCounter (intptr_t value) const
 
bool WasExecuted () const
 
void SetWasExecuted (bool value) const
 
bool is_optimizable () const
 
void set_is_optimizable (bool value) const
 
 COMPILE_ASSERT (MethodRecognizer::kNumRecognizedMethods<(1<< kRecognizedTagSize))
 
 COMPILE_ASSERT (kNumTagBits<=(kBitsPerByte *sizeof(decltype(UntaggedFunction::kind_tag_))))
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static intptr_t signature_offset ()
 
static CodePtr CurrentCodeOf (const FunctionPtr function)
 
static bool HasCode (FunctionPtr function)
 
static intptr_t code_offset ()
 
static uword EntryPointOf (const FunctionPtr function)
 
static intptr_t entry_point_offset (CodeEntryKind entry_kind=CodeEntryKind::kNormal)
 
static intptr_t unchecked_entry_point_offset ()
 
static UntaggedFunction::Kind KindOf (FunctionPtr func)
 
static const char * KindToCString (UntaggedFunction::Kind kind)
 
static constexpr intptr_t maximum_unboxed_parameter_count ()
 
static bool IsImplicitClosureFunction (FunctionPtr func)
 
static bool IsImplicitStaticClosureFunction (FunctionPtr func)
 
static bool IsImplicitInstanceClosureFunction (FunctionPtr func)
 
static bool IsFfiCallbackTrampoline (FunctionPtr function)
 
static intptr_t InstanceSize ()
 
static FunctionPtr New (const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
 
static FunctionPtr NewClosureFunctionWithKind (UntaggedFunction::Kind kind, const String &name, const Function &parent, bool is_static, TokenPosition token_pos, const Object &owner)
 
static FunctionPtr NewClosureFunction (const String &name, const Function &parent, TokenPosition token_pos)
 
static FunctionPtr NewImplicitClosureFunction (const String &name, const Function &parent, TokenPosition token_pos)
 
static bool IsDynamicInvocationForwarderName (const String &name)
 
static bool IsDynamicInvocationForwarderName (StringPtr name)
 
static StringPtr DemangleDynamicInvocationForwarderName (const String &name)
 
static StringPtr CreateDynamicInvocationForwarderName (const String &name)
 
static intptr_t data_offset ()
 
static intptr_t kind_tag_offset ()
 
static bool is_visible (FunctionPtr f)
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Static Public Attributes

static constexpr intptr_t kMaxInstructionCount = (1 << 16) - 1
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Friends

class Class
 
class Parser
 
class UntaggedFunction
 
class ClassFinalizer
 
class Type
 
class Precompiler
 
class ProgramVisitor
 

Additional Inherited Members

- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 2990 of file object.h.

Member Enumeration Documentation

◆ KindTagBits

Enumerator
kKindTagPos 
kKindTagSize 
kRecognizedTagPos 
kRecognizedTagSize 
kModifierPos 
kModifierSize 
kLastModifierBitPos 
kNumTagBits 

Definition at line 4216 of file object.h.

4216 {
4217 kKindTagPos = 0,
4218 kKindTagSize = 5,
4222 kModifierSize = 2,
4224// Single bit sized fields start here.
4225#define DECLARE_BIT(name, _) k##name##Bit,
4228#undef DECLARE_BIT
4230 };
StringPtr name() const
Definition: object.h:2992
@ kRecognizedTagSize
Definition: object.h:4220
@ kLastModifierBitPos
Definition: object.h:4223
@ kRecognizedTagPos
Definition: object.h:4219
#define FOR_EACH_FUNCTION_KIND_BIT(V)
Definition: object.h:4157
#define DECLARE_BIT(name, _)
Definition: object.h:4225
#define FOR_EACH_FUNCTION_VOLATILE_KIND_BIT(V)
Definition: object.h:4175

◆ StateBits

Definition at line 4097 of file object.h.

4097 {
4098#define DECLARE_FLAG_POS(Name) k##Name##Pos,
4100#undef DECLARE_FLAG_POS
4101 };
#define DECLARE_FLAG_POS(Name)
Definition: object.h:4098
#define STATE_BITS_LIST(V)
Definition: object.h:4090

Member Function Documentation

◆ accessor_field()

FieldPtr dart::Function::accessor_field ( ) const

Definition at line 8149 of file object.cc.

8149 {
8150 ASSERT(kind() == UntaggedFunction::kImplicitGetter ||
8151 kind() == UntaggedFunction::kImplicitSetter ||
8152 kind() == UntaggedFunction::kImplicitStaticGetter ||
8153 kind() == UntaggedFunction::kFieldInitializer);
8154 return Field::RawCast(untag()->data());
8155}
UntaggedFunction::Kind kind() const
Definition: object.h:3349
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
#define ASSERT(E)
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558

◆ AddFunctionServiceId()

void dart::Function::AddFunctionServiceId ( const JSONObject obj) const

Definition at line 280 of file object_service.cc.

280 {
281 Class& cls = Class::Handle(Owner());
282 // Special kinds of functions use indices in their respective lists.
283 intptr_t id = -1;
284 const char* selector = nullptr;
285 // Regular functions known to their owner use their name (percent-encoded).
286 String& name = String::Handle(this->name());
287
290 selector = "closures";
291 } else if (IsImplicitClosureFunction()) {
292 id = cls.FindImplicitClosureFunctionIndex(*this);
293 selector = "implicit_closures";
295 id = cls.FindInvocationDispatcherFunctionIndex(*this);
296 selector = "dispatchers";
297 } else if (IsFieldInitializer()) {
299 const char* encoded_field_name = String::EncodeIRI(name);
300 if (cls.IsTopLevel()) {
301 const auto& library = Library::Handle(cls.library());
302 const auto& private_key = String::Handle(library.private_key());
303 jsobj.AddFixedServiceId("libraries/%s/field_inits/%s",
304 private_key.ToCString(), encoded_field_name);
305 } else {
306 jsobj.AddFixedServiceId("classes/%" Pd "/field_inits/%s", cls.id(),
307 encoded_field_name);
308 }
309 return;
310 }
311 if (id != -1) {
312 ASSERT(selector != nullptr);
313 if (cls.IsTopLevel()) {
314 const auto& library = Library::Handle(cls.library());
315 const auto& private_key = String::Handle(library.private_key());
316 jsobj.AddFixedServiceId("libraries/%s/%s/%" Pd "",
317 private_key.ToCString(), selector, id);
318 } else {
319 jsobj.AddFixedServiceId("classes/%" Pd "/%s/%" Pd "", cls.id(), selector,
320 id);
321 }
322 return;
323 }
324 Thread* thread = Thread::Current();
325 if (Resolver::ResolveFunction(thread->zone(), cls, name) == ptr()) {
326 const char* encoded_name = String::EncodeIRI(name);
327 if (cls.IsTopLevel()) {
328 const auto& library = Library::Handle(cls.library());
329 const auto& private_key = String::Handle(library.private_key());
330 jsobj.AddFixedServiceId("libraries/%s/functions/%s",
331 private_key.ToCString(), encoded_name);
332 } else {
333 jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s", cls.id(),
334 encoded_name);
335 }
336 return;
337 }
338 // Oddball functions (not known to their owner) fall back to use the object
339 // id ring. Current known examples are signature functions of closures
340 // and stubs like 'megamorphic_call_miss'.
341 jsobj.AddServiceId(*this);
342}
static intptr_t FindClosureIndex(const Function &needle)
static StringPtr NameFromInit(const String &init_name)
Definition: object.cc:11826
bool IsImplicitClosureFunction() const
Definition: object.h:3903
bool IsNoSuchMethodDispatcher() const
Definition: object.h:3288
bool IsFieldInitializer() const
Definition: object.h:3885
bool IsInvokeFieldDispatcher() const
Definition: object.h:3296
bool IsNonImplicitClosureFunction() const
Definition: object.h:3911
ClassPtr Owner() const
Definition: object.cc:10841
friend class Class
Definition: object.h:4303
ObjectPtr ptr() const
Definition: object.h:332
static Object & Handle()
Definition: object.h:407
friend class Thread
Definition: object.h:1025
static FunctionPtr ResolveFunction(Zone *zone, const Class &receiver_class, const String &function_name)
Definition: resolver.cc:167
static const char * EncodeIRI(const String &str)
Definition: object.cc:23918
static Thread * Current()
Definition: thread.h:362
#define Pd
Definition: globals.h:408

◆ AreValidArgumentCounts()

bool dart::Function::AreValidArgumentCounts ( intptr_t  num_type_arguments,
intptr_t  num_arguments,
intptr_t  num_named_arguments,
String error_message 
) const

Definition at line 9250 of file object.cc.

9253 {
9254 if ((num_type_arguments != 0) &&
9255 (num_type_arguments != NumTypeParameters())) {
9256 if (error_message != nullptr) {
9257 const intptr_t kMessageBufferSize = 64;
9258 char message_buffer[kMessageBufferSize];
9259 Utils::SNPrint(message_buffer, kMessageBufferSize,
9260 "%" Pd " type arguments passed, but %" Pd " expected",
9261 num_type_arguments, NumTypeParameters());
9262 // Allocate in old space because it can be invoked in background
9263 // optimizing compilation.
9264 *error_message = String::New(message_buffer, Heap::kOld);
9265 }
9266 return false; // Too many type arguments.
9267 }
9268 if (num_named_arguments > NumOptionalNamedParameters()) {
9269 if (error_message != nullptr) {
9270 const intptr_t kMessageBufferSize = 64;
9271 char message_buffer[kMessageBufferSize];
9272 Utils::SNPrint(message_buffer, kMessageBufferSize,
9273 "%" Pd " named passed, at most %" Pd " expected",
9274 num_named_arguments, NumOptionalNamedParameters());
9275 // Allocate in old space because it can be invoked in background
9276 // optimizing compilation.
9277 *error_message = String::New(message_buffer, Heap::kOld);
9278 }
9279 return false; // Too many named arguments.
9280 }
9281 const intptr_t num_pos_args = num_arguments - num_named_arguments;
9282 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
9283 const intptr_t num_pos_params = num_fixed_parameters() + num_opt_pos_params;
9284 if (num_pos_args > num_pos_params) {
9285 if (error_message != nullptr) {
9286 const intptr_t kMessageBufferSize = 64;
9287 char message_buffer[kMessageBufferSize];
9288 // Hide implicit parameters to the user.
9289 const intptr_t num_hidden_params = NumImplicitParameters();
9290 Utils::SNPrint(message_buffer, kMessageBufferSize,
9291 "%" Pd "%s passed, %s%" Pd " expected",
9292 num_pos_args - num_hidden_params,
9293 num_opt_pos_params > 0 ? " positional" : "",
9294 num_opt_pos_params > 0 ? "at most " : "",
9295 num_pos_params - num_hidden_params);
9296 // Allocate in old space because it can be invoked in background
9297 // optimizing compilation.
9298 *error_message = String::New(message_buffer, Heap::kOld);
9299 }
9300 return false; // Too many fixed and/or positional arguments.
9301 }
9302 if (num_pos_args < num_fixed_parameters()) {
9303 if (error_message != nullptr) {
9304 const intptr_t kMessageBufferSize = 64;
9305 char message_buffer[kMessageBufferSize];
9306 // Hide implicit parameters to the user.
9307 const intptr_t num_hidden_params = NumImplicitParameters();
9308 Utils::SNPrint(message_buffer, kMessageBufferSize,
9309 "%" Pd "%s passed, %s%" Pd " expected",
9310 num_pos_args - num_hidden_params,
9311 num_opt_pos_params > 0 ? " positional" : "",
9312 num_opt_pos_params > 0 ? "at least " : "",
9313 num_fixed_parameters() - num_hidden_params);
9314 // Allocate in old space because it can be invoked in background
9315 // optimizing compilation.
9316 *error_message = String::New(message_buffer, Heap::kOld);
9317 }
9318 return false; // Too few fixed and/or positional arguments.
9319 }
9320 return true;
9321}
intptr_t NumOptionalNamedParameters() const
Definition: object.cc:8874
intptr_t NumOptionalPositionalParameters() const
Definition: object.cc:8871
intptr_t NumTypeParameters() const
Definition: object.cc:8847
intptr_t NumImplicitParameters() const
Definition: object.cc:9228
intptr_t num_fixed_parameters() const
Definition: object.cc:8856
@ kOld
Definition: heap.h:39
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3

◆ AreValidArguments() [1/2]

bool dart::Function::AreValidArguments ( const ArgumentsDescriptor args_desc,
String error_message 
) const

Definition at line 9333 of file object.cc.

9334 {
9335 const intptr_t num_type_arguments = args_desc.TypeArgsLen();
9336 const intptr_t num_arguments = args_desc.Count();
9337 const intptr_t num_named_arguments = args_desc.NamedCount();
9338
9339 if (!AreValidArgumentCounts(num_type_arguments, num_arguments,
9340 num_named_arguments, error_message)) {
9341 return false;
9342 }
9343 // Verify that all argument names are valid parameter names.
9344 Thread* thread = Thread::Current();
9345 Zone* zone = thread->zone();
9346 String& argument_name = String::Handle(zone);
9347 String& parameter_name = String::Handle(zone);
9348 const intptr_t num_positional_args = num_arguments - num_named_arguments;
9349 const intptr_t num_parameters = NumParameters();
9350 for (intptr_t i = 0; i < num_named_arguments; i++) {
9351 argument_name = args_desc.NameAt(i);
9352 ASSERT(argument_name.IsSymbol());
9353 bool found = false;
9354 for (intptr_t j = num_positional_args; j < num_parameters; j++) {
9355 parameter_name = ParameterNameAt(j);
9356 ASSERT(parameter_name.IsSymbol());
9357 if (argument_name.Equals(parameter_name)) {
9358 found = true;
9359 break;
9360 }
9361 }
9362 if (!found) {
9363 if (error_message != nullptr) {
9364 const intptr_t kMessageBufferSize = 64;
9365 char message_buffer[kMessageBufferSize];
9366 Utils::SNPrint(message_buffer, kMessageBufferSize,
9367 "no optional formal parameter named '%s'",
9368 argument_name.ToCString());
9369 *error_message = String::New(message_buffer);
9370 }
9371 return false;
9372 }
9373 }
9374 // Verify that all required named parameters are filled.
9375 for (intptr_t j = num_parameters - NumOptionalNamedParameters();
9376 j < num_parameters; j++) {
9377 if (IsRequiredAt(j)) {
9378 parameter_name = ParameterNameAt(j);
9379 ASSERT(parameter_name.IsSymbol());
9380 bool found = false;
9381 for (intptr_t i = 0; i < num_named_arguments; i++) {
9382 argument_name = args_desc.NameAt(i);
9383 ASSERT(argument_name.IsSymbol());
9384 if (argument_name.Equals(parameter_name)) {
9385 found = true;
9386 break;
9387 }
9388 }
9389 if (!found) {
9390 if (error_message != nullptr) {
9391 const intptr_t kMessageBufferSize = 64;
9392 char message_buffer[kMessageBufferSize];
9393 Utils::SNPrint(message_buffer, kMessageBufferSize,
9394 "missing required named parameter '%s'",
9395 parameter_name.ToCString());
9396 *error_message = String::New(message_buffer);
9397 }
9398 return false;
9399 }
9400 }
9401 }
9402 return true;
9403}
StringPtr ParameterNameAt(intptr_t index) const
Definition: object.cc:8602
bool IsRequiredAt(intptr_t index) const
Definition: object.cc:8741
bool AreValidArgumentCounts(intptr_t num_type_arguments, intptr_t num_arguments, intptr_t num_named_arguments, String *error_message) const
Definition: object.cc:9250
intptr_t NumParameters() const
Definition: object.cc:8877

◆ AreValidArguments() [2/2]

bool dart::Function::AreValidArguments ( intptr_t  num_type_arguments,
intptr_t  num_arguments,
const Array argument_names,
String error_message 
) const

Definition at line 9323 of file object.cc.

9326 {
9327 const Array& args_desc_array = Array::Handle(ArgumentsDescriptor::NewBoxed(
9328 num_type_arguments, num_arguments, argument_names, Heap::kNew));
9329 ArgumentsDescriptor args_desc(args_desc_array);
9330 return AreValidArguments(args_desc, error_message);
9331}
static ArrayPtr NewBoxed(intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
Definition: dart_entry.h:83
bool AreValidArguments(intptr_t num_type_arguments, intptr_t num_arguments, const Array &argument_names, String *error_message) const
Definition: object.cc:9323
@ kNew
Definition: heap.h:38

◆ AssignFfiCallbackId()

void dart::Function::AssignFfiCallbackId ( int32_t  callback_id) const

Definition at line 8344 of file object.cc.

8344 {
8346
8347 const auto& obj = Object::Handle(data());
8348 ASSERT(!obj.IsNull());
8349 const auto& trampoline_data = FfiTrampolineData::Cast(obj);
8350
8351 ASSERT(trampoline_data.callback_id() == -1);
8352 trampoline_data.set_callback_id(callback_id);
8353}
bool IsFfiCallbackTrampoline() const
Definition: object.h:3938

◆ AttachCode()

void dart::Function::AttachCode ( const Code value) const

Definition at line 7927 of file object.cc.

7927 {
7928 ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
7929 // Finish setting up code before activating it.
7930 value.set_owner(*this);
7932 ASSERT(Function::Handle(value.function()).IsNull() ||
7933 (value.function() == this->ptr()));
7934}
void SetInstructions(const Code &value) const
Definition: object.cc:7909
static IsolateGroup * Current()
Definition: isolate.h:539
bool IsNull() const
Definition: object.h:363
uint8_t value

◆ awaiter_link()

Function::AwaiterLink dart::Function::awaiter_link ( ) const

Definition at line 8067 of file object.cc.

8067 {
8068 if (IsClosureFunction()) {
8069 const Object& obj = Object::Handle(untag()->data());
8070 ASSERT(!obj.IsNull());
8071 return ClosureData::Cast(obj).awaiter_link();
8072 }
8073 UNREACHABLE();
8074 return {};
8075}
#define UNREACHABLE()
Definition: assert.h:248
bool IsClosureFunction() const
Definition: object.h:3891

◆ CanBeInlined()

bool dart::Function::CanBeInlined ( ) const

Definition at line 9199 of file object.cc.

9199 {
9200 if (ForceOptimize()) {
9202 // We currently don't support inlining FFI trampolines. Some of them
9203 // are naturally non-inlinable because they contain a try/catch block,
9204 // but this condition is broader than strictly necessary.
9205 // The work necessary for inlining FFI trampolines is tracked by
9206 // http://dartbug.com/45055.
9207 return false;
9208 }
9209 if (CompilerState::Current().is_aot()) {
9210 return true;
9211 }
9212 // Inlining of force-optimized functions requires target function to be
9213 // idempotent becase if deoptimization is needed in inlined body, the
9214 // execution of the force-optimized will be restarted at the beginning of
9215 // the function.
9217 return IsIdempotent();
9218 }
9219
9220 if (HasBreakpoint()) {
9221 return false;
9222 }
9223
9224 return is_inlinable();
9225}
static CompilerState & Current()
bool IsPreferInline() const
Definition: object.cc:9035
bool IsFfiCallClosure() const
Definition: object.cc:9067
bool IsIdempotent() const
Definition: object.cc:9042
bool ForceOptimize() const
Definition: object.cc:9017
bool is_ffi_native() const
Definition: object.cc:8542
bool HasBreakpoint() const
Definition: object.cc:7890

◆ CheckSourceFingerprint()

bool dart::Function::CheckSourceFingerprint ( int32_t  fp,
const char *  kind = nullptr 
) const

Definition at line 11304 of file object.cc.

11304 {
11305#if !defined(DEBUG)
11306 return true; // Only check on debug.
11307#endif
11308
11309#if !defined(DART_PRECOMPILED_RUNTIME)
11310 // Check that the function is marked as recognized via the vm:recognized
11311 // pragma. This is so that optimizations that change the signature will know
11312 // not to touch it.
11313 if (kind != nullptr && !MethodRecognizer::IsMarkedAsRecognized(*this, kind)) {
11315 "Recognized method %s should be marked with: "
11316 "@pragma(\"vm:recognized\", \"%s\")\n",
11318 return false;
11319 }
11320#endif
11321
11322 if (IsolateGroup::Current()->obfuscate() || FLAG_precompiled_mode ||
11324 return true; // The kernel structure has been altered, skip checking.
11325 }
11326
11327 if (SourceFingerprint() != fp) {
11328 // This output can be copied into a file, then used with sed
11329 // to replace the old values.
11330 // sed -i.bak -f /tmp/newkeys \
11331 // runtime/vm/compiler/recognized_methods_list.h
11332 THR_Print("s/0x%08x/0x%08x/\n", fp, SourceFingerprint());
11333 return false;
11334 }
11335 return true;
11336}
static Snapshot::Kind vm_snapshot_kind()
Definition: dart.h:95
int32_t SourceFingerprint() const
Definition: object.cc:11169
const char * ToQualifiedCString() const
Definition: object.cc:9776
static bool IsMarkedAsRecognized(const Function &function, const char *kind=nullptr)
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
#define THR_Print(format,...)
Definition: log.h:20
const uint32_t fp

◆ ClearCode()

void dart::Function::ClearCode ( ) const

Definition at line 7948 of file object.cc.

7948 {
7949#if defined(DART_PRECOMPILED_RUNTIME)
7950 UNREACHABLE();
7951#else
7952 ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
7953 untag()->set_unoptimized_code(Code::null());
7954 SetInstructions(StubCode::LazyCompile());
7955#endif // defined(DART_PRECOMPILED_RUNTIME)
7956}
static ObjectPtr null()
Definition: object.h:433

◆ ClearCodeSafe()

void dart::Function::ClearCodeSafe ( ) const

Definition at line 7958 of file object.cc.

7958 {
7959#if defined(DART_PRECOMPILED_RUNTIME)
7960 UNREACHABLE();
7961#else
7962 untag()->set_unoptimized_code(Code::null());
7963
7964 SetInstructionsSafe(StubCode::LazyCompile());
7965#endif // defined(DART_PRECOMPILED_RUNTIME)
7966}
void SetInstructionsSafe(const Code &value) const
Definition: object.cc:7920

◆ ClearICDataArray()

void dart::Function::ClearICDataArray ( ) const

Definition at line 11276 of file object.cc.

11276 {
11277 set_ic_data_array(Array::null_array());
11278}

◆ code_offset()

static intptr_t dart::Function::code_offset ( )
inlinestatic

Definition at line 3196 of file object.h.

3196{ return OFFSET_OF(UntaggedFunction, code_); }
friend class UntaggedFunction
Definition: object.h:4307
#define OFFSET_OF(type, field)
Definition: globals.h:138

◆ COMPILE_ASSERT() [1/2]

dart::Function::COMPILE_ASSERT ( kNumTagBits<=  kBitsPerByte *sizeof(decltype(UntaggedFunction::kind_tag_)))

◆ COMPILE_ASSERT() [2/2]

dart::Function::COMPILE_ASSERT ( )

◆ context_scope()

ContextScopePtr dart::Function::context_scope ( ) const

Definition at line 8048 of file object.cc.

8048 {
8049 if (IsClosureFunction()) {
8050 const Object& obj = Object::Handle(untag()->data());
8051 ASSERT(!obj.IsNull());
8052 return ClosureData::Cast(obj).context_scope();
8053 }
8054 return ContextScope::null();
8055}

◆ CreateDynamicInvocationForwarder()

FunctionPtr dart::Function::CreateDynamicInvocationForwarder ( const String mangled_name) const

Definition at line 4210 of file object.cc.

4211 {
4212 Thread* thread = Thread::Current();
4213 Zone* zone = thread->zone();
4214
4215 Function& forwarder = Function::Handle(zone);
4216 forwarder ^= Object::Clone(*this, Heap::kOld);
4217
4218 forwarder.reset_unboxed_parameters_and_return();
4219
4220 forwarder.set_name(mangled_name);
4221 forwarder.set_is_native(false);
4222 // TODO(dartbug.com/37737): Currently, we intentionally keep the recognized
4223 // kind when creating the dynamic invocation forwarder.
4224 forwarder.set_kind(UntaggedFunction::kDynamicInvocationForwarder);
4225 forwarder.set_modifier(UntaggedFunction::kNoModifier);
4226 forwarder.set_is_debuggable(false);
4227
4228 // TODO(vegorov) for error reporting reasons it is better to make this
4229 // function visible and instead use a TailCall to invoke the target.
4230 // Our TailCall instruction is not ready for such usage though it
4231 // blocks inlining and can't take Function-s only Code objects.
4232 forwarder.set_is_visible(false);
4233
4234 forwarder.ClearICDataArray();
4235 forwarder.ClearCode();
4236 forwarder.set_usage_counter(0);
4237 forwarder.set_deoptimization_counter(0);
4238 forwarder.set_optimized_instruction_count(0);
4239 forwarder.set_inlining_depth(0);
4240 forwarder.set_optimized_call_site_count(0);
4241
4242 forwarder.InheritKernelOffsetFrom(*this);
4243 forwarder.SetForwardingTarget(*this);
4244
4245 return forwarder.ptr();
4246}
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition: object.cc:2899

◆ CreateDynamicInvocationForwarderName()

StringPtr dart::Function::CreateDynamicInvocationForwarderName ( const String name)
static

Definition at line 4205 of file object.cc.

4205 {
4206 return Symbols::FromConcat(Thread::Current(), Symbols::DynamicPrefix(), name);
4207}
static StringPtr FromConcat(Thread *thread, const String &str1, const String &str2)
Definition: symbols.cc:235

◆ CreateMethodExtractor()

FunctionPtr dart::Function::CreateMethodExtractor ( const String getter_name) const

Definition at line 3967 of file object.cc.

3967 {
3968 Thread* thread = Thread::Current();
3969 Zone* zone = thread->zone();
3970 ASSERT(Field::IsGetterName(getter_name));
3971 const Function& closure_function =
3973
3974 const Class& owner = Class::Handle(zone, closure_function.Owner());
3975 FunctionType& signature = FunctionType::Handle(zone, FunctionType::New());
3976 const Function& extractor = Function::Handle(
3977 zone,
3978 Function::New(signature,
3979 String::Handle(zone, Symbols::New(thread, getter_name)),
3980 UntaggedFunction::kMethodExtractor,
3981 false, // Not static.
3982 false, // Not const.
3983 is_abstract(),
3984 false, // Not external.
3985 false, // Not native.
3986 owner, TokenPosition::kMethodExtractor));
3987
3988 // Initialize signature: receiver is a single fixed parameter.
3989 const intptr_t kNumParameters = 1;
3990 signature.set_num_fixed_parameters(kNumParameters);
3991 signature.SetNumOptionalParameters(0, false);
3992 signature.set_parameter_types(Object::synthetic_getter_parameter_types());
3993#if !defined(DART_PRECOMPILED_RUNTIME)
3994 extractor.set_positional_parameter_names(
3995 Object::synthetic_getter_parameter_names());
3996#endif
3997 signature.set_result_type(Object::dynamic_type());
3998
3999 extractor.InheritKernelOffsetFrom(*this);
4000
4001 extractor.set_extracted_method_closure(closure_function);
4002 extractor.set_is_debuggable(false);
4003 extractor.set_is_visible(false);
4004
4005 signature ^= ClassFinalizer::FinalizeType(signature);
4006 extractor.SetSignature(signature);
4007
4008 owner.AddFunction(extractor);
4009
4010 return extractor.ptr();
4011}
static AbstractTypePtr FinalizeType(const AbstractType &type, FinalizationKind finalization=kCanonicalize)
static bool IsGetterName(const String &function_name)
Definition: object.cc:11831
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
Definition: object.cc:11631
static FunctionPtr New(const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
Definition: object.cc:10243
FunctionPtr ImplicitClosureFunction() const
Definition: object.cc:10385
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723

◆ CreateNameArray()

void dart::Function::CreateNameArray ( Heap::Space  space = Heap::kOld) const

Definition at line 8677 of file object.cc.

8677 {
8678#if defined(DART_PRECOMPILED_RUNTIME)
8679 UNREACHABLE();
8680#else
8681 const intptr_t num_positional_params =
8683 if (num_positional_params == 0) {
8684 set_positional_parameter_names(Object::empty_array());
8685 } else {
8686 set_positional_parameter_names(
8687 Array::Handle(Array::New(num_positional_params, space)));
8688 }
8689#endif
8690}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959

◆ CurrentCode()

CodePtr dart::Function::CurrentCode ( ) const
inline

Definition at line 3177 of file object.h.

3177{ return CurrentCodeOf(ptr()); }
static CodePtr CurrentCodeOf(const FunctionPtr function)
Definition: object.h:3181

◆ CurrentCodeOf()

static CodePtr dart::Function::CurrentCodeOf ( const FunctionPtr  function)
inlinestatic

Definition at line 3181 of file object.h.

3181 {
3182 return function->untag()->code<std::memory_order_acquire>();
3183 }
Dart_NativeFunction function
Definition: fuchsia.cc:51

◆ data_offset()

static intptr_t dart::Function::data_offset ( )
inlinestatic

Definition at line 4126 of file object.h.

4126{ return OFFSET_OF(UntaggedFunction, data_); }

◆ default_type_arguments_instantiation_mode()

InstantiationMode dart::Function::default_type_arguments_instantiation_mode ( ) const

Definition at line 8188 of file object.cc.

8188 {
8189 if (!IsClosureFunction()) {
8190 UNREACHABLE();
8191 }
8192 return ClosureData::DefaultTypeArgumentsInstantiationMode(
8193 ClosureData::RawCast(data()));
8194}

◆ DefaultTypeArguments()

TypeArgumentsPtr dart::Function::DefaultTypeArguments ( Zone zone) const

Definition at line 8181 of file object.cc.

8181 {
8183 return Object::empty_type_arguments().ptr();
8184 }
8185 return TypeParameters::Handle(zone, type_parameters()).defaults();
8186}
TypeParametersPtr type_parameters() const
Definition: object.h:3129

◆ DemangleDynamicInvocationForwarderName()

StringPtr dart::Function::DemangleDynamicInvocationForwarderName ( const String name)
static

Definition at line 4198 of file object.cc.

4198 {
4199 const intptr_t kDynamicPrefixLength = 4; // "dyn:"
4200 ASSERT(Symbols::DynamicPrefix().Length() == kDynamicPrefixLength);
4201 return Symbols::New(Thread::Current(), name, kDynamicPrefixLength,
4202 name.Length() - kDynamicPrefixLength);
4203}

◆ DictionaryName()

virtual StringPtr dart::Function::DictionaryName ( ) const
inlinevirtual

Reimplemented from dart::Object.

Definition at line 3005 of file object.h.

3005{ return name(); }

◆ DoArgumentTypesMatch() [1/3]

ObjectPtr dart::Function::DoArgumentTypesMatch ( const Array args,
const ArgumentsDescriptor arg_names 
) const

Definition at line 9505 of file object.cc.

9507 {
9508#if defined(DART_PRECOMPILED_RUNTIME)
9509 if (signature() == FunctionType::null()) {
9510 // Precompiler deleted signature because of missing entry point pragma.
9511 return EntryPointMemberInvocationError(*this);
9512 }
9513#endif
9514 Thread* thread = Thread::Current();
9515 Zone* zone = thread->zone();
9516
9517 auto& receiver = Instance::Handle(zone);
9519 receiver ^= args.At(args_desc.FirstArgIndex());
9520 }
9521 const auto& instantiator_type_arguments = TypeArguments::Handle(
9522 zone, RetrieveInstantiatorTypeArguments(zone, *this, receiver));
9523 return Function::DoArgumentTypesMatch(args, args_desc,
9524 instantiator_type_arguments);
9525}
ObjectPtr DoArgumentTypesMatch(const Array &args, const ArgumentsDescriptor &arg_names) const
Definition: object.cc:9505
bool HasThisParameter() const
Definition: object.h:3369
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DART_WARN_UNUSED_RESULT ErrorPtr EntryPointMemberInvocationError(const Object &member)
Definition: object.cc:27212
static TypeArgumentsPtr RetrieveInstantiatorTypeArguments(Zone *zone, const Function &function, const Instance &receiver)
Definition: object.cc:9487

◆ DoArgumentTypesMatch() [2/3]

ObjectPtr dart::Function::DoArgumentTypesMatch ( const Array args,
const ArgumentsDescriptor arg_names,
const TypeArguments instantiator_type_args 
) const

Definition at line 9527 of file object.cc.

9530 {
9531#if defined(DART_PRECOMPILED_RUNTIME)
9532 if (signature() == FunctionType::null()) {
9533 // Precompiler deleted signature because of missing entry point pragma.
9534 return EntryPointMemberInvocationError(*this);
9535 }
9536#endif
9537 Thread* thread = Thread::Current();
9538 Zone* zone = thread->zone();
9539
9540 auto& receiver = Instance::Handle(zone);
9542 receiver ^= args.At(args_desc.FirstArgIndex());
9543 }
9544
9545 const auto& function_type_arguments = TypeArguments::Handle(
9546 zone, RetrieveFunctionTypeArguments(thread, zone, *this, receiver,
9547 instantiator_type_arguments, args,
9548 args_desc));
9550 args, args_desc, instantiator_type_arguments, function_type_arguments);
9551}
static TypeArgumentsPtr RetrieveFunctionTypeArguments(Thread *thread, Zone *zone, const Function &function, const Instance &receiver, const TypeArguments &instantiator_type_args, const Array &args, const ArgumentsDescriptor &args_desc)
Definition: object.cc:9409

◆ DoArgumentTypesMatch() [3/3]

ObjectPtr dart::Function::DoArgumentTypesMatch ( const Array args,
const ArgumentsDescriptor arg_names,
const TypeArguments instantiator_type_args,
const TypeArguments function_type_args 
) const

Definition at line 9553 of file object.cc.

9557 {
9558#if defined(DART_PRECOMPILED_RUNTIME)
9559 if (signature() == FunctionType::null()) {
9560 // Precompiler deleted signature because of missing entry point pragma.
9561 return EntryPointMemberInvocationError(*this);
9562 }
9563#endif
9564 Thread* thread = Thread::Current();
9565 Zone* zone = thread->zone();
9566
9567 // Perform any non-covariant bounds checks on the provided function type
9568 // arguments to make sure they are appropriate subtypes of the bounds.
9569 const intptr_t kNumLocalTypeArgs = NumTypeParameters();
9570 if (kNumLocalTypeArgs > 0) {
9571 const intptr_t kNumParentTypeArgs = NumParentTypeArguments();
9572 ASSERT(function_type_arguments.HasCount(kNumParentTypeArgs +
9573 kNumLocalTypeArgs));
9574 const auto& params = TypeParameters::Handle(zone, type_parameters());
9575 // No checks are needed if all bounds are dynamic.
9576 if (!params.AllDynamicBounds()) {
9577 auto& param = AbstractType::Handle(zone);
9578 auto& bound = AbstractType::Handle(zone);
9579 for (intptr_t i = 0; i < kNumLocalTypeArgs; i++) {
9580 bound = params.BoundAt(i);
9581 // Only perform non-covariant checks where the bound is not
9582 // the top type.
9583 if (params.IsGenericCovariantImplAt(i) ||
9584 bound.IsTopTypeForSubtyping()) {
9585 continue;
9586 }
9587 param = TypeParameterAt(i);
9589 &param, &bound, instantiator_type_arguments,
9590 function_type_arguments)) {
9591 const auto& names = Array::Handle(zone, params.names());
9592 auto& name = String::Handle(zone);
9593 name ^= names.At(i);
9594 return Error::RawCast(
9595 ThrowTypeError(token_pos(), param, bound, name));
9596 }
9597 }
9598 }
9599 } else {
9600 ASSERT(function_type_arguments.HasCount(NumParentTypeArguments()));
9601 }
9602
9603 AbstractType& type = AbstractType::Handle(zone);
9604 Instance& argument = Instance::Handle(zone);
9605
9606 auto check_argument = [](const Instance& argument, const AbstractType& type,
9607 const TypeArguments& instantiator_type_args,
9608 const TypeArguments& function_type_args) -> bool {
9609 // If the argument type is the top type, no need to check.
9610 if (type.IsTopTypeForSubtyping()) return true;
9611 if (argument.IsNull()) {
9612 return Instance::NullIsAssignableTo(type, instantiator_type_args,
9613 function_type_args);
9614 }
9615 return argument.IsAssignableTo(type, instantiator_type_args,
9616 function_type_args);
9617 };
9618
9619 // Check types of the provided arguments against the expected parameter types.
9620 const intptr_t arg_offset = args_desc.FirstArgIndex();
9621 // Only check explicit arguments.
9622 const intptr_t arg_start = arg_offset + NumImplicitParameters();
9623 const intptr_t end_positional_args = arg_offset + args_desc.PositionalCount();
9624 for (intptr_t arg_index = arg_start; arg_index < end_positional_args;
9625 ++arg_index) {
9626 argument ^= args.At(arg_index);
9627 // Adjust for type arguments when they're present.
9628 const intptr_t param_index = arg_index - arg_offset;
9629 type = ParameterTypeAt(param_index);
9630 if (!check_argument(argument, type, instantiator_type_arguments,
9631 function_type_arguments)) {
9632 auto& name = String::Handle(zone, ParameterNameAt(param_index));
9633 if (!type.IsInstantiated()) {
9634 type =
9635 type.InstantiateFrom(instantiator_type_arguments,
9636 function_type_arguments, kAllFree, Heap::kNew);
9637 }
9638 return ThrowTypeError(token_pos(), argument, type, name);
9639 }
9640 }
9641
9642 const intptr_t num_named_arguments = args_desc.NamedCount();
9643 if (num_named_arguments == 0) {
9644 return Error::null();
9645 }
9646
9647 const int num_parameters = NumParameters();
9648 const int num_fixed_params = num_fixed_parameters();
9649
9650 String& argument_name = String::Handle(zone);
9651 String& parameter_name = String::Handle(zone);
9652
9653 // Check types of named arguments against expected parameter type.
9654 for (intptr_t named_index = 0; named_index < num_named_arguments;
9655 named_index++) {
9656 argument_name = args_desc.NameAt(named_index);
9657 ASSERT(argument_name.IsSymbol());
9658 argument ^= args.At(arg_offset + args_desc.PositionAt(named_index));
9659
9660 // Try to find the named parameter that matches the provided argument.
9661 // Even when annotated with @required, named parameters are still stored
9662 // as if they were optional and so come after the fixed parameters.
9663 // Currently O(n^2) as there's no guarantee from either the CFE or the
9664 // VM that named parameters and named arguments are sorted in the same way.
9665 intptr_t param_index = num_fixed_params;
9666 for (; param_index < num_parameters; param_index++) {
9667 parameter_name = ParameterNameAt(param_index);
9668 ASSERT(parameter_name.IsSymbol());
9669
9670 if (!parameter_name.Equals(argument_name)) continue;
9671
9672 type = ParameterTypeAt(param_index);
9673 if (!check_argument(argument, type, instantiator_type_arguments,
9674 function_type_arguments)) {
9675 auto& name = String::Handle(zone, ParameterNameAt(param_index));
9676 if (!type.IsInstantiated()) {
9677 type = type.InstantiateFrom(instantiator_type_arguments,
9678 function_type_arguments, kAllFree,
9679 Heap::kNew);
9680 }
9681 return ThrowTypeError(token_pos(), argument, type, name);
9682 }
9683 break;
9684 }
9685 // Only should fail if AreValidArguments returns a false positive.
9686 ASSERT(param_index < num_parameters);
9687 }
9688 return Error::null();
9689}
GLenum type
static bool InstantiateAndTestSubtype(AbstractType *subtype, AbstractType *supertype, const TypeArguments &instantiator_type_args, const TypeArguments &function_type_args)
Definition: object.cc:4287
intptr_t NumParentTypeArguments() const
Definition: object.cc:8850
TokenPosition token_pos() const
Definition: object.h:3446
AbstractTypePtr ParameterTypeAt(intptr_t index) const
Definition: object.cc:8580
TypeParameterPtr TypeParameterAt(intptr_t index, Nullability nullability=Nullability::kNonNullable) const
Definition: object.cc:8881
static bool NullIsAssignableTo(const AbstractType &other)
Definition: object.cc:20674
const EmbeddedViewParams * params
static const char *const names[]
Definition: symbols.cc:24
static ObjectPtr ThrowTypeError(const TokenPosition token_pos, const Instance &src_value, const AbstractType &dst_type, const String &dst_name)
Definition: object.cc:4496
@ kAllFree
Definition: object.h:2940

◆ DropUncompiledImplicitClosureFunction()

void dart::Function::DropUncompiledImplicitClosureFunction ( ) const

Definition at line 10607 of file object.cc.

10607 {
10608 if (implicit_closure_function() != Function::null()) {
10609 const Function& func = Function::Handle(implicit_closure_function());
10610 if (!func.HasCode()) {
10611 set_implicit_closure_function(Function::Handle());
10612 }
10613 }
10614}

◆ end_token_pos()

TokenPosition dart::Function::end_token_pos ( ) const
inline

Definition at line 3455 of file object.h.

3455 {
3456#if defined(DART_PRECOMPILED_RUNTIME)
3457 return TokenPosition::kNoSource;
3458#else
3459 return untag()->end_token_pos_;
3460#endif
3461 }

◆ EnsureHasCode()

CodePtr dart::Function::EnsureHasCode ( ) const

Definition at line 11338 of file object.cc.

11338 {
11339 if (HasCode()) return CurrentCode();
11340 Thread* thread = Thread::Current();
11341 ASSERT(thread->IsDartMutatorThread());
11342 DEBUG_ASSERT(thread->TopErrorHandlerIsExitFrame());
11343 Zone* zone = thread->zone();
11344 const Object& result =
11345 Object::Handle(zone, Compiler::CompileFunction(thread, *this));
11346 if (result.IsError()) {
11347 if (result.ptr() == Object::out_of_memory_error().ptr()) {
11349 UNREACHABLE();
11350 }
11351 if (result.IsLanguageError()) {
11352 Exceptions::ThrowCompileTimeError(LanguageError::Cast(result));
11353 UNREACHABLE();
11354 }
11355 Exceptions::PropagateError(Error::Cast(result));
11356 UNREACHABLE();
11357 }
11358 // Compiling in unoptimized mode should never fail if there are no errors.
11361 return CurrentCode();
11362}
#define DEBUG_ASSERT(cond)
Definition: assert.h:321
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
static ObjectPtr CompileFunction(Thread *thread, const Function &function)
Definition: compiler.cc:824
static DART_NORETURN void ThrowOOM()
Definition: exceptions.cc:1066
static DART_NORETURN void ThrowCompileTimeError(const LanguageError &error)
Definition: exceptions.cc:1112
static DART_NORETURN void PropagateError(const Error &error)
Definition: exceptions.cc:1003
CodePtr CurrentCode() const
Definition: object.h:3177
bool HasCode() const
Definition: object.cc:7936
CodePtr unoptimized_code() const
Definition: object.h:3185
GAsyncResult * result

◆ EnsureHasCompiledUnoptimizedCode()

void dart::Function::EnsureHasCompiledUnoptimizedCode ( ) const

Definition at line 7968 of file object.cc.

7968 {
7970 Thread* thread = Thread::Current();
7971 ASSERT(thread->IsDartMutatorThread());
7972 // TODO(35224): DEBUG_ASSERT(thread->TopErrorHandlerIsExitFrame());
7973 Zone* zone = thread->zone();
7974
7975 const Error& error =
7976 Error::Handle(zone, Compiler::EnsureUnoptimizedCode(thread, *this));
7977 if (!error.IsNull()) {
7979 }
7980}
static ErrorPtr EnsureUnoptimizedCode(Thread *thread, const Function &function)
Definition: compiler.cc:854
const uint8_t uint32_t uint32_t GError ** error

◆ entry_point()

uword dart::Function::entry_point ( ) const
inline

Definition at line 3198 of file object.h.

3198{ return EntryPointOf(ptr()); }
static uword EntryPointOf(const FunctionPtr function)
Definition: object.h:3199

◆ entry_point_offset()

static intptr_t dart::Function::entry_point_offset ( CodeEntryKind  entry_kind = CodeEntryKind::kNormal)
inlinestatic

Definition at line 3203 of file object.h.

3204 {
3205 switch (entry_kind) {
3207 return OFFSET_OF(UntaggedFunction, entry_point_);
3209 return OFFSET_OF(UntaggedFunction, unchecked_entry_point_);
3210 default:
3211 UNREACHABLE();
3212 }
3213 }

◆ EntryPointOf()

static uword dart::Function::EntryPointOf ( const FunctionPtr  function)
inlinestatic

Definition at line 3199 of file object.h.

3199 {
3200 return function->untag()->entry_point_;
3201 }

◆ extracted_method_closure()

FunctionPtr dart::Function::extracted_method_closure ( ) const

Definition at line 8120 of file object.cc.

8120 {
8121 ASSERT(kind() == UntaggedFunction::kMethodExtractor);
8122 const Object& obj = Object::Handle(untag()->data());
8123 ASSERT(obj.IsFunction());
8124 return Function::Cast(obj).ptr();
8125}

◆ FfiCallbackExceptionalReturn()

InstancePtr dart::Function::FfiCallbackExceptionalReturn ( ) const

Definition at line 8391 of file object.cc.

8391 {
8393 const Object& obj = Object::Handle(data());
8394 ASSERT(!obj.IsNull());
8395 return FfiTrampolineData::Cast(obj).callback_exceptional_return();
8396}

◆ FfiCallbackId()

int32_t dart::Function::FfiCallbackId ( ) const

Definition at line 8332 of file object.cc.

8332 {
8334
8335 const auto& obj = Object::Handle(data());
8336 ASSERT(!obj.IsNull());
8337 const auto& trampoline_data = FfiTrampolineData::Cast(obj);
8338
8339 ASSERT(trampoline_data.callback_id() != -1);
8340
8341 return trampoline_data.callback_id();
8342}

◆ FfiCallbackTarget()

FunctionPtr dart::Function::FfiCallbackTarget ( ) const

Definition at line 8377 of file object.cc.

8377 {
8379 const Object& obj = Object::Handle(data());
8380 ASSERT(!obj.IsNull());
8381 return FfiTrampolineData::Cast(obj).callback_target();
8382}

◆ FfiCSignature()

FunctionTypePtr dart::Function::FfiCSignature ( ) const

Definition at line 8264 of file object.cc.

8264 {
8265 auto* const zone = Thread::Current()->zone();
8267 const Object& obj = Object::Handle(zone, data());
8268 ASSERT(!obj.IsNull());
8269 return FfiTrampolineData::Cast(obj).c_signature();
8270 }
8271 auto& pragma_value = Instance::Handle(zone);
8272 if (is_ffi_native()) {
8273 pragma_value = GetNativeAnnotation();
8274 } else if (IsFfiCallClosure()) {
8275 pragma_value = GetFfiCallClosurePragmaValue();
8276 } else {
8277 UNREACHABLE();
8278 }
8279 const auto& type_args =
8280 TypeArguments::Handle(zone, pragma_value.GetTypeArguments());
8281 ASSERT(type_args.Length() == 1);
8282 const auto& native_type =
8283 FunctionType::Cast(AbstractType::ZoneHandle(zone, type_args.TypeAt(0)));
8284 return native_type.ptr();
8285}
InstancePtr GetFfiCallClosurePragmaValue() const
Definition: object.cc:9074
InstancePtr GetNativeAnnotation() const
Definition: object.cc:8520
static Object & ZoneHandle()
Definition: object.h:419
Zone * zone() const
Definition: thread_state.h:37

◆ FfiCSignatureContainsHandles()

bool dart::Function::FfiCSignatureContainsHandles ( ) const

Definition at line 8287 of file object.cc.

8287 {
8288 const FunctionType& c_signature = FunctionType::Handle(FfiCSignature());
8289 return c_signature.ContainsHandles();
8290}
FunctionTypePtr FfiCSignature() const
Definition: object.cc:8264

◆ FfiCSignatureReturnsStruct()

bool dart::Function::FfiCSignatureReturnsStruct ( ) const

Definition at line 8306 of file object.cc.

8306 {
8308 Zone* zone = Thread::Current()->zone();
8309 const auto& c_signature = FunctionType::Handle(zone, FfiCSignature());
8310 const auto& type = AbstractType::Handle(zone, c_signature.result_type());
8311 if (IsFfiTypeClassId(type.type_class_id())) {
8312 return false;
8313 }
8314 const auto& cls = Class::Handle(zone, type.type_class());
8315 const auto& superClass = Class::Handle(zone, cls.SuperClass());
8316 const bool is_abi_specific_int =
8317 String::Handle(zone, superClass.UserVisibleName())
8318 .Equals(Symbols::AbiSpecificInteger());
8319 if (is_abi_specific_int) {
8320 return false;
8321 }
8322#ifdef DEBUG
8323 const bool is_struct = String::Handle(zone, superClass.UserVisibleName())
8324 .Equals(Symbols::Struct());
8325 const bool is_union = String::Handle(zone, superClass.UserVisibleName())
8326 .Equals(Symbols::Union());
8327 ASSERT(is_struct || is_union);
8328#endif
8329 return true;
8330}
static void Union(SkRegion *rgn, const SkIRect &rect)
Definition: RegionTest.cpp:27
bool IsFfiTypeClassId(intptr_t index)
Definition: class_id.h:513

◆ FfiIsLeaf()

bool dart::Function::FfiIsLeaf ( ) const

Definition at line 8355 of file object.cc.

8355 {
8356 Zone* zone = Thread::Current()->zone();
8357 auto& pragma_value = Instance::Handle(zone);
8358 if (is_ffi_native()) {
8359 pragma_value = GetNativeAnnotation();
8360 } else if (IsFfiCallClosure()) {
8361 pragma_value = GetFfiCallClosurePragmaValue();
8362 } else {
8363 UNREACHABLE();
8364 }
8365 const auto& pragma_value_class = Class::Handle(zone, pragma_value.clazz());
8366 const auto& pragma_value_fields =
8367 Array::Handle(zone, pragma_value_class.fields());
8368 ASSERT(pragma_value_fields.Length() >= 1);
8369 const auto& is_leaf_field = Field::Handle(
8370 zone,
8371 Field::RawCast(pragma_value_fields.At(pragma_value_fields.Length() - 1)));
8372 ASSERT(is_leaf_field.name() == Symbols::isLeaf().ptr());
8373 return Bool::Handle(zone, Bool::RawCast(pragma_value.GetField(is_leaf_field)))
8374 .value();
8375}

◆ FindICData()

ICDataPtr dart::Function::FindICData ( intptr_t  deopt_id) const

Definition at line 11280 of file object.cc.

11280 {
11281 const Array& array = Array::Handle(ic_data_array());
11282 ICData& ic_data = ICData::Handle();
11283 for (intptr_t i = ICDataArrayIndices::kFirstICData; i < array.Length(); i++) {
11284 ic_data ^= array.At(i);
11285 if (ic_data.deopt_id() == deopt_id) {
11286 return ic_data.ptr();
11287 }
11288 }
11289 return ICData::null();
11290}
ArrayPtr ic_data_array() const
Definition: object.cc:11272
static constexpr intptr_t kFirstICData
Definition: object.h:4060

◆ ForceOptimize()

bool dart::Function::ForceOptimize ( ) const

Definition at line 9017 of file object.cc.

9017 {
9021 return true;
9022 }
9023
9024 if (!has_pragma()) return false;
9025
9026 const bool has_vm_pragma = Library::FindPragma(
9027 Thread::Current(), false, *this, Symbols::vm_force_optimize());
9028 if (!has_vm_pragma) return false;
9029
9030 // For run_vm_tests and runtime/tests/vm allow marking arbitrary functions as
9031 // force-optimize via `@pragma('vm:force-optimize')`.
9032 return InVmTests(*this);
9033}
bool IsTypedDataViewFactory() const
Definition: object.cc:8957
bool IsUnmodifiableTypedDataViewFactory() const
Definition: object.cc:8980
bool RecognizedKindForceOptimize() const
Definition: object.cc:9086
static bool FindPragma(Thread *T, bool only_core, const Object &object, const String &pragma_name, bool multiple=false, Object *options=nullptr)
Definition: object.cc:4151
static bool InVmTests(const Function &function)
Definition: object.cc:9003

◆ ForwardingTarget()

FunctionPtr dart::Function::ForwardingTarget ( ) const

Definition at line 8423 of file object.cc.

8423 {
8424 ASSERT(kind() == UntaggedFunction::kDynamicInvocationForwarder);
8426}
static ObjectPtr Unwrap(ObjectPtr obj)
Definition: object.h:6667

◆ GetCoverageArray()

ArrayPtr dart::Function::GetCoverageArray ( ) const

Definition at line 11260 of file object.cc.

11260 {
11261 const Array& arr = Array::Handle(ic_data_array());
11262 if (arr.IsNull()) {
11263 return Array::null();
11264 }
11266}
static constexpr intptr_t kCoverageData
Definition: object.h:4059

◆ GetDynamicInvocationForwarder()

FunctionPtr dart::Function::GetDynamicInvocationForwarder ( const String mangled_name) const

Definition at line 4248 of file object.cc.

4249 {
4251 auto thread = Thread::Current();
4252 auto zone = thread->zone();
4253 const Class& owner = Class::Handle(zone, Owner());
4254 Function& result = Function::Handle(zone);
4255
4256 // First we'll try to find it without using locks.
4257 result = owner.GetInvocationDispatcher(
4258 mangled_name, Array::null_array(),
4259 UntaggedFunction::kDynamicInvocationForwarder,
4260 /*create_if_absent=*/false);
4261 if (!result.IsNull()) return result.ptr();
4262
4263 const bool needs_dyn_forwarder =
4265 if (!needs_dyn_forwarder) {
4266 return ptr();
4267 }
4268
4269 // If we failed to find it and possibly need to create it, use a write lock.
4270 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
4271
4272 // Try to find it again & return if it was added in the mean time.
4273 result = owner.GetInvocationDispatcher(
4274 mangled_name, Array::null_array(),
4275 UntaggedFunction::kDynamicInvocationForwarder,
4276 /*create_if_absent=*/false);
4277 if (!result.IsNull()) return result.ptr();
4278
4279 // Otherwise create it & add it.
4281 owner.AddInvocationDispatcher(mangled_name, Array::null_array(), result);
4282 return result.ptr();
4283}
FunctionPtr CreateDynamicInvocationForwarder(const String &mangled_name) const
Definition: object.cc:4210
static bool IsDynamicInvocationForwarderName(const String &name)
Definition: object.cc:4190
bool NeedsDynamicInvocationForwarder(const Function &function)
Definition: kernel.cc:657

◆ GetFfiCallbackKind()

FfiCallbackKind dart::Function::GetFfiCallbackKind ( ) const

Definition at line 8405 of file object.cc.

8405 {
8407 const Object& obj = Object::Handle(data());
8408 ASSERT(!obj.IsNull());
8409 return FfiTrampolineData::Cast(obj).ffi_function_kind();
8410}

◆ GetFfiCallClosurePragmaValue()

InstancePtr dart::Function::GetFfiCallClosurePragmaValue ( ) const

Definition at line 9074 of file object.cc.

9074 {
9076 Thread* thread = Thread::Current();
9077 Zone* zone = thread->zone();
9078 auto& pragma_value = Object::Handle(zone);
9079 Library::FindPragma(thread, /*only_core=*/false, *this,
9080 Symbols::vm_ffi_call_closure(),
9081 /*multiple=*/false, &pragma_value);
9082 ASSERT(!pragma_value.IsNull());
9083 return Instance::Cast(pragma_value).ptr();
9084}

◆ GetMethodExtractor()

FunctionPtr dart::Function::GetMethodExtractor ( const String getter_name) const

Definition at line 4013 of file object.cc.

4013 {
4014 ASSERT(Field::IsGetterName(getter_name));
4015 const Function& closure_function =
4017 const Class& owner = Class::Handle(closure_function.Owner());
4018 Thread* thread = Thread::Current();
4019 if (owner.EnsureIsFinalized(thread) != Error::null()) {
4020 return Function::null();
4021 }
4022 IsolateGroup* group = thread->isolate_group();
4023 Function& result = Function::Handle(
4024 Resolver::ResolveDynamicFunction(thread->zone(), owner, getter_name));
4025 if (result.IsNull()) {
4026 SafepointWriteRwLocker ml(thread, group->program_lock());
4027 result = owner.LookupDynamicFunctionUnsafe(getter_name);
4028 if (result.IsNull()) {
4029 result = CreateMethodExtractor(getter_name);
4030 }
4031 }
4032 ASSERT(result.kind() == UntaggedFunction::kMethodExtractor);
4033 return result.ptr();
4034}
FunctionPtr CreateMethodExtractor(const String &getter_name) const
Definition: object.cc:3967
static FunctionPtr ResolveDynamicFunction(Zone *zone, const Class &receiver_class, const String &function_name)
Definition: resolver.cc:176

◆ GetNativeAnnotation()

InstancePtr dart::Function::GetNativeAnnotation ( ) const

Definition at line 8520 of file object.cc.

8520 {
8522 Zone* zone = Thread::Current()->zone();
8523 auto& pragma_value = Object::Handle(zone);
8524 Library::FindPragma(dart::Thread::Current(), /*only_core=*/false,
8525 Object::Handle(zone, ptr()),
8526 String::Handle(zone, Symbols::vm_ffi_native().ptr()),
8527 /*multiple=*/false, &pragma_value);
8528 auto const& native_instance = Instance::Cast(pragma_value);
8529 ASSERT(!native_instance.IsNull());
8530#if defined(DEBUG)
8531 const auto& native_class = Class::Handle(zone, native_instance.clazz());
8532 ASSERT(String::Handle(zone, native_class.UserVisibleName())
8533 .Equals(Symbols::FfiNative()));
8534#endif
8535 return native_instance.ptr();
8536}

◆ GetOutermostFunction()

FunctionPtr dart::Function::GetOutermostFunction ( ) const

Definition at line 8207 of file object.cc.

8207 {
8208 FunctionPtr parent = parent_function();
8209 if (parent == Object::null()) {
8210 return ptr();
8211 }
8212 Function& function = Function::Handle();
8213 do {
8214 function = parent;
8215 parent = function.parent_function();
8216 } while (parent != Object::null());
8217 return function.ptr();
8218}
FunctionPtr parent_function() const
Definition: object.cc:8167

◆ GetSource()

StringPtr dart::Function::GetSource ( ) const

Definition at line 11119 of file object.cc.

11119 {
11120 if (IsImplicitConstructor() || is_synthetic()) {
11121 // We may need to handle more cases when the restrictions on mixins are
11122 // relaxed. In particular we might start associating some source with the
11123 // forwarding constructors when it becomes possible to specify a particular
11124 // constructor from the mixin to use.
11125 return String::null();
11126 }
11127 Zone* zone = Thread::Current()->zone();
11128 const Script& func_script = Script::Handle(zone, script());
11129
11130 intptr_t from_line, from_col;
11131 if (!func_script.GetTokenLocation(token_pos(), &from_line, &from_col)) {
11132 return String::null();
11133 }
11134 intptr_t to_line, to_col;
11135 if (!func_script.GetTokenLocation(end_token_pos(), &to_line, &to_col)) {
11136 return String::null();
11137 }
11138 intptr_t to_length = func_script.GetTokenLength(end_token_pos());
11139 if (to_length < 0) {
11140 return String::null();
11141 }
11142
11143 if (to_length == 1) {
11144 // Handle special cases for end tokens of closures (where we exclude the
11145 // last token):
11146 // (1) "foo(() => null, bar);": End token is `,', but we don't print it.
11147 // (2) "foo(() => null);": End token is ')`, but we don't print it.
11148 // (3) "var foo = () => null;": End token is `;', but in this case the
11149 // token semicolon belongs to the assignment so we skip it.
11150 const String& src = String::Handle(func_script.Source());
11151 if (src.IsNull() || src.Length() == 0) {
11152 return Symbols::OptimizedOut().ptr();
11153 }
11154 uint16_t end_char = src.CharAt(end_token_pos().Pos());
11155 if ((end_char == ',') || // Case 1.
11156 (end_char == ')') || // Case 2.
11157 (end_char == ';' && String::Handle(zone, name())
11158 .Equals("<anonymous closure>"))) { // Case 3.
11159 to_length = 0;
11160 }
11161 }
11162
11163 return func_script.GetSnippet(from_line, from_col, to_line,
11164 to_col + to_length);
11165}
bool IsImplicitConstructor() const
Definition: object.cc:10218
ScriptPtr script() const
Definition: object.cc:10881
TokenPosition end_token_pos() const
Definition: object.h:3455
static bool Equals(const Object &expected, const Object &actual)

◆ has_unboxed_double_return()

bool dart::Function::has_unboxed_double_return ( ) const
inline

Definition at line 3819 of file object.h.

3819 {
3820#if !defined(DART_PRECOMPILED_RUNTIME)
3821 return untag()->unboxed_parameters_info_.IsUnboxedDouble(0);
3822#else
3823 return false;
3824#endif // !defined(DART_PRECOMPILED_RUNTIME)
3825 }

◆ has_unboxed_integer_return()

bool dart::Function::has_unboxed_integer_return ( ) const
inline

Definition at line 3811 of file object.h.

3811 {
3812#if !defined(DART_PRECOMPILED_RUNTIME)
3813 return untag()->unboxed_parameters_info_.IsUnboxedInteger(0);
3814#else
3815 return false;
3816#endif // !defined(DART_PRECOMPILED_RUNTIME)
3817 }

◆ has_unboxed_record_return()

bool dart::Function::has_unboxed_record_return ( ) const
inline

Definition at line 3827 of file object.h.

3827 {
3828#if !defined(DART_PRECOMPILED_RUNTIME)
3829 return untag()->unboxed_parameters_info_.IsUnboxedRecord(0);
3830#else
3831 return false;
3832#endif // !defined(DART_PRECOMPILED_RUNTIME)
3833 }

◆ has_unboxed_return()

bool dart::Function::has_unboxed_return ( ) const
inline

Definition at line 3803 of file object.h.

3803 {
3804#if !defined(DART_PRECOMPILED_RUNTIME)
3805 return untag()->unboxed_parameters_info_.IsUnboxed(0);
3806#else
3807 return false;
3808#endif // !defined(DART_PRECOMPILED_RUNTIME)
3809 }

◆ HasAwaiterLink()

bool dart::Function::HasAwaiterLink ( ) const
inline

Definition at line 3239 of file object.h.

3239 {
3240 return IsClosureFunction() &&
3241 (awaiter_link().depth != UntaggedClosureData::kNoAwaiterLinkDepth);
3242 }
AwaiterLink awaiter_link() const
Definition: object.cc:8067

◆ HasBreakpoint()

bool dart::Function::HasBreakpoint ( ) const

Definition at line 7890 of file object.cc.

7890 {
7891#if defined(PRODUCT)
7892 return false;
7893#else
7894 auto thread = Thread::Current();
7895 return thread->isolate_group()->debugger()->HasBreakpoint(thread, *this);
7896#endif
7897}

◆ HasCode() [1/2]

bool dart::Function::HasCode ( ) const

Definition at line 7936 of file object.cc.

7936 {
7937 NoSafepointScope no_safepoint;
7938 ASSERT(untag()->code() != Code::null());
7939 return untag()->code() != StubCode::LazyCompile().ptr();
7940}

◆ HasCode() [2/2]

bool dart::Function::HasCode ( FunctionPtr  function)
static

Definition at line 7942 of file object.cc.

7942 {
7943 NoSafepointScope no_safepoint;
7944 ASSERT(function->untag()->code() != Code::null());
7945 return function->untag()->code() != StubCode::LazyCompile().ptr();
7946}

◆ HasDynamicCallers()

bool dart::Function::HasDynamicCallers ( Zone zone) const

Definition at line 11409 of file object.cc.

11409 {
11410#if !defined(DART_PRECOMPILED_RUNTIME)
11411 // Issue(dartbug.com/42719):
11412 // Right now the metadata of _Closure.call says there are no dynamic callers -
11413 // even though there can be. To be conservative we return true.
11414 if ((name() == Symbols::GetCall().ptr() || name() == Symbols::call().ptr()) &&
11416 return true;
11417 }
11418
11419 // Use the results of TFA to determine whether this function is ever
11420 // called dynamically, i.e. using switchable calls.
11421 kernel::ProcedureAttributesMetadata metadata;
11422 metadata = kernel::ProcedureAttributesOf(*this, zone);
11424 // Dynamic method call through field/getter involves dynamic call of
11425 // the field/getter.
11426 return metadata.getter_called_dynamically ||
11427 metadata.method_or_setter_called_dynamically;
11428 } else {
11429 return metadata.method_or_setter_called_dynamically;
11430 }
11431#else
11432 UNREACHABLE();
11433 return true;
11434#endif
11435}
bool IsClosureClass() const
Definition: object.h:1577
bool IsImplicitGetterFunction() const
Definition: object.h:3862
bool IsGetterFunction() const
Definition: object.h:3857
bool IsMethodExtractor() const
Definition: object.h:3284
static ProcedureAttributesMetadata ProcedureAttributesOf(Zone *zone, const KernelProgramInfo &kernel_program_info, const TypedDataView &kernel_data, intptr_t kernel_data_program_offset, intptr_t kernel_offset)
Definition: kernel.cc:740
def call(args)
Definition: dom.py:159

◆ HasGenericParent()

bool dart::Function::HasGenericParent ( ) const
inline

Definition at line 3143 of file object.h.

3143{ return NumParentTypeArguments() > 0; }

◆ Hash()

uword dart::Function::Hash ( ) const
virtual

Definition at line 7879 of file object.cc.

7879 {
7881 if (IsClosureFunction()) {
7882 hash = hash ^ token_pos().Hash();
7883 }
7884 if (Owner()->IsClass()) {
7886 }
7887 return hash;
7888}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
uint32_t Hash() const
Definition: object.cc:5597
static uword HashRawSymbol(const StringPtr symbol)
Definition: object.h:10247
uword Hash() const
uintptr_t uword
Definition: globals.h:501

◆ HasImplicitClosureFunction()

bool dart::Function::HasImplicitClosureFunction ( ) const
inline

Definition at line 3326 of file object.h.

3326 {
3327 return implicit_closure_function() != null();
3328 }

◆ HasInstantiatedSignature()

bool dart::Function::HasInstantiatedSignature ( Genericity  genericity = kAny,
intptr_t  num_free_fun_type_params = kAllFree 
) const

Definition at line 10785 of file object.cc.

10787 {
10788 return FunctionType::Handle(signature())
10789 .IsInstantiated(genericity, num_free_fun_type_params);
10790}

◆ HasOptimizedCode()

bool dart::Function::HasOptimizedCode ( ) const

Definition at line 10974 of file object.cc.

10974 {
10975 return HasCode() && Code::Handle(CurrentCode()).is_optimized();
10976}

◆ HasOptionalNamedParameters()

bool dart::Function::HasOptionalNamedParameters ( ) const

Definition at line 8862 of file object.cc.

8862 {
8863 return FunctionType::HasOptionalNamedParameters(signature());
8864}
bool HasOptionalNamedParameters() const
Definition: object.h:9609

◆ HasOptionalParameters()

bool dart::Function::HasOptionalParameters ( ) const

Definition at line 8859 of file object.cc.

8859 {
8860 return FunctionType::HasOptionalParameters(signature());
8861}
bool HasOptionalParameters() const
Definition: object.h:9603

◆ HasOptionalPositionalParameters()

bool dart::Function::HasOptionalPositionalParameters ( ) const

Definition at line 8865 of file object.cc.

8865 {
8867}
bool HasOptionalPositionalParameters() const
Definition: object.h:9617

◆ HasParent()

bool dart::Function::HasParent ( ) const
inline

Definition at line 3930 of file object.h.

3930{ return parent_function() != Function::null(); }

◆ HasRequiredNamedParameters()

bool dart::Function::HasRequiredNamedParameters ( ) const

Definition at line 8731 of file object.cc.

8731 {
8732#if defined(DART_PRECOMPILED_RUNTIME)
8733 if (signature() == FunctionType::null()) {
8734 // Signatures for functions with required named parameters are not dropped.
8735 return false;
8736 }
8737#endif
8738 return FunctionType::Handle(signature()).HasRequiredNamedParameters();
8739}

◆ HasSavedArgumentsDescriptor()

bool dart::Function::HasSavedArgumentsDescriptor ( ) const
inline

Definition at line 3273 of file object.h.

3273 {
3275 }

◆ HasThisParameter()

bool dart::Function::HasThisParameter ( ) const
inline

Definition at line 3369 of file object.h.

3369 {
3370 return IsDynamicFunction(/*allow_abstract=*/true) ||
3371 IsGenerativeConstructor() || (IsFieldInitializer() && !is_static());
3372 }
bool IsDynamicFunction(bool allow_abstract=false) const
Definition: object.h:3374
bool IsGenerativeConstructor() const
Definition: object.h:3363

◆ HasUnboxedParameters()

bool dart::Function::HasUnboxedParameters ( ) const
inline

Definition at line 3836 of file object.h.

3836 {
3837 return untag()->unboxed_parameters_info_.HasUnboxedParameters();
3838 }

◆ HasUnboxedReturnValue()

bool dart::Function::HasUnboxedReturnValue ( ) const
inline

Definition at line 3839 of file object.h.

3839{ return has_unboxed_return(); }
bool has_unboxed_return() const
Definition: object.h:3803

◆ ic_data_array()

ArrayPtr dart::Function::ic_data_array ( ) const

Definition at line 11272 of file object.cc.

11272 {
11273 return untag()->ic_data_array<std::memory_order_acquire>();
11274}

◆ ImplicitClosureFunction()

FunctionPtr dart::Function::ImplicitClosureFunction ( ) const

Definition at line 10385 of file object.cc.

10385 {
10386 // Return the existing implicit closure function if any.
10387 if (implicit_closure_function() != Function::null()) {
10388 return implicit_closure_function();
10389 }
10390
10391#if defined(DART_PRECOMPILED_RUNTIME)
10392 // In AOT mode all implicit closures are pre-created.
10393 FATAL("Cannot create implicit closure in AOT!");
10394 return Function::null();
10395#else
10397 Thread* thread = Thread::Current();
10398 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
10399
10400 if (implicit_closure_function() != Function::null()) {
10401 return implicit_closure_function();
10402 }
10403
10404 // Create closure function.
10405 Zone* zone = thread->zone();
10406 const String& closure_name = String::Handle(zone, name());
10407 const Function& closure_function = Function::Handle(
10408 zone, NewImplicitClosureFunction(closure_name, *this, token_pos()));
10409
10410 // Set closure function's context scope.
10411 if (is_static() || IsConstructor()) {
10412 closure_function.set_context_scope(Object::empty_context_scope());
10413 } else {
10414 const ContextScope& context_scope = ContextScope::Handle(
10416 closure_function.set_context_scope(context_scope);
10417 }
10418
10419 FunctionType& closure_signature =
10420 FunctionType::Handle(zone, closure_function.signature());
10421
10422 const auto& cls = Class::Handle(zone, Owner());
10423
10424 if (!is_static() && !IsConstructor() &&
10426 closure_function.set_awaiter_link({0, 0});
10427 }
10428
10429 const intptr_t num_type_params =
10430 IsConstructor() ? cls.NumTypeParameters() : NumTypeParameters();
10431
10432 TypeArguments& instantiator_type_arguments = TypeArguments::Handle(zone);
10433 TypeArguments& function_type_arguments = TypeArguments::Handle(zone);
10434
10435 FunctionTypeMapping* function_type_mapping = nullptr;
10436 FunctionTypeMapping scope(zone, &function_type_mapping,
10437 FunctionType::Handle(zone, signature()),
10438 closure_signature);
10439
10440 auto transform_type = [&](AbstractType& type) {
10441 if (num_type_params > 0) {
10442 if (IsConstructor()) {
10443 type = type.UpdateFunctionTypes(num_type_params, kAllFree, Heap::kOld,
10444 nullptr);
10445 if (!type.IsInstantiated(kCurrentClass)) {
10446 type = type.InstantiateFrom(
10447 instantiator_type_arguments, function_type_arguments,
10448 kNoneFree /* avoid truncating parent type args */, Heap::kOld);
10449 }
10450 } else {
10451 type = type.UpdateFunctionTypes(0, kNoneFree, Heap::kOld,
10452 function_type_mapping);
10453 }
10454 }
10455 };
10456
10457 auto transform_type_args = [&](TypeArguments& type_args) {
10458 ASSERT(num_type_params > 0);
10459 if (!type_args.IsNull()) {
10460 if (IsConstructor()) {
10461 type_args = type_args.UpdateFunctionTypes(num_type_params, kAllFree,
10462 Heap::kOld, nullptr);
10463 if (!type_args.IsInstantiated(kCurrentClass)) {
10464 type_args = type_args.InstantiateFrom(
10465 instantiator_type_arguments, function_type_arguments,
10466 kNoneFree /* avoid truncating parent type args */, Heap::kOld);
10467 }
10468 } else {
10469 type_args = type_args.UpdateFunctionTypes(0, kNoneFree, Heap::kOld,
10470 function_type_mapping);
10471 }
10472 }
10473 };
10474
10475 // Set closure function's type parameters.
10476 if (num_type_params > 0) {
10477 const TypeParameters& old_type_params = TypeParameters::Handle(
10478 zone, IsConstructor() ? cls.type_parameters() : type_parameters());
10479 const TypeParameters& new_type_params =
10481 // No need to set names that are ignored in a signature, however, the
10482 // length of the names array defines the number of type parameters.
10483 new_type_params.set_names(Array::Handle(zone, old_type_params.names()));
10484 new_type_params.set_flags(Array::Handle(zone, old_type_params.flags()));
10485
10486 closure_signature.SetTypeParameters(new_type_params);
10487 ASSERT(closure_signature.NumTypeParameters() == num_type_params);
10488
10489 TypeArguments& type_args = TypeArguments::Handle(zone);
10490 type_args = TypeArguments::New(num_type_params);
10491 TypeParameter& type_param = TypeParameter::Handle(zone);
10492 for (intptr_t i = 0; i < num_type_params; i++) {
10493 type_param = closure_signature.TypeParameterAt(i);
10494 type_args.SetTypeAt(i, type_param);
10495 }
10496
10497 if (IsConstructor()) {
10498 instantiator_type_arguments =
10499 type_args.ToInstantiatorTypeArguments(thread, cls);
10500 } else {
10501 ASSERT(NumTypeArguments() == type_args.Length());
10502 function_type_arguments = type_args.ptr();
10503 }
10504
10505 type_args = old_type_params.bounds();
10506 transform_type_args(type_args);
10507 new_type_params.set_bounds(type_args);
10508
10509 type_args = old_type_params.defaults();
10510 transform_type_args(type_args);
10511 new_type_params.set_defaults(type_args);
10512 }
10513
10514 // Set closure function's result type.
10515 AbstractType& result_type = AbstractType::Handle(zone);
10516 if (IsConstructor()) {
10517 result_type = cls.DeclarationType();
10518 } else {
10519 result_type = this->result_type();
10520 }
10521 transform_type(result_type);
10522 closure_signature.set_result_type(result_type);
10523
10524 // Set closure function's end token to this end token.
10525 closure_function.set_end_token_pos(end_token_pos());
10526
10527 // The closurized method stub just calls into the original method and should
10528 // therefore be skipped by the debugger and in stack traces.
10529 closure_function.set_is_debuggable(false);
10530 closure_function.set_is_visible(false);
10531
10532 // Set closure function's formal parameters to this formal parameters,
10533 // removing the receiver if this is an instance method and adding the closure
10534 // object as first parameter.
10535 const int kClosure = 1;
10536 const int num_implicit_params = NumImplicitParameters();
10537 const int num_fixed_params =
10538 kClosure - num_implicit_params + num_fixed_parameters();
10539 const int num_opt_params = NumOptionalParameters();
10540 const bool has_opt_pos_params = HasOptionalPositionalParameters();
10541 const int num_params = num_fixed_params + num_opt_params;
10542 const int num_pos_params = has_opt_pos_params ? num_params : num_fixed_params;
10543 closure_signature.set_num_fixed_parameters(num_fixed_params);
10544 closure_signature.SetNumOptionalParameters(num_opt_params,
10545 has_opt_pos_params);
10546 closure_signature.set_parameter_types(
10547 Array::Handle(zone, Array::New(num_params, Heap::kOld)));
10548 closure_function.CreateNameArray();
10549 closure_signature.CreateNameArrayIncludingFlags();
10550 AbstractType& param_type = AbstractType::Handle(zone);
10551 String& param_name = String::Handle(zone);
10552 // Add implicit closure object parameter.
10553 param_type = Type::DynamicType();
10554 closure_signature.SetParameterTypeAt(0, param_type);
10555 closure_function.SetParameterNameAt(0, Symbols::ClosureParameter());
10556 for (int i = kClosure; i < num_pos_params; i++) {
10557 param_type = ParameterTypeAt(num_implicit_params - kClosure + i);
10558 transform_type(param_type);
10559 closure_signature.SetParameterTypeAt(i, param_type);
10560 param_name = ParameterNameAt(num_implicit_params - kClosure + i);
10561 // Set the name in the function for positional parameters.
10562 closure_function.SetParameterNameAt(i, param_name);
10563 }
10564 for (int i = num_pos_params; i < num_params; i++) {
10565 param_type = ParameterTypeAt(num_implicit_params - kClosure + i);
10566 transform_type(param_type);
10567 closure_signature.SetParameterTypeAt(i, param_type);
10568 param_name = ParameterNameAt(num_implicit_params - kClosure + i);
10569 // Set the name in the signature for named parameters.
10570 closure_signature.SetParameterNameAt(i, param_name);
10571 if (IsRequiredAt(num_implicit_params - kClosure + i)) {
10572 closure_signature.SetIsRequiredAt(i);
10573 }
10574 }
10575 closure_signature.FinalizeNameArray();
10576 closure_function.InheritKernelOffsetFrom(*this);
10577
10578 if (!is_static() && !IsConstructor()) {
10579 // Change covariant parameter types to Object?.
10580 BitVector is_covariant(zone, NumParameters());
10581 BitVector is_generic_covariant_impl(zone, NumParameters());
10582 kernel::ReadParameterCovariance(*this, &is_covariant,
10583 &is_generic_covariant_impl);
10584
10585 ObjectStore* object_store = IsolateGroup::Current()->object_store();
10586 const auto& object_type =
10587 Type::Handle(zone, object_store->nullable_object_type());
10588 ASSERT(object_type.IsCanonical());
10589 for (intptr_t i = kClosure; i < num_params; ++i) {
10590 const intptr_t original_param_index = num_implicit_params - kClosure + i;
10591 if (is_covariant.Contains(original_param_index) ||
10592 is_generic_covariant_impl.Contains(original_param_index)) {
10593 closure_signature.SetParameterTypeAt(i, object_type);
10594 }
10595 }
10596 }
10597 ASSERT(!closure_signature.IsFinalized());
10598 closure_signature ^= ClassFinalizer::FinalizeType(closure_signature);
10599 closure_function.SetSignature(closure_signature);
10600 set_implicit_closure_function(closure_function);
10601 ASSERT(closure_function.IsImplicitClosureFunction());
10603 return closure_function.ptr();
10604#endif // defined(DART_PRECOMPILED_RUNTIME)
10605}
intptr_t NumOptionalParameters() const
Definition: object.cc:8868
intptr_t NumTypeArguments() const
Definition: object.cc:8853
bool HasOptionalPositionalParameters() const
Definition: object.cc:8865
static FunctionPtr NewImplicitClosureFunction(const String &name, const Function &parent, TokenPosition token_pos)
Definition: object.cc:10358
bool IsConstructor() const
Definition: object.h:3360
ContextScopePtr context_scope() const
Definition: object.cc:8048
bool HasImplicitClosureFunction() const
Definition: object.h:3326
AbstractTypePtr result_type() const
Definition: object.h:3099
ObjectStore * object_store() const
Definition: isolate.h:510
static ContextScopePtr CreateImplicitClosureScope(const Function &func)
Definition: scopes.cc:580
static bool IsPossibleAwaiterLink(const Class &cls)
Definition: stack_trace.cc:711
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition: object.cc:7675
static TypeParametersPtr New(Heap::Space space=Heap::kOld)
Definition: object.cc:6723
static TypePtr DynamicType()
#define FATAL(error)
void ReadParameterCovariance(const Function &function, BitVector *is_covariant, BitVector *is_generic_covariant_impl)
Definition: kernel.cc:599
@ kCurrentClass
Definition: object.h:2250
@ kNoneFree
Definition: object.h:2926

◆ ImplicitClosureTarget()

FunctionPtr dart::Function::ImplicitClosureTarget ( Zone zone) const

Definition at line 10734 of file object.cc.

10734 {
10735 const auto& parent = Function::Handle(zone, parent_function());
10736 const auto& func_name = String::Handle(zone, parent.name());
10737 const auto& owner = Class::Handle(zone, parent.Owner());
10738 Thread* thread = Thread::Current();
10739 const auto& error = owner.EnsureIsFinalized(thread);
10740 ASSERT(error == Error::null());
10741 auto& target =
10742 Function::Handle(zone, Resolver::ResolveFunction(zone, owner, func_name));
10743
10744 if (!target.IsNull() && (target.ptr() != parent.ptr())) {
10745 DEBUG_ASSERT(IsolateGroup::Current()->HasAttemptedReload());
10746 if ((target.is_static() != parent.is_static()) ||
10747 (target.kind() != parent.kind())) {
10749 }
10750 }
10751
10752 return target.ptr();
10753}
uint32_t * target

◆ ImplicitInstanceClosure()

ClosurePtr dart::Function::ImplicitInstanceClosure ( const Instance receiver) const

Definition at line 10722 of file object.cc.

10722 {
10724 Zone* zone = Thread::Current()->zone();
10725 TypeArguments& instantiator_type_arguments = TypeArguments::Handle(zone);
10727 instantiator_type_arguments = receiver.GetTypeArguments();
10728 }
10729 ASSERT(!HasGenericParent()); // No generic parent function.
10730 return Closure::New(instantiator_type_arguments,
10731 Object::null_type_arguments(), *this, receiver);
10732}
static ClosurePtr New(const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, const Function &function, const Object &context, Heap::Space space=Heap::kNew)
Definition: object.cc:25942
bool HasInstantiatedSignature(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition: object.cc:10785
bool HasGenericParent() const
Definition: object.h:3143

◆ ImplicitStaticClosure()

ClosurePtr dart::Function::ImplicitStaticClosure ( ) const

Definition at line 10700 of file object.cc.

10700 {
10702 if (implicit_static_closure() != Closure::null()) {
10703 return implicit_static_closure();
10704 }
10705
10706 auto thread = Thread::Current();
10707 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
10708
10709 if (implicit_static_closure() != Closure::null()) {
10710 return implicit_static_closure();
10711 }
10712
10713 Zone* zone = thread->zone();
10714 const auto& closure =
10715 Closure::Handle(zone, Closure::New(Object::null_type_arguments(),
10716 Object::null_type_arguments(), *this,
10717 Object::null_object(), Heap::kOld));
10718 set_implicit_static_closure(closure);
10719 return implicit_static_closure();
10720}
bool IsImplicitStaticClosureFunction() const
Definition: object.h:3917
std::function< void()> closure
Definition: closure.h:14

◆ InheritKernelOffsetFrom() [1/2]

void dart::Function::InheritKernelOffsetFrom ( const Field src) const

Definition at line 10859 of file object.cc.

10859 {
10860#if defined(DART_PRECOMPILED_RUNTIME)
10861 UNREACHABLE();
10862#else
10863 set_kernel_offset(src.kernel_offset());
10864#endif
10865}
void set_kernel_offset(intptr_t value) const
Definition: object.h:3558

◆ InheritKernelOffsetFrom() [2/2]

void dart::Function::InheritKernelOffsetFrom ( const Function src) const

Definition at line 10851 of file object.cc.

10851 {
10852#if defined(DART_PRECOMPILED_RUNTIME)
10853 UNREACHABLE();
10854#else
10855 StoreNonPointer(&untag()->kernel_offset_, src.untag()->kernel_offset_);
10856#endif
10857}
void StoreNonPointer(const FieldType *addr, ValueType value) const
Definition: object.h:819

◆ InstallOptimizedCode()

void dart::Function::InstallOptimizedCode ( const Code code) const

Definition at line 7899 of file object.cc.

7899 {
7900 ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
7901 // We may not have previous code if FLAG_precompile is set.
7902 // Hot-reload may have already disabled the current code.
7903 if (HasCode() && !Code::Handle(CurrentCode()).IsDisabled()) {
7904 Code::Handle(CurrentCode()).DisableDartCode();
7905 }
7907}
void AttachCode(const Code &value) const
Definition: object.cc:7927

◆ InstanceSize()

static intptr_t dart::Function::InstanceSize ( )
inlinestatic

Definition at line 3985 of file object.h.

3985 {
3987 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758

◆ InternalSignature()

StringPtr dart::Function::InternalSignature ( ) const

Definition at line 10616 of file object.cc.

10616 {
10617#if defined(DART_PRECOMPILED_RUNTIME)
10618 if (signature() == FunctionType::null()) {
10619 return String::null();
10620 }
10621#endif
10622 Thread* thread = Thread::Current();
10623 ZoneTextBuffer printer(thread->zone());
10624 const FunctionType& sig = FunctionType::Handle(signature());
10625 sig.Print(kInternalName, &printer);
10626 return Symbols::New(thread, printer.buffer());
10627}
@ kInternalName
Definition: object.h:622

◆ is_ffi_native()

bool dart::Function::is_ffi_native ( ) const

Definition at line 8542 of file object.cc.

8542 {
8543 return is_native() && is_external();
8544}

◆ is_old_native()

bool dart::Function::is_old_native ( ) const

Definition at line 8538 of file object.cc.

8538 {
8539 return is_native() && !is_external();
8540}

◆ is_optimizable()

bool dart::Function::is_optimizable ( ) const
inline

Definition at line 4200 of file object.h.

4200 {
4201#if defined(DART_PRECOMPILED_RUNTIME)
4202 return false;
4203#else
4204 return untag()->packed_fields_.Read<UntaggedFunction::PackedOptimizable>();
4205#endif
4206 }

◆ is_sticky_specialization()

bool dart::Function::is_sticky_specialization ( ) const

Definition at line 8486 of file object.cc.

8486 {
8487 ASSERT(kind() == UntaggedFunction::kIrregexpFunction);
8488 const Array& pair = Array::Cast(Object::Handle(data()));
8490}
static constexpr bool decode(intptr_t value)
Definition: bitfield.h:171
intptr_t Value() const
Definition: object.h:9990

◆ is_unboxed_double_parameter_at()

bool dart::Function::is_unboxed_double_parameter_at ( intptr_t  index) const
inline

Definition at line 3793 of file object.h.

3793 {
3794#if !defined(DART_PRECOMPILED_RUNTIME)
3795 ASSERT(index >= 0);
3796 index++; // position 0 is reserved for the return value
3797 return untag()->unboxed_parameters_info_.IsUnboxedDouble(index);
3798#else
3799 return false;
3800#endif // !defined(DART_PRECOMPILED_RUNTIME)
3801 }

◆ is_unboxed_integer_parameter_at()

bool dart::Function::is_unboxed_integer_parameter_at ( intptr_t  index) const
inline

Definition at line 3783 of file object.h.

3783 {
3784#if !defined(DART_PRECOMPILED_RUNTIME)
3785 ASSERT(index >= 0);
3786 index++; // position 0 is reserved for the return value
3787 return untag()->unboxed_parameters_info_.IsUnboxedInteger(index);
3788#else
3789 return false;
3790#endif // !defined(DART_PRECOMPILED_RUNTIME)
3791 }

◆ is_unboxed_parameter_at()

bool dart::Function::is_unboxed_parameter_at ( intptr_t  index) const
inline

Definition at line 3773 of file object.h.

3773 {
3774#if !defined(DART_PRECOMPILED_RUNTIME)
3775 ASSERT(index >= 0);
3776 index++; // position 0 is reserved for the return value
3777 return untag()->unboxed_parameters_info_.IsUnboxed(index);
3778#else
3779 return false;
3780#endif // !defined(DART_PRECOMPILED_RUNTIME)
3781 }

◆ is_visible()

static bool dart::Function::is_visible ( FunctionPtr  f)
inlinestatic

Definition at line 4185 of file object.h.

4185 {
4186 return f.untag()->kind_tag_.Read<VisibleBit>();
4187 }

◆ IsAsyncFunction()

bool dart::Function::IsAsyncFunction ( ) const
inline

Definition at line 3962 of file object.h.

3962 {
3964 }
UntaggedFunction::AsyncModifier modifier() const
Definition: object.h:3354

◆ IsAsyncGenerator()

bool dart::Function::IsAsyncGenerator ( ) const
inline

Definition at line 3972 of file object.h.

3972 {
3974 }

◆ IsCachableIdempotent()

bool dart::Function::IsCachableIdempotent ( ) const

Definition at line 9055 of file object.cc.

9055 {
9056 if (!has_pragma()) return false;
9057
9058 const bool has_vm_pragma =
9059 Library::FindPragma(Thread::Current(), /*only_core=*/false, *this,
9060 Symbols::vm_cachable_idempotent());
9061 if (!has_vm_pragma) return false;
9062
9063 // For run_vm_tests and runtime/tests/vm allow marking arbitrary functions.
9064 return InVmTests(*this);
9065}

◆ IsClosureFunction()

bool dart::Function::IsClosureFunction ( ) const
inline

Definition at line 3891 of file object.h.

3891 {
3893 return (k == UntaggedFunction::kClosureFunction) ||
3894 (k == UntaggedFunction::kImplicitClosureFunction);
3895 }

◆ IsConstructor()

bool dart::Function::IsConstructor ( ) const
inline

Definition at line 3360 of file object.h.

3360 {
3361 return kind() == UntaggedFunction::kConstructor;
3362 }

◆ IsDispatcherOrImplicitAccessor()

bool dart::Function::IsDispatcherOrImplicitAccessor ( ) const
inline

Definition at line 3842 of file object.h.

3842 {
3843 switch (kind()) {
3844 case UntaggedFunction::kImplicitGetter:
3845 case UntaggedFunction::kImplicitSetter:
3846 case UntaggedFunction::kImplicitStaticGetter:
3847 case UntaggedFunction::kNoSuchMethodDispatcher:
3848 case UntaggedFunction::kInvokeFieldDispatcher:
3849 case UntaggedFunction::kDynamicInvocationForwarder:
3850 return true;
3851 default:
3852 return false;
3853 }
3854 }

◆ IsDynamicClosureCallDispatcher() [1/2]

bool dart::Function::IsDynamicClosureCallDispatcher ( ) const
inline

Definition at line 3308 of file object.h.

3308 {
3309 if (!IsDynamicInvokeFieldDispatcher()) return false;
3311 }
bool IsDynamicClosureCallDispatcher() const
Definition: object.h:3308
bool IsDynamicInvokeFieldDispatcher() const
Definition: object.h:3300

◆ IsDynamicClosureCallDispatcher() [2/2]

bool dart::Function::IsDynamicClosureCallDispatcher ( Thread thread) const

Definition at line 10376 of file object.cc.

10376 {
10377 if (!IsInvokeFieldDispatcher()) return false;
10378 if (thread->isolate_group()->object_store()->closure_class() != Owner()) {
10379 return false;
10380 }
10381 const auto& handle = String::Handle(thread->zone(), name());
10382 return handle.Equals(Symbols::DynamicCall());
10383}

◆ IsDynamicFunction()

bool dart::Function::IsDynamicFunction ( bool  allow_abstract = false) const
inline

Definition at line 3374 of file object.h.

3374 {
3375 if (is_static() || (!allow_abstract && is_abstract())) {
3376 return false;
3377 }
3378 switch (kind()) {
3379 case UntaggedFunction::kRegularFunction:
3380 case UntaggedFunction::kGetterFunction:
3381 case UntaggedFunction::kSetterFunction:
3382 case UntaggedFunction::kImplicitGetter:
3383 case UntaggedFunction::kImplicitSetter:
3384 case UntaggedFunction::kMethodExtractor:
3385 case UntaggedFunction::kNoSuchMethodDispatcher:
3386 case UntaggedFunction::kInvokeFieldDispatcher:
3387 case UntaggedFunction::kDynamicInvocationForwarder:
3388 case UntaggedFunction::kRecordFieldGetter:
3389 return true;
3390 case UntaggedFunction::kClosureFunction:
3391 case UntaggedFunction::kImplicitClosureFunction:
3392 case UntaggedFunction::kConstructor:
3393 case UntaggedFunction::kImplicitStaticGetter:
3394 case UntaggedFunction::kFieldInitializer:
3395 case UntaggedFunction::kIrregexpFunction:
3396 return false;
3397 default:
3398 UNREACHABLE();
3399 return false;
3400 }
3401 }

◆ IsDynamicInvocationForwarder()

bool dart::Function::IsDynamicInvocationForwarder ( ) const
inline

Definition at line 3314 of file object.h.

3314 {
3315 return kind() == UntaggedFunction::kDynamicInvocationForwarder;
3316 }

◆ IsDynamicInvocationForwarderName() [1/2]

bool dart::Function::IsDynamicInvocationForwarderName ( const String name)
static

Definition at line 4190 of file object.cc.

4190 {
4192}

◆ IsDynamicInvocationForwarderName() [2/2]

bool dart::Function::IsDynamicInvocationForwarderName ( StringPtr  name)
static

Definition at line 4194 of file object.cc.

4194 {
4195 return String::StartsWith(name, Symbols::DynamicPrefix().ptr());
4196}
bool StartsWith(const String &other) const
Definition: object.h:10298

◆ IsDynamicInvokeFieldDispatcher()

bool dart::Function::IsDynamicInvokeFieldDispatcher ( ) const
inline

Definition at line 3300 of file object.h.

3300 {
3301 return IsInvokeFieldDispatcher() &&
3303 }

◆ IsFactory()

bool dart::Function::IsFactory ( ) const
inline

Definition at line 3367 of file object.h.

3367{ return IsConstructor() && is_static(); }

◆ IsFfiCallbackTrampoline() [1/2]

bool dart::Function::IsFfiCallbackTrampoline ( ) const
inline

Definition at line 3938 of file object.h.

3938 {
3939 return kind() == UntaggedFunction::kFfiTrampoline;
3940 }

◆ IsFfiCallbackTrampoline() [2/2]

static bool dart::Function::IsFfiCallbackTrampoline ( FunctionPtr  function)
inlinestatic

Definition at line 3941 of file object.h.

3941 {
3942 NoSafepointScope no_safepoint;
3943 return function->untag()->kind_tag_.Read<KindBits>() ==
3944 UntaggedFunction::kFfiTrampoline;
3945 }

◆ IsFfiCallClosure()

bool dart::Function::IsFfiCallClosure ( ) const

Definition at line 9067 of file object.cc.

9067 {
9068 if (!IsNonImplicitClosureFunction()) return false;
9069 if (!has_pragma()) return false;
9070 return Library::FindPragma(Thread::Current(), /*only_core=*/false, *this,
9071 Symbols::vm_ffi_call_closure());
9072}

◆ IsFieldInitializer()

bool dart::Function::IsFieldInitializer ( ) const
inline

Definition at line 3885 of file object.h.

3885 {
3886 return kind() == UntaggedFunction::kFieldInitializer;
3887 }

◆ IsGenerativeConstructor()

bool dart::Function::IsGenerativeConstructor ( ) const
inline

Definition at line 3363 of file object.h.

3363 {
3364 return IsConstructor() && !is_static();
3365 }

◆ IsGeneric()

bool dart::Function::IsGeneric ( ) const

Definition at line 8844 of file object.cc.

8844 {
8845 return FunctionType::IsGeneric(signature());
8846}
bool IsGeneric() const
Definition: object.h:9747

◆ IsGetterFunction()

bool dart::Function::IsGetterFunction ( ) const
inline

Definition at line 3857 of file object.h.

3857 {
3858 return kind() == UntaggedFunction::kGetterFunction;
3859 }

◆ IsIdempotent()

bool dart::Function::IsIdempotent ( ) const

Definition at line 9042 of file object.cc.

9042 {
9043 if (!has_pragma()) return false;
9044
9045#if defined(TESTING)
9046 const bool kAllowOnlyForCoreLibFunctions = false;
9047#else
9048 const bool kAllowOnlyForCoreLibFunctions = true;
9049#endif // defined(TESTING)
9050
9051 return Library::FindPragma(Thread::Current(), kAllowOnlyForCoreLibFunctions,
9052 *this, Symbols::vm_idempotent());
9053}

◆ IsImplicitClosureFunction() [1/2]

bool dart::Function::IsImplicitClosureFunction ( ) const
inline

Definition at line 3903 of file object.h.

3903 {
3904 return kind() == UntaggedFunction::kImplicitClosureFunction;
3905 }

◆ IsImplicitClosureFunction() [2/2]

static bool dart::Function::IsImplicitClosureFunction ( FunctionPtr  func)
inlinestatic

Definition at line 3906 of file object.h.

3906 {
3907 return KindOf(func) == UntaggedFunction::kImplicitClosureFunction;
3908 }
static UntaggedFunction::Kind KindOf(FunctionPtr func)
Definition: object.h:3350

◆ IsImplicitConstructor()

bool dart::Function::IsImplicitConstructor ( ) const

Definition at line 10218 of file object.cc.

10218 {
10219 return IsGenerativeConstructor() && (token_pos() == end_token_pos());
10220}

◆ IsImplicitGetterFunction()

bool dart::Function::IsImplicitGetterFunction ( ) const
inline

Definition at line 3862 of file object.h.

3862 {
3863 return kind() == UntaggedFunction::kImplicitGetter;
3864 }

◆ IsImplicitGetterOrSetter()

bool dart::Function::IsImplicitGetterOrSetter ( ) const
inline

Definition at line 3318 of file object.h.

3318 {
3319 return kind() == UntaggedFunction::kImplicitGetter ||
3320 kind() == UntaggedFunction::kImplicitSetter ||
3321 kind() == UntaggedFunction::kImplicitStaticGetter;
3322 }

◆ IsImplicitInstanceClosureFunction() [1/2]

bool dart::Function::IsImplicitInstanceClosureFunction ( ) const
inline

Definition at line 3924 of file object.h.

3924 {
3925 return IsImplicitClosureFunction() && !is_static();
3926 }

◆ IsImplicitInstanceClosureFunction() [2/2]

bool dart::Function::IsImplicitInstanceClosureFunction ( FunctionPtr  func)
static

Definition at line 10230 of file object.cc.

10230 {
10231 NoSafepointScope no_safepoint;
10232 uint32_t kind_tag = func->untag()->kind_tag_.load(std::memory_order_relaxed);
10233 return (KindBits::decode(kind_tag) ==
10234 UntaggedFunction::kImplicitClosureFunction) &&
10235 !StaticBit::decode(kind_tag);
10236}
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124

◆ IsImplicitSetterFunction()

bool dart::Function::IsImplicitSetterFunction ( ) const
inline

Definition at line 3878 of file object.h.

3878 {
3879 return kind() == UntaggedFunction::kImplicitSetter;
3880 }

◆ IsImplicitStaticClosureFunction() [1/2]

bool dart::Function::IsImplicitStaticClosureFunction ( ) const
inline

Definition at line 3917 of file object.h.

3917 {
3918 return IsImplicitClosureFunction() && is_static();
3919 }

◆ IsImplicitStaticClosureFunction() [2/2]

bool dart::Function::IsImplicitStaticClosureFunction ( FunctionPtr  func)
static

Definition at line 10222 of file object.cc.

10222 {
10223 NoSafepointScope no_safepoint;
10224 uint32_t kind_tag = func->untag()->kind_tag_.load(std::memory_order_relaxed);
10225 return (KindBits::decode(kind_tag) ==
10226 UntaggedFunction::kImplicitClosureFunction) &&
10227 StaticBit::decode(kind_tag);
10228}

◆ IsImplicitStaticGetterFunction()

bool dart::Function::IsImplicitStaticGetterFunction ( ) const
inline

Definition at line 3868 of file object.h.

3868 {
3869 return kind() == UntaggedFunction::kImplicitStaticGetter;
3870 }

◆ IsInvokeFieldDispatcher()

bool dart::Function::IsInvokeFieldDispatcher ( ) const
inline

Definition at line 3296 of file object.h.

3296 {
3297 return kind() == UntaggedFunction::kInvokeFieldDispatcher;
3298 }

◆ IsIrregexpFunction()

bool dart::Function::IsIrregexpFunction ( ) const
inline

Definition at line 3898 of file object.h.

3898 {
3899 return kind() == UntaggedFunction::kIrregexpFunction;
3900 }

◆ IsLocalFunction()

bool dart::Function::IsLocalFunction ( ) const
inline

Definition at line 3933 of file object.h.

3933 {
3934 return !IsImplicitClosureFunction() && HasParent();
3935 }
bool HasParent() const
Definition: object.h:3930

◆ IsMethodExtractor()

bool dart::Function::IsMethodExtractor ( ) const
inline

Definition at line 3284 of file object.h.

3284 {
3285 return kind() == UntaggedFunction::kMethodExtractor;
3286 }

◆ IsNonImplicitClosureFunction()

bool dart::Function::IsNonImplicitClosureFunction ( ) const
inline

Definition at line 3911 of file object.h.

3911 {
3913 }

◆ IsNoSuchMethodDispatcher()

bool dart::Function::IsNoSuchMethodDispatcher ( ) const
inline

Definition at line 3288 of file object.h.

3288 {
3289 return kind() == UntaggedFunction::kNoSuchMethodDispatcher;
3290 }

◆ IsOptimizable()

bool dart::Function::IsOptimizable ( ) const

Definition at line 8930 of file object.cc.

8930 {
8931 if (FLAG_precompiled_mode) {
8932 return true;
8933 }
8934 if (ForceOptimize()) return true;
8935 if (is_old_native()) {
8936 // Native methods don't need to be optimized.
8937 return false;
8938 }
8939 if (is_optimizable() && (script() != Script::null())) {
8940 // Additional check needed for implicit getters.
8941 return (unoptimized_code() == Object::null()) ||
8942 (Code::Handle(unoptimized_code()).Size() <
8943 FLAG_huge_method_cutoff_in_code_size);
8944 }
8945 return false;
8946}
bool is_old_native() const
Definition: object.cc:8538
bool is_optimizable() const
Definition: object.h:4200

◆ IsPreferInline()

bool dart::Function::IsPreferInline ( ) const

Definition at line 9035 of file object.cc.

9035 {
9036 if (!has_pragma()) return false;
9037
9038 return Library::FindPragma(Thread::Current(), /*only_core=*/false, *this,
9039 Symbols::vm_prefer_inline());
9040}

◆ IsPrivate()

bool dart::Function::IsPrivate ( ) const

Definition at line 10837 of file object.cc.

10837 {
10839}
static bool IsPrivate(const String &name)
Definition: object.cc:14619

◆ IsRecognized()

bool dart::Function::IsRecognized ( ) const
inline

Definition at line 3624 of file object.h.

3624 {
3626 }
MethodRecognizer::Kind recognized_kind() const
Definition: object.h:3619

◆ IsRecordFieldGetter()

bool dart::Function::IsRecordFieldGetter ( ) const
inline

Definition at line 3292 of file object.h.

3292 {
3293 return kind() == UntaggedFunction::kRecordFieldGetter;
3294 }

◆ IsRegularFunction()

bool dart::Function::IsRegularFunction ( ) const
inline

Definition at line 3280 of file object.h.

3280 {
3281 return kind() == UntaggedFunction::kRegularFunction;
3282 }

◆ IsRequiredAt()

bool dart::Function::IsRequiredAt ( intptr_t  index) const

Definition at line 8741 of file object.cc.

8741 {
8742#if defined(DART_PRECOMPILED_RUNTIME)
8743 if (signature() == FunctionType::null()) {
8744 // Signature is not dropped in aot when any named parameter is required.
8745 return false;
8746 }
8747#endif
8749 return false;
8750 }
8751 const FunctionType& sig = FunctionType::Handle(signature());
8752 return sig.IsRequiredAt(index);
8753}
bool HasOptionalNamedParameters() const
Definition: object.cc:8862

◆ IsSetterFunction()

bool dart::Function::IsSetterFunction ( ) const
inline

Definition at line 3873 of file object.h.

3873 {
3874 return kind() == UntaggedFunction::kSetterFunction;
3875 }

◆ IsStaticFunction()

bool dart::Function::IsStaticFunction ( ) const
inline

Definition at line 3402 of file object.h.

3402 {
3403 if (!is_static()) {
3404 return false;
3405 }
3406 switch (kind()) {
3407 case UntaggedFunction::kRegularFunction:
3408 case UntaggedFunction::kGetterFunction:
3409 case UntaggedFunction::kSetterFunction:
3410 case UntaggedFunction::kImplicitGetter:
3411 case UntaggedFunction::kImplicitSetter:
3412 case UntaggedFunction::kImplicitStaticGetter:
3413 case UntaggedFunction::kFieldInitializer:
3414 case UntaggedFunction::kIrregexpFunction:
3415 return true;
3416 case UntaggedFunction::kClosureFunction:
3417 case UntaggedFunction::kImplicitClosureFunction:
3418 case UntaggedFunction::kConstructor:
3419 case UntaggedFunction::kMethodExtractor:
3420 case UntaggedFunction::kNoSuchMethodDispatcher:
3421 case UntaggedFunction::kInvokeFieldDispatcher:
3422 case UntaggedFunction::kDynamicInvocationForwarder:
3423 case UntaggedFunction::kFfiTrampoline:
3424 case UntaggedFunction::kRecordFieldGetter:
3425 return false;
3426 default:
3427 UNREACHABLE();
3428 return false;
3429 }
3430 }

◆ IsSuspendableFunction()

bool dart::Function::IsSuspendableFunction ( ) const
inline

Definition at line 3957 of file object.h.

3957 {
3959 }

◆ IsSyncGenerator()

bool dart::Function::IsSyncGenerator ( ) const
inline

Definition at line 3967 of file object.h.

3967 {
3969 }

◆ IsTypedDataViewFactory()

bool dart::Function::IsTypedDataViewFactory ( ) const

Definition at line 8957 of file object.cc.

8957 {
8958 switch (recognized_kind()) {
8959 case MethodRecognizer::kTypedData_ByteDataView_factory:
8960 case MethodRecognizer::kTypedData_Int8ArrayView_factory:
8961 case MethodRecognizer::kTypedData_Uint8ArrayView_factory:
8962 case MethodRecognizer::kTypedData_Uint8ClampedArrayView_factory:
8963 case MethodRecognizer::kTypedData_Int16ArrayView_factory:
8964 case MethodRecognizer::kTypedData_Uint16ArrayView_factory:
8965 case MethodRecognizer::kTypedData_Int32ArrayView_factory:
8966 case MethodRecognizer::kTypedData_Uint32ArrayView_factory:
8967 case MethodRecognizer::kTypedData_Int64ArrayView_factory:
8968 case MethodRecognizer::kTypedData_Uint64ArrayView_factory:
8969 case MethodRecognizer::kTypedData_Float32ArrayView_factory:
8970 case MethodRecognizer::kTypedData_Float64ArrayView_factory:
8971 case MethodRecognizer::kTypedData_Float32x4ArrayView_factory:
8972 case MethodRecognizer::kTypedData_Int32x4ArrayView_factory:
8973 case MethodRecognizer::kTypedData_Float64x2ArrayView_factory:
8974 return true;
8975 default:
8976 return false;
8977 }
8978}

◆ IsUnmodifiableTypedDataViewFactory()

bool dart::Function::IsUnmodifiableTypedDataViewFactory ( ) const

Definition at line 8980 of file object.cc.

8980 {
8981 switch (recognized_kind()) {
8982 case MethodRecognizer::kTypedData_UnmodifiableByteDataView_factory:
8983 case MethodRecognizer::kTypedData_UnmodifiableInt8ArrayView_factory:
8984 case MethodRecognizer::kTypedData_UnmodifiableUint8ArrayView_factory:
8985 case MethodRecognizer::kTypedData_UnmodifiableUint8ClampedArrayView_factory:
8986 case MethodRecognizer::kTypedData_UnmodifiableInt16ArrayView_factory:
8987 case MethodRecognizer::kTypedData_UnmodifiableUint16ArrayView_factory:
8988 case MethodRecognizer::kTypedData_UnmodifiableInt32ArrayView_factory:
8989 case MethodRecognizer::kTypedData_UnmodifiableUint32ArrayView_factory:
8990 case MethodRecognizer::kTypedData_UnmodifiableInt64ArrayView_factory:
8991 case MethodRecognizer::kTypedData_UnmodifiableUint64ArrayView_factory:
8992 case MethodRecognizer::kTypedData_UnmodifiableFloat32ArrayView_factory:
8993 case MethodRecognizer::kTypedData_UnmodifiableFloat64ArrayView_factory:
8994 case MethodRecognizer::kTypedData_UnmodifiableFloat32x4ArrayView_factory:
8995 case MethodRecognizer::kTypedData_UnmodifiableInt32x4ArrayView_factory:
8996 case MethodRecognizer::kTypedData_UnmodifiableFloat64x2ArrayView_factory:
8997 return true;
8998 default:
8999 return false;
9000 }
9001}

◆ kernel_offset()

intptr_t dart::Function::kernel_offset ( ) const
inline

Definition at line 3550 of file object.h.

3550 {
3551#if defined(DART_PRECOMPILED_RUNTIME)
3552 return 0;
3553#else
3554 return untag()->kernel_offset_;
3555#endif
3556 }

◆ KernelLibrary()

TypedDataViewPtr dart::Function::KernelLibrary ( ) const

Definition at line 10936 of file object.cc.

10936 {
10938 return info.KernelLibrary(KernelLibraryIndex());
10939}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
intptr_t KernelLibraryIndex() const
Definition: object.cc:10948
KernelProgramInfoPtr KernelProgramInfo() const
Definition: object.cc:10919

◆ KernelLibraryIndex()

intptr_t dart::Function::KernelLibraryIndex ( ) const

Definition at line 10948 of file object.cc.

10948 {
10951 return -1;
10952 }
10953 if (is_eval_function()) {
10954 const auto& fdata = Array::Handle(Array::RawCast(data()));
10955 return Smi::Value(static_cast<SmiPtr>(fdata.At(
10956 static_cast<intptr_t>(EvalFunctionData::kKernelLibraryIndex))));
10957 }
10958 if (IsClosureFunction()) {
10959 const auto& parent = Function::Handle(parent_function());
10960 ASSERT(!parent.IsNull());
10961 return parent.KernelLibraryIndex();
10962 }
10963
10964 const auto& obj = Object::Handle(untag()->owner());
10965 if (obj.IsClass()) {
10966 const auto& lib = Library::Handle(Class::Cast(obj).library());
10967 return lib.kernel_library_index();
10968 }
10969 ASSERT(obj.IsPatchClass());
10970 return PatchClass::Cast(obj).kernel_library_index();
10971}

◆ KernelLibraryOffset()

intptr_t dart::Function::KernelLibraryOffset ( ) const

Definition at line 10941 of file object.cc.

10941 {
10942 const intptr_t kernel_library_index = KernelLibraryIndex();
10943 if (kernel_library_index == -1) return 0;
10945 return info.KernelLibraryStartOffset(kernel_library_index);
10946}

◆ KernelProgramInfo()

KernelProgramInfoPtr dart::Function::KernelProgramInfo ( ) const

Definition at line 10919 of file object.cc.

10919 {
10920 if (is_eval_function()) {
10921 const auto& fdata = Array::Handle(Array::RawCast(data()));
10923 fdata.At(static_cast<intptr_t>(EvalFunctionData::kKernelProgramInfo)));
10924 }
10925 if (IsClosureFunction()) {
10926 const auto& parent = Function::Handle(parent_function());
10927 return parent.KernelProgramInfo();
10928 }
10929 const auto& owner = Object::Handle(RawOwner());
10930 if (owner.IsClass()) {
10931 return Class::Cast(owner).KernelProgramInfo();
10932 }
10933 return PatchClass::Cast(owner).kernel_program_info();
10934}
ObjectPtr RawOwner() const
Definition: object.h:3083

◆ kind()

UntaggedFunction::Kind dart::Function::kind ( ) const
inline

Definition at line 3349 of file object.h.

3349{ return KindOf(ptr()); }

◆ kind_tag_offset()

static intptr_t dart::Function::kind_tag_offset ( )
inlinestatic

Definition at line 4128 of file object.h.

4128 {
4129 return OFFSET_OF(UntaggedFunction, kind_tag_);
4130 }

◆ KindOf()

static UntaggedFunction::Kind dart::Function::KindOf ( FunctionPtr  func)
inlinestatic

Definition at line 3350 of file object.h.

3350 {
3351 return func->untag()->kind_tag_.Read<KindBits>();
3352 }

◆ KindToCString()

const char * dart::Function::KindToCString ( UntaggedFunction::Kind  kind)
static

Definition at line 8419 of file object.cc.

8419 {
8421}
static const char * KindToCString(Kind k)
Definition: raw_object.h:1283

◆ MakesCopyOfParameters()

bool dart::Function::MakesCopyOfParameters ( ) const
inline

Definition at line 3514 of file object.h.

3514 {
3516 }
bool HasOptionalParameters() const
Definition: object.cc:8859
bool IsSuspendableFunction() const
Definition: object.h:3957

◆ maximum_unboxed_parameter_count()

static constexpr intptr_t dart::Function::maximum_unboxed_parameter_count ( )
inlinestaticconstexpr

Definition at line 3704 of file object.h.

3704 {
3705 // Subtracts one that represents the return value
3707 }

◆ MaxNumberOfParametersInRegisters()

intptr_t dart::Function::MaxNumberOfParametersInRegisters ( Zone zone) const

Definition at line 27248 of file object.cc.

27248 {
27249#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) || \
27250 defined(TARGET_ARCH_ARM)
27251 if (!FLAG_precompiled_mode) {
27252 return 0;
27253 }
27254
27255 if (!FLAG_use_register_cc) {
27256 return 0;
27257 }
27258
27259 if (IsGeneric()) {
27260 return 0;
27261 }
27262
27263 switch (kind()) {
27264 case UntaggedFunction::kClosureFunction:
27265 case UntaggedFunction::kImplicitClosureFunction:
27266 case UntaggedFunction::kNoSuchMethodDispatcher:
27267 case UntaggedFunction::kInvokeFieldDispatcher:
27268 case UntaggedFunction::kDynamicInvocationForwarder:
27269 case UntaggedFunction::kMethodExtractor:
27270 case UntaggedFunction::kFfiTrampoline:
27271 case UntaggedFunction::kFieldInitializer:
27272 case UntaggedFunction::kIrregexpFunction:
27273 return 0;
27274
27275 default:
27276 break;
27277 }
27278
27279 const auto unboxing_metadata = kernel::UnboxingInfoMetadataOf(*this, zone);
27280 if (unboxing_metadata != nullptr &&
27281 unboxing_metadata->must_use_stack_calling_convention) {
27282 return 0;
27283 }
27284
27285 // Getters and setters have fixed signatures.
27286 switch (kind()) {
27287 case UntaggedFunction::kGetterFunction:
27288 case UntaggedFunction::kImplicitGetter:
27289 case UntaggedFunction::kSetterFunction:
27290 case UntaggedFunction::kImplicitSetter:
27291 return num_fixed_parameters();
27292
27293 default:
27294 break;
27295 }
27296
27297 if (unboxing_metadata != nullptr &&
27298 unboxing_metadata->has_overrides_with_less_direct_parameters) {
27299 // Receiver (`this`) can always be passed in the register because it is
27300 // never an optional or named parameter.
27301 return unboxing_metadata->unboxed_args_info.length() + 1;
27302 }
27303
27304 return num_fixed_parameters();
27305#endif
27306 return 0;
27307}
bool IsGeneric() const
Definition: object.cc:8844
static UnboxingInfoMetadata * UnboxingInfoMetadataOf(Zone *zone, const KernelProgramInfo &kernel_program_info, const TypedDataView &kernel_data, intptr_t kernel_data_program_offset, intptr_t kernel_offset)
Definition: kernel.cc:778

◆ MayHaveUncheckedEntryPoint()

bool dart::Function::MayHaveUncheckedEntryPoint ( ) const

Definition at line 11448 of file object.cc.

11448 {
11449 return FLAG_enable_multiple_entrypoints &&
11451}
bool NeedsTypeArgumentTypeChecks() const
Definition: object.h:3432
bool NeedsArgumentTypeChecks() const
Definition: object.h:3436

◆ modifier()

UntaggedFunction::AsyncModifier dart::Function::modifier ( ) const
inline

Definition at line 3354 of file object.h.

3354 {
3355 return untag()->kind_tag_.Read<ModifierBits>();
3356 }

◆ name()

StringPtr dart::Function::name ( ) const
inline

Definition at line 2992 of file object.h.

2992{ return untag()->name(); }

◆ NameCString()

const char * dart::Function::NameCString ( NameVisibility  name_visibility) const

Definition at line 10978 of file object.cc.

10978 {
10979 switch (name_visibility) {
10980 case kInternalName:
10981 return String::Handle(name()).ToCString();
10982 case kScrubbedName:
10983 case kUserVisibleName:
10984 return UserVisibleNameCString();
10985 }
10986 UNREACHABLE();
10987 return nullptr;
10988}
const char * UserVisibleNameCString() const
Definition: object.cc:10990
@ kUserVisibleName
Definition: object.h:645
@ kScrubbedName
Definition: object.h:633
virtual const char * ToCString() const
Definition: object.h:366

◆ native_name()

StringPtr dart::Function::native_name ( ) const

Definition at line 8506 of file object.cc.

8506 {
8507 ASSERT(is_native());
8508 const Object& obj = Object::Handle(data());
8509 ASSERT(obj.IsArray());
8510 return String::RawCast(Array::Cast(obj).At(0));
8511}

◆ NeedsArgumentTypeChecks()

bool dart::Function::NeedsArgumentTypeChecks ( ) const
inline

Definition at line 3436 of file object.h.

3436 {
3437 return !(is_static() || (kind() == UntaggedFunction::kConstructor));
3438 }

◆ NeedsMonomorphicCheckedEntry()

bool dart::Function::NeedsMonomorphicCheckedEntry ( Zone zone) const

Definition at line 11364 of file object.cc.

11364 {
11365#if !defined(DART_PRECOMPILED_RUNTIME)
11366 if (!IsDynamicFunction()) {
11367 return false;
11368 }
11369
11370 // For functions which need an args descriptor the switchable call sites will
11371 // transition directly to calling via a stub (and therefore never call the
11372 // monomorphic entry).
11373 //
11374 // See runtime_entry.cc:DEFINE_RUNTIME_ENTRY(UnlinkedCall)
11376 return false;
11377 }
11378
11379 // All dyn:* forwarders are called via SwitchableCalls and all except the ones
11380 // with `PrologueNeedsArgumentsDescriptor()` transition into monomorphic
11381 // state.
11383 return true;
11384 }
11385
11386 // AOT mode uses table dispatch.
11387 // In JIT mode all instance calls use switchable calls.
11388 if (!FLAG_precompiled_mode) {
11389 return true;
11390 }
11391
11392 // Any method from the class with a dynamically loaded subtype
11393 // can be called via switchable call (when cid range check fails
11394 // during conditional table dispatch).
11395 if (Class::Handle(zone, Owner()).has_dynamically_extendable_subtypes()) {
11396 return true;
11397 }
11398
11399 // Only if there are dynamic callers and if we didn't create a dyn:* forwarder
11400 // for it do we need the monomorphic checked entry.
11401 return HasDynamicCallers(zone) &&
11403#else
11404 UNREACHABLE();
11405 return true;
11406#endif
11407}
bool PrologueNeedsArgumentsDescriptor() const
Definition: object.cc:11437
bool HasDynamicCallers(Zone *zone) const
Definition: object.cc:11409

◆ NeedsTypeArgumentTypeChecks()

bool dart::Function::NeedsTypeArgumentTypeChecks ( ) const
inline

Definition at line 3432 of file object.h.

3432 {
3433 return !(is_static() || (kind() == UntaggedFunction::kConstructor));
3434 }

◆ New()

FunctionPtr dart::Function::New ( const FunctionType signature,
const String name,
UntaggedFunction::Kind  kind,
bool  is_static,
bool  is_const,
bool  is_abstract,
bool  is_external,
bool  is_native,
const Object owner,
TokenPosition  token_pos,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 10243 of file object.cc.

10253 {
10254 ASSERT(!owner.IsNull());
10255 ASSERT(!signature.IsNull());
10256 const Function& result = Function::Handle(Function::New(space));
10257 result.set_kind_tag(0);
10258 result.set_packed_fields(0);
10259 result.set_name(name);
10260 result.set_kind_tag(0); // Ensure determinism of uninitialized bits.
10261 result.set_kind(kind);
10262 result.set_recognized_kind(MethodRecognizer::kUnknown);
10264 result.set_is_static(is_static);
10265 result.set_is_const(is_const);
10266 result.set_is_abstract(is_abstract);
10267 result.set_is_external(is_external);
10268 result.set_is_native(is_native);
10269 result.set_is_reflectable(true); // Will be computed later.
10270 result.set_is_visible(true); // Will be computed later.
10271 result.set_is_debuggable(true); // Will be computed later.
10272 result.set_is_intrinsic(false);
10273 result.set_has_pragma(false);
10274 result.set_is_polymorphic_target(false);
10275 result.set_is_synthetic(false);
10276 NOT_IN_PRECOMPILED(result.set_state_bits(0));
10277 result.set_owner(owner);
10278 NOT_IN_PRECOMPILED(result.set_token_pos(token_pos));
10279 NOT_IN_PRECOMPILED(result.set_end_token_pos(token_pos));
10280 NOT_IN_PRECOMPILED(result.set_usage_counter(0));
10281 NOT_IN_PRECOMPILED(result.set_deoptimization_counter(0));
10282 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0));
10283 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0));
10284 NOT_IN_PRECOMPILED(result.set_inlining_depth(0));
10285 NOT_IN_PRECOMPILED(result.set_kernel_offset(0));
10286 result.set_is_optimizable(is_native ? false : true);
10287 result.set_is_inlinable(true);
10288 result.reset_unboxed_parameters_and_return();
10289 result.SetInstructionsSafe(StubCode::LazyCompile());
10290
10291 // See Function::set_data() for more information.
10292 if (kind == UntaggedFunction::kClosureFunction ||
10293 kind == UntaggedFunction::kImplicitClosureFunction) {
10294 ASSERT(space == Heap::kOld);
10295 const ClosureData& data = ClosureData::Handle(ClosureData::New());
10296 data.set_awaiter_link({});
10297 result.set_data(data);
10298 } else if (kind == UntaggedFunction::kFfiTrampoline) {
10299 const FfiTrampolineData& data =
10300 FfiTrampolineData::Handle(FfiTrampolineData::New());
10301 result.set_data(data);
10302 } else if (result.is_old_native()) {
10303 const auto& data =
10305 result.set_data(data);
10306 } else {
10307 // Functions other than signature functions have no reason to be allocated
10308 // in new space.
10309 ASSERT(space == Heap::kOld);
10310 }
10311
10312 // Force-optimized functions are not debuggable because they cannot
10313 // deoptimize.
10314 if (result.ForceOptimize()) {
10315 result.set_is_debuggable(false);
10316 }
10317 signature.set_num_implicit_parameters(result.NumImplicitParameters());
10318 result.SetSignature(signature);
10320 result.set_positional_parameter_names(Object::empty_array()));
10321 return result.ptr();
10322}
static int kLength
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
#define NOT_IN_PRECOMPILED(code)
Definition: globals.h:100

◆ NewClosureFunction()

FunctionPtr dart::Function::NewClosureFunction ( const String name,
const Function parent,
TokenPosition  token_pos 
)
static

Definition at line 10348 of file object.cc.

10350 {
10351 // Use the owner defining the parent function and not the class containing it.
10352 const Object& parent_owner = Object::Handle(parent.RawOwner());
10353 return NewClosureFunctionWithKind(UntaggedFunction::kClosureFunction, name,
10354 parent, parent.is_static(), token_pos,
10355 parent_owner);
10356}
static FunctionPtr NewClosureFunctionWithKind(UntaggedFunction::Kind kind, const String &name, const Function &parent, bool is_static, TokenPosition token_pos, const Object &owner)
Definition: object.cc:10324

◆ NewClosureFunctionWithKind()

FunctionPtr dart::Function::NewClosureFunctionWithKind ( UntaggedFunction::Kind  kind,
const String name,
const Function parent,
bool  is_static,
TokenPosition  token_pos,
const Object owner 
)
static

Definition at line 10324 of file object.cc.

10329 {
10330 ASSERT((kind == UntaggedFunction::kClosureFunction) ||
10331 (kind == UntaggedFunction::kImplicitClosureFunction));
10332 ASSERT(!parent.IsNull());
10333 ASSERT(!owner.IsNull());
10334 const FunctionType& signature = FunctionType::Handle(FunctionType::New(
10335 kind == UntaggedFunction::kClosureFunction ? parent.NumTypeArguments()
10336 : 0));
10337 const Function& result = Function::Handle(
10338 Function::New(signature, name, kind,
10339 /* is_static = */ is_static,
10340 /* is_const = */ false,
10341 /* is_abstract = */ false,
10342 /* is_external = */ false,
10343 /* is_native = */ false, owner, token_pos));
10344 result.set_parent_function(parent);
10345 return result.ptr();
10346}

◆ NewImplicitClosureFunction()

FunctionPtr dart::Function::NewImplicitClosureFunction ( const String name,
const Function parent,
TokenPosition  token_pos 
)
static

Definition at line 10358 of file object.cc.

10360 {
10361 // Use the owner defining the parent function and not the class containing it.
10362 const Object& parent_owner = Object::Handle(parent.RawOwner());
10364 UntaggedFunction::kImplicitClosureFunction, name, parent,
10365 parent.is_static() || parent.IsConstructor(), token_pos, parent_owner);
10366}

◆ num_fixed_parameters()

intptr_t dart::Function::num_fixed_parameters ( ) const

Definition at line 8856 of file object.cc.

8856 {
8857 return FunctionType::NumFixedParametersOf(signature());
8858}
static intptr_t NumFixedParametersOf(FunctionTypePtr ptr)
Definition: object.h:9591

◆ NumImplicitParameters()

intptr_t dart::Function::NumImplicitParameters ( ) const

Definition at line 9228 of file object.cc.

9228 {
9229 const UntaggedFunction::Kind k = kind();
9230 if (k == UntaggedFunction::kConstructor) {
9231 // Type arguments for factory; instance for generative constructor.
9232 return 1;
9233 }
9234 if ((k == UntaggedFunction::kClosureFunction) ||
9235 (k == UntaggedFunction::kImplicitClosureFunction) ||
9236 (k == UntaggedFunction::kFfiTrampoline)) {
9237 return 1; // Closure object.
9238 }
9239 if (!is_static()) {
9240 // Closure functions defined inside instance (i.e. non-static) functions are
9241 // marked as non-static, but they do not have a receiver.
9242 // Closures are handled above.
9243 ASSERT((k != UntaggedFunction::kClosureFunction) &&
9244 (k != UntaggedFunction::kImplicitClosureFunction));
9245 return 1; // Receiver.
9246 }
9247 return 0; // No implicit parameters.
9248}

◆ NumOptionalNamedParameters()

intptr_t dart::Function::NumOptionalNamedParameters ( ) const

Definition at line 8874 of file object.cc.

8874 {
8876}
static intptr_t NumOptionalNamedParametersOf(FunctionTypePtr ptr)
Definition: object.h:9638

◆ NumOptionalParameters()

intptr_t dart::Function::NumOptionalParameters ( ) const

Definition at line 8868 of file object.cc.

8868 {
8869 return FunctionType::NumOptionalParametersOf(signature());
8870}
static intptr_t NumOptionalParametersOf(FunctionTypePtr ptr)
Definition: object.h:9621

◆ NumOptionalPositionalParameters()

intptr_t dart::Function::NumOptionalPositionalParameters ( ) const

Definition at line 8871 of file object.cc.

8871 {
8873}
static intptr_t NumOptionalPositionalParametersOf(FunctionTypePtr ptr)
Definition: object.h:9631

◆ NumParameters()

intptr_t dart::Function::NumParameters ( ) const

Definition at line 8877 of file object.cc.

8877 {
8878 return FunctionType::NumParametersOf(signature());
8879}
static intptr_t NumParametersOf(FunctionTypePtr ptr)
Definition: object.h:9645

◆ NumParentTypeArguments()

intptr_t dart::Function::NumParentTypeArguments ( ) const

Definition at line 8850 of file object.cc.

8850 {
8851 return FunctionType::NumParentTypeArgumentsOf(signature());
8852}
static intptr_t NumParentTypeArgumentsOf(FunctionTypePtr ptr)
Definition: object.h:9565

◆ NumTypeArguments()

intptr_t dart::Function::NumTypeArguments ( ) const

Definition at line 8853 of file object.cc.

8853 {
8854 return FunctionType::NumTypeArgumentsOf(signature());
8855}
static intptr_t NumTypeArgumentsOf(FunctionTypePtr ptr)
Definition: object.h:9580

◆ NumTypeParameters()

intptr_t dart::Function::NumTypeParameters ( ) const

Definition at line 8847 of file object.cc.

8847 {
8848 return FunctionType::NumTypeParametersOf(signature());
8849}
static intptr_t NumTypeParametersOf(FunctionTypePtr ptr)
Definition: object.h:9574

◆ Owner()

ClassPtr dart::Function::Owner ( ) const

Definition at line 10841 of file object.cc.

10841 {
10842 ASSERT(untag()->owner() != Object::null());
10843 if (untag()->owner()->IsClass()) {
10844 return Class::RawCast(untag()->owner());
10845 }
10846 const Object& obj = Object::Handle(untag()->owner());
10847 ASSERT(obj.IsPatchClass());
10848 return PatchClass::Cast(obj).wrapped_class();
10849}

◆ packed_fields()

uint32_t dart::Function::packed_fields ( ) const
inline

Definition at line 3482 of file object.h.

3482 {
3483#if defined(DART_PRECOMPILED_RUNTIME)
3484 UNREACHABLE();
3485#else
3486 return untag()->packed_fields_;
3487#endif
3488 }

◆ parameter_types()

ArrayPtr dart::Function::parameter_types ( ) const
inline

Definition at line 3107 of file object.h.

3107 {
3108 return signature()->untag()->parameter_types();
3109 }

◆ ParameterNameAt()

StringPtr dart::Function::ParameterNameAt ( intptr_t  index) const

Definition at line 8602 of file object.cc.

8602 {
8603#if defined(DART_PRECOMPILED_RUNTIME)
8604 if (signature() == FunctionType::null()) {
8605 // Without the signature, we're guaranteed not to have any name information.
8606 return Symbols::OptimizedOut().ptr();
8607 }
8608#endif
8609 const intptr_t num_fixed = num_fixed_parameters();
8610 if (HasOptionalNamedParameters() && index >= num_fixed) {
8611 const Array& parameter_names =
8612 Array::Handle(signature()->untag()->named_parameter_names());
8613 return String::RawCast(parameter_names.At(index - num_fixed));
8614 }
8615#if defined(DART_PRECOMPILED_RUNTIME)
8616 return Symbols::OptimizedOut().ptr();
8617#else
8618 const Array& names = Array::Handle(untag()->positional_parameter_names());
8619 return String::RawCast(names.At(index));
8620#endif
8621}

◆ ParameterTypeAt()

AbstractTypePtr dart::Function::ParameterTypeAt ( intptr_t  index) const

Definition at line 8580 of file object.cc.

8580 {
8581 const Array& types = Array::Handle(parameter_types());
8582 return AbstractType::RawCast(types.At(index));
8583}
ArrayPtr parameter_types() const
Definition: object.h:3107

◆ parent_function()

FunctionPtr dart::Function::parent_function ( ) const

Definition at line 8167 of file object.cc.

8167 {
8168 if (!IsClosureFunction()) return Function::null();
8169 Object& obj = Object::Handle(untag()->data());
8170 ASSERT(!obj.IsNull());
8171 return ClosureData::Cast(obj).parent_function();
8172}

◆ PRECOMPILER_WSR_FIELD_DECLARATION()

dart::Function::PRECOMPILER_WSR_FIELD_DECLARATION ( FunctionType  ,
signature   
)

◆ PrintName()

void dart::Function::PrintName ( const NameFormattingParams params,
BaseTextBuffer printer 
) const

Definition at line 11109 of file object.cc.

11110 {
11111 if (!IsLocalFunction()) {
11112 FunctionPrintNameHelper(*this, params, printer);
11113 return;
11114 }
11115 auto& fun = Function::Handle(ptr());
11116 FunctionPrintNameHelper(fun, params, printer);
11117}
bool IsLocalFunction() const
Definition: object.h:3933
static void FunctionPrintNameHelper(const Function &fun, const NameFormattingParams &params, BaseTextBuffer *printer)
Definition: object.cc:11037

◆ PrologueNeedsArgumentsDescriptor()

bool dart::Function::PrologueNeedsArgumentsDescriptor ( ) const

Definition at line 11437 of file object.cc.

11437 {
11438 // These functions have a saved compile-time arguments descriptor that is
11439 // used in lieu of the runtime arguments descriptor in generated IL.
11441 return false;
11442 }
11443 // The prologue of those functions need to examine the arg descriptor for
11444 // various purposes.
11445 return IsGeneric() || HasOptionalParameters();
11446}
bool HasSavedArgumentsDescriptor() const
Definition: object.h:3273

◆ QualifiedScrubbedName()

StringPtr dart::Function::QualifiedScrubbedName ( ) const

Definition at line 11009 of file object.cc.

11009 {
11010 Thread* thread = Thread::Current();
11011 ZoneTextBuffer printer(thread->zone());
11012 PrintName(NameFormattingParams(kScrubbedName), &printer);
11013 return Symbols::New(thread, printer.buffer());
11014}
void PrintName(const NameFormattingParams &params, BaseTextBuffer *printer) const
Definition: object.cc:11109

◆ QualifiedScrubbedNameCString()

const char * dart::Function::QualifiedScrubbedNameCString ( ) const

Definition at line 11016 of file object.cc.

11016 {
11017 Thread* thread = Thread::Current();
11018 ZoneTextBuffer printer(thread->zone());
11019 PrintName(NameFormattingParams(kScrubbedName), &printer);
11020 return printer.buffer();
11021}

◆ QualifiedUserVisibleName()

StringPtr dart::Function::QualifiedUserVisibleName ( ) const

Definition at line 11023 of file object.cc.

11023 {
11024 Thread* thread = Thread::Current();
11025 ZoneTextBuffer printer(thread->zone());
11026 PrintName(NameFormattingParams(kUserVisibleName), &printer);
11027 return Symbols::New(thread, printer.buffer());
11028}

◆ QualifiedUserVisibleNameCString()

const char * dart::Function::QualifiedUserVisibleNameCString ( ) const

Definition at line 11030 of file object.cc.

11030 {
11031 Thread* thread = Thread::Current();
11032 ZoneTextBuffer printer(thread->zone());
11033 PrintName(NameFormattingParams(kUserVisibleName), &printer);
11034 return printer.buffer();
11035}

◆ RawOwner()

ObjectPtr dart::Function::RawOwner ( ) const
inline

Definition at line 3083 of file object.h.

3083{ return untag()->owner(); }

◆ recognized_kind()

MethodRecognizer::Kind dart::Function::recognized_kind ( ) const
inline

Definition at line 3619 of file object.h.

3619 {
3620 return untag()->kind_tag_.Read<RecognizedBits>();
3621 }

◆ RecognizedKindForceOptimize()

bool dart::Function::RecognizedKindForceOptimize ( ) const

Definition at line 9086 of file object.cc.

9086 {
9087 switch (recognized_kind()) {
9088 // Uses unboxed/untagged data not supported in unoptimized, or uses
9089 // LoadIndexed/StoreIndexed/MemoryCopy instructions with typed data
9090 // arrays, which requires optimization for payload extraction.
9091 case MethodRecognizer::kObjectArrayGetIndexed:
9092 case MethodRecognizer::kGrowableArrayGetIndexed:
9093#define TYPED_DATA_GET_INDEXED_CASES(clazz) \
9094 case MethodRecognizer::k##clazz##ArrayGetIndexed: \
9095 FALL_THROUGH; \
9096 case MethodRecognizer::kExternal##clazz##ArrayGetIndexed: \
9097 FALL_THROUGH; \
9098 case MethodRecognizer::k##clazz##ArrayViewGetIndexed: \
9099 FALL_THROUGH;
9101#undef TYPED_DATA_GET_INDEXED_CASES
9102 case MethodRecognizer::kCopyRangeFromUint8ListToOneByteString:
9103 case MethodRecognizer::kFinalizerBase_getIsolateFinalizers:
9104 case MethodRecognizer::kFinalizerBase_setIsolate:
9105 case MethodRecognizer::kFinalizerBase_setIsolateFinalizers:
9106 case MethodRecognizer::kFinalizerEntry_getExternalSize:
9107 case MethodRecognizer::kExtensionStreamHasListener:
9108 case MethodRecognizer::kFfiLoadInt8:
9109 case MethodRecognizer::kFfiLoadInt16:
9110 case MethodRecognizer::kFfiLoadInt32:
9111 case MethodRecognizer::kFfiLoadInt64:
9112 case MethodRecognizer::kFfiLoadUint8:
9113 case MethodRecognizer::kFfiLoadUint16:
9114 case MethodRecognizer::kFfiLoadUint32:
9115 case MethodRecognizer::kFfiLoadUint64:
9116 case MethodRecognizer::kFfiLoadFloat:
9117 case MethodRecognizer::kFfiLoadFloatUnaligned:
9118 case MethodRecognizer::kFfiLoadDouble:
9119 case MethodRecognizer::kFfiLoadDoubleUnaligned:
9120 case MethodRecognizer::kFfiLoadPointer:
9121 case MethodRecognizer::kFfiStoreInt8:
9122 case MethodRecognizer::kFfiStoreInt16:
9123 case MethodRecognizer::kFfiStoreInt32:
9124 case MethodRecognizer::kFfiStoreInt64:
9125 case MethodRecognizer::kFfiStoreUint8:
9126 case MethodRecognizer::kFfiStoreUint16:
9127 case MethodRecognizer::kFfiStoreUint32:
9128 case MethodRecognizer::kFfiStoreUint64:
9129 case MethodRecognizer::kFfiStoreFloat:
9130 case MethodRecognizer::kFfiStoreFloatUnaligned:
9131 case MethodRecognizer::kFfiStoreDouble:
9132 case MethodRecognizer::kFfiStoreDoubleUnaligned:
9133 case MethodRecognizer::kFfiStorePointer:
9134 case MethodRecognizer::kFfiFromAddress:
9135 case MethodRecognizer::kFfiGetAddress:
9136 case MethodRecognizer::kFfiAsExternalTypedDataInt8:
9137 case MethodRecognizer::kFfiAsExternalTypedDataInt16:
9138 case MethodRecognizer::kFfiAsExternalTypedDataInt32:
9139 case MethodRecognizer::kFfiAsExternalTypedDataInt64:
9140 case MethodRecognizer::kFfiAsExternalTypedDataUint8:
9141 case MethodRecognizer::kFfiAsExternalTypedDataUint16:
9142 case MethodRecognizer::kFfiAsExternalTypedDataUint32:
9143 case MethodRecognizer::kFfiAsExternalTypedDataUint64:
9144 case MethodRecognizer::kFfiAsExternalTypedDataFloat:
9145 case MethodRecognizer::kFfiAsExternalTypedDataDouble:
9146 case MethodRecognizer::kGetNativeField:
9147 case MethodRecognizer::kRecord_fieldNames:
9148 case MethodRecognizer::kRecord_numFields:
9149 case MethodRecognizer::kStringBaseCodeUnitAt:
9150 case MethodRecognizer::kUtf8DecoderScan:
9151 case MethodRecognizer::kDouble_hashCode:
9152 case MethodRecognizer::kTypedList_GetInt8:
9153 case MethodRecognizer::kTypedList_SetInt8:
9154 case MethodRecognizer::kTypedList_GetUint8:
9155 case MethodRecognizer::kTypedList_SetUint8:
9156 case MethodRecognizer::kTypedList_GetInt16:
9157 case MethodRecognizer::kTypedList_SetInt16:
9158 case MethodRecognizer::kTypedList_GetUint16:
9159 case MethodRecognizer::kTypedList_SetUint16:
9160 case MethodRecognizer::kTypedList_GetInt32:
9161 case MethodRecognizer::kTypedList_SetInt32:
9162 case MethodRecognizer::kTypedList_GetUint32:
9163 case MethodRecognizer::kTypedList_SetUint32:
9164 case MethodRecognizer::kTypedList_GetInt64:
9165 case MethodRecognizer::kTypedList_SetInt64:
9166 case MethodRecognizer::kTypedList_GetUint64:
9167 case MethodRecognizer::kTypedList_SetUint64:
9168 case MethodRecognizer::kTypedList_GetFloat32:
9169 case MethodRecognizer::kTypedList_SetFloat32:
9170 case MethodRecognizer::kTypedList_GetFloat64:
9171 case MethodRecognizer::kTypedList_SetFloat64:
9172 case MethodRecognizer::kTypedList_GetInt32x4:
9173 case MethodRecognizer::kTypedList_SetInt32x4:
9174 case MethodRecognizer::kTypedList_GetFloat32x4:
9175 case MethodRecognizer::kTypedList_SetFloat32x4:
9176 case MethodRecognizer::kTypedList_GetFloat64x2:
9177 case MethodRecognizer::kTypedList_SetFloat64x2:
9178 case MethodRecognizer::kTypedData_memMove1:
9179 case MethodRecognizer::kTypedData_memMove2:
9180 case MethodRecognizer::kTypedData_memMove4:
9181 case MethodRecognizer::kTypedData_memMove8:
9182 case MethodRecognizer::kTypedData_memMove16:
9183 case MethodRecognizer::kMemCopy:
9184 // Prevent the GC from running so that the operation is atomic from
9185 // a GC point of view. Always double check implementation in
9186 // kernel_to_il.cc that no GC can happen in between the relevant IL
9187 // instructions.
9188 // TODO(https://dartbug.com/48527): Support inlining.
9189 case MethodRecognizer::kFinalizerBase_exchangeEntriesCollectedWithNull:
9190 // Both unboxed/untagged data and atomic-to-GC operation.
9191 case MethodRecognizer::kFinalizerEntry_allocate:
9192 return true;
9193 default:
9194 return false;
9195 }
9196}
#define DART_CLASS_LIST_TYPED_DATA(V)
Definition: class_id.h:177
#define TYPED_DATA_GET_INDEXED_CASES(clazz)

◆ regexp()

RegExpPtr dart::Function::regexp ( ) const

Definition at line 8469 of file object.cc.

8469 {
8470 ASSERT(kind() == UntaggedFunction::kIrregexpFunction);
8471 const Array& pair = Array::Cast(Object::Handle(data()));
8472 return RegExp::RawCast(pair.At(0));
8473}

◆ reset_unboxed_parameters_and_return()

void dart::Function::reset_unboxed_parameters_and_return ( ) const
inline

Definition at line 3709 of file object.h.

3709 {
3710#if !defined(DART_PRECOMPILED_RUNTIME)
3711 StoreNonPointer(&untag()->unboxed_parameters_info_,
3712 UntaggedFunction::UnboxedParameterBitmap());
3713#endif // !defined(DART_PRECOMPILED_RUNTIME)
3714 }

◆ RestoreICDataMap()

void dart::Function::RestoreICDataMap ( ZoneGrowableArray< const ICData * > *  deopt_id_to_ic_data,
bool  clone_ic_data 
) const

Definition at line 11217 of file object.cc.

11219 {
11220#if !defined(DART_PRECOMPILED_RUNTIME)
11221 if (FLAG_force_clone_compiler_objects) {
11222 clone_ic_data = true;
11223 }
11224 ASSERT(deopt_id_to_ic_data->is_empty());
11225 Zone* zone = Thread::Current()->zone();
11226 const Array& saved_ic_data = Array::Handle(zone, ic_data_array());
11227 if (saved_ic_data.IsNull()) {
11228 // Could happen with not-yet compiled unoptimized code or force-optimized
11229 // functions.
11230 return;
11231 }
11232 const intptr_t saved_length = saved_ic_data.Length();
11233 ASSERT(saved_length > 0);
11234 if (saved_length > ICDataArrayIndices::kFirstICData) {
11235 const intptr_t restored_length =
11236 ICData::Cast(Object::Handle(zone, saved_ic_data.At(saved_length - 1)))
11237 .deopt_id() +
11238 1;
11239 deopt_id_to_ic_data->SetLength(restored_length);
11240 for (intptr_t i = 0; i < restored_length; i++) {
11241 (*deopt_id_to_ic_data)[i] = nullptr;
11242 }
11243 for (intptr_t i = ICDataArrayIndices::kFirstICData; i < saved_length; i++) {
11244 ICData& ic_data = ICData::ZoneHandle(zone);
11245 ic_data ^= saved_ic_data.At(i);
11246 if (clone_ic_data) {
11247 const ICData& original_ic_data = ICData::Handle(zone, ic_data.ptr());
11248 ic_data = ICData::Clone(ic_data);
11249 ic_data.SetOriginal(original_ic_data);
11250 }
11251 ASSERT(deopt_id_to_ic_data->At(ic_data.deopt_id()) == nullptr);
11252 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data;
11253 }
11254 }
11255#else // DART_PRECOMPILED_RUNTIME
11256 UNREACHABLE();
11257#endif // DART_PRECOMPILED_RUNTIME
11258}
static ICDataPtr Clone(const ICData &from)
Definition: object.cc:17439

◆ result_type()

AbstractTypePtr dart::Function::result_type ( ) const
inline

Definition at line 3099 of file object.h.

3099 {
3100 return signature()->untag()->result_type();
3101 }

◆ SafeToClosurize()

bool dart::Function::SafeToClosurize ( ) const

Definition at line 10368 of file object.cc.

10368 {
10369#if defined(DART_PRECOMPILED_RUNTIME)
10371#else
10372 return true;
10373#endif
10374}

◆ saved_args_desc()

ArrayPtr dart::Function::saved_args_desc ( ) const

Definition at line 8133 of file object.cc.

8133 {
8134 if (kind() == UntaggedFunction::kDynamicInvocationForwarder) {
8135 return Array::null();
8136 }
8137 ASSERT(kind() == UntaggedFunction::kNoSuchMethodDispatcher ||
8138 kind() == UntaggedFunction::kInvokeFieldDispatcher);
8139 return Array::RawCast(untag()->data());
8140}

◆ SaveICDataMap()

void dart::Function::SaveICDataMap ( const ZoneGrowableArray< const ICData * > &  deopt_id_to_ic_data,
const Array edge_counters_array,
const Array coverage_array 
) const

Definition at line 11178 of file object.cc.

11181 {
11182#if !defined(DART_PRECOMPILED_RUNTIME)
11183 // Already installed nothing to do.
11184 if (ic_data_array() != Array::null()) {
11185 ASSERT(coverage_array.ptr() == GetCoverageArray());
11186 return;
11187 }
11188
11189 // Compute number of ICData objects to save.
11190 intptr_t count = 0;
11191 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
11192 if (deopt_id_to_ic_data[i] != nullptr) {
11193 count++;
11194 }
11195 }
11196
11197 // Compress sparse deopt_id_to_ic_data mapping into a linear sequence of
11198 // ICData objects.
11199 const Array& array = Array::Handle(
11201 for (intptr_t i = 0, pos = ICDataArrayIndices::kFirstICData;
11202 i < deopt_id_to_ic_data.length(); i++) {
11203 if (deopt_id_to_ic_data[i] != nullptr) {
11204 ASSERT(i == deopt_id_to_ic_data[i]->deopt_id());
11205 array.SetAt(pos++, *deopt_id_to_ic_data[i]);
11206 }
11207 }
11208 array.SetAt(ICDataArrayIndices::kEdgeCounters, edge_counters_array);
11209 // Preserve coverage_array which is stored early after graph construction.
11210 array.SetAt(ICDataArrayIndices::kCoverageData, coverage_array);
11211 set_ic_data_array(array);
11212#else // DART_PRECOMPILED_RUNTIME
11213 UNREACHABLE();
11214#endif // DART_PRECOMPILED_RUNTIME
11215}
int count
Definition: FontMgrTest.cpp:50
SkPoint pos
ArrayPtr GetCoverageArray() const
Definition: object.cc:11260
static constexpr intptr_t kEdgeCounters
Definition: object.h:4058

◆ script()

ScriptPtr dart::Function::script ( ) const

Definition at line 10881 of file object.cc.

10881 {
10882 // NOTE(turnidge): If you update this function, you probably want to
10883 // update Class::PatchFieldsAndFunctions() at the same time.
10885 const Function& target = Function::Handle(ForwardingTarget());
10886 return target.IsNull() ? Script::null() : target.script();
10887 }
10889 const auto& field = Field::Handle(accessor_field());
10890 return field.IsNull() ? Script::null() : field.Script();
10891 }
10892 if (is_eval_function()) {
10893 const auto& fdata = Array::Handle(Array::RawCast(data()));
10894 return Script::RawCast(
10895 fdata.At(static_cast<intptr_t>(EvalFunctionData::kScript)));
10896 }
10898 // Testing for position 0 is an optimization that relies on temporary
10899 // eval functions having token position 0.
10900 const Script& script = Script::Handle(eval_script());
10901 if (!script.IsNull()) {
10902 return script.ptr();
10903 }
10904 }
10905 const Object& obj = Object::Handle(untag()->owner());
10906 if (obj.IsPatchClass()) {
10907 return PatchClass::Cast(obj).script();
10908 }
10909 if (IsClosureFunction()) {
10910 const Function& function = Function::Handle(parent_function());
10911 if (function.IsNull()) return Script::null();
10912 return function.script();
10913 }
10914 ASSERT(obj.IsClass());
10915 return Class::Cast(obj).script();
10916}
FunctionPtr ForwardingTarget() const
Definition: object.cc:8423
bool IsImplicitGetterOrSetter() const
Definition: object.h:3318
FieldPtr accessor_field() const
Definition: object.cc:8149
bool IsDynamicInvocationForwarder() const
Definition: object.h:3314
static const TokenPosition kMinSource

◆ set_accessor_field()

void dart::Function::set_accessor_field ( const Field value) const

Definition at line 8157 of file object.cc.

8157 {
8158 ASSERT(kind() == UntaggedFunction::kImplicitGetter ||
8159 kind() == UntaggedFunction::kImplicitSetter ||
8160 kind() == UntaggedFunction::kImplicitStaticGetter ||
8161 kind() == UntaggedFunction::kFieldInitializer);
8162 // Top level classes may be finalized multiple times.
8163 ASSERT(untag()->data() == Object::null() || untag()->data() == value.ptr());
8164 set_data(value);
8165}

◆ set_awaiter_link()

void dart::Function::set_awaiter_link ( Function::AwaiterLink  link) const

Definition at line 8077 of file object.cc.

8077 {
8078 if (IsClosureFunction()) {
8079 const Object& obj = Object::Handle(untag()->data());
8080 ASSERT(!obj.IsNull());
8081 ClosureData::Cast(obj).set_awaiter_link(link);
8082 return;
8083 }
8084 UNREACHABLE();
8085}
def link(from_root, to_root)
Definition: dart_pkg.py:44

◆ set_context_scope()

void dart::Function::set_context_scope ( const ContextScope value) const

Definition at line 8057 of file object.cc.

8057 {
8058 if (IsClosureFunction()) {
8059 const Object& obj = Object::Handle(untag()->data());
8060 ASSERT(!obj.IsNull());
8061 ClosureData::Cast(obj).set_context_scope(value);
8062 return;
8063 }
8064 UNREACHABLE();
8065}

◆ set_default_type_arguments_instantiation_mode()

void dart::Function::set_default_type_arguments_instantiation_mode ( InstantiationMode  value) const

Definition at line 8196 of file object.cc.

8197 {
8198 if (!IsClosureFunction()) {
8199 UNREACHABLE();
8200 }
8201 const auto& closure_data = ClosureData::Handle(ClosureData::RawCast(data()));
8202 ASSERT(!closure_data.IsNull());
8203 closure_data.set_default_type_arguments_instantiation_mode(value);
8204}

◆ set_end_token_pos()

void dart::Function::set_end_token_pos ( TokenPosition  value) const
inline

Definition at line 3462 of file object.h.

3462 {
3463#if defined(DART_PRECOMPILED_RUNTIME)
3464 UNREACHABLE();
3465#else
3466 StoreNonPointer(&untag()->end_token_pos_, value);
3467#endif
3468 }

◆ set_extracted_method_closure()

void dart::Function::set_extracted_method_closure ( const Function function) const

Definition at line 8127 of file object.cc.

8127 {
8128 ASSERT(kind() == UntaggedFunction::kMethodExtractor);
8129 ASSERT(untag()->data() == Object::null());
8130 set_data(value);
8131}

◆ set_is_optimizable()

void dart::Function::set_is_optimizable ( bool  value) const
inline

Definition at line 4207 of file object.h.

4207 {
4208#if defined(DART_PRECOMPILED_RUNTIME)
4209 UNREACHABLE();
4210#else
4211 untag()->packed_fields_.UpdateBool<UntaggedFunction::PackedOptimizable>(
4212 value);
4213#endif
4214 }

◆ set_kernel_offset()

void dart::Function::set_kernel_offset ( intptr_t  value) const
inline

Definition at line 3558 of file object.h.

3558 {
3559#if defined(DART_PRECOMPILED_RUNTIME)
3560 UNREACHABLE();
3561#else
3562 ASSERT(value >= 0);
3563 StoreNonPointer(&untag()->kernel_offset_, value);
3564#endif
3565 }

◆ set_modifier()

void dart::Function::set_modifier ( UntaggedFunction::AsyncModifier  value) const

Definition at line 8891 of file object.cc.

8891 {
8892 untag()->kind_tag_.Update<ModifierBits>(value);
8893}

◆ set_native_name()

void dart::Function::set_native_name ( const String name) const

Definition at line 8513 of file object.cc.

8513 {
8514 ASSERT(is_native());
8515 const auto& pair = Array::Cast(Object::Handle(data()));
8516 ASSERT(pair.At(0) == Object::null());
8517 pair.SetAt(NativeFunctionData::kNativeName, value);
8518}

◆ set_owner()

void dart::Function::set_owner ( const Object value) const

Definition at line 8464 of file object.cc.

8464 {
8465 ASSERT(!value.IsNull());
8466 untag()->set_owner(value.ptr());
8467}

◆ set_packed_fields()

void dart::Function::set_packed_fields ( uint32_t  packed_fields) const

Definition at line 8922 of file object.cc.

8922 {
8923#if defined(DART_PRECOMPILED_RUNTIME)
8924 UNREACHABLE();
8925#else
8926 StoreNonPointer(&untag()->packed_fields_, packed_fields);
8927#endif
8928}
uint32_t packed_fields() const
Definition: object.h:3482

◆ set_recognized_kind()

void dart::Function::set_recognized_kind ( MethodRecognizer::Kind  value) const

Definition at line 8895 of file object.cc.

8895 {
8896 // Prevent multiple settings of kind.
8898 untag()->kind_tag_.Update<RecognizedBits>(value);
8899}
bool IsRecognized() const
Definition: object.h:3624

◆ set_saved_args_desc()

void dart::Function::set_saved_args_desc ( const Array array) const

Definition at line 8142 of file object.cc.

8142 {
8143 ASSERT(kind() == UntaggedFunction::kNoSuchMethodDispatcher ||
8144 kind() == UntaggedFunction::kInvokeFieldDispatcher);
8145 ASSERT(untag()->data() == Object::null());
8146 set_data(value);
8147}

◆ set_token_pos()

void dart::Function::set_token_pos ( TokenPosition  value) const

Definition at line 8901 of file object.cc.

8901 {
8902#if defined(DART_PRECOMPILED_RUNTIME)
8903 UNREACHABLE();
8904#else
8906 StoreNonPointer(&untag()->token_pos_, token_pos);
8907#endif
8908}
bool IsClassifying() const

◆ set_unboxed_double_parameter_at()

void dart::Function::set_unboxed_double_parameter_at ( intptr_t  index) const
inline

Definition at line 3728 of file object.h.

3728 {
3729#if !defined(DART_PRECOMPILED_RUNTIME)
3730 ASSERT(index >= 0 && index < maximum_unboxed_parameter_count());
3731 index++; // position 0 is reserved for the return value
3732 const_cast<UntaggedFunction::UnboxedParameterBitmap*>(
3733 &untag()->unboxed_parameters_info_)
3734 ->SetUnboxedDouble(index);
3735
3736#else
3737 UNREACHABLE();
3738#endif // !defined(DART_PRECOMPILED_RUNTIME)
3739 }
static constexpr intptr_t maximum_unboxed_parameter_count()
Definition: object.h:3704

◆ set_unboxed_double_return()

void dart::Function::set_unboxed_double_return ( ) const
inline

Definition at line 3751 of file object.h.

3751 {
3752#if !defined(DART_PRECOMPILED_RUNTIME)
3753 const_cast<UntaggedFunction::UnboxedParameterBitmap*>(
3754 &untag()->unboxed_parameters_info_)
3755 ->SetUnboxedDouble(0);
3756
3757#else
3758 UNREACHABLE();
3759#endif // !defined(DART_PRECOMPILED_RUNTIME)
3760 }

◆ set_unboxed_integer_parameter_at()

void dart::Function::set_unboxed_integer_parameter_at ( intptr_t  index) const
inline

Definition at line 3716 of file object.h.

3716 {
3717#if !defined(DART_PRECOMPILED_RUNTIME)
3718 ASSERT(index >= 0 && index < maximum_unboxed_parameter_count());
3719 index++; // position 0 is reserved for the return value
3720 const_cast<UntaggedFunction::UnboxedParameterBitmap*>(
3721 &untag()->unboxed_parameters_info_)
3722 ->SetUnboxedInteger(index);
3723#else
3724 UNREACHABLE();
3725#endif // !defined(DART_PRECOMPILED_RUNTIME)
3726 }

◆ set_unboxed_integer_return()

void dart::Function::set_unboxed_integer_return ( ) const
inline

Definition at line 3741 of file object.h.

3741 {
3742#if !defined(DART_PRECOMPILED_RUNTIME)
3743 const_cast<UntaggedFunction::UnboxedParameterBitmap*>(
3744 &untag()->unboxed_parameters_info_)
3745 ->SetUnboxedInteger(0);
3746#else
3747 UNREACHABLE();
3748#endif // !defined(DART_PRECOMPILED_RUNTIME)
3749 }

◆ set_unboxed_record_return()

void dart::Function::set_unboxed_record_return ( ) const
inline

Definition at line 3762 of file object.h.

3762 {
3763#if !defined(DART_PRECOMPILED_RUNTIME)
3764 const_cast<UntaggedFunction::UnboxedParameterBitmap*>(
3765 &untag()->unboxed_parameters_info_)
3766 ->SetUnboxedRecord(0);
3767
3768#else
3769 UNREACHABLE();
3770#endif // !defined(DART_PRECOMPILED_RUNTIME)
3771 }

◆ set_unoptimized_code()

void dart::Function::set_unoptimized_code ( const Code value) const

Definition at line 8038 of file object.cc.

8038 {
8039#if defined(DART_PRECOMPILED_RUNTIME)
8040 UNREACHABLE();
8041#else
8042 DEBUG_ASSERT(IsMutatorOrAtDeoptSafepoint());
8043 ASSERT(value.IsNull() || !value.is_optimized());
8044 untag()->set_unoptimized_code(value.ptr());
8045#endif
8046}

◆ SetDeoptReasonForAll()

void dart::Function::SetDeoptReasonForAll ( intptr_t  deopt_id,
ICData::DeoptReasonId  reason 
)

Definition at line 11292 of file object.cc.

11293 {
11294 const Array& array = Array::Handle(ic_data_array());
11295 ICData& ic_data = ICData::Handle();
11296 for (intptr_t i = ICDataArrayIndices::kFirstICData; i < array.Length(); i++) {
11297 ic_data ^= array.At(i);
11298 if (ic_data.deopt_id() == deopt_id) {
11299 ic_data.AddDeoptReason(reason);
11300 }
11301 }
11302}

◆ SetFfiCallbackExceptionalReturn()

void dart::Function::SetFfiCallbackExceptionalReturn ( const Instance value) const

Definition at line 8398 of file object.cc.

8398 {
8400 const Object& obj = Object::Handle(data());
8401 ASSERT(!obj.IsNull());
8402 FfiTrampolineData::Cast(obj).set_callback_exceptional_return(value);
8403}

◆ SetFfiCallbackKind()

void dart::Function::SetFfiCallbackKind ( FfiCallbackKind  value) const

Definition at line 8412 of file object.cc.

8412 {
8414 const Object& obj = Object::Handle(data());
8415 ASSERT(!obj.IsNull());
8416 FfiTrampolineData::Cast(obj).set_ffi_function_kind(value);
8417}

◆ SetFfiCallbackTarget()

void dart::Function::SetFfiCallbackTarget ( const Function target) const

Definition at line 8384 of file object.cc.

8384 {
8386 const Object& obj = Object::Handle(data());
8387 ASSERT(!obj.IsNull());
8388 FfiTrampolineData::Cast(obj).set_callback_target(target);
8389}

◆ SetFfiCSignature()

void dart::Function::SetFfiCSignature ( const FunctionType sig) const

Definition at line 8257 of file object.cc.

8257 {
8259 const Object& obj = Object::Handle(data());
8260 ASSERT(!obj.IsNull());
8261 FfiTrampolineData::Cast(obj).set_c_signature(sig);
8262}

◆ SetForwardingTarget()

void dart::Function::SetForwardingTarget ( const Function target) const

Definition at line 8428 of file object.cc.

8428 {
8429 ASSERT(kind() == UntaggedFunction::kDynamicInvocationForwarder);
8430 set_data(target);
8431}

◆ SetInstructions()

void dart::Function::SetInstructions ( const Code value) const

Definition at line 7909 of file object.cc.

7909 {
7910 // Ensure that nobody is executing this function when we install it.
7911 if (untag()->code() != Code::null() && HasCode()) {
7912 GcSafepointOperationScope safepoint(Thread::Current());
7914 } else {
7915 ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
7917 }
7918}

◆ SetInstructionsSafe()

void dart::Function::SetInstructionsSafe ( const Code value) const

Definition at line 7920 of file object.cc.

7920 {
7921 untag()->set_code<std::memory_order_release>(value.ptr());
7922 StoreNonPointer(&untag()->entry_point_, value.EntryPoint());
7923 StoreNonPointer(&untag()->unchecked_entry_point_,
7924 value.UncheckedEntryPoint());
7925}

◆ SetIsOptimizable()

void dart::Function::SetIsOptimizable ( bool  value) const

Definition at line 8948 of file object.cc.

8948 {
8949 ASSERT(!is_native());
8951 if (!value) {
8952 set_is_inlinable(false);
8953 set_usage_counter(INT32_MIN);
8954 }
8955}
void set_is_optimizable(bool value) const
Definition: object.h:4207

◆ SetKernelLibraryAndEvalScript()

void dart::Function::SetKernelLibraryAndEvalScript ( const Script script,
const class KernelProgramInfo kernel_program_info,
intptr_t  index 
) const

Definition at line 10867 of file object.cc.

10870 {
10871 Array& data_field = Array::Handle(
10872 Array::New(static_cast<intptr_t>(EvalFunctionData::kLength)));
10873 data_field.SetAt(static_cast<intptr_t>(EvalFunctionData::kScript), script);
10874 data_field.SetAt(static_cast<intptr_t>(EvalFunctionData::kKernelProgramInfo),
10875 kernel_program_info);
10876 data_field.SetAt(static_cast<intptr_t>(EvalFunctionData::kKernelLibraryIndex),
10877 Smi::Handle(Smi::New(index)));
10878 set_data(data_field);
10879}
static SmiPtr New(intptr_t value)
Definition: object.h:10006

◆ SetOptimizedCallSiteCountClamped()

void dart::Function::SetOptimizedCallSiteCountClamped ( uintptr_t  value) const
inline

Definition at line 3577 of file object.h.

3577 {
3579 set_optimized_call_site_count(value);
3580 }
static constexpr intptr_t kMaxInstructionCount
Definition: object.h:3570

◆ SetOptimizedInstructionCountClamped()

void dart::Function::SetOptimizedInstructionCountClamped ( uintptr_t  value) const
inline

Definition at line 3572 of file object.h.

3572 {
3574 set_optimized_instruction_count(value);
3575 }

◆ SetParameterNameAt()

void dart::Function::SetParameterNameAt ( intptr_t  index,
const String value 
) const

Definition at line 8623 of file object.cc.

8623 {
8624#if defined(DART_PRECOMPILED_RUNTIME)
8625 UNREACHABLE();
8626#else
8627 ASSERT(!value.IsNull() && value.IsSymbol());
8629 // These should be set on the signature, not the function.
8630 UNREACHABLE();
8631 }
8632 const Array& parameter_names =
8633 Array::Handle(untag()->positional_parameter_names());
8634 parameter_names.SetAt(index, value);
8635#endif
8636}

◆ SetRegExpData()

void dart::Function::SetRegExpData ( const RegExp regexp,
intptr_t  string_specialization_cid,
bool  sticky 
) const

Definition at line 8492 of file object.cc.

8494 {
8495 ASSERT(kind() == UntaggedFunction::kIrregexpFunction);
8497 ASSERT(data() == Object::null());
8498 const Array& pair = Array::Handle(Array::New(2, Heap::kOld));
8499 pair.SetAt(0, regexp);
8500 pair.SetAt(1, Smi::Handle(Smi::New(StickySpecialization::encode(sticky) |
8503 set_data(pair);
8504}
static constexpr intptr_t encode(bool value)
Definition: bitfield.h:165
intptr_t string_specialization_cid() const
Definition: object.cc:8480
RegExpPtr regexp() const
Definition: object.cc:8469
bool IsStringClassId(intptr_t index)
Definition: class_id.h:350

◆ SetSignature()

void dart::Function::SetSignature ( const FunctionType value) const

Definition at line 8546 of file object.cc.

8546 {
8547 set_signature(value);
8548 ASSERT(NumImplicitParameters() == value.num_implicit_parameters());
8549 if (IsClosureFunction() && value.IsGeneric()) {
8550 Zone* zone = Thread::Current()->zone();
8551 const TypeParameters& type_params =
8552 TypeParameters::Handle(zone, value.type_parameters());
8553 const TypeArguments& defaults =
8554 TypeArguments::Handle(zone, type_params.defaults());
8555 auto mode = defaults.GetInstantiationMode(zone, this);
8557 }
8558}
void set_default_type_arguments_instantiation_mode(InstantiationMode value) const
Definition: object.cc:8196
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ SetUsageCounter()

void dart::Function::SetUsageCounter ( intptr_t  value) const
inline

Definition at line 4115 of file object.h.

4115 {
4116 if (usage_counter() > 0) {
4117 SetWasExecuted(true);
4118 }
4119 set_usage_counter(value);
4120 }
void SetWasExecuted(bool value) const
Definition: object.h:4124

◆ SetWasExecuted()

void dart::Function::SetWasExecuted ( bool  value) const
inline

Definition at line 4124 of file object.h.

4124{ SetWasExecutedBit(value); }

◆ signature_offset()

static intptr_t dart::Function::signature_offset ( )
inlinestatic

Definition at line 3049 of file object.h.

3049 {
3050 return OFFSET_OF(UntaggedFunction, signature_);
3051 }

◆ SourceFingerprint()

int32_t dart::Function::SourceFingerprint ( ) const

Definition at line 11169 of file object.cc.

11169 {
11170#if !defined(DART_PRECOMPILED_RUNTIME)
11172 *this);
11173#else
11174 return 0;
11175#endif // !defined(DART_PRECOMPILED_RUNTIME)
11176}
static uint32_t CalculateFunctionFingerprint(const Function &func)

◆ SourceSize()

intptr_t dart::Function::SourceSize ( ) const

Definition at line 11453 of file object.cc.

11453 {
11454 const TokenPosition& start = token_pos();
11455 const TokenPosition& end = end_token_pos();
11456 if (!end.IsReal() || start.IsNoSource() || start.IsClassifying()) {
11457 // No source information, so just return 0.
11458 return 0;
11459 }
11460 if (start.IsSynthetic()) {
11461 // Try and approximate the source size using the parent's source size.
11462 const auto& parent = Function::Handle(parent_function());
11463 ASSERT(!parent.IsNull());
11464 const intptr_t parent_size = parent.SourceSize();
11465 if (parent_size == 0) {
11466 return parent_size;
11467 }
11468 // Parent must have a real ending position.
11469 return parent_size - (parent.end_token_pos().Pos() - end.Pos());
11470 }
11471 return end.Pos() - start.Pos();
11472}
glong glong end

◆ string_specialization_cid()

intptr_t dart::Function::string_specialization_cid ( ) const

Definition at line 8480 of file object.cc.

8480 {
8481 ASSERT(kind() == UntaggedFunction::kIrregexpFunction);
8482 const Array& pair = Array::Cast(Object::Handle(data()));
8484}

◆ SwitchToLazyCompiledUnoptimizedCode()

void dart::Function::SwitchToLazyCompiledUnoptimizedCode ( ) const

Definition at line 8007 of file object.cc.

8007 {
8008#if defined(DART_PRECOMPILED_RUNTIME)
8009 UNREACHABLE();
8010#else
8011 if (!HasOptimizedCode()) {
8012 return;
8013 }
8014
8015 Thread* thread = Thread::Current();
8016 Zone* zone = thread->zone();
8017 ASSERT(thread->IsDartMutatorThread());
8018
8019 const Code& current_code = Code::Handle(zone, CurrentCode());
8020 TIR_Print("Disabling optimized code for %s\n", ToCString());
8021 current_code.DisableDartCode();
8022
8023 const Code& unopt_code = Code::Handle(zone, unoptimized_code());
8024 if (unopt_code.IsNull()) {
8025 // Set the lazy compile stub code.
8026 TIR_Print("Switched to lazy compile stub for %s\n", ToCString());
8027 SetInstructions(StubCode::LazyCompile());
8028 return;
8029 }
8030
8031 TIR_Print("Switched to unoptimized code for %s\n", ToCString());
8032
8033 AttachCode(unopt_code);
8034 unopt_code.Enable();
8035#endif
8036}
bool HasOptimizedCode() const
Definition: object.cc:10974
#define TIR_Print(format,...)

◆ SwitchToUnoptimizedCode()

void dart::Function::SwitchToUnoptimizedCode ( ) const

Definition at line 7982 of file object.cc.

7982 {
7985 Thread* thread = Thread::Current();
7987 thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
7988 Zone* zone = thread->zone();
7989 // TODO(35224): DEBUG_ASSERT(thread->TopErrorHandlerIsExitFrame());
7990 const Code& current_code = Code::Handle(zone, CurrentCode());
7991
7992 if (FLAG_trace_deoptimization_verbose) {
7993 THR_Print("Disabling optimized code: '%s' entry: %#" Px "\n",
7994 ToFullyQualifiedCString(), current_code.EntryPoint());
7995 }
7996 current_code.DisableDartCode();
7997 const Error& error =
7998 Error::Handle(zone, Compiler::EnsureUnoptimizedCode(thread, *this));
7999 if (!error.IsNull()) {
8001 }
8002 const Code& unopt_code = Code::Handle(zone, unoptimized_code());
8003 unopt_code.Enable();
8004 AttachCode(unopt_code);
8005}
const char * ToFullyQualifiedCString() const
Definition: object.cc:9762
#define Px
Definition: globals.h:410

◆ ToFullyQualifiedCString()

const char * dart::Function::ToFullyQualifiedCString ( ) const

Definition at line 9762 of file object.cc.

9762 {
9763 char* chars = nullptr;
9764 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true,
9766 return chars;
9767}
@ kQualifiedFunctionLibKindLibUrl
Definition: object.cc:9697
static intptr_t ConstructFunctionFullyQualifiedCString(const Function &function, char **chars, intptr_t reserve_len, bool with_lib, QualifiedFunctionLibKind lib_kind)
Definition: object.cc:9701

◆ token_pos()

TokenPosition dart::Function::token_pos ( ) const
inline

Definition at line 3446 of file object.h.

3446 {
3447#if defined(DART_PRECOMPILED_RUNTIME)
3448 return TokenPosition::kNoSource;
3449#else
3450 return untag()->token_pos_;
3451#endif
3452 }

◆ ToLibNamePrefixedQualifiedCString()

const char * dart::Function::ToLibNamePrefixedQualifiedCString ( ) const

Definition at line 9769 of file object.cc.

9769 {
9770 char* chars = nullptr;
9771 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true,
9773 return chars;
9774}
@ kQualifiedFunctionLibKindLibName
Definition: object.cc:9698

◆ ToQualifiedCString()

const char * dart::Function::ToQualifiedCString ( ) const

Definition at line 9776 of file object.cc.

9776 {
9777 char* chars = nullptr;
9778 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false,
9780 return chars;
9781}

◆ type_parameters()

TypeParametersPtr dart::Function::type_parameters ( ) const
inline

Definition at line 3129 of file object.h.

3129 {
3130 return signature()->untag()->type_parameters();
3131 }

◆ TypeParameterAt()

TypeParameterPtr dart::Function::TypeParameterAt ( intptr_t  index,
Nullability  nullability = Nullability::kNonNullable 
) const

Definition at line 8881 of file object.cc.

8882 {
8883 const FunctionType& sig = FunctionType::Handle(signature());
8884 return sig.TypeParameterAt(index, nullability);
8885}

◆ unchecked_entry_point_offset()

static intptr_t dart::Function::unchecked_entry_point_offset ( )
inlinestatic

Definition at line 3215 of file object.h.

3215 {
3216 return OFFSET_OF(UntaggedFunction, unchecked_entry_point_);
3217 }

◆ unoptimized_code()

CodePtr dart::Function::unoptimized_code ( ) const
inline

Definition at line 3185 of file object.h.

3185 {
3186#if defined(DART_PRECOMPILED_RUNTIME)
3187 return static_cast<CodePtr>(Object::null());
3188#else
3189 return untag()->unoptimized_code();
3190#endif
3191 }

◆ UserVisibleName()

StringPtr dart::Function::UserVisibleName ( ) const

Definition at line 10999 of file object.cc.

10999 {
11000 if (FLAG_show_internal_names) {
11001 return name();
11002 }
11003 return Symbols::New(
11006 is_extension_member() || is_extension_type_member()));
11007}
static const char * ScrubName(const String &name, bool is_extension=false)
Definition: object.cc:287

◆ UserVisibleNameCString()

const char * dart::Function::UserVisibleNameCString ( ) const

Definition at line 10990 of file object.cc.

10990 {
10991 if (FLAG_show_internal_names) {
10992 return String::Handle(name()).ToCString();
10993 }
10994 is_extension_type_member();
10996 is_extension_member() || is_extension_type_member());
10997}

◆ UserVisibleSignature()

StringPtr dart::Function::UserVisibleSignature ( ) const

Definition at line 10629 of file object.cc.

10629 {
10630#if defined(DART_PRECOMPILED_RUNTIME)
10631 if (signature() == FunctionType::null()) {
10632 return String::null();
10633 }
10634#endif
10635 Thread* thread = Thread::Current();
10636 ZoneTextBuffer printer(thread->zone());
10637 const FunctionType& sig = FunctionType::Handle(signature());
10638 sig.Print(kUserVisibleName, &printer);
10639 return Symbols::New(thread, printer.buffer());
10640}

◆ VerifyCallEntryPoint()

ErrorPtr dart::Function::VerifyCallEntryPoint ( ) const

Definition at line 27310 of file object.cc.

27310 {
27311 if (!FLAG_verify_entry_points) return Error::null();
27312
27313 const Class& cls = Class::Handle(Owner());
27314 const Library& lib = Library::Handle(cls.library());
27315 switch (kind()) {
27316 case UntaggedFunction::kRegularFunction:
27317 case UntaggedFunction::kSetterFunction:
27318 case UntaggedFunction::kConstructor:
27319 return dart::VerifyEntryPoint(lib, *this, *this,
27321 break;
27322 case UntaggedFunction::kGetterFunction:
27324 lib, *this, *this,
27326 break;
27327 case UntaggedFunction::kImplicitGetter:
27330 break;
27331 case UntaggedFunction::kImplicitSetter:
27334 case UntaggedFunction::kMethodExtractor:
27336 .VerifyClosurizedEntryPoint();
27337 break;
27338 default:
27339 return dart::VerifyEntryPoint(lib, *this, Object::Handle(), {});
27340 break;
27341 }
27342}
FunctionPtr extracted_method_closure() const
Definition: object.cc:8120
DART_WARN_UNUSED_RESULT ErrorPtr VerifyEntryPoint(const Library &lib, const Object &member, const Object &annotated, std::initializer_list< EntryPointPragma > allowed_kinds)
Definition: object.cc:27151

◆ VerifyClosurizedEntryPoint()

ErrorPtr dart::Function::VerifyClosurizedEntryPoint ( ) const

Definition at line 27344 of file object.cc.

27344 {
27345 if (!FLAG_verify_entry_points) return Error::null();
27346
27347 const Class& cls = Class::Handle(Owner());
27348 const Library& lib = Library::Handle(cls.library());
27349 switch (kind()) {
27350 case UntaggedFunction::kRegularFunction:
27351 return dart::VerifyEntryPoint(lib, *this, *this,
27353 case UntaggedFunction::kImplicitClosureFunction: {
27354 const Function& parent = Function::Handle(parent_function());
27355 return dart::VerifyEntryPoint(lib, parent, parent,
27357 }
27358 default:
27359 UNREACHABLE();
27360 }
27361}

◆ WasExecuted()

bool dart::Function::WasExecuted ( ) const
inline

Definition at line 4122 of file object.h.

4122{ return (usage_counter() > 0) || WasExecutedBit(); }

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 4303 of file object.h.

◆ ClassFinalizer

friend class ClassFinalizer
friend

Definition at line 4308 of file object.h.

◆ Parser

friend class Parser
friend

Definition at line 4304 of file object.h.

◆ Precompiler

friend class Precompiler
friend

Definition at line 4310 of file object.h.

◆ ProgramVisitor

friend class ProgramVisitor
friend

Definition at line 4311 of file object.h.

◆ Type

friend class Type
friend

Definition at line 4309 of file object.h.

◆ UntaggedFunction

friend class UntaggedFunction
friend

Definition at line 4307 of file object.h.

Member Data Documentation

◆ kMaxInstructionCount

constexpr intptr_t dart::Function::kMaxInstructionCount = (1 << 16) - 1
staticconstexpr

Definition at line 3570 of file object.h.


The documentation for this class was generated from the following files: