Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::kernel::MetadataHelper Class Reference

#include <kernel_translation_helper.h>

Inheritance diagram for dart::kernel::MetadataHelper:
dart::kernel::CallSiteAttributesMetadataHelper dart::kernel::DirectCallMetadataHelper dart::kernel::InferredTypeMetadataHelper dart::kernel::LoadingUnitsMetadataHelper dart::kernel::ObfuscationProhibitionsMetadataHelper dart::kernel::ProcedureAttributesMetadataHelper dart::kernel::TableSelectorMetadataHelper dart::kernel::UnboxingInfoMetadataHelper

Public Member Functions

 MetadataHelper (KernelReaderHelper *helper, const char *tag, bool precompiler_only)
 

Protected Member Functions

intptr_t FindMetadataMapping (intptr_t node_offset)
 
intptr_t GetNextMetadataPayloadOffset (intptr_t node_offset)
 
intptr_t GetComponentMetadataPayloadOffset ()
 

Protected Attributes

KernelReaderHelperhelper_
 
TranslationHelpertranslation_helper_
 

Detailed Description

Definition at line 935 of file kernel_translation_helper.h.

Constructor & Destructor Documentation

◆ MetadataHelper()

dart::kernel::MetadataHelper::MetadataHelper ( KernelReaderHelper helper,
const char *  tag,
bool  precompiler_only 
)

Definition at line 1586 of file kernel_translation_helper.cc.

1589 : helper_(helper),
1590 translation_helper_(helper->translation_helper_),
1591 tag_(tag),
1592 mappings_scanned_(false),
1593 precompiler_only_(precompiler_only),
1594 mappings_offset_(0),
1595 mappings_num_(0),
1596 last_node_offset_(0),
1597 last_mapping_index_(0) {}

Member Function Documentation

◆ FindMetadataMapping()

intptr_t dart::kernel::MetadataHelper::FindMetadataMapping ( intptr_t  node_offset)
protected

Definition at line 1651 of file kernel_translation_helper.cc.

1651 {
1652 const intptr_t kUInt32Size = 4;
1653 ASSERT(mappings_num_ > 0);
1654
1655 Reader reader(H.metadata_mappings());
1656
1657 intptr_t left = 0;
1658 intptr_t right = mappings_num_ - 1;
1659 while (left < right) {
1660 intptr_t mid = ((right - left) / 2) + left;
1661 intptr_t mid_node_offset =
1662 reader.ReadUInt32At(mappings_offset_ + mid * 2 * kUInt32Size);
1663
1664 if (node_offset < mid_node_offset) {
1665 right = mid - 1;
1666 } else if (node_offset > mid_node_offset) {
1667 left = mid + 1;
1668 } else {
1669 return mid; // Exact match found.
1670 }
1671 }
1672 ASSERT((0 <= left) && (left <= mappings_num_));
1673
1674 // Approximate match is found. Make sure it has an offset greater or equal
1675 // to the given node offset.
1676 if (left < mappings_num_) {
1677 intptr_t found_node_offset =
1678 reader.ReadUInt32At(mappings_offset_ + left * 2 * kUInt32Size);
1679
1680 if (found_node_offset < node_offset) {
1681 ++left;
1682 }
1683 }
1684 ASSERT((left == mappings_num_) ||
1685 static_cast<intptr_t>(reader.ReadUInt32At(
1686 mappings_offset_ + left * 2 * kUInt32Size)) >= node_offset);
1687
1688 return left;
1689}
static int const kUInt32Size
#define ASSERT(E)
Definition: SkMD5.cpp:130

◆ GetComponentMetadataPayloadOffset()

intptr_t dart::kernel::MetadataHelper::GetComponentMetadataPayloadOffset ( )
protected

Definition at line 1737 of file kernel_translation_helper.cc.

1737 {
1738 const intptr_t kComponentNodeOffset = 0;
1739 return GetNextMetadataPayloadOffset(kComponentNodeOffset -
1741}
intptr_t GetNextMetadataPayloadOffset(intptr_t node_offset)

◆ GetNextMetadataPayloadOffset()

intptr_t dart::kernel::MetadataHelper::GetNextMetadataPayloadOffset ( intptr_t  node_offset)
protected

Definition at line 1691 of file kernel_translation_helper.cc.

1691 {
1692 if (!mappings_scanned_) {
1693 ScanMetadataMappings();
1694 mappings_scanned_ = true;
1695 }
1696
1697 if (mappings_num_ == 0) {
1698 return -1; // No metadata.
1699 }
1700
1701 node_offset += helper_->data_program_offset_;
1702
1703 // Nodes are parsed in linear order most of the time, so do the search
1704 // only if looking back.
1705 if (node_offset < last_node_offset_) {
1706 last_mapping_index_ = FindMetadataMapping(node_offset);
1707 }
1708
1709 intptr_t index = last_mapping_index_;
1710 intptr_t mapping_node_offset = 0;
1711 intptr_t mapping_md_offset = -1;
1712
1713 Reader reader(H.metadata_mappings());
1714 const intptr_t kUInt32Size = 4;
1715 reader.set_offset(mappings_offset_ + index * 2 * kUInt32Size);
1716
1717 for (; index < mappings_num_; ++index) {
1718 mapping_node_offset = reader.ReadUInt32();
1719 mapping_md_offset = reader.ReadUInt32();
1720
1721 if (mapping_node_offset >= node_offset) {
1722 break;
1723 }
1724 }
1725
1726 last_mapping_index_ = index;
1727 last_node_offset_ = node_offset;
1728
1729 if ((index < mappings_num_) && (mapping_node_offset == node_offset)) {
1730 ASSERT(mapping_md_offset >= 0);
1731 return mapping_md_offset;
1732 } else {
1733 return -1;
1734 }
1735}
intptr_t FindMetadataMapping(intptr_t node_offset)

Member Data Documentation

◆ helper_

KernelReaderHelper* dart::kernel::MetadataHelper::helper_
protected

Definition at line 957 of file kernel_translation_helper.h.

◆ translation_helper_

TranslationHelper& dart::kernel::MetadataHelper::translation_helper_
protected

Definition at line 958 of file kernel_translation_helper.h.


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