Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
offsets_extractor.cc File Reference
#include <iostream>
#include "vm/compiler/runtime_api.h"
#include "vm/compiler/runtime_offsets_list.h"
#include "vm/dart_api_state.h"
#include "vm/dart_entry.h"
#include "vm/longjump.h"
#include "vm/native_arguments.h"
#include "vm/native_entry.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/runtime_entry.h"
#include "vm/symbols.h"
#include "vm/timeline.h"

Go to the source code of this file.

Classes

class  dart::OffsetsExtractor
 

Namespaces

namespace  dart
 

Macros

#define PRODUCT_DEF   "!defined(PRODUCT)"
 
#define COMPRESSED_DEF   "!defined(DART_COMPRESSED_POINTERS)"
 
#define PREPROCESSOR_CONDITION    "#if " PRODUCT_DEF " && " ARCH_DEF_CPU " && " COMPRESSED_DEF
 
#define PREPROCESSOR_CONDITION_END
 
#define PRINT_ARRAY_SIZEOF(Class, Name, ElementOffset)
 
#define PRINT_PAYLOAD_SIZEOF(Class, Name, HeaderSize)
 
#define PRINT_FIELD_OFFSET(Class, Name)
 
#define PRINT_ARRAY_LAYOUT(Class, Name)
 
#define PRINT_SIZEOF(Class, Name, What)
 
#define PRINT_RANGE(Class, Name, Type, First, Last, Filter)
 
#define PRINT_CONSTANT(Class, Name)
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ COMPRESSED_DEF

#define COMPRESSED_DEF   "!defined(DART_COMPRESSED_POINTERS)"

Definition at line 45 of file offsets_extractor.cc.

◆ PREPROCESSOR_CONDITION

#define PREPROCESSOR_CONDITION    "#if " PRODUCT_DEF " && " ARCH_DEF_CPU " && " COMPRESSED_DEF

Definition at line 48 of file offsets_extractor.cc.

54 {
55
56void Assert::Fail(const char* format, ...) const {
57 abort();
58}
59
60class OffsetsExtractor : public AllStatic {
61 public:
62 static void DumpOffsets() {
63// Currently we have two different axes for offset generation:
64//
65// * Target architecture
66// * DART_PRECOMPILED_RUNTIME (i.e, AOT vs. JIT)
67//
68// TODO(dartbug.com/43646): Add DART_PRECOMPILER as another axis.
69
70// These macros don't use any special constants, just method calls, so no
71// output.
72#define PRINT_ARRAY_SIZEOF(Class, Name, ElementOffset)
73#define PRINT_PAYLOAD_SIZEOF(Class, Name, HeaderSize)
74
75#if defined(DART_PRECOMPILED_RUNTIME)
76
77#define PRINT_FIELD_OFFSET(Class, Name) \
78 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
79 "_" #Name " = 0x" \
80 << Class::Name() << ";\n";
81
82#define PRINT_ARRAY_LAYOUT(Class, Name) \
83 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
84 "_elements_start_offset = 0x" \
85 << Class::ArrayTraits::elements_start_offset() << ";\n"; \
86 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
87 "_element_size = 0x" \
88 << Class::ArrayTraits::kElementSize << ";\n";
89
90#define PRINT_SIZEOF(Class, Name, What) \
91 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
92 "_" #Name " = 0x" \
93 << sizeof(What) << ";\n";
94
95#define PRINT_RANGE(Class, Name, Type, First, Last, Filter) \
96 { \
97 auto filter = Filter; \
98 bool comma = false; \
99 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
100 "_" #Name "[] = {"; \
101 for (intptr_t i = static_cast<intptr_t>(First); \
102 i <= static_cast<intptr_t>(Last); i++) { \
103 auto v = static_cast<Type>(i); \
104 std::cout << (comma ? ", " : ""); \
105 if (filter(v)) { \
106 std::cout << "0x" << Class::Name(v); \
107 } else { \
108 std::cout << "-1"; \
109 } \
110 comma = true; \
111 } \
112 std::cout << "};\n"; \
113 }
114
115#define PRINT_CONSTANT(Class, Name) \
116 std::cout << "static constexpr dart::compiler::target::word AOT_" #Class \
117 "_" #Name " = 0x" \
118 << Class::Name << ";\n";
119
123
124#else // defined(DART_PRECOMPILED_RUNTIME)
125
126#define PRINT_FIELD_OFFSET(Class, Name) \
127 std::cout << "static constexpr dart::compiler::target::word " #Class \
128 "_" #Name " = 0x" \
129 << Class::Name() << ";\n";
130
131#define PRINT_ARRAY_LAYOUT(Class, Name) \
132 std::cout << "static constexpr dart::compiler::target::word " #Class \
133 "_elements_start_offset = 0x" \
134 << Class::ArrayTraits::elements_start_offset() << ";\n"; \
135 std::cout << "static constexpr dart::compiler::target::word " #Class \
136 "_element_size = 0x" \
137 << Class::ArrayTraits::kElementSize << ";\n";
138
139#define PRINT_SIZEOF(Class, Name, What) \
140 std::cout << "static constexpr dart::compiler::target::word " #Class \
141 "_" #Name " = 0x" \
142 << sizeof(What) << ";\n";
143
144#define PRINT_RANGE(Class, Name, Type, First, Last, Filter) \
145 { \
146 auto filter = Filter; \
147 bool comma = false; \
148 std::cout << "static constexpr dart::compiler::target::word " #Class \
149 "_" #Name "[] = {"; \
150 for (intptr_t i = static_cast<intptr_t>(First); \
151 i <= static_cast<intptr_t>(Last); i++) { \
152 auto v = static_cast<Type>(i); \
153 std::cout << (comma ? ", " : ""); \
154 if (filter(v)) { \
155 std::cout << "0x" << Class::Name(v); \
156 } else { \
157 std::cout << "-1"; \
158 } \
159 comma = true; \
160 } \
161 std::cout << "};\n"; \
162 }
163
164#define PRINT_CONSTANT(Class, Name) \
165 std::cout << "static constexpr dart::compiler::target::word " #Class \
166 "_" #Name " = 0x" \
167 << Class::Name << ";\n";
168
172
173#endif // defined(DART_PRECOMPILED_RUNTIME)
174
178
179#undef PRINT_FIELD_OFFSET
180#undef PRINT_ARRAY_LAYOUT
181#undef PRINT_SIZEOF
182#undef PRINT_RANGE
183#undef PRINT_CONSTANT
184#undef PRINT_ARRAY_SIZEOF
185#undef PRINT_PAYLOAD_SIZEOF
186 }
187};
188
189} // namespace dart
190
191int main(int argc, char* argv[]) {
192 std::cout << std::hex << PREPROCESSOR_CONDITION << std::endl;
193#if !defined(TARGET_ARCH_IA32) || !defined(DART_PRECOMPILED_RUNTIME)
195#endif
196 std::cout << PREPROCESSOR_CONDITION_END << std::endl;
197 return 0;
198}
uint32_t uint32_t * format
Definition main.py:1
#define PRINT_CONSTANT(Class, Name)
#define PRINT_FIELD_OFFSET(Class, Name)
#define PRINT_ARRAY_SIZEOF(Class, Name, ElementOffset)
#define PRINT_SIZEOF(Class, Name, What)
#define PREPROCESSOR_CONDITION_END
#define PREPROCESSOR_CONDITION
#define PRINT_PAYLOAD_SIZEOF(Class, Name, HeaderSize)
#define PRINT_ARRAY_LAYOUT(Class, Name)
#define PRINT_RANGE(Class, Name, Type, First, Last, Filter)
#define JIT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
#define AOT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
#define COMMON_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)

