Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
dart::kernel::DirectCallMetadataHelper Class Reference

#include <kernel_translation_helper.h>

Inheritance diagram for dart::kernel::DirectCallMetadataHelper:
dart::kernel::MetadataHelper

Public Member Functions

 DirectCallMetadataHelper (KernelReaderHelper *helper)
 
DirectCallMetadata GetDirectTargetForPropertyGet (intptr_t node_offset)
 
DirectCallMetadata GetDirectTargetForPropertySet (intptr_t node_offset)
 
DirectCallMetadata GetDirectTargetForMethodInvocation (intptr_t node_offset)
 
DirectCallMetadata GetDirectTargetForFunctionInvocation (intptr_t node_offset)
 
- Public Member Functions inherited from dart::kernel::MetadataHelper
 MetadataHelper (KernelReaderHelper *helper, const char *tag, bool precompiler_only)
 

Static Public Member Functions

static const char * tag ()
 

Additional Inherited Members

- Protected Member Functions inherited from dart::kernel::MetadataHelper
intptr_t FindMetadataMapping (intptr_t node_offset)
 
intptr_t GetNextMetadataPayloadOffset (intptr_t node_offset)
 
intptr_t GetComponentMetadataPayloadOffset ()
 
- Protected Attributes inherited from dart::kernel::MetadataHelper
KernelReaderHelperhelper_
 
TranslationHelpertranslation_helper_
 

Detailed Description

Definition at line 991 of file kernel_translation_helper.h.

Constructor & Destructor Documentation

◆ DirectCallMetadataHelper()

dart::kernel::DirectCallMetadataHelper::DirectCallMetadataHelper ( KernelReaderHelper helper)
explicit

Definition at line 1743 of file kernel_translation_helper.cc.

1744 : MetadataHelper(helper, tag(), /* precompiler_only = */ true) {}
MetadataHelper(KernelReaderHelper *helper, const char *tag, bool precompiler_only)

Member Function Documentation

◆ GetDirectTargetForFunctionInvocation()

DirectCallMetadata dart::kernel::DirectCallMetadataHelper::GetDirectTargetForFunctionInvocation ( intptr_t  node_offset)

Definition at line 1830 of file kernel_translation_helper.cc.

1831 {
1832 NameIndex kernel_name;
1833 bool check_receiver_for_null = false;
1834 intptr_t closure_id = -1;
1835 if (!ReadMetadata(node_offset, &kernel_name, &check_receiver_for_null,
1836 &closure_id)) {
1837 return DirectCallMetadata(Function::null_function(), false);
1838 }
1839
1840 const auto& member =
1841 Object::Handle(helper_->zone_, H.LookupMemberByMember(kernel_name));
1843 if (member.IsField()) {
1844 const auto& field = Field::Cast(member);
1845 // Non-trivial initializers of instance non-late fields should be
1846 // inlined into constructors on kernel AST
1847 // during MoveFieldInitializers transformation.
1848 ASSERT(field.is_static() || field.is_late());
1849 ASSERT(field.has_nontrivial_initializer());
1850 function = field.EnsureInitializerFunction();
1851 } else {
1852 function = Function::Cast(member).ptr();
1853 }
1854
1855 ASSERT(closure_id >= 0);
1856 if (closure_id == 0) {
1857 // Tear-off
1858 ASSERT(!member.IsField());
1859 function = function.ImplicitClosureFunction();
1860 ASSERT(!function.IsNull());
1861 return DirectCallMetadata(function, check_receiver_for_null);
1862 }
1863
1864 // TODO(alexmarkov): support devirtualization of arbitrary closure calls.
1865 return DirectCallMetadata(Function::null_function(), false);
1866}
static Object & Handle()
Definition: object.h:407
static Object & ZoneHandle()
Definition: object.h:419
#define ASSERT(E)
Dart_NativeFunction function
Definition: fuchsia.cc:51
Definition: SkMD5.cpp:130

◆ GetDirectTargetForMethodInvocation()

DirectCallMetadata dart::kernel::DirectCallMetadataHelper::GetDirectTargetForMethodInvocation ( intptr_t  node_offset)

Definition at line 1814 of file kernel_translation_helper.cc.

1815 {
1816 NameIndex kernel_name;
1817 bool check_receiver_for_null = false;
1818 if (!ReadMetadata(node_offset, &kernel_name, &check_receiver_for_null)) {
1819 return DirectCallMetadata(Function::null_function(), false);
1820 }
1821
1822 const String& method_name = H.DartProcedureName(kernel_name);
1823 const Function& target = Function::ZoneHandle(
1824 helper_->zone_, H.LookupMethodByMember(kernel_name, method_name));
1825
1826 return DirectCallMetadata(target, check_receiver_for_null);
1827}
uint32_t * target

◆ GetDirectTargetForPropertyGet()

DirectCallMetadata dart::kernel::DirectCallMetadataHelper::GetDirectTargetForPropertyGet ( intptr_t  node_offset)

Definition at line 1771 of file kernel_translation_helper.cc.

1772 {
1773 NameIndex kernel_name;
1774 bool check_receiver_for_null = false;
1775 if (!ReadMetadata(node_offset, &kernel_name, &check_receiver_for_null)) {
1776 return DirectCallMetadata(Function::null_function(), false);
1777 }
1778
1779 if (H.IsProcedure(kernel_name) && !H.IsGetter(kernel_name)) {
1780 // Tear-off. Use method extractor as direct call target.
1781 const String& method_name = H.DartMethodName(kernel_name);
1782 const Function& target_method = Function::ZoneHandle(
1783 helper_->zone_, H.LookupMethodByMember(kernel_name, method_name));
1784 const String& getter_name = H.DartGetterName(kernel_name);
1785 return DirectCallMetadata(
1787 target_method.GetMethodExtractor(getter_name)),
1788 check_receiver_for_null);
1789 } else {
1790 const String& getter_name = H.DartGetterName(kernel_name);
1791 const Function& target = Function::ZoneHandle(
1792 helper_->zone_, H.LookupMethodByMember(kernel_name, getter_name));
1793 ASSERT(target.IsGetterFunction() || target.IsImplicitGetterFunction());
1794 return DirectCallMetadata(target, check_receiver_for_null);
1795 }
1796}

◆ GetDirectTargetForPropertySet()

DirectCallMetadata dart::kernel::DirectCallMetadataHelper::GetDirectTargetForPropertySet ( intptr_t  node_offset)

Definition at line 1798 of file kernel_translation_helper.cc.

1799 {
1800 NameIndex kernel_name;
1801 bool check_receiver_for_null = false;
1802 if (!ReadMetadata(node_offset, &kernel_name, &check_receiver_for_null)) {
1803 return DirectCallMetadata(Function::null_function(), false);
1804 }
1805
1806 const String& method_name = H.DartSetterName(kernel_name);
1807 const Function& target = Function::ZoneHandle(
1808 helper_->zone_, H.LookupMethodByMember(kernel_name, method_name));
1809 ASSERT(target.IsSetterFunction() || target.IsImplicitSetterFunction());
1810
1811 return DirectCallMetadata(target, check_receiver_for_null);
1812}

◆ tag()

static const char * dart::kernel::DirectCallMetadataHelper::tag ( )
inlinestatic

Definition at line 993 of file kernel_translation_helper.h.

993{ return "vm.direct-call.metadata"; }

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