enterInterpreted static method

Object? enterInterpreted(
  1. InterpreterVisitor visitor,
  2. Callable callable,
  3. List<Object?> args, [
  4. Map<String, Object?> namedArgs = const {},
  5. D4rtEntryKind kind = D4rtEntryKind.callback,
  6. String? name,
])

Calls the interpreted callable from native code as one entry of the execution visitor runs for (GitHub #19, per-execution hooks).

Without hooks this is callable.call(visitor, args, namedArgs). With hooks the entry passes onEntry (and, unless interpreted code of the run is on the stack, onNativeEntry), is refused after revoke() unless it runs on behalf of work accepted before, is counted while pending, and an accepted native entry runs in a child Zone of the run carrying it (D4rtEntry.current). The result is returned as the callable gave it (not unwrapped; callInterpreterCallback unwraps).

Generated proxies call this with kind D4rtEntryKind.proxyMethod and name Class.member; callInterpreterCallback calls it for every interpreted callback. Inlined, so without hooks a call site pays one field read and a type test (ยง14 of the specification).

Implementation

@pragma('vm:prefer-inline')
static Object? enterInterpreted(
  InterpreterVisitor visitor,
  Callable callable,
  List<Object?> args, [
  Map<String, Object?> namedArgs = const {},
  D4rtEntryKind kind = D4rtEntryKind.callback,
  String? name,
]) {
  final run = visitor.executionContext;
  if (run is! ExecutionRun) return callable.call(visitor, args, namedArgs);
  return run.enter(
    kind,
    name ?? _entryName(callable),
    visitor.callStack.depth > 0,
    () => callable.call(visitor, args, namedArgs),
  );
}