• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_EXECUTION_EXECUTION_H_
6 #define V8_EXECUTION_EXECUTION_H_
7 
8 #include "src/common/globals.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 class MicrotaskQueue;
14 
15 template <typename T>
16 class Handle;
17 
18 class Execution final : public AllStatic {
19  public:
20   // Whether to report pending messages, or keep them pending on the isolate.
21   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   // When the function called is not in strict mode, receiver is
28   // converted to an object.
29   //
30   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Call(
31       Isolate* isolate, Handle<Object> callable, Handle<Object> receiver,
32       int argc, Handle<Object> argv[]);
33 
34   V8_WARN_UNUSED_RESULT static MaybeHandle<Object> CallBuiltin(
35       Isolate* isolate, Handle<JSFunction> builtin, Handle<Object> receiver,
36       int argc, Handle<Object> argv[]);
37 
38   // Construct object from function, the caller supplies an array of
39   // arguments.
40   V8_WARN_UNUSED_RESULT static MaybeHandle<Object> New(
41       Isolate* isolate, Handle<Object> constructor, int argc,
42       Handle<Object> argv[]);
43   V8_WARN_UNUSED_RESULT static MaybeHandle<Object> New(
44       Isolate* isolate, Handle<Object> constructor, Handle<Object> new_target,
45       int argc, Handle<Object> argv[]);
46 
47   // Call a function, just like Call(), but handle don't report exceptions
48   // externally.
49   // The return value is either the result of calling the function (if no
50   // exception occurred), or an empty handle.
51   // If message_handling is MessageHandling::kReport, exceptions (except for
52   // termination exceptions) will be stored in exception_out (if not a
53   // nullptr).
54   V8_EXPORT_PRIVATE static MaybeHandle<Object> TryCall(
55       Isolate* isolate, Handle<Object> callable, Handle<Object> receiver,
56       int argc, Handle<Object> argv[], MessageHandling message_handling,
57       MaybeHandle<Object>* exception_out, bool reschedule_terminate = true);
58   // Convenience method for performing RunMicrotasks
59   static MaybeHandle<Object> TryRunMicrotasks(
60       Isolate* isolate, MicrotaskQueue* microtask_queue,
61       MaybeHandle<Object>* exception_out);
62 
63   // Call a Wasm function identified by {wasm_call_target} through the
64   // provided {wrapper_code}, which must match the function's signature.
65   // Upon return, either isolate->has_pending_exception() is true, or
66   // the function's return values are in {packed_args}.
67   V8_EXPORT_PRIVATE static void CallWasm(Isolate* isolate,
68                                          Handle<Code> wrapper_code,
69                                          Address wasm_call_target,
70                                          Handle<Object> object_ref,
71                                          Address packed_args);
72 };
73 
74 }  // namespace internal
75 }  // namespace v8
76 
77 #endif  // V8_EXECUTION_EXECUTION_H_
78