5#ifndef RUNTIME_VM_COMPILER_AOT_PRECOMPILER_TRACER_H_
6#define RUNTIME_VM_COMPILER_AOT_PRECOMPILER_TRACER_H_
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
21#if defined(DART_PRECOMPILER)
26class PrecompilerTracer :
public ZoneAllocated {
28 static PrecompilerTracer* StartTracingIfRequested(Precompiler* precompiler);
32 void WriteEntityRef(
const Object& field) {
33 Write(
"%" Pd ",", InternEntity(field));
36 void WriteFieldRef(
const Field& field) { WriteEntityRef(field); }
38 void WriteFunctionRef(
const Function&
function) { WriteEntityRef(
function); }
40 void WriteSelectorRef(
const String& selector) {
41 Write(
"\"S\",%" Pd ",", InternString(selector));
44 void WriteTableSelectorRef(intptr_t
id) { Write(
"\"T\",%" Pd ",",
id); }
46 void WriteClassInstantiationRef(
const Class& cls) { WriteEntityRef(cls); }
48 void WriteCompileFunctionEvent(
const Function&
function) {
60 struct StringTableTraits {
61 static bool ReportStats() {
return false; }
62 static const char*
Name() {
return "StringTableTraits"; }
64 static bool IsMatch(
const Object&
a,
const Object&
b) {
65 return String::Cast(
a).Equals(String::Cast(
b));
68 static bool IsMatch(
const CString& cstr,
const Object& other) {
69 const String& other_str = String::Cast(other);
70 if (other_str.Hash() != cstr.hash) {
74 if (other_str.Length() != cstr.length) {
78 return other_str.Equals(cstr.str);
81 static uword Hash(
const CString& cstr) {
return cstr.hash; }
83 static uword Hash(
const Object& obj) {
return String::Cast(obj).Hash(); }
85 static ObjectPtr NewKey(
const CString& cstr) {
90 struct EntityTableTraits {
91 static bool ReportStats() {
return false; }
92 static const char*
Name() {
return "EntityTableTraits"; }
94 static bool IsMatch(
const Object&
a,
const Object&
b) {
95 return a.ptr() ==
b.ptr();
99 if (obj.IsFunction()) {
100 return Function::Cast(obj).Hash();
101 }
else if (obj.IsClass()) {
102 return Class::Cast(obj).Hash();
103 }
else if (obj.IsField()) {
104 return Field::Cast(obj).Hash();
106 return obj.GetClassId();
110 using StringTable = UnorderedHashMap<StringTableTraits>;
111 using EntityTable = UnorderedHashMap<EntityTableTraits>;
113 PrecompilerTracer(Precompiler* precompiler,
void*
stream);
115 intptr_t InternString(
const CString& cstr);
116 intptr_t InternString(
const String& str);
117 intptr_t InternEntity(
const Object& obj);
122 buffer_.VPrintf(
format, va);
126 CString NameForTrace(
const Function&
f);
128 void WriteEntityTable();
129 void WriteStringTable();
132 Precompiler* precompiler_;
135 StringTable strings_;
136 EntityTable entities_;
static uint32_t hash(const SkShaderBase::GradientInfo &v)
static StringPtr New(Thread *thread, const char *cstr)
static Thread * Current()
uint32_t uint32_t * format
Dart_NativeFunction function
static uint32_t Hash(uint32_t key)