libv8 6.7.288.46.1-universal-darwin-15 → 8.4.255.0-universal-darwin-15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/version.rb +1 -1
  3. data/vendor/v8/include/cppgc/allocation.h +124 -0
  4. data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
  5. data/vendor/v8/include/cppgc/heap.h +50 -0
  6. data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
  7. data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
  8. data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
  9. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
  10. data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
  11. data/vendor/v8/include/cppgc/internal/logging.h +50 -0
  12. data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
  13. data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
  14. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
  15. data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
  16. data/vendor/v8/include/cppgc/macros.h +26 -0
  17. data/vendor/v8/include/cppgc/member.h +206 -0
  18. data/vendor/v8/include/cppgc/persistent.h +304 -0
  19. data/vendor/v8/include/cppgc/platform.h +31 -0
  20. data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
  21. data/vendor/v8/include/cppgc/source-location.h +59 -0
  22. data/vendor/v8/include/cppgc/trace-trait.h +67 -0
  23. data/vendor/v8/include/cppgc/type-traits.h +109 -0
  24. data/vendor/v8/include/cppgc/visitor.h +137 -0
  25. data/vendor/v8/include/libplatform/libplatform.h +13 -24
  26. data/vendor/v8/include/libplatform/v8-tracing.h +57 -20
  27. data/vendor/v8/include/v8-fast-api-calls.h +412 -0
  28. data/vendor/v8/include/v8-inspector-protocol.h +4 -4
  29. data/vendor/v8/include/v8-inspector.h +74 -36
  30. data/vendor/v8/include/v8-internal.h +389 -0
  31. data/vendor/v8/include/v8-platform.h +228 -124
  32. data/vendor/v8/include/v8-profiler.h +292 -228
  33. data/vendor/v8/include/v8-util.h +27 -25
  34. data/vendor/v8/include/v8-version-string.h +1 -1
  35. data/vendor/v8/include/v8-version.h +4 -4
  36. data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
  37. data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
  38. data/vendor/v8/include/v8.h +2966 -1362
  39. data/vendor/v8/include/v8config.h +156 -114
  40. data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
  41. data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
  42. data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
  43. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
  44. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
  45. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
  46. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
  47. metadata +37 -9
  48. data/vendor/v8/include/v8-testing.h +0 -48
@@ -11,12 +11,34 @@
11
11
  #include <memory>
12
12
  #include <string>
13
13
 
14
- #include "v8config.h" // NOLINT(build/include)
14
+ #include "v8config.h" // NOLINT(build/include_directory)
15
15
 
