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

#include <dart_entry.h>

Inheritance diagram for dart::DartEntry:
dart::AllStatic

Static Public Member Functions

static ObjectPtr InvokeFunction (const Function &function, const Array &arguments)
 
static ObjectPtr InvokeFunction (const Function &function, const Array &arguments, const Array &arguments_descriptor)
 
static ObjectPtr InvokeClosure (Thread *thread, const Array &arguments)
 
static ObjectPtr InvokeClosure (Thread *thread, const Array &arguments, const Array &arguments_descriptor)
 
static ObjectPtr InvokeNoSuchMethod (Thread *thread, const Instance &receiver, const String &target_name, const Array &arguments, const Array &arguments_descriptor)
 

Detailed Description

Definition at line 189 of file dart_entry.h.

Member Function Documentation

◆ InvokeClosure() [1/2]

ObjectPtr dart::DartEntry::InvokeClosure ( Thread thread,
const Array arguments 
)
static

Definition at line 282 of file dart_entry.cc.

282 {
283 auto const zone = thread->zone();
284 const int kTypeArgsLen = 0; // No support to pass type args to generic func.
285
286 // Closures always have boxed parameters
287 const Array& arguments_descriptor = Array::Handle(
288 zone, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, arguments.Length()));
289 return InvokeClosure(thread, arguments, arguments_descriptor);
290}
static ArrayPtr NewBoxed(intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
Definition: dart_entry.h:83
static ObjectPtr InvokeClosure(Thread *thread, const Array &arguments)
Definition: dart_entry.cc:282
static Object & Handle()
Definition: object.h:407

◆ InvokeClosure() [2/2]

ObjectPtr dart::DartEntry::InvokeClosure ( Thread thread,
const Array arguments,
const Array arguments_descriptor 
)
static

Definition at line 292 of file dart_entry.cc.

294 {
295 auto const zone = thread->zone();
296 const Object& resolved_result = Object::Handle(
297 zone, ResolveCallable(thread, arguments, arguments_descriptor));
298 if (resolved_result.IsError()) {
299 return resolved_result.ptr();
300 }
301
302 const auto& function =
303 Function::Handle(zone, Function::RawCast(resolved_result.ptr()));
304 return InvokeCallable(thread, function, arguments, arguments_descriptor);
305}
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
Dart_NativeFunction function
Definition: fuchsia.cc:51

◆ InvokeFunction() [1/2]

ObjectPtr dart::DartEntry::InvokeFunction ( const Function function,
const Array arguments 
)
static

Definition at line 31 of file dart_entry.cc.

32 {
33 ASSERT(Thread::Current()->IsDartMutatorThread());
34 const int kTypeArgsLen = 0; // No support to pass type args to generic func.
35 const Array& arguments_descriptor = Array::Handle(
36 ArgumentsDescriptor::NewBoxed(kTypeArgsLen, arguments.Length()));
37 return InvokeFunction(function, arguments, arguments_descriptor);
38}
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
Definition: dart_entry.cc:31
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)

◆ InvokeFunction() [2/2]

ObjectPtr dart::DartEntry::InvokeFunction ( const Function function,
const Array arguments,
const Array arguments_descriptor 
)
static

Definition at line 85 of file dart_entry.cc.

