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

#include <image_snapshot.h>

Public Types

typedef ObjectPtr Key
 
typedef int32_t Value
 
typedef ObjectOffsetPair Pair
 

Static Public Member Functions

static Key KeyOf (Pair kv)
 
static Value ValueOf (Pair kv)
 
static uword Hash (Key key)
 
static bool IsKeyEqual (Pair pair, Key key)
 

Detailed Description

Definition at line 179 of file image_snapshot.h.

Member Typedef Documentation

◆ Key

Definition at line 182 of file image_snapshot.h.

◆ Pair

Definition at line 184 of file image_snapshot.h.

◆ Value

Definition at line 183 of file image_snapshot.h.

Member Function Documentation

◆ Hash()

uword dart::ObjectOffsetTrait::Hash ( Key  key)
static

Definition at line 127 of file image_snapshot.cc.

127 {
128 ObjectPtr obj = key;
129 ASSERT(!obj->IsSmi());
130
131 uword body = UntaggedObject::ToAddr(obj) + sizeof(UntaggedObject);
132 uword end = UntaggedObject::ToAddr(obj) + obj->untag()->HeapSize();
133
134 uint32_t hash = obj->GetClassId();
135 // Don't include the header. Objects in the image are pre-marked, but objects
136 // in the current isolate are not.
137 for (uword cursor = body; cursor < end; cursor += sizeof(uint32_t)) {
138 hash = CombineHashes(hash, *reinterpret_cast<uint32_t*>(cursor));
139 }
140
141 return FinalizeHash(hash, 30);
142}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
static uword ToAddr(const UntaggedObject *raw_obj)
Definition: raw_object.h:522
#define ASSERT(E)
glong glong end
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition: hash.h:12
uintptr_t uword
Definition: globals.h:501
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition: hash.h:20

◆ IsKeyEqual()

bool dart::ObjectOffsetTrait::IsKeyEqual ( Pair  pair,
Key  key 
)
inlinestatic

Definition at line 144 of file image_snapshot.cc.

144 {
145 ObjectPtr a = pair.object;
146 ObjectPtr b = key;
147 ASSERT(!a->IsSmi());
148 ASSERT(!b->IsSmi());
149
150 if (a->GetClassId() != b->GetClassId()) {
151 return false;
152 }
153
154 intptr_t heap_size = a->untag()->HeapSize();
155 if (b->untag()->HeapSize() != heap_size) {
156 return false;
157 }
158
159 // Don't include the header. Objects in the image are pre-marked, but objects
160 // in the current isolate are not.
161 uword body_a = UntaggedObject::ToAddr(a) + sizeof(UntaggedObject);
162 uword body_b = UntaggedObject::ToAddr(b) + sizeof(UntaggedObject);
163 uword body_size = heap_size - sizeof(UntaggedObject);
164 return 0 == memcmp(reinterpret_cast<const void*>(body_a),
165 reinterpret_cast<const void*>(body_b), body_size);
166}
static bool b
struct MyStruct a[10]

◆ KeyOf()

static Key dart::ObjectOffsetTrait::KeyOf ( Pair  kv)
inlinestatic

Definition at line 186 of file image_snapshot.h.

186{ return kv.object; }

◆ ValueOf()

static Value dart::ObjectOffsetTrait::ValueOf ( Pair  kv)
inlinestatic

Definition at line 187 of file image_snapshot.h.

187{ return kv.offset; }

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