Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
async.cc
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
6#include "vm/debugger.h"
7#include "vm/exceptions.h"
8#include "vm/native_entry.h"
9#include "vm/object_store.h"
10#include "vm/runtime_entry.h"
11
12namespace dart {
13
14DEFINE_NATIVE_ENTRY(AsyncStarMoveNext_debuggerStepCheck, 0, 1) {
15#if !defined(PRODUCT)
16 GET_NON_NULL_NATIVE_ARGUMENT(Closure, generator, arguments->NativeArgAt(0));
17 Debugger* debugger = isolate->debugger();
18 if (debugger != nullptr && debugger->IsSingleStepping()) {
19 debugger->AsyncStepInto(generator);
20 }
21#endif
22 return Object::null();
23}
24
25// Instantiate generic [closure] using the type argument T
26// corresponding to Future<T> in the given [future] instance
27// (which may extend or implement Future).
28DEFINE_NATIVE_ENTRY(SuspendState_instantiateClosureWithFutureTypeArgument,
29 0,
30 2) {
31 GET_NON_NULL_NATIVE_ARGUMENT(Closure, closure, arguments->NativeArgAt(0));
32 GET_NON_NULL_NATIVE_ARGUMENT(Instance, future, arguments->NativeArgAt(1));
33 IsolateGroup* isolate_group = thread->isolate_group();
34
35 const auto& future_class =
36 Class::Handle(zone, isolate_group->object_store()->future_class());
37 ASSERT(future_class.NumTypeArguments() == 1);
38
39 const auto& cls = Class::Handle(zone, future.clazz());
40 auto& type = Type::Handle(zone, cls.GetInstantiationOf(zone, future_class));
41 ASSERT(!type.IsNull());
42 if (!type.IsInstantiated()) {
43 const auto& instance_type_args =
44 TypeArguments::Handle(zone, future.GetTypeArguments());
45 type ^=
46 type.InstantiateFrom(instance_type_args, Object::null_type_arguments(),
48 }
49 auto& type_args = TypeArguments::Handle(zone, type.arguments());
50 ASSERT(type_args.IsNull() || type_args.Length() == 1);
51 type_args = type_args.Canonicalize(thread);
52
53 ASSERT(closure.delayed_type_arguments() ==
54 Object::empty_type_arguments().ptr());
55 closure.set_delayed_type_arguments(type_args);
56 return closure.ptr();
57}
58
59} // namespace dart
void AsyncStepInto(const Closure &awaiter)
Definition debugger.cc:4142
bool IsSingleStepping() const
Definition debugger.h:712
@ kOld
Definition heap.h:39
ObjectStore * object_store() const
Definition isolate.h:505
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
#define ASSERT(E)
@ kNoneFree
Definition object.h:2906
#define DEFINE_NATIVE_ENTRY(name, type_argument_count, argument_count)
#define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value)