87 {
88#if defined(DART_PRECOMPILER)
89 if (FLAG_precompiled_mode) {
90 FATAL("Should never invoke Dart code during AOT compilation");
91 }
92#endif
93
94 Thread* thread = Thread::Current();
95 ASSERT(thread->IsDartMutatorThread());
96 ASSERT(!function.IsNull());
97
98#if !defined(DART_PRECOMPILED_RUNTIME)
99 if (!function.HasCode()) {
100 const Object& result = Object::Handle(
101 thread->zone(), Compiler::CompileFunction(thread, function));
102 if (result.IsError()) {
103 return Error::Cast(result).ptr();
104 }
105 }
106#endif // defined(DART_PRECOMPILED_RUNTIME)
107
108 ASSERT(function.HasCode());
109
110 DartEntryScope dart_entry_scope(thread);
111
112 const uword stub = StubCode::InvokeDartCode().EntryPoint();
113#if defined(USING_SIMULATOR)
114 return bit_copy<ObjectPtr, int64_t>(Simulator::Current()->Call(
115 static_cast<intptr_t>(stub),
116#if defined(DART_PRECOMPILED_RUNTIME)
117 static_cast<intptr_t>(function.entry_point()),
118#else
119 static_cast<intptr_t>(function.CurrentCode()),
120#endif
121 static_cast<intptr_t>(arguments_descriptor.ptr()),
122 static_cast<intptr_t>(arguments.ptr()),
123 reinterpret_cast<intptr_t>(thread)));
124#else // USING_SIMULATOR
125 return static_cast<ObjectPtr>((reinterpret_cast<invokestub>(stub))(
126#if defined(DART_PRECOMPILED_RUNTIME)
127 function.entry_point(),
128#else
129 static_cast<uword>(function.CurrentCode()),
130#endif
131 static_cast<uword>(arguments_descriptor.ptr()),
132 static_cast<uword>(arguments.ptr()), thread));
133#endif
134}
static ObjectPtr CompileFunction(Thread *thread, const Function &function)
Definition: compiler.cc:824
static Simulator * Current()
#define FATAL(error)
GAsyncResult * result
uintptr_t uword
Definition: globals.h:501
uword(* invokestub)(uword target_code, uword arguments_descriptor, uword arguments, Thread *thread)
Definition: dart_entry.cc:75

◆ InvokeNoSuchMethod()

ObjectPtr dart::DartEntry::InvokeNoSuchMethod ( Thread thread,
const Instance receiver,
const String target_name,
const Array arguments,
const Array arguments_descriptor 
)
static

Definition at line 307 of file dart_entry.cc.

311 {
312 auto const zone = thread->zone();
313 const ArgumentsDescriptor args_desc(arguments_descriptor);
314 ASSERT(
315 CompressedInstancePtr(receiver.ptr()).Decompress(thread->heap_base()) ==
316 arguments.At(args_desc.FirstArgIndex()));
317 // Allocate an Invocation object.
318 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
319
320 Class& invocation_mirror_class = Class::Handle(
321 zone, core_lib.LookupClass(String::Handle(
322 zone, core_lib.PrivateName(Symbols::InvocationMirror()))));
323 ASSERT(!invocation_mirror_class.IsNull());
324 const auto& error = invocation_mirror_class.EnsureIsFinalized(thread);
326 const String& function_name = String::Handle(
327 zone, core_lib.PrivateName(Symbols::AllocateInvocationMirror()));
328 const Function& allocation_function = Function::Handle(
329 zone, invocation_mirror_class.LookupStaticFunction(function_name));
330 ASSERT(!allocation_function.IsNull());
331 const int kNumAllocationArgs = 4;
332 const Array& allocation_args =
333 Array::Handle(zone, Array::New(kNumAllocationArgs));
334 allocation_args.SetAt(0, target_name);
335 allocation_args.SetAt(1, arguments_descriptor);
336 allocation_args.SetAt(2, arguments);
337 allocation_args.SetAt(3, Bool::False()); // Not a super invocation.
338 const Object& invocation_mirror = Object::Handle(
339 zone, InvokeFunction(allocation_function, allocation_args));
340 if (invocation_mirror.IsError()) {
341 Exceptions::PropagateError(Error::Cast(invocation_mirror));
342 UNREACHABLE();
343 }
344
345 // Now use the invocation mirror object and invoke NoSuchMethod.
346 const int kNumArguments = 2;
347 const Function& function = Function::Handle(
348 zone,
349 core_lib.LookupFunctionAllowPrivate(Symbols::_objectNoSuchMethod()));
350 ASSERT(!function.IsNull());
351 const Array& args = Array::Handle(zone, Array::New(kNumArguments));
352 args.SetAt(0, receiver);
353 args.SetAt(1, invocation_mirror);
355}
#define UNREACHABLE()
Definition: assert.h:248
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
static const Bool & False()
Definition: object.h:10799
static DART_NORETURN void PropagateError(const Error &error)
Definition: exceptions.cc:1003
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
static ObjectPtr null()
Definition: object.h:433
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
const char *const function_name

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