◆ PREPROCESSOR_CONDITION_END

#define PREPROCESSOR_CONDITION_END
Value:
"#endif // " PRODUCT_DEF " && \n // " ARCH_DEF_CPU \
" && \n // " COMPRESSED_DEF
#define PRODUCT_DEF
#define COMPRESSED_DEF

Definition at line 51 of file offsets_extractor.cc.

◆ PRINT_ARRAY_LAYOUT

#define PRINT_ARRAY_LAYOUT (   Class,
  Name 
)
Value:
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_elements_start_offset = 0x" \
<< Class::ArrayTraits::elements_start_offset() << ";\n"; \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_element_size = 0x" \
<< Class::ArrayTraits::kElementSize << ";\n";

◆ PRINT_ARRAY_SIZEOF

#define PRINT_ARRAY_SIZEOF (   Class,
  Name,
  ElementOffset 
)

◆ PRINT_CONSTANT

#define PRINT_CONSTANT (   Class,
  Name 
)
Value:
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = 0x" \
<< Class::Name << ";\n";

◆ PRINT_FIELD_OFFSET

#define PRINT_FIELD_OFFSET (   Class,
  Name 
)
Value:
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = 0x" \
<< Class::Name() << ";\n";

◆ PRINT_PAYLOAD_SIZEOF

#define PRINT_PAYLOAD_SIZEOF (   Class,
  Name,
  HeaderSize 
)

◆ PRINT_RANGE

#define PRINT_RANGE (   Class,
  Name,
  Type,
  First,
  Last,
  Filter 
)
Value:
{ \
auto filter = Filter; \
bool comma = false; \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name "[] = {"; \
for (intptr_t i = static_cast<intptr_t>(First); \
i <= static_cast<intptr_t>(Last); i++) { \
auto v = static_cast<Type>(i); \
std::cout << (comma ? ", " : ""); \
if (filter(v)) { \
std::cout << "0x" << Class::Name(v); \
} else { \
std::cout << "-1"; \
} \
comma = true; \
} \
std::cout << "};\n"; \
}
GrSamplerState::Filter Filter

◆ PRINT_SIZEOF

#define PRINT_SIZEOF (   Class,
  Name,
  What 
)
Value:
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = 0x" \
<< sizeof(What) << ";\n";

◆ PRODUCT_DEF

#define PRODUCT_DEF   "!defined(PRODUCT)"

Definition at line 23 of file offsets_extractor.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 192 of file offsets_extractor.cc.

192 {
193 std::cout << std::hex << PREPROCESSOR_CONDITION << std::endl;
194#if !defined(TARGET_ARCH_IA32) || !defined(DART_PRECOMPILED_RUNTIME)
196#endif
197 std::cout << PREPROCESSOR_CONDITION_END << std::endl;
198 return 0;
199}