16
16
  namespace v8 {
17
17
 
18
18
  class Isolate;
19
19
 
20
+ // Valid priorities supported by the task scheduling infrastructure.
21
+ enum class TaskPriority : uint8_t {
22
+ /**
23
+ * Best effort tasks are not critical for performance of the application. The
24
+ * platform implementation should preempt such tasks if higher priority tasks
25
+ * arrive.
26
+ */
27
+ kBestEffort,
28
+ /**
29
+ * User visible tasks are long running background tasks that will
30
+ * improve performance and memory usage of the application upon completion.
31
+ * Example: background compilation and garbage collection.
32
+ */
33
+ kUserVisible,
34
+ /**
35
+ * User blocking tasks are highest priority tasks that block the execution
36
+ * thread (e.g. major garbage collection). They must be finished as soon as
37
+ * possible.
38
+ */
39
+ kUserBlocking,
40
+ };
41
+
20
42
  /**
21
43
  * A Task represents a unit of work.
22
44
  */
@@ -53,6 +75,15 @@ class TaskRunner {
53
75
  */
54
76
  virtual void PostTask(std::unique_ptr<Task> task) = 0;
55
77
 
78
+ /**
79
+ * Schedules a task to be invoked by this TaskRunner. The TaskRunner
80
+ * implementation takes ownership of |task|. The |task| cannot be nested
81
+ * within other task executions.
82
+ *
83
+ * Requires that |TaskRunner::NonNestableTasksEnabled()| is true.
84
+ */
85
+ virtual void PostNonNestableTask(std::unique_ptr<Task> task) {}
86
+
56
87
  /**
57
88
  * Schedules a task to be invoked by this TaskRunner. The task is scheduled
58
89
  * after the given number of seconds |delay_in_seconds|. The TaskRunner
@@ -61,10 +92,21 @@ class TaskRunner {
61
92
  virtual void PostDelayedTask(std::unique_ptr<Task> task,
62
93
  double delay_in_seconds) = 0;
63
94
 
95
+ /**
96
+ * Schedules a task to be invoked by this TaskRunner. The task is scheduled
97
+ * after the given number of seconds |delay_in_seconds|. The TaskRunner
98
+ * implementation takes ownership of |task|. The |task| cannot be nested
99
+ * within other task executions.
100
+ *
101
+ * Requires that |TaskRunner::NonNestableDelayedTasksEnabled()| is true.
102
+ */
103
+ virtual void PostNonNestableDelayedTask(std::unique_ptr<Task> task,
104
+ double delay_in_seconds) {}
105
+
64
106
  /**
65
107
  * Schedules an idle task to be invoked by this TaskRunner. The task is
66
108
  * scheduled when the embedder is idle. Requires that
67
- * TaskRunner::SupportsIdleTasks(isolate) is true. Idle tasks may be reordered
109
+ * |TaskRunner::IdleTasksEnabled()| is true. Idle tasks may be reordered
68
110
  * relative to other task types and may be starved for an arbitrarily long
69
111
  * time if no idle time is available. The TaskRunner implementation takes
70
112
  * ownership of |task|.
@@ -76,14 +118,99 @@ class TaskRunner {
76
118
  */
77
119
  virtual bool IdleTasksEnabled() = 0;
78
120
 
121
+ /**
122
+ * Returns true if non-nestable tasks are enabled for this TaskRunner.
123
+ */
124
+ virtual bool NonNestableTasksEnabled() const { return false; }
125
+
126
+ /**
127
+ * Returns true if non-nestable delayed tasks are enabled for this TaskRunner.
128
+ */
129
+ virtual bool NonNestableDelayedTasksEnabled() const { return false; }
130
+
79
131
  TaskRunner() = default;
80
132
  virtual ~TaskRunner() = default;
81
133
 
82
- private:
83
134
  TaskRunner(const TaskRunner&) = delete;
84
135
  TaskRunner& operator=(const TaskRunner&) = delete;
85
136
  };
86
137
 
138
+ /**
139
+ * Delegate that's passed to Job's worker task, providing an entry point to
140
+ * communicate with the scheduler.
141
+ */
142
+ class JobDelegate {
143
+ public:
144
+ /**
145
+ * Returns true if this thread should return from the worker task on the
146
+ * current thread ASAP. Workers should periodically invoke ShouldYield (or
147
+ * YieldIfNeeded()) as often as is reasonable.
148
+ */
149
+ virtual bool ShouldYield() = 0;
150
+
151
+ /**
152
+ * Notifies the scheduler that max concurrency was increased, and the number
153
+ * of worker should be adjusted accordingly. See Platform::PostJob() for more
154
+ * details.
155
+ */
156
+ virtual void NotifyConcurrencyIncrease() = 0;
157
+ };
158
+
159
+ /**
160
+ * Handle returned when posting a Job. Provides methods to control execution of
161
+ * the posted Job.
162
+ */
163
+ class JobHandle {
164
+ public:
165
+ virtual ~JobHandle() = default;
166
+
167
+ /**
168
+ * Notifies the scheduler that max concurrency was increased, and the number
169
+ * of worker should be adjusted accordingly. See Platform::PostJob() for more
170
+ * details.
171
+ */
172
+ virtual void NotifyConcurrencyIncrease() = 0;
173
+
174
+ /**
175
+ * Contributes to the job on this thread. Doesn't return until all tasks have
176
+ * completed and max concurrency becomes 0. When Join() is called and max
177
+ * concurrency reaches 0, it should not increase again. This also promotes
178
+ * this Job's priority to be at least as high as the calling thread's
179
+ * priority.
180
+ */
181
+ virtual void Join() = 0;
182
+
183
+ /**
184
+ * Forces all existing workers to yield ASAP. Waits until they have all
185
+ * returned from the Job's callback before returning.
186
+ */
187
+ virtual void Cancel() = 0;
188
+
189
+ /**
190
+ * Returns true if associated with a Job and other methods may be called.
191
+ * Returns false after Join() or Cancel() was called.
192
+ */
193
+ virtual bool IsRunning() = 0;
194
+ };
195
+
196
+ /**
197
+ * A JobTask represents work to run in parallel from Platform::PostJob().
198
+ */
199
+ class JobTask {
200
+ public:
201
+ virtual ~JobTask() = default;
202
+
203
+ virtual void Run(JobDelegate* delegate) = 0;
204
+
205
+ /**
206
+ * Controls the maximum number of threads calling Run() concurrently. Run() is
207
+ * only invoked if the number of threads previously running Run() was less
208
+ * than the value returned. Since GetMaxConcurrency() is a leaf function, it
209
+ * must not call back any JobHandle methods.
210
+ */
211
+ virtual size_t GetMaxConcurrency() const = 0;
212
+ };
213
+
87
214
  /**
88
215
  * The interface represents complex arguments to trace events.
89
216
  */
@@ -109,6 +236,10 @@ class TracingController {
109
236
  public:
110
237
  virtual ~TracingController() = default;
111
238
 
239
+ // In Perfetto mode, trace events are written using Perfetto's Track Event
240
+ // API directly without going through the embedder. However, it is still
241
+ // possible to observe tracing being enabled and disabled.
242
+ #if !defined(V8_USE_PERFETTO)
112
243
  /**
113
244
  * Called by TRACE_EVENT* macros, don't call this directly.
114
245
  * The name parameter is a category group for example:
@@ -154,6 +285,7 @@ class TracingController {
154
285
  **/
155
286
  virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
156
287
  const char* name, uint64_t handle) {}
288
+ #endif // !defined(V8_USE_PERFETTO)
157
289
 
158
290
  class TraceStateObserver {
159
291
  public:
@@ -207,6 +339,7 @@ class PageAllocator {
207
339
  */
208
340
  enum Permission {
209
341
  kNoAccess,
342
+ kRead,
210
343
  kReadWrite,
211
344
  // TODO(hpayer): Remove this flag. Memory should never be rwx.
212
345
  kReadWriteExecute,
@@ -235,6 +368,13 @@ class PageAllocator {
235
368
  */
236
369
  virtual bool SetPermissions(void* address, size_t length,
237
370
  Permission permissions) = 0;
371
+
372
+ /**
373
+ * Frees memory in the given [address, address + size) range. address and size
374
+ * should be operating system page-aligned. The next write to this
375
+ * memory area brings the memory transparently back.
376
+ */
377
+ virtual bool DiscardSystemPages(void* address, size_t size) { return true; }
238
378
  };
239
379
 
240
380
  /**
@@ -245,16 +385,6 @@ class PageAllocator {
245
385
  */
246
386
  class Platform {
247
387
  public:
248
- /**
249
- * This enum is used to indicate whether a task is potentially long running,
250
- * or causes a long wait. The embedder might want to use this hint to decide
251
- * whether to execute the task on a dedicated thread.
252
- */
253
- enum ExpectedRuntime {
254
- kShortRunningTask,
255
- kLongRunningTask
256
- };
257
-
258
388
  virtual ~Platform() = default;
259
389
 
260
390
  /**
@@ -289,101 +419,26 @@ class Platform {
289
419
  virtual bool OnCriticalMemoryPressure(size_t length) { return false; }
290
420
 
291
421
  /**
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.
422
+ * Gets the number of worker threads used by
423
+ * Call(BlockingTask)OnWorkerThread(). This can be used to estimate the number
424
+ * of tasks a work package should be split into. A return value of 0 means
425
+ * that there are no worker threads available. Note that a value of 0 won't
426
+ * prohibit V8 from posting tasks using |CallOnWorkerThread|.
306
427
  */
307
- V8_DEPRECATE_SOON(
308
- "NumberOfAvailableBackgroundThreads() is deprecated, use "
309
- "NumberOfAvailableBackgroundThreads() instead.",
310
- virtual size_t NumberOfAvailableBackgroundThreads()) {
311
- return 0;
312
- }
428
+ virtual int NumberOfWorkerThreads() = 0;
313
429
 
314
430
  /**
315
431
  * 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.
432
+ * The TaskRunner's NonNestableTasksEnabled() must be true. This function
433
+ * should only be called from a foreground thread.
317
434
  */
318
435
  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
- }
347
-
348
- /**
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.
351
- */
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
- }
358
-
359
- /**
360
- * Schedules a task to be invoked on a background thread. |expected_runtime|
361
- * indicates that the task will run a long time. The Platform implementation
362
- * takes ownership of |task|. There is no guarantee about order of execution
363
- * of tasks wrt order of scheduling, nor is there a guarantee about the
364
- * thread the task will be run on.
365
- */
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
- }
436
+ Isolate* isolate) = 0;
378
437
 
379
438
  /**
380
439
  * 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
440
  */
384
- virtual void CallOnWorkerThread(std::unique_ptr<Task> task) {
385
- CallOnBackgroundThread(task.release(), kShortRunningTask);
386
- }
441
+ virtual void CallOnWorkerThread(std::unique_ptr<Task> task) = 0;
387
442
 
388
443
  /**
389
444
  * Schedules a task that blocks the main thread to be invoked with
@@ -396,39 +451,82 @@ class Platform {
396
451
  }
397
452
 
398
453
  /**
399
- * Schedules a task to be invoked on a foreground thread wrt a specific
400
- * |isolate|. Tasks posted for the same isolate should be execute in order of
401
- * scheduling. The definition of "foreground" is opaque to V8.
454
+ * Schedules a task to be invoked with low-priority on a worker thread.
402
455
  */
403
- virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
404
-
405
- /**
406
- * Schedules a task to be invoked on a foreground thread wrt a specific
407
- * |isolate| after the given number of seconds |delay_in_seconds|.
408
- * Tasks posted for the same isolate should be execute in order of
409
- * scheduling. The definition of "foreground" is opaque to V8.
410
- */
411
- virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
412
- double delay_in_seconds) = 0;
456
+ virtual void CallLowPriorityTaskOnWorkerThread(std::unique_ptr<Task> task) {
457
+ // Embedders may optionally override this to process these tasks in a low
458
+ // priority pool.
459
+ CallOnWorkerThread(std::move(task));
460
+ }
413
461
 
414
462
  /**
415
- * Schedules a task to be invoked on a foreground thread wrt a specific
416
- * |isolate| when the embedder is idle.
417
- * Requires that SupportsIdleTasks(isolate) is true.
418
- * Idle tasks may be reordered relative to other task types and may be
419
- * starved for an arbitrarily long time if no idle time is available.
420
- * The definition of "foreground" is opaque to V8.
463
+ * Schedules a task to be invoked on a worker thread after |delay_in_seconds|
464
+ * expires.
421
465
  */
422
- virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) {
423
- // TODO(ulan): Make this function abstract after V8 roll in Chromium.
424
- }
466
+ virtual void CallDelayedOnWorkerThread(std::unique_ptr<Task> task,
467
+ double delay_in_seconds) = 0;
425
468
 
426
469
  /**
427
470
  * Returns true if idle tasks are enabled for the given |isolate|.
428
471
  */
429
- virtual bool IdleTasksEnabled(Isolate* isolate) {
430
- // TODO(ulan): Make this function abstract after V8 roll in Chromium.
431
- return false;
472
+ virtual bool IdleTasksEnabled(Isolate* isolate) { return false; }
473
+
474
+ /**
475
+ * Posts |job_task| to run in parallel. Returns a JobHandle associated with
476
+ * the Job, which can be joined or canceled.
477
+ * This avoids degenerate cases:
478
+ * - Calling CallOnWorkerThread() for each work item, causing significant
479
+ * overhead.
480
+ * - Fixed number of CallOnWorkerThread() calls that split the work and might
481
+ * run for a long time. This is problematic when many components post
482
+ * "num cores" tasks and all expect to use all the cores. In these cases,
483
+ * the scheduler lacks context to be fair to multiple same-priority requests
484
+ * and/or ability to request lower priority work to yield when high priority
485
+ * work comes in.
486
+ * A canonical implementation of |job_task| looks like:
487
+ * class MyJobTask : public JobTask {
488
+ * public:
489
+ * MyJobTask(...) : worker_queue_(...) {}
490
+ * // JobTask:
491
+ * void Run(JobDelegate* delegate) override {
492
+ * while (!delegate->ShouldYield()) {
493
+ * // Smallest unit of work.
494
+ * auto work_item = worker_queue_.TakeWorkItem(); // Thread safe.
495
+ * if (!work_item) return;
496
+ * ProcessWork(work_item);
497
+ * }
498
+ * }
499
+ *
500
+ * size_t GetMaxConcurrency() const override {
501
+ * return worker_queue_.GetSize(); // Thread safe.
502
+ * }
503
+ * };
504
+ * auto handle = PostJob(TaskPriority::kUserVisible,
505
+ * std::make_unique<MyJobTask>(...));
506
+ * handle->Join();
507
+ *
508
+ * PostJob() and methods of the returned JobHandle/JobDelegate, must never be
509
+ * called while holding a lock that could be acquired by JobTask::Run or
510
+ * JobTask::GetMaxConcurrency -- that could result in a deadlock. This is
511
+ * because [1] JobTask::GetMaxConcurrency may be invoked while holding
512
+ * internal lock (A), hence JobTask::GetMaxConcurrency can only use a lock (B)
513
+ * if that lock is *never* held while calling back into JobHandle from any
514
+ * thread (A=>B/B=>A deadlock) and [2] JobTask::Run or
515
+ * JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle
516
+ * (B=>JobHandle::foo=>B deadlock).
517
+ *
518
+ * A sufficient PostJob() implementation that uses the default Job provided in
519
+ * libplatform looks like:
520
+ * std::unique_ptr<JobHandle> PostJob(
521
+ * TaskPriority priority, std::unique_ptr<JobTask> job_task) override {
522
+ * return std::make_unique<DefaultJobHandle>(
523
+ * std::make_shared<DefaultJobState>(
524
+ * this, std::move(job_task), kNumThreads));
525
+ * }
526
+ */
527
+ virtual std::unique_ptr<JobHandle> PostJob(
528
+ TaskPriority priority, std::unique_ptr<JobTask> job_task) {
529
+ return nullptr;
432
530
  }
433
531
 
434
532
  /**
@@ -459,13 +557,19 @@ class Platform {
459
557
  */
460
558
  virtual TracingController* GetTracingController() = 0;
461
559
 
560
+ /**
561
+ * Tells the embedder to generate and upload a crashdump during an unexpected
562
+ * but non-critical scenario.
563
+ */
564
+ virtual void DumpWithoutCrashing() {}
565
+
462
566
  protected:
463
567
  /**
464
568
  * Default implementation of current wall-clock time in milliseconds
465
569
  * since epoch. Useful for implementing |CurrentClockTimeMillis| if
466
570
  * nothing special needed.
467
571
  */
468
- static double SystemClockTimeMillis();
572
+ V8_EXPORT static double SystemClockTimeMillis();
469
573
  };
470
574
 
471
575
  } // namespace v8