execution.h 3.01 KB
Newer Older
1 2 3
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_EXECUTION_EXECUTION_H_
#define V8_EXECUTION_EXECUTION_H_
7

8
#include "src/common/globals.h"
9

10 11
namespace v8 {
namespace internal {
12

13 14
class MicrotaskQueue;

marja's avatar
marja committed
15 16 17
template <typename T>
class Handle;

18
class Execution final : public AllStatic {
19
 public:
20 21
  // Whether to report pending messages, or keep them pending on the isolate.
  enum class MessageHandling { kReport, kKeepPending };
22
  enum class Target { kCallable, kRunMicrotasks };
23

24
  // Call a function, the caller supplies a receiver and an array
25
  // of arguments.
26
  //
27 28
  // When the function called is not in strict mode, receiver is
  // converted to an object.
29
  //
30
  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Call(
31 32
      Isolate* isolate, Handle<Object> callable, Handle<Object> receiver,
      int argc, Handle<Object> argv[]);
33

34 35 36 37
  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> CallBuiltin(
      Isolate* isolate, Handle<JSFunction> builtin, Handle<Object> receiver,
      int argc, Handle<Object> argv[]);

38
  // Construct object from function, the caller supplies an array of
39
  // arguments.
40 41 42 43 44 45
  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> New(
      Isolate* isolate, Handle<Object> constructor, int argc,
      Handle<Object> argv[]);
  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> New(
      Isolate* isolate, Handle<Object> constructor, Handle<Object> new_target,
      int argc, Handle<Object> argv[]);
46

47 48 49 50 51 52 53
  // Call a function, just like Call(), but handle don't report exceptions
  // externally.
  // The return value is either the result of calling the function (if no
  // exception occurred), or an empty handle.
  // If message_handling is MessageHandling::kReport, exceptions (except for
  // termination exceptions) will be stored in exception_out (if not a
  // nullptr).
54 55 56 57
  V8_EXPORT_PRIVATE static MaybeHandle<Object> TryCall(
      Isolate* isolate, Handle<Object> callable, Handle<Object> receiver,
      int argc, Handle<Object> argv[], MessageHandling message_handling,
      MaybeHandle<Object>* exception_out);
58
  // Convenience method for performing RunMicrotasks
59 60 61
  static MaybeHandle<Object> TryRunMicrotasks(
      Isolate* isolate, MicrotaskQueue* microtask_queue,
      MaybeHandle<Object>* exception_out);
62 63 64 65 66 67 68 69 70 71

  // Call a Wasm function identified by {wasm_call_target} through the
  // provided {wrapper_code}, which must match the function's signature.
  // Upon return, either isolate->has_pending_exception() is true, or
  // the function's return values are in {packed_args}.
  V8_EXPORT_PRIVATE static void CallWasm(Isolate* isolate,
                                         Handle<Code> wrapper_code,
                                         Address wasm_call_target,
                                         Handle<Object> object_ref,
                                         Address packed_args);
72 73
};

74 75
}  // namespace internal
}  // namespace v8
76

77
#endif  // V8_EXECUTION_EXECUTION_H_