libv8 6.3.292.48.1-universal-darwin-17 → 6.7.288.46.1beta0-universal-darwin-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/ext/libv8/paths.rb +5 -18
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/libplatform/libplatform.h +25 -12
- data/vendor/v8/include/libplatform/v8-tracing.h +13 -2
- data/vendor/v8/include/v8-inspector.h +22 -2
- data/vendor/v8/include/v8-platform.h +247 -12
- data/vendor/v8/include/v8-profiler.h +93 -7
- data/vendor/v8/include/v8-util.h +6 -11
- data/vendor/v8/include/v8-version-string.h +4 -3
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8.h +663 -692
- data/vendor/v8/include/v8config.h +7 -1
- data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
- data/vendor/v8/{out/x64.release/libv8_base.a → out.gn/libv8/obj/libv8_monolith.a} +0 -0
- metadata +8 -15
- data/ext/libv8/arch.rb +0 -20
- data/vendor/v8/include/v8-debug.h +0 -255
- data/vendor/v8/out/x64.release/libv8_init.a +0 -0
- data/vendor/v8/out/x64.release/libv8_initializers.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libbase.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libplatform.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libsampler.a +0 -0
- data/vendor/v8/out/x64.release/libv8_nosnapshot.a +0 -0
- data/vendor/v8/out/x64.release/libv8_snapshot.a +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cd14c5059c6e5410d3461c8c4bb2e161d8b4addd4242e1e6aa5856869b85121
|
4
|
+
data.tar.gz: 8fbe0b8671c69ec8e60c32a37c4a0777d5352073b27dae409d9c6a4ce84ccbbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730053482252b6085e917902d66149ee23229eca0907dea72754ffe7480561c2b4db33a6acddd1527594992cf647f0adcb373b54131eb3bc341cfce756c83e00
|
7
|
+
data.tar.gz: 97cbd00e3dfc695c04bb2710e7009e8a6164ca78dd4b306ef924b229a9fcdd0f792bea3d3ae63014d8cbbb7f0758ec6da95faadd797c77f2753a545e29fe1e60
|
data/ext/libv8/paths.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
require 'shellwords'
|
3
|
-
require File.expand_path '../arch', __FILE__
|
4
3
|
|
5
4
|
module Libv8
|
6
5
|
module Paths
|
@@ -11,29 +10,17 @@ module Libv8
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def object_paths
|
14
|
-
[
|
15
|
-
|
16
|
-
|
13
|
+
[Shellwords.escape(File.join(vendored_source_path,
|
14
|
+
'out.gn',
|
15
|
+
'libv8',
|
16
|
+
'obj',
|
17
|
+
"libv8_monolith.#{config['LIBEXT']}"))]
|
17
18
|
end
|
18
19
|
|
19
20
|
def config
|
20
21
|
RbConfig::MAKEFILE_CONFIG
|
21
22
|
end
|
22
23
|
|
23
|
-
def libv8_object(name)
|
24
|
-
filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
|
25
|
-
unless File.exist? filename
|
26
|
-
filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
|
27
|
-
end
|
28
|
-
return filename
|
29
|
-
end
|
30
|
-
|
31
|
-
def libv8_profile
|
32
|
-
base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}"
|
33
|
-
debug = "#{base}.debug"
|
34
|
-
File.exist?(debug) ? debug : "#{base}.release"
|
35
|
-
end
|
36
|
-
|
37
24
|
def vendored_source_path
|
38
25
|
File.expand_path "../../../vendor/v8", __FILE__
|
39
26
|
end
|
data/lib/libv8/version.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
#include "libplatform/libplatform-export.h"
|
9
9
|
#include "libplatform/v8-tracing.h"
|
10
10
|
#include "v8-platform.h" // NOLINT(build/include)
|
11
|
+
#include "v8config.h" // NOLINT(build/include)
|
11
12
|
|
12
13
|
namespace v8 {
|
13
14
|
namespace platform {
|
@@ -33,12 +34,21 @@ enum class MessageLoopBehavior : bool {
|
|
33
34
|
* If |tracing_controller| is nullptr, the default platform will create a
|
34
35
|
* v8::platform::TracingController instance and use it.
|
35
36
|
*/
|
36
|
-
V8_PLATFORM_EXPORT v8::Platform
|
37
|
+
V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
|
37
38
|
int thread_pool_size = 0,
|
38
39
|
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
|
39
40
|
InProcessStackDumping in_process_stack_dumping =
|
40
|
-
InProcessStackDumping::
|
41
|
-
v8::TracingController
|
41
|
+
InProcessStackDumping::kDisabled,
|
42
|
+
std::unique_ptr<v8::TracingController> tracing_controller = {});
|
43
|
+
|
44
|
+
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
|
45
|
+
"Use NewDefaultPlatform instead",
|
46
|
+
v8::Platform* CreateDefaultPlatform(
|
47
|
+
int thread_pool_size = 0,
|
48
|
+
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
|
49
|
+
InProcessStackDumping in_process_stack_dumping =
|
50
|
+
InProcessStackDumping::kDisabled,
|
51
|
+
v8::TracingController* tracing_controller = nullptr));
|
42
52
|
|
43
53
|
/**
|
44
54
|
* Pumps the message loop for the given isolate.
|
@@ -46,21 +56,23 @@ V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
|
|
46
56
|
* The caller has to make sure that this is called from the right thread.
|
47
57
|
* Returns true if a task was executed, and false otherwise. Unless requested
|
48
58
|
* through the |behavior| parameter, this call does not block if no task is
|
49
|
-
* pending. The |platform| has to be created using |
|
59
|
+
* pending. The |platform| has to be created using |NewDefaultPlatform|.
|
50
60
|
*/
|
51
61
|
V8_PLATFORM_EXPORT bool PumpMessageLoop(
|
52
62
|
v8::Platform* platform, v8::Isolate* isolate,
|
53
63
|
MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
|
54
64
|
|
55
|
-
V8_PLATFORM_EXPORT
|
56
|
-
|
65
|
+
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
|
66
|
+
"This function has become obsolete and is essentially a nop",
|
67
|
+
void EnsureEventLoopInitialized(v8::Platform* platform,
|
68
|
+
v8::Isolate* isolate));
|
57
69
|
|
58
70
|
/**
|
59
71
|
* Runs pending idle tasks for at most |idle_time_in_seconds| seconds.
|
60
72
|
*
|
61
73
|
* The caller has to make sure that this is called from the right thread.
|
62
74
|
* This call does not block if no task is pending. The |platform| has to be
|
63
|
-
* created using |
|
75
|
+
* created using |NewDefaultPlatform|.
|
64
76
|
*/
|
65
77
|
V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
|
66
78
|
v8::Isolate* isolate,
|
@@ -69,13 +81,14 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
|
|
69
81
|
/**
|
70
82
|
* Attempts to set the tracing controller for the given platform.
|
71
83
|
*
|
72
|
-
* The |platform| has to be created using |
|
84
|
+
* The |platform| has to be created using |NewDefaultPlatform|.
|
73
85
|
*
|
74
|
-
* DEPRECATED: Will be removed soon.
|
75
86
|
*/
|
76
|
-
V8_PLATFORM_EXPORT
|
77
|
-
|
78
|
-
|
87
|
+
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
|
88
|
+
"Access the DefaultPlatform directly",
|
89
|
+
void SetTracingController(
|
90
|
+
v8::Platform* platform,
|
91
|
+
v8::platform::tracing::TracingController* tracing_controller));
|
79
92
|
|
80
93
|
} // namespace platform
|
81
94
|
} // namespace v8
|
@@ -43,8 +43,8 @@ class V8_PLATFORM_EXPORT TraceObject {
|
|
43
43
|
const char** arg_names, const uint8_t* arg_types,
|
44
44
|
const uint64_t* arg_values,
|
45
45
|
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
|
46
|
-
unsigned int flags);
|
47
|
-
void UpdateDuration();
|
46
|
+
unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
|
47
|
+
void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
|
48
48
|
void InitializeForTesting(
|
49
49
|
char phase, const uint8_t* category_enabled_flag, const char* name,
|
50
50
|
const char* scope, uint64_t id, uint64_t bind_id, int num_args,
|
@@ -247,6 +247,13 @@ class V8_PLATFORM_EXPORT TracingController
|
|
247
247
|
const uint64_t* arg_values,
|
248
248
|
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
|
249
249
|
unsigned int flags) override;
|
250
|
+
uint64_t AddTraceEventWithTimestamp(
|
251
|
+
char phase, const uint8_t* category_enabled_flag, const char* name,
|
252
|
+
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
|
253
|
+
const char** arg_names, const uint8_t* arg_types,
|
254
|
+
const uint64_t* arg_values,
|
255
|
+
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
|
256
|
+
unsigned int flags, int64_t timestamp) override;
|
250
257
|
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
|
251
258
|
const char* name, uint64_t handle) override;
|
252
259
|
void AddTraceStateObserver(
|
@@ -259,6 +266,10 @@ class V8_PLATFORM_EXPORT TracingController
|
|
259
266
|
|
260
267
|
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
|
261
268
|
|
269
|
+
protected:
|
270
|
+
virtual int64_t CurrentTimestampMicroseconds();
|
271
|
+
virtual int64_t CurrentCpuTimestampMicroseconds();
|
272
|
+
|
262
273
|
private:
|
263
274
|
const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
|
264
275
|
void UpdateCategoryGroupEnabledFlag(size_t category_index);
|
@@ -149,8 +149,9 @@ class V8_EXPORT V8InspectorSession {
|
|
149
149
|
|
150
150
|
// Remote objects.
|
151
151
|
virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
|
152
|
-
v8::Local<v8::Context>, v8::Local<v8::Value>,
|
153
|
-
|
152
|
+
v8::Local<v8::Context>, v8::Local<v8::Value>, const StringView& groupName,
|
153
|
+
bool generatePreview) = 0;
|
154
|
+
|
154
155
|
virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
|
155
156
|
const StringView& objectId, v8::Local<v8::Value>*,
|
156
157
|
v8::Local<v8::Context>*,
|
@@ -215,6 +216,20 @@ class V8_EXPORT V8InspectorClient {
|
|
215
216
|
virtual void maxAsyncCallStackDepthChanged(int depth) {}
|
216
217
|
};
|
217
218
|
|
219
|
+
// These stack trace ids are intended to be passed between debuggers and be
|
220
|
+
// resolved later. This allows to track cross-debugger calls and step between
|
221
|
+
// them if a single client connects to multiple debuggers.
|
222
|
+
struct V8_EXPORT V8StackTraceId {
|
223
|
+
uintptr_t id;
|
224
|
+
std::pair<int64_t, int64_t> debugger_id;
|
225
|
+
|
226
|
+
V8StackTraceId();
|
227
|
+
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id);
|
228
|
+
~V8StackTraceId() = default;
|
229
|
+
|
230
|
+
bool IsInvalid() const;
|
231
|
+
};
|
232
|
+
|
218
233
|
class V8_EXPORT V8Inspector {
|
219
234
|
public:
|
220
235
|
static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
|
@@ -237,6 +252,11 @@ class V8_EXPORT V8Inspector {
|
|
237
252
|
virtual void asyncTaskFinished(void* task) = 0;
|
238
253
|
virtual void allAsyncTasksCanceled() = 0;
|
239
254
|
|
255
|
+
virtual V8StackTraceId storeCurrentStackTrace(
|
256
|
+
const StringView& description) = 0;
|
257
|
+
virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0;
|
258
|
+
virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0;
|
259
|
+
|
240
260
|
// Exceptions instrumentation.
|
241
261
|
virtual unsigned exceptionThrown(
|
242
262
|
v8::Local<v8::Context>, const StringView& message,
|
@@ -7,9 +7,12 @@
|
|
7
7
|
|
8
8
|
#include <stddef.h>
|
9
9
|
#include <stdint.h>
|
10
|
+
#include <stdlib.h> // For abort.
|
10
11
|
#include <memory>
|
11
12
|
#include <string>
|
12
13
|
|
14
|
+
#include "v8config.h" // NOLINT(build/include)
|
15
|
+
|
13
16
|
namespace v8 {
|
14
17
|
|
15
18
|
class Isolate;
|
@@ -36,6 +39,51 @@ class IdleTask {
|
|
36
39
|
virtual void Run(double deadline_in_seconds) = 0;
|
37
40
|
};
|
38
41
|
|
42
|
+
/**
|
43
|
+
* A TaskRunner allows scheduling of tasks. The TaskRunner may still be used to
|
44
|
+
* post tasks after the isolate gets destructed, but these tasks may not get
|
45
|
+
* executed anymore. All tasks posted to a given TaskRunner will be invoked in
|
46
|
+
* sequence. Tasks can be posted from any thread.
|
47
|
+
*/
|
48
|
+
class TaskRunner {
|
49
|
+
public:
|
50
|
+
/**
|
51
|
+
* Schedules a task to be invoked by this TaskRunner. The TaskRunner
|
52
|
+
* implementation takes ownership of |task|.
|
53
|
+
*/
|
54
|
+
virtual void PostTask(std::unique_ptr<Task> task) = 0;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Schedules a task to be invoked by this TaskRunner. The task is scheduled
|
58
|
+
* after the given number of seconds |delay_in_seconds|. The TaskRunner
|
59
|
+
* implementation takes ownership of |task|.
|
60
|
+
*/
|
61
|
+
virtual void PostDelayedTask(std::unique_ptr<Task> task,
|
62
|
+
double delay_in_seconds) = 0;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Schedules an idle task to be invoked by this TaskRunner. The task is
|
66
|
+
* scheduled when the embedder is idle. Requires that
|
67
|
+
* TaskRunner::SupportsIdleTasks(isolate) is true. Idle tasks may be reordered
|
68
|
+
* relative to other task types and may be starved for an arbitrarily long
|
69
|
+
* time if no idle time is available. The TaskRunner implementation takes
|
70
|
+
* ownership of |task|.
|
71
|
+
*/
|
72
|
+
virtual void PostIdleTask(std::unique_ptr<IdleTask> task) = 0;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Returns true if idle tasks are enabled for this TaskRunner.
|
76
|
+
*/
|
77
|
+
virtual bool IdleTasksEnabled() = 0;
|
78
|
+
|
79
|
+
TaskRunner() = default;
|
80
|
+
virtual ~TaskRunner() = default;
|
81
|
+
|
82
|
+
private:
|
83
|
+
TaskRunner(const TaskRunner&) = delete;
|
84
|
+
TaskRunner& operator=(const TaskRunner&) = delete;
|
85
|
+
};
|
86
|
+
|
39
87
|
/**
|
40
88
|
* The interface represents complex arguments to trace events.
|
41
89
|
*/
|
@@ -74,11 +122,11 @@ class TracingController {
|
|
74
122
|
}
|
75
123
|
|
76
124
|
/**
|
77
|
-
* Adds a trace event to the platform tracing system.
|
125
|
+
* Adds a trace event to the platform tracing system. These function calls are
|
78
126
|
* usually the result of a TRACE_* macro from trace_event_common.h when
|
79
127
|
* tracing and the category of the particular trace are enabled. It is not
|
80
|
-
* advisable to call
|
81
|
-
* used by the trace macros. The returned handle can be used by
|
128
|
+
* advisable to call these functions on their own; they are really only meant
|
129
|
+
* to be used by the trace macros. The returned handle can be used by
|
82
130
|
* UpdateTraceEventDuration to update the duration of COMPLETE events.
|
83
131
|
*/
|
84
132
|
virtual uint64_t AddTraceEvent(
|
@@ -90,6 +138,15 @@ class TracingController {
|
|
90
138
|
unsigned int flags) {
|
91
139
|
return 0;
|
92
140
|
}
|
141
|
+
virtual uint64_t AddTraceEventWithTimestamp(
|
142
|
+
char phase, const uint8_t* category_enabled_flag, const char* name,
|
143
|
+
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
|
144
|
+
const char** arg_names, const uint8_t* arg_types,
|
145
|
+
const uint64_t* arg_values,
|
146
|
+
std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
|
147
|
+
unsigned int flags, int64_t timestamp) {
|
148
|
+
return 0;
|
149
|
+
}
|
93
150
|
|
94
151
|
/**
|
95
152
|
* Sets the duration field of a COMPLETE trace event. It must be called with
|
@@ -112,6 +169,74 @@ class TracingController {
|
|
112
169
|
virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
|
113
170
|
};
|
114
171
|
|
172
|
+
/**
|
173
|
+
* A V8 memory page allocator.
|
174
|
+
*
|
175
|
+
* Can be implemented by an embedder to manage large host OS allocations.
|
176
|
+
*/
|
177
|
+
class PageAllocator {
|
178
|
+
public:
|
179
|
+
virtual ~PageAllocator() = default;
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Gets the page granularity for AllocatePages and FreePages. Addresses and
|
183
|
+
* lengths for those calls should be multiples of AllocatePageSize().
|
184
|
+
*/
|
185
|
+
virtual size_t AllocatePageSize() = 0;
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Gets the page granularity for SetPermissions and ReleasePages. Addresses
|
189
|
+
* and lengths for those calls should be multiples of CommitPageSize().
|
190
|
+
*/
|
191
|
+
virtual size_t CommitPageSize() = 0;
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Sets the random seed so that GetRandomMmapAddr() will generate repeatable
|
195
|
+
* sequences of random mmap addresses.
|
196
|
+
*/
|
197
|
+
virtual void SetRandomMmapSeed(int64_t seed) = 0;
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Returns a randomized address, suitable for memory allocation under ASLR.
|
201
|
+
* The address will be aligned to AllocatePageSize.
|
202
|
+
*/
|
203
|
+
virtual void* GetRandomMmapAddr() = 0;
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Memory permissions.
|
207
|
+
*/
|
208
|
+
enum Permission {
|
209
|
+
kNoAccess,
|
210
|
+
kReadWrite,
|
211
|
+
// TODO(hpayer): Remove this flag. Memory should never be rwx.
|
212
|
+
kReadWriteExecute,
|
213
|
+
kReadExecute
|
214
|
+
};
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Allocates memory in range with the given alignment and permission.
|
218
|
+
*/
|
219
|
+
virtual void* AllocatePages(void* address, size_t length, size_t alignment,
|
220
|
+
Permission permissions) = 0;
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Frees memory in a range that was allocated by a call to AllocatePages.
|
224
|
+
*/
|
225
|
+
virtual bool FreePages(void* address, size_t length) = 0;
|
226
|
+
|
227
|
+
/**
|
228
|
+
* Releases memory in a range that was allocated by a call to AllocatePages.
|
229
|
+
*/
|
230
|
+
virtual bool ReleasePages(void* address, size_t length,
|
231
|
+
size_t new_length) = 0;
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Sets permissions on pages in an allocated range.
|
235
|
+
*/
|
236
|
+
virtual bool SetPermissions(void* address, size_t length,
|
237
|
+
Permission permissions) = 0;
|
238
|
+
};
|
239
|
+
|
115
240
|
/**
|
116
241
|
* V8 Platform abstraction layer.
|
117
242
|
*
|
@@ -132,6 +257,14 @@ class Platform {
|
|
132
257
|
|
133
258
|
virtual ~Platform() = default;
|
134
259
|
|
260
|
+
/**
|
261
|
+
* Allows the embedder to manage memory page allocations.
|
262
|
+
*/
|
263
|
+
virtual PageAllocator* GetPageAllocator() {
|
264
|
+
// TODO(bbudge) Make this abstract after all embedders implement this.
|
265
|
+
return nullptr;
|
266
|
+
}
|
267
|
+
|
135
268
|
/**
|
136
269
|
* Enables the embedder to respond in cases where V8 can't allocate large
|
137
270
|
* blocks of memory. V8 retries the failed allocation once after calling this
|
@@ -139,16 +272,89 @@ class Platform {
|
|
139
272
|
* error.
|
140
273
|
* Embedder overrides of this function must NOT call back into V8.
|
141
274
|
*/
|
142
|
-
virtual void OnCriticalMemoryPressure() {
|
275
|
+
virtual void OnCriticalMemoryPressure() {
|
276
|
+
// TODO(bbudge) Remove this when embedders override the following method.
|
277
|
+
// See crbug.com/634547.
|
278
|
+
}
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Enables the embedder to respond in cases where V8 can't allocate large
|
282
|
+
* memory regions. The |length| parameter is the amount of memory needed.
|
283
|
+
* Returns true if memory is now available. Returns false if no memory could
|
284
|
+
* be made available. V8 will retry allocations until this method returns
|
285
|
+
* false.
|
286
|
+
*
|
287
|
+
* Embedder overrides of this function must NOT call back into V8.
|
288
|
+
*/
|
289
|
+
virtual bool OnCriticalMemoryPressure(size_t length) { return false; }
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Gets the number of worker threads used by GetWorkerThreadsTaskRunner() and
|
293
|
+
* CallOnWorkerThread(). This can be used to estimate the number of tasks a
|
294
|
+
* work package should be split into. A return value of 0 means that there are
|
295
|
+
* no worker threads available. Note that a value of 0 won't prohibit V8 from
|
296
|
+
* posting tasks using |CallOnWorkerThread|.
|
297
|
+
*/
|
298
|
+
virtual int NumberOfWorkerThreads() {
|
299
|
+
return static_cast<int>(NumberOfAvailableBackgroundThreads());
|
300
|
+
}
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Deprecated. Use NumberOfWorkerThreads() instead.
|
304
|
+
* TODO(gab): Remove this when all embedders override
|
305
|
+
* NumberOfWorkerThreads() instead.
|
306
|
+
*/
|
307
|
+
V8_DEPRECATE_SOON(
|
308
|
+
"NumberOfAvailableBackgroundThreads() is deprecated, use "
|
309
|
+
"NumberOfAvailableBackgroundThreads() instead.",
|
310
|
+
virtual size_t NumberOfAvailableBackgroundThreads()) {
|
311
|
+
return 0;
|
312
|
+
}
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Returns a TaskRunner which can be used to post a task on the foreground.
|
316
|
+
* This function should only be called from a foreground thread.
|
317
|
+
*/
|
318
|
+
virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
|
319
|
+
Isolate* isolate) {
|
320
|
+
// TODO(ahaas): Make this function abstract after it got implemented on all
|
321
|
+
// platforms.
|
322
|
+
return {};
|
323
|
+
}
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Returns a TaskRunner which can be used to post a task on a background.
|
327
|
+
* This function should only be called from a foreground thread.
|
328
|
+
*/
|
329
|
+
V8_DEPRECATE_SOON(
|
330
|
+
"GetBackgroundTaskRunner() is deprecated, use "
|
331
|
+
"GetWorkerThreadsTaskRunner() "
|
332
|
+
"instead.",
|
333
|
+
virtual std::shared_ptr<v8::TaskRunner> GetBackgroundTaskRunner(
|
334
|
+
Isolate* isolate)) {
|
335
|
+
// TODO(gab): Remove this method when all embedders have moved to
|
336
|
+
// GetWorkerThreadsTaskRunner().
|
337
|
+
|
338
|
+
// An implementation needs to be provided here because this is called by the
|
339
|
+
// default GetWorkerThreadsTaskRunner() implementation below. In practice
|
340
|
+
// however, all code either:
|
341
|
+
// - Overrides GetWorkerThreadsTaskRunner() (thus not making this call) --
|
342
|
+
// i.e. all v8 code.
|
343
|
+
// - Overrides this method (thus not making this call) -- i.e. all
|
344
|
+
// unadapted embedders.
|
345
|
+
abort();
|
346
|
+
}
|
143
347
|
|
144
348
|
/**
|
145
|
-
*
|
146
|
-
*
|
147
|
-
* A return value of 0 means that there are no background threads available.
|
148
|
-
* Note that a value of 0 won't prohibit V8 from posting tasks using
|
149
|
-
* |CallOnBackgroundThread|.
|
349
|
+
* Returns a TaskRunner which can be used to post async tasks on a worker.
|
350
|
+
* This function should only be called from a foreground thread.
|
150
351
|
*/
|
151
|
-
virtual
|
352
|
+
virtual std::shared_ptr<v8::TaskRunner> GetWorkerThreadsTaskRunner(
|
353
|
+
Isolate* isolate) {
|
354
|
+
// TODO(gab): Make this function abstract after it got implemented on all
|
355
|
+
// platforms.
|
356
|
+
return GetBackgroundTaskRunner(isolate);
|
357
|
+
}
|
152
358
|
|
153
359
|
/**
|
154
360
|
* Schedules a task to be invoked on a background thread. |expected_runtime|
|
@@ -157,8 +363,37 @@ class Platform {
|
|
157
363
|
* of tasks wrt order of scheduling, nor is there a guarantee about the
|
158
364
|
* thread the task will be run on.
|
159
365
|
*/
|
160
|
-
|
161
|
-
|
366
|
+
V8_DEPRECATE_SOON(
|
367
|
+
"ExpectedRuntime is deprecated, use CallOnWorkerThread() instead.",
|
368
|
+
virtual void CallOnBackgroundThread(Task* task,
|
369
|
+
ExpectedRuntime expected_runtime)) {
|
370
|
+
// An implementation needs to be provided here because this is called by the
|
371
|
+
// default implementation below. In practice however, all code either:
|
372
|
+
// - Overrides the new method (thus not making this call) -- i.e. all v8
|
373
|
+
// code.
|
374
|
+
// - Overrides this method (thus not making this call) -- i.e. all
|
375
|
+
// unadapted embedders.
|
376
|
+
abort();
|
377
|
+
}
|
378
|
+
|
379
|
+
/**
|
380
|
+
* Schedules a task to be invoked on a worker thread.
|
381
|
+
* TODO(gab): Make pure virtual when all embedders override this instead of
|
382
|
+
* CallOnBackgroundThread().
|
383
|
+
*/
|
384
|
+
virtual void CallOnWorkerThread(std::unique_ptr<Task> task) {
|
385
|
+
CallOnBackgroundThread(task.release(), kShortRunningTask);
|
386
|
+
}
|
387
|
+
|
388
|
+
/**
|
389
|
+
* Schedules a task that blocks the main thread to be invoked with
|
390
|
+
* high-priority on a worker thread.
|
391
|
+
*/
|
392
|
+
virtual void CallBlockingTaskOnWorkerThread(std::unique_ptr<Task> task) {
|
393
|
+
// Embedders may optionally override this to process these tasks in a high
|
394
|
+
// priority pool.
|
395
|
+
CallOnWorkerThread(std::move(task));
|
396
|
+
}
|
162
397
|
|
163
398
|
/**
|
164
399
|
* Schedules a task to be invoked on a foreground thread wrt a specific
|