libv8-node 16.10.0.0-x86_64-linux → 18.8.0.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/paths.rb +5 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/include/cppgc/allocation.h +100 -22
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +114 -33
- data/vendor/v8/include/cppgc/default-platform.h +2 -10
- data/vendor/v8/include/cppgc/explicit-management.h +22 -4
- data/vendor/v8/include/cppgc/garbage-collected.h +15 -26
- data/vendor/v8/include/cppgc/heap-consistency.h +30 -0
- data/vendor/v8/include/cppgc/heap-state.h +12 -0
- data/vendor/v8/include/cppgc/heap.h +7 -2
- data/vendor/v8/include/cppgc/internal/api-constants.h +8 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +25 -14
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +73 -29
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +26 -15
- data/vendor/v8/include/cppgc/internal/write-barrier.h +62 -23
- data/vendor/v8/include/cppgc/liveness-broker.h +4 -1
- data/vendor/v8/include/cppgc/member.h +7 -2
- data/vendor/v8/include/cppgc/persistent.h +38 -33
- data/vendor/v8/include/cppgc/platform.h +4 -1
- data/vendor/v8/include/cppgc/prefinalizer.h +35 -12
- data/vendor/v8/include/cppgc/testing.h +9 -2
- data/vendor/v8/include/cppgc/type-traits.h +6 -13
- data/vendor/v8/include/cppgc/visitor.h +9 -7
- data/vendor/v8/include/libplatform/libplatform.h +0 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
- data/vendor/v8/include/v8-array-buffer.h +445 -0
- data/vendor/v8/include/v8-callbacks.h +397 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +407 -0
- data/vendor/v8/include/v8-cppgc.h +21 -128
- data/vendor/v8/include/v8-data.h +80 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +168 -0
- data/vendor/v8/include/v8-embedder-heap.h +218 -0
- data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
- data/vendor/v8/include/v8-exception.h +217 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +172 -24
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +125 -0
- data/vendor/v8/include/v8-initialization.h +315 -0
- data/vendor/v8/include/v8-inspector.h +56 -28
- data/vendor/v8/include/v8-internal.h +217 -55
- data/vendor/v8/include/v8-isolate.h +1709 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +455 -0
- data/vendor/v8/include/v8-locker.h +149 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +216 -0
- data/vendor/v8/include/v8-metrics.h +69 -16
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +775 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +400 -17
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +866 -0
- data/vendor/v8/include/v8-profiler.h +88 -13
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +747 -0
- data/vendor/v8/include/v8-snapshot.h +196 -0
- data/vendor/v8/include/v8-statistics.h +217 -0
- data/vendor/v8/include/v8-template.h +1079 -0
- data/vendor/v8/include/v8-traced-handle.h +420 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +4 -3
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +7 -1
- data/vendor/v8/include/v8-value-serializer-version.h +1 -1
- data/vendor/v8/include/v8-value-serializer.h +279 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +257 -0
- data/vendor/v8/include/v8-weak-callback-info.h +87 -0
- data/vendor/v8/include/v8.h +41 -12601
- data/vendor/v8/include/v8config.h +102 -12
- data/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a +0 -0
- metadata +47 -5
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
@@ -0,0 +1,137 @@
|
|
1
|
+
// Copyright 2021 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 INCLUDE_V8_MAYBE_H_
|
6
|
+
#define INCLUDE_V8_MAYBE_H_
|
7
|
+
|
8
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace v8 {
|
12
|
+
|
13
|
+
namespace api_internal {
|
14
|
+
// Called when ToChecked is called on an empty Maybe.
|
15
|
+
V8_EXPORT void FromJustIsNothing();
|
16
|
+
} // namespace api_internal
|
17
|
+
|
18
|
+
/**
|
19
|
+
* A simple Maybe type, representing an object which may or may not have a
|
20
|
+
* value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
|
21
|
+
*
|
22
|
+
* If an API method returns a Maybe<>, the API method can potentially fail
|
23
|
+
* either because an exception is thrown, or because an exception is pending,
|
24
|
+
* e.g. because a previous API call threw an exception that hasn't been caught
|
25
|
+
* yet, or because a TerminateExecution exception was thrown. In that case, a
|
26
|
+
* "Nothing" value is returned.
|
27
|
+
*/
|
28
|
+
template <class T>
|
29
|
+
class Maybe {
|
30
|
+
public:
|
31
|
+
V8_INLINE bool IsNothing() const { return !has_value_; }
|
32
|
+
V8_INLINE bool IsJust() const { return has_value_; }
|
33
|
+
|
34
|
+
/**
|
35
|
+
* An alias for |FromJust|. Will crash if the Maybe<> is nothing.
|
36
|
+
*/
|
37
|
+
V8_INLINE T ToChecked() const { return FromJust(); }
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Short-hand for ToChecked(), which doesn't return a value. To be used, where
|
41
|
+
* the actual value of the Maybe is not needed like Object::Set.
|
42
|
+
*/
|
43
|
+
V8_INLINE void Check() const {
|
44
|
+
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
49
|
+
* nothing (empty), |false| is returned and |out| is left untouched.
|
50
|
+
*/
|
51
|
+
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const {
|
52
|
+
if (V8_LIKELY(IsJust())) *out = value_;
|
53
|
+
return IsJust();
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
58
|
+
* nothing (empty), V8 will crash the process.
|
59
|
+
*/
|
60
|
+
V8_INLINE T FromJust() const {
|
61
|
+
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
62
|
+
return value_;
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Converts this Maybe<> to a value of type T, using a default value if this
|
67
|
+
* Maybe<> is nothing (empty).
|
68
|
+
*/
|
69
|
+
V8_INLINE T FromMaybe(const T& default_value) const {
|
70
|
+
return has_value_ ? value_ : default_value;
|
71
|
+
}
|
72
|
+
|
73
|
+
V8_INLINE bool operator==(const Maybe& other) const {
|
74
|
+
return (IsJust() == other.IsJust()) &&
|
75
|
+
(!IsJust() || FromJust() == other.FromJust());
|
76
|
+
}
|
77
|
+
|
78
|
+
V8_INLINE bool operator!=(const Maybe& other) const {
|
79
|
+
return !operator==(other);
|
80
|
+
}
|
81
|
+
|
82
|
+
private:
|
83
|
+
Maybe() : has_value_(false) {}
|
84
|
+
explicit Maybe(const T& t) : has_value_(true), value_(t) {}
|
85
|
+
|
86
|
+
bool has_value_;
|
87
|
+
T value_;
|
88
|
+
|
89
|
+
template <class U>
|
90
|
+
friend Maybe<U> Nothing();
|
91
|
+
template <class U>
|
92
|
+
friend Maybe<U> Just(const U& u);
|
93
|
+
};
|
94
|
+
|
95
|
+
template <class T>
|
96
|
+
inline Maybe<T> Nothing() {
|
97
|
+
return Maybe<T>();
|
98
|
+
}
|
99
|
+
|
100
|
+
template <class T>
|
101
|
+
inline Maybe<T> Just(const T& t) {
|
102
|
+
return Maybe<T>(t);
|
103
|
+
}
|
104
|
+
|
105
|
+
// A template specialization of Maybe<T> for the case of T = void.
|
106
|
+
template <>
|
107
|
+
class Maybe<void> {
|
108
|
+
public:
|
109
|
+
V8_INLINE bool IsNothing() const { return !is_valid_; }
|
110
|
+
V8_INLINE bool IsJust() const { return is_valid_; }
|
111
|
+
|
112
|
+
V8_INLINE bool operator==(const Maybe& other) const {
|
113
|
+
return IsJust() == other.IsJust();
|
114
|
+
}
|
115
|
+
|
116
|
+
V8_INLINE bool operator!=(const Maybe& other) const {
|
117
|
+
return !operator==(other);
|
118
|
+
}
|
119
|
+
|
120
|
+
private:
|
121
|
+
struct JustTag {};
|
122
|
+
|
123
|
+
Maybe() : is_valid_(false) {}
|
124
|
+
explicit Maybe(JustTag) : is_valid_(true) {}
|
125
|
+
|
126
|
+
bool is_valid_;
|
127
|
+
|
128
|
+
template <class U>
|
129
|
+
friend Maybe<U> Nothing();
|
130
|
+
friend Maybe<void> JustVoid();
|
131
|
+
};
|
132
|
+
|
133
|
+
inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); }
|
134
|
+
|
135
|
+
} // namespace v8
|
136
|
+
|
137
|
+
#endif // INCLUDE_V8_MAYBE_H_
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// Copyright 2021 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 INCLUDE_V8_MEMORY_SPAN_H_
|
6
|
+
#define INCLUDE_V8_MEMORY_SPAN_H_
|
7
|
+
|
8
|
+
#include <stddef.h>
|
9
|
+
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Points to an unowned continous buffer holding a known number of elements.
|
16
|
+
*
|
17
|
+
* This is similar to std::span (under consideration for C++20), but does not
|
18
|
+
* require advanced C++ support. In the (far) future, this may be replaced with
|
19
|
+
* or aliased to std::span.
|
20
|
+
*
|
21
|
+
* To facilitate future migration, this class exposes a subset of the interface
|
22
|
+
* implemented by std::span.
|
23
|
+
*/
|
24
|
+
template <typename T>
|
25
|
+
class V8_EXPORT MemorySpan {
|
26
|
+
public:
|
27
|
+
/** The default constructor creates an empty span. */
|
28
|
+
constexpr MemorySpan() = default;
|
29
|
+
|
30
|
+
constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
|
31
|
+
|
32
|
+
/** Returns a pointer to the beginning of the buffer. */
|
33
|
+
constexpr T* data() const { return data_; }
|
34
|
+
/** Returns the number of elements that the buffer holds. */
|
35
|
+
constexpr size_t size() const { return size_; }
|
36
|
+
|
37
|
+
private:
|
38
|
+
T* data_ = nullptr;
|
39
|
+
size_t size_ = 0;
|
40
|
+
};
|
41
|
+
|
42
|
+
} // namespace v8
|
43
|
+
#endif // INCLUDE_V8_MEMORY_SPAN_H_
|
@@ -0,0 +1,216 @@
|
|
1
|
+
// Copyright 2021 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 INCLUDE_V8_MESSAGE_H_
|
6
|
+
#define INCLUDE_V8_MESSAGE_H_
|
7
|
+
|
8
|
+
#include <stdio.h>
|
9
|
+
|
10
|
+
#include <iosfwd>
|
11
|
+
|
12
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
13
|
+
#include "v8-maybe.h" // NOLINT(build/include_directory)
|
14
|
+
#include "v8-primitive.h" // NOLINT(build/include_directory)
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
16
|
+
|
17
|
+
namespace v8 {
|
18
|
+
|
19
|
+
class Integer;
|
20
|
+
class PrimitiveArray;
|
21
|
+
class StackTrace;
|
22
|
+
class String;
|
23
|
+
class Value;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The optional attributes of ScriptOrigin.
|
27
|
+
*/
|
28
|
+
class ScriptOriginOptions {
|
29
|
+
public:
|
30
|
+
V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
|
31
|
+
bool is_opaque = false, bool is_wasm = false,
|
32
|
+
bool is_module = false)
|
33
|
+
: flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
|
34
|
+
(is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
|
35
|
+
(is_module ? kIsModule : 0)) {}
|
36
|
+
V8_INLINE ScriptOriginOptions(int flags)
|
37
|
+
: flags_(flags &
|
38
|
+
(kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
|
39
|
+
|
40
|
+
bool IsSharedCrossOrigin() const {
|
41
|
+
return (flags_ & kIsSharedCrossOrigin) != 0;
|
42
|
+
}
|
43
|
+
bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
|
44
|
+
bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
|
45
|
+
bool IsModule() const { return (flags_ & kIsModule) != 0; }
|
46
|
+
|
47
|
+
int Flags() const { return flags_; }
|
48
|
+
|
49
|
+
private:
|
50
|
+
enum {
|
51
|
+
kIsSharedCrossOrigin = 1,
|
52
|
+
kIsOpaque = 1 << 1,
|
53
|
+
kIsWasm = 1 << 2,
|
54
|
+
kIsModule = 1 << 3
|
55
|
+
};
|
56
|
+
const int flags_;
|
57
|
+
};
|
58
|
+
|
59
|
+
/**
|
60
|
+
* The origin, within a file, of a script.
|
61
|
+
*/
|
62
|
+
class V8_EXPORT ScriptOrigin {
|
63
|
+
public:
|
64
|
+
V8_INLINE ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
|
65
|
+
int resource_line_offset = 0,
|
66
|
+
int resource_column_offset = 0,
|
67
|
+
bool resource_is_shared_cross_origin = false,
|
68
|
+
int script_id = -1,
|
69
|
+
Local<Value> source_map_url = Local<Value>(),
|
70
|
+
bool resource_is_opaque = false, bool is_wasm = false,
|
71
|
+
bool is_module = false,
|
72
|
+
Local<Data> host_defined_options = Local<Data>())
|
73
|
+
: isolate_(isolate),
|
74
|
+
resource_name_(resource_name),
|
75
|
+
resource_line_offset_(resource_line_offset),
|
76
|
+
resource_column_offset_(resource_column_offset),
|
77
|
+
options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm,
|
78
|
+
is_module),
|
79
|
+
script_id_(script_id),
|
80
|
+
source_map_url_(source_map_url),
|
81
|
+
host_defined_options_(host_defined_options) {
|
82
|
+
VerifyHostDefinedOptions();
|
83
|
+
}
|
84
|
+
|
85
|
+
V8_INLINE Local<Value> ResourceName() const;
|
86
|
+
V8_INLINE int LineOffset() const;
|
87
|
+
V8_INLINE int ColumnOffset() const;
|
88
|
+
V8_INLINE int ScriptId() const;
|
89
|
+
V8_INLINE Local<Value> SourceMapUrl() const;
|
90
|
+
V8_DEPRECATE_SOON("Use GetHostDefinedOptions")
|
91
|
+
Local<PrimitiveArray> HostDefinedOptions() const;
|
92
|
+
V8_INLINE Local<Data> GetHostDefinedOptions() const;
|
93
|
+
V8_INLINE ScriptOriginOptions Options() const { return options_; }
|
94
|
+
|
95
|
+
private:
|
96
|
+
void VerifyHostDefinedOptions() const;
|
97
|
+
Isolate* isolate_;
|
98
|
+
Local<Value> resource_name_;
|
99
|
+
int resource_line_offset_;
|
100
|
+
int resource_column_offset_;
|
101
|
+
ScriptOriginOptions options_;
|
102
|
+
int script_id_;
|
103
|
+
Local<Value> source_map_url_;
|
104
|
+
Local<Data> host_defined_options_;
|
105
|
+
};
|
106
|
+
|
107
|
+
/**
|
108
|
+
* An error message.
|
109
|
+
*/
|
110
|
+
class V8_EXPORT Message {
|
111
|
+
public:
|
112
|
+
Local<String> Get() const;
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Return the isolate to which the Message belongs.
|
116
|
+
*/
|
117
|
+
Isolate* GetIsolate() const;
|
118
|
+
|
119
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSource(
|
120
|
+
Local<Context> context) const;
|
121
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
|
122
|
+
Local<Context> context) const;
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Returns the origin for the script from where the function causing the
|
126
|
+
* error originates.
|
127
|
+
*/
|
128
|
+
ScriptOrigin GetScriptOrigin() const;
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Returns the resource name for the script from where the function causing
|
132
|
+
* the error originates.
|
133
|
+
*/
|
134
|
+
Local<Value> GetScriptResourceName() const;
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Exception stack trace. By default stack traces are not captured for
|
138
|
+
* uncaught exceptions. SetCaptureStackTraceForUncaughtExceptions allows
|
139
|
+
* to change this option.
|
140
|
+
*/
|
141
|
+
Local<StackTrace> GetStackTrace() const;
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Returns the number, 1-based, of the line where the error occurred.
|
145
|
+
*/
|
146
|
+
V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Returns the index within the script of the first character where
|
150
|
+
* the error occurred.
|
151
|
+
*/
|
152
|
+
int GetStartPosition() const;
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Returns the index within the script of the last character where
|
156
|
+
* the error occurred.
|
157
|
+
*/
|
158
|
+
int GetEndPosition() const;
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Returns the Wasm function index where the error occurred. Returns -1 if
|
162
|
+
* message is not from a Wasm script.
|
163
|
+
*/
|
164
|
+
int GetWasmFunctionIndex() const;
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Returns the error level of the message.
|
168
|
+
*/
|
169
|
+
int ErrorLevel() const;
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Returns the index within the line of the first character where
|
173
|
+
* the error occurred.
|
174
|
+
*/
|
175
|
+
int GetStartColumn() const;
|
176
|
+
V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Returns the index within the line of the last character where
|
180
|
+
* the error occurred.
|
181
|
+
*/
|
182
|
+
int GetEndColumn() const;
|
183
|
+
V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Passes on the value set by the embedder when it fed the script from which
|
187
|
+
* this Message was generated to V8.
|
188
|
+
*/
|
189
|
+
bool IsSharedCrossOrigin() const;
|
190
|
+
bool IsOpaque() const;
|
191
|
+
|
192
|
+
static void PrintCurrentStackTrace(Isolate* isolate, std::ostream& out);
|
193
|
+
|
194
|
+
static const int kNoLineNumberInfo = 0;
|
195
|
+
static const int kNoColumnInfo = 0;
|
196
|
+
static const int kNoScriptIdInfo = 0;
|
197
|
+
static const int kNoWasmFunctionIndexInfo = -1;
|
198
|
+
};
|
199
|
+
|
200
|
+
Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
|
201
|
+
|
202
|
+
Local<Data> ScriptOrigin::GetHostDefinedOptions() const {
|
203
|
+
return host_defined_options_;
|
204
|
+
}
|
205
|
+
|
206
|
+
int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
|
207
|
+
|
208
|
+
int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
|
209
|
+
|
210
|
+
int ScriptOrigin::ScriptId() const { return script_id_; }
|
211
|
+
|
212
|
+
Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
|
213
|
+
|
214
|
+
} // namespace v8
|
215
|
+
|
216
|
+
#endif // INCLUDE_V8_MESSAGE_H_
|
@@ -5,12 +5,23 @@
|
|
5
5
|
#ifndef V8_METRICS_H_
|
6
6
|
#define V8_METRICS_H_
|
7
7
|
|
8
|
-
#include
|
8
|
+
#include <stddef.h>
|
9
|
+
#include <stdint.h>
|
10
|
+
|
11
|
+
#include <vector>
|
12
|
+
|
13
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
14
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
15
|
|
10
16
|
namespace v8 {
|
17
|
+
|
18
|
+
class Context;
|
19
|
+
class Isolate;
|
20
|
+
|
11
21
|
namespace metrics {
|
12
22
|
|
13
23
|
struct GarbageCollectionPhases {
|
24
|
+
int64_t total_wall_clock_duration_in_us = -1;
|
14
25
|
int64_t compact_wall_clock_duration_in_us = -1;
|
15
26
|
int64_t mark_wall_clock_duration_in_us = -1;
|
16
27
|
int64_t sweep_wall_clock_duration_in_us = -1;
|
@@ -24,6 +35,7 @@ struct GarbageCollectionSizes {
|
|
24
35
|
};
|
25
36
|
|
26
37
|
struct GarbageCollectionFullCycle {
|
38
|
+
int reason = -1;
|
27
39
|
GarbageCollectionPhases total;
|
28
40
|
GarbageCollectionPhases total_cpp;
|
29
41
|
GarbageCollectionPhases main_thread;
|
@@ -36,12 +48,12 @@ struct GarbageCollectionFullCycle {
|
|
36
48
|
GarbageCollectionSizes objects_cpp;
|
37
49
|
GarbageCollectionSizes memory;
|
38
50
|
GarbageCollectionSizes memory_cpp;
|
39
|
-
double collection_rate_in_percent;
|
40
|
-
double collection_rate_cpp_in_percent;
|
41
|
-
double efficiency_in_bytes_per_us;
|
42
|
-
double efficiency_cpp_in_bytes_per_us;
|
43
|
-
double main_thread_efficiency_in_bytes_per_us;
|
44
|
-
double main_thread_efficiency_cpp_in_bytes_per_us;
|
51
|
+
double collection_rate_in_percent = -1.0;
|
52
|
+
double collection_rate_cpp_in_percent = -1.0;
|
53
|
+
double efficiency_in_bytes_per_us = -1.0;
|
54
|
+
double efficiency_cpp_in_bytes_per_us = -1.0;
|
55
|
+
double main_thread_efficiency_in_bytes_per_us = -1.0;
|
56
|
+
double main_thread_efficiency_cpp_in_bytes_per_us = -1.0;
|
45
57
|
};
|
46
58
|
|
47
59
|
struct GarbageCollectionFullMainThreadIncrementalMark {
|
@@ -49,25 +61,38 @@ struct GarbageCollectionFullMainThreadIncrementalMark {
|
|
49
61
|
int64_t cpp_wall_clock_duration_in_us = -1;
|
50
62
|
};
|
51
63
|
|
52
|
-
struct GarbageCollectionFullMainThreadBatchedIncrementalMark {
|
53
|
-
std::vector<GarbageCollectionFullMainThreadIncrementalMark> events;
|
54
|
-
};
|
55
|
-
|
56
64
|
struct GarbageCollectionFullMainThreadIncrementalSweep {
|
57
65
|
int64_t wall_clock_duration_in_us = -1;
|
58
66
|
int64_t cpp_wall_clock_duration_in_us = -1;
|
59
67
|
};
|
60
68
|
|
61
|
-
|
62
|
-
|
69
|
+
template <typename EventType>
|
70
|
+
struct GarbageCollectionBatchedEvents {
|
71
|
+
std::vector<EventType> events;
|
63
72
|
};
|
64
73
|
|
74
|
+
using GarbageCollectionFullMainThreadBatchedIncrementalMark =
|
75
|
+
GarbageCollectionBatchedEvents<
|
76
|
+
GarbageCollectionFullMainThreadIncrementalMark>;
|
77
|
+
using GarbageCollectionFullMainThreadBatchedIncrementalSweep =
|
78
|
+
GarbageCollectionBatchedEvents<
|
79
|
+
GarbageCollectionFullMainThreadIncrementalSweep>;
|
80
|
+
|
65
81
|
struct GarbageCollectionYoungCycle {
|
82
|
+
int reason = -1;
|
66
83
|
int64_t total_wall_clock_duration_in_us = -1;
|
67
84
|
int64_t main_thread_wall_clock_duration_in_us = -1;
|
68
|
-
double collection_rate_in_percent;
|
69
|
-
double efficiency_in_bytes_per_us;
|
70
|
-
double main_thread_efficiency_in_bytes_per_us;
|
85
|
+
double collection_rate_in_percent = -1.0;
|
86
|
+
double efficiency_in_bytes_per_us = -1.0;
|
87
|
+
double main_thread_efficiency_in_bytes_per_us = -1.0;
|
88
|
+
#if defined(CPPGC_YOUNG_GENERATION)
|
89
|
+
GarbageCollectionPhases total_cpp;
|
90
|
+
GarbageCollectionSizes objects_cpp;
|
91
|
+
GarbageCollectionSizes memory_cpp;
|
92
|
+
double collection_rate_cpp_in_percent = -1.0;
|
93
|
+
double efficiency_cpp_in_bytes_per_us = -1.0;
|
94
|
+
double main_thread_efficiency_cpp_in_bytes_per_us = -1.0;
|
95
|
+
#endif // defined(CPPGC_YOUNG_GENERATION)
|
71
96
|
};
|
72
97
|
|
73
98
|
struct WasmModuleDecoded {
|
@@ -196,6 +221,34 @@ class V8_EXPORT Recorder {
|
|
196
221
|
static ContextId GetContextId(Local<Context> context);
|
197
222
|
};
|
198
223
|
|
224
|
+
/**
|
225
|
+
* Experimental API intended for the LongTasks UKM (crbug.com/1173527).
|
226
|
+
* The Reset() method should be called at the start of a potential
|
227
|
+
* long task. The Get() method returns durations of V8 work that
|
228
|
+
* happened during the task.
|
229
|
+
*
|
230
|
+
* This API is experimental and may be removed/changed in the future.
|
231
|
+
*/
|
232
|
+
struct V8_EXPORT LongTaskStats {
|
233
|
+
/**
|
234
|
+
* Resets durations of V8 work for the new task.
|
235
|
+
*/
|
236
|
+
V8_INLINE static void Reset(Isolate* isolate) {
|
237
|
+
v8::internal::Internals::IncrementLongTasksStatsCounter(isolate);
|
238
|
+
}
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Returns durations of V8 work that happened since the last Reset().
|
242
|
+
*/
|
243
|
+
static LongTaskStats Get(Isolate* isolate);
|
244
|
+
|
245
|
+
int64_t gc_full_atomic_wall_clock_duration_us = 0;
|
246
|
+
int64_t gc_full_incremental_wall_clock_duration_us = 0;
|
247
|
+
int64_t gc_young_wall_clock_duration_us = 0;
|
248
|
+
// Only collected with --slow-histograms
|
249
|
+
int64_t v8_execute_us = 0;
|
250
|
+
};
|
251
|
+
|
199
252
|
} // namespace metrics
|
200
253
|
} // namespace v8
|
201
254
|
|
@@ -0,0 +1,152 @@
|
|
1
|
+
// Copyright 2021 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 INCLUDE_V8_MICROTASKS_QUEUE_H_
|
6
|
+
#define INCLUDE_V8_MICROTASKS_QUEUE_H_
|
7
|
+
|
8
|
+
#include <stddef.h>
|
9
|
+
|
10
|
+
#include <memory>
|
11
|
+
|
12
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
13
|
+
#include "v8-microtask.h" // NOLINT(build/include_directory)
|
14
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
15
|
+
|
16
|
+
namespace v8 {
|
17
|
+
|
18
|
+
class Function;
|
19
|
+
|
20
|
+
namespace internal {
|
21
|
+
class Isolate;
|
22
|
+
class MicrotaskQueue;
|
23
|
+
} // namespace internal
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Represents the microtask queue, where microtasks are stored and processed.
|
27
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#microtask-queue
|
28
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#enqueuejob(queuename,-job,-arguments)
|
29
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint
|
30
|
+
*
|
31
|
+
* A MicrotaskQueue instance may be associated to multiple Contexts by passing
|
32
|
+
* it to Context::New(), and they can be detached by Context::DetachGlobal().
|
33
|
+
* The embedder must keep the MicrotaskQueue instance alive until all associated
|
34
|
+
* Contexts are gone or detached.
|
35
|
+
*
|
36
|
+
* Use the same instance of MicrotaskQueue for all Contexts that may access each
|
37
|
+
* other synchronously. E.g. for Web embedding, use the same instance for all
|
38
|
+
* origins that share the same URL scheme and eTLD+1.
|
39
|
+
*/
|
40
|
+
class V8_EXPORT MicrotaskQueue {
|
41
|
+
public:
|
42
|
+
/**
|
43
|
+
* Creates an empty MicrotaskQueue instance.
|
44
|
+
*/
|
45
|
+
static std::unique_ptr<MicrotaskQueue> New(
|
46
|
+
Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto);
|
47
|
+
|
48
|
+
virtual ~MicrotaskQueue() = default;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Enqueues the callback to the queue.
|
52
|
+
*/
|
53
|
+
virtual void EnqueueMicrotask(Isolate* isolate,
|
54
|
+
Local<Function> microtask) = 0;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Enqueues the callback to the queue.
|
58
|
+
*/
|
59
|
+
virtual void EnqueueMicrotask(v8::Isolate* isolate,
|
60
|
+
MicrotaskCallback callback,
|
61
|
+
void* data = nullptr) = 0;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Adds a callback to notify the embedder after microtasks were run. The
|
65
|
+
* callback is triggered by explicit RunMicrotasks call or automatic
|
66
|
+
* microtasks execution (see Isolate::SetMicrotasksPolicy).
|
67
|
+
*
|
68
|
+
* Callback will trigger even if microtasks were attempted to run,
|
69
|
+
* but the microtasks queue was empty and no single microtask was actually
|
70
|
+
* executed.
|
71
|
+
*
|
72
|
+
* Executing scripts inside the callback will not re-trigger microtasks and
|
73
|
+
* the callback.
|
74
|
+
*/
|
75
|
+
virtual void AddMicrotasksCompletedCallback(
|
76
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Removes callback that was installed by AddMicrotasksCompletedCallback.
|
80
|
+
*/
|
81
|
+
virtual void RemoveMicrotasksCompletedCallback(
|
82
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Runs microtasks if no microtask is running on this MicrotaskQueue instance.
|
86
|
+
*/
|
87
|
+
virtual void PerformCheckpoint(Isolate* isolate) = 0;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Returns true if a microtask is running on this MicrotaskQueue instance.
|
91
|
+
*/
|
92
|
+
virtual bool IsRunningMicrotasks() const = 0;
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Returns the current depth of nested MicrotasksScope that has
|
96
|
+
* kRunMicrotasks.
|
97
|
+
*/
|
98
|
+
virtual int GetMicrotasksScopeDepth() const = 0;
|
99
|
+
|
100
|
+
MicrotaskQueue(const MicrotaskQueue&) = delete;
|
101
|
+
MicrotaskQueue& operator=(const MicrotaskQueue&) = delete;
|
102
|
+
|
103
|
+
private:
|
104
|
+
friend class internal::MicrotaskQueue;
|
105
|
+
MicrotaskQueue() = default;
|
106
|
+
};
|
107
|
+
|
108
|
+
/**
|
109
|
+
* This scope is used to control microtasks when MicrotasksPolicy::kScoped
|
110
|
+
* is used on Isolate. In this mode every non-primitive call to V8 should be
|
111
|
+
* done inside some MicrotasksScope.
|
112
|
+
* Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks
|
113
|
+
* exits.
|
114
|
+
* kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
|
115
|
+
* microtasks.
|
116
|
+
*/
|
117
|
+
class V8_EXPORT V8_NODISCARD MicrotasksScope {
|
118
|
+
public:
|
119
|
+
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
|
120
|
+
|
121
|
+
MicrotasksScope(Isolate* isolate, Type type);
|
122
|
+
MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
|
123
|
+
~MicrotasksScope();
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Runs microtasks if no kRunMicrotasks scope is currently active.
|
127
|
+
*/
|
128
|
+
static void PerformCheckpoint(Isolate* isolate);
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Returns current depth of nested kRunMicrotasks scopes.
|
132
|
+
*/
|
133
|
+
static int GetCurrentDepth(Isolate* isolate);
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Returns true while microtasks are being executed.
|
137
|
+
*/
|
138
|
+
static bool IsRunningMicrotasks(Isolate* isolate);
|
139
|
+
|
140
|
+
// Prevent copying.
|
141
|
+
MicrotasksScope(const MicrotasksScope&) = delete;
|
142
|
+
MicrotasksScope& operator=(const MicrotasksScope&) = delete;
|
143
|
+
|
144
|
+
private:
|
145
|
+
internal::Isolate* const isolate_;
|
146
|
+
internal::MicrotaskQueue* const microtask_queue_;
|
147
|
+
bool run_;
|
148
|
+
};
|
149
|
+
|
150
|
+
} // namespace v8
|
151
|
+
|
152
|
+
#endif // INCLUDE_V8_MICROTASKS_QUEUE_H_
|