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

#include <intrinsifier.h>

Inheritance diagram for dart::compiler::Intrinsifier:
dart::AllStatic

Static Public Member Functions

static bool Intrinsify (const ParsedFunction &parsed_function, FlowGraphCompiler *compiler)
 
static void InitializeState ()
 

Detailed Description

Definition at line 29 of file intrinsifier.h.

Member Function Documentation

◆ InitializeState()

void dart::compiler::Intrinsifier::InitializeState ( )
static

Definition at line 115 of file intrinsifier.cc.

115 {
116 Thread* thread = Thread::Current();
117 Zone* zone = thread->zone();
118 Library& lib = Library::Handle(zone);
119 Class& cls = Class::Handle(zone);
120 Function& func = Function::Handle(zone);
121 String& str = String::Handle(zone);
122 String& str2 = String::Handle(zone);
123 Error& error = Error::Handle(zone);
124
125 const intptr_t kNumLibs = 4;
126 const LibraryIntrinsicsDesc intrinsics[kNumLibs] = {
133 };
134
135 for (intptr_t i = 0; i < kNumLibs; i++) {
136 lib = intrinsics[i].library.ptr();
137 for (const IntrinsicDesc* intrinsic = intrinsics[i].intrinsics;
138 intrinsic->class_name != nullptr; intrinsic++) {
139 func = Function::null();
140 if (strcmp(intrinsic->class_name, "::") == 0) {
141 str = String::New(intrinsic->function_name);
142 func = lib.LookupFunctionAllowPrivate(str);
143 } else {
144 str = String::New(intrinsic->class_name);
145 cls = lib.LookupClassAllowPrivate(str);
146 ASSERT(FLAG_precompiled_mode || !cls.IsNull());
147 if (!cls.IsNull()) {
148 error = cls.EnsureIsFinalized(thread);
149 if (!error.IsNull()) {
150 OS::PrintErr("%s\n", error.ToErrorCString());
151 }
152 ASSERT(error.IsNull());
153 str = String::New(intrinsic->function_name);
154 if (intrinsic->function_name[0] == '.') {
155 str2 = String::New(intrinsic->class_name);
156 str = String::Concat(str2, str);
157 }
158 func = cls.LookupFunctionAllowPrivate(str);
159 }
160 }
161 if (!func.IsNull()) {
162 func.set_is_intrinsic(true);
163 } else if (!FLAG_precompiled_mode) {
164 FATAL("Intrinsifier failed to find method %s in class %s\n",
165 intrinsic->function_name, intrinsic->class_name);
166 }
167 }
168 }
169#undef SETUP_FUNCTION
170}
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
static LibraryPtr InternalLibrary()
Definition: object.cc:14803
static LibraryPtr DeveloperLibrary()
Definition: object.cc:14795
static LibraryPtr TypedDataLibrary()
Definition: object.cc:14825
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static ObjectPtr null()
Definition: object.h:433
static Object & Handle()
Definition: object.h:407
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition: object.cc:24037
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)
#define FATAL(error)
const uint8_t uint32_t uint32_t GError ** error
static const IntrinsicDesc developer_intrinsics[]
static const IntrinsicDesc core_intrinsics[]
Definition: intrinsifier.cc:92
static const IntrinsicDesc internal_intrinsics[]
static const IntrinsicDesc typed_data_intrinsics[]
Definition: intrinsifier.cc:99

◆ Intrinsify()

bool dart::compiler::Intrinsifier::Intrinsify ( const ParsedFunction parsed_function,
FlowGraphCompiler compiler 
)
static

Definition at line 173 of file intrinsifier.cc.

174 {
175 if (!CanIntrinsify(parsed_function)) {
176 return false;
177 }
178
179 if (GraphIntrinsifier::GraphIntrinsify(parsed_function, compiler)) {
180 return compiler->intrinsic_slow_path_label()->IsUnused();
181 }
182
183 const Function& function = parsed_function.function();
184#if !defined(HASH_IN_OBJECT_HEADER)
185 // These two are more complicated on 32 bit platforms, where the
186 // identity hash is not stored in the header of the object. We
187 // therefore don't intrinsify them, falling back on the native C++
188 // implementations.
189 if (function.recognized_kind() == MethodRecognizer::kObject_getHash) {
190 return false;
191 }
192#endif
193
194#if !defined(PRODUCT)
195#define EMIT_BREAKPOINT() compiler->assembler()->Breakpoint()
196#else
197#define EMIT_BREAKPOINT()
198#endif
199
200#define EMIT_CASE(class_name, function_name, enum_name, fp) \
201 case MethodRecognizer::k##enum_name: { \
202 compiler->assembler()->Comment("Intrinsic"); \
203 Label normal_ir_body; \
204 const auto size_before = compiler->assembler()->CodeSize(); \
205 AsmIntrinsifier::enum_name(compiler->assembler(), &normal_ir_body); \
206 const auto size_after = compiler->assembler()->CodeSize(); \
207 if (size_before == size_after) return false; \
208 if (function.HasUnboxedParameters()) { \
209 FATAL("Unsupported unboxed parameters in asm intrinsic %s", \
210 function.ToFullyQualifiedCString()); \
211 } \
212 if (function.HasUnboxedReturnValue()) { \
213 FATAL("Unsupported unboxed return value in asm intrinsic %s", \
214 function.ToFullyQualifiedCString()); \
215 } \
216 if (!normal_ir_body.IsBound()) { \
217 EMIT_BREAKPOINT(); \
218 return true; \
219 } \
220 return false; \
221 }
222
223 switch (function.recognized_kind()) {
225 default:
226 break;
227 }
228 switch (function.recognized_kind()) {
230 default:
231 break;
232 }
233
234#undef EMIT_BREAKPOINT
235
236#undef EMIT_INTRINSIC
237 return false;
238}
static bool GraphIntrinsify(const ParsedFunction &parsed_function, FlowGraphCompiler *compiler)
Dart_NativeFunction function
Definition: fuchsia.cc:51
#define EMIT_CASE(class_name, function_name, enum_name, fp)
#define CORE_INTEGER_LIB_INTRINSIC_LIST(V)
#define ALL_INTRINSICS_NO_INTEGER_LIB_LIST(V)

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