Skip to content

Commit 8bcefd0

Browse files
psmarshallMylesBorins
authored andcommitted
deps: patch the V8 API to be forward compatible with 6.7
PR-URL: #19999 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c98eeb6 commit 8bcefd0

File tree

8 files changed

+114
-109
lines changed

8 files changed

+114
-109
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.4',
30+
'v8_embedder_string': '-node.5',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,

deps/v8/include/libplatform/libplatform.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
3838
int thread_pool_size = 0,
3939
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
4040
InProcessStackDumping in_process_stack_dumping =
41-
InProcessStackDumping::kEnabled,
41+
InProcessStackDumping::kDisabled,
4242
std::unique_ptr<v8::TracingController> tracing_controller = {});
4343

4444
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
@@ -47,7 +47,7 @@ V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
4747
int thread_pool_size = 0,
4848
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
4949
InProcessStackDumping in_process_stack_dumping =
50-
InProcessStackDumping::kEnabled,
50+
InProcessStackDumping::kDisabled,
5151
v8::TracingController* tracing_controller = nullptr));
5252

5353
/**

deps/v8/include/v8-platform.h

+56-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
#ifndef V8_V8_PLATFORM_H_
66
#define V8_V8_PLATFORM_H_
77

8+
#include <cstdlib>
89
#include <stddef.h>
910
#include <stdint.h>
1011
#include <memory>
1112
#include <string>
1213

14+
#include "v8config.h" // NOLINT(build/include)
15+
1316
namespace v8 {
1417

1518
class Isolate;
@@ -285,14 +288,23 @@ class Platform {
285288
*/
286289
virtual bool OnCriticalMemoryPressure(size_t length) { return false; }
287290

291+
virtual int NumberOfWorkerThreads() {
292+
return static_cast<int>(NumberOfAvailableBackgroundThreads());
293+
}
294+
288295
/**
289296
* Gets the number of threads that are used to execute background tasks. Is
290297
* used to estimate the number of tasks a work package should be split into.
291298
* A return value of 0 means that there are no background threads available.
292299
* Note that a value of 0 won't prohibit V8 from posting tasks using
293300
* |CallOnBackgroundThread|.
294301
*/
295-
virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
302+
V8_DEPRECATE_SOON(
303+
"NumberOfAvailableBackgroundThreads() is deprecated, use "
304+
"NumberOfAvailableBackgroundThreads() instead.",
305+
virtual size_t NumberOfAvailableBackgroundThreads()) {
306+
return 0;
307+
}
296308

297309
/**
298310
* Returns a TaskRunner which can be used to post a task on the foreground.
@@ -309,11 +321,28 @@ class Platform {
309321
* Returns a TaskRunner which can be used to post a task on a background.
310322
* This function should only be called from a foreground thread.
311323
*/
312-
virtual std::shared_ptr<v8::TaskRunner> GetBackgroundTaskRunner(
324+
V8_DEPRECATE_SOON(
325+
"GetBackgroundTaskRunner() is deprecated, use "
326+
"GetWorkerThreadsTaskRunner() "
327+
"instead.",
328+
virtual std::shared_ptr<v8::TaskRunner> GetBackgroundTaskRunner(
329+
Isolate* isolate)) {
330+
// TODO(gab): Remove this method when all embedders have moved to
331+
// GetWorkerThreadsTaskRunner().
332+
333+
// An implementation needs to be provided here because this is called by the
334+
// default GetWorkerThreadsTaskRunner() implementation below. In practice
335+
// however, all code either:
336+
// - Overrides GetWorkerThreadsTaskRunner() (thus not making this call) --
337+
// i.e. all v8 code.
338+
// - Overrides this method (thus not making this call) -- i.e. all
339+
// unadapted embedders.
340+
abort();
341+
}
342+
343+
virtual std::shared_ptr<v8::TaskRunner> GetWorkerThreadsTaskRunner(
313344
Isolate* isolate) {
314-
// TODO(ahaas): Make this function abstract after it got implemented on all
315-
// platforms.
316-
return {};
345+
return GetBackgroundTaskRunner(isolate);
317346
}
318347

319348
/**
@@ -323,8 +352,28 @@ class Platform {
323352
* of tasks wrt order of scheduling, nor is there a guarantee about the
324353
* thread the task will be run on.
325354
*/
326-
virtual void CallOnBackgroundThread(Task* task,
327-
ExpectedRuntime expected_runtime) = 0;
355+
V8_DEPRECATE_SOON(
356+
"ExpectedRuntime is deprecated, use CallOnWorkerThread() instead.",
357+
virtual void CallOnBackgroundThread(Task* task,
358+
ExpectedRuntime expected_runtime)) {
359+
// An implementation needs to be provided here because this is called by the
360+
// default implementation below. In practice however, all code either:
361+
// - Overrides the new method (thus not making this call) -- i.e. all v8
362+
// code.
363+
// - Overrides this method (thus not making this call) -- i.e. all
364+
// unadapted embedders.
365+
abort();
366+
}
367+
368+
virtual void CallOnWorkerThread(std::unique_ptr<Task> task) {
369+
CallOnBackgroundThread(task.release(), kShortRunningTask);
370+
}
371+
372+
virtual void CallBlockingTaskOnWorkerThread(std::unique_ptr<Task> task) {
373+
// Embedders may optionally override this to process these tasks in a high
374+
// priority pool.
375+
CallOnWorkerThread(std::move(task));
376+
}
328377

329378
/**
330379
* Schedules a task to be invoked on a foreground thread wrt a specific

deps/v8/include/v8.h

+32-47
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,9 @@ class V8_EXPORT ScriptCompiler {
15671567
static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
15681568
Local<Context> context, Source* source, size_t arguments_count,
15691569
Local<String> arguments[], size_t context_extension_count,
1570-
Local<Object> context_extensions[]);
1570+
Local<Object> context_extensions[],
1571+
CompileOptions options = kNoCompileOptions,
1572+
NoCacheReason no_cache_reason = kNoCacheNoReason);
15711573

15721574
/**
15731575
* Creates and returns code cache for the specified unbound_script.
@@ -1641,7 +1643,7 @@ class V8_EXPORT Message {
16411643
* Returns the index within the line of the first character where
16421644
* the error occurred.
16431645
*/
1644-
V8_DEPRECATED("Use maybe version", int GetStartColumn() const);
1646+
int GetStartColumn() const;
16451647
V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
16461648

16471649
/**
@@ -3075,6 +3077,8 @@ enum PropertyFilter {
30753077
SKIP_SYMBOLS = 16
30763078
};
30773079

3080+
enum class SideEffectType { kHasSideEffect, kHasNoSideEffect };
3081+
30783082
/**
30793083
* Keys/Properties filter enums:
30803084
*
@@ -3207,13 +3211,12 @@ class V8_EXPORT Object : public Value {
32073211
V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
32083212
uint32_t index);
32093213

3210-
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(Local<Context> context,
3211-
Local<Name> name,
3212-
AccessorNameGetterCallback getter,
3213-
AccessorNameSetterCallback setter = 0,
3214-
MaybeLocal<Value> data = MaybeLocal<Value>(),
3215-
AccessControl settings = DEFAULT,
3216-
PropertyAttribute attribute = None);
3214+
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
3215+
Local<Context> context, Local<Name> name,
3216+
AccessorNameGetterCallback getter, AccessorNameSetterCallback setter = 0,
3217+
MaybeLocal<Value> data = MaybeLocal<Value>(),
3218+
AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
3219+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
32173220

32183221
void SetAccessorProperty(Local<Name> name, Local<Function> getter,
32193222
Local<Function> setter = Local<Function>(),
@@ -3228,7 +3231,8 @@ class V8_EXPORT Object : public Value {
32283231
Local<Context> context, Local<Name> name,
32293232
AccessorNameGetterCallback getter,
32303233
AccessorNameSetterCallback setter = nullptr,
3231-
Local<Value> data = Local<Value>(), PropertyAttribute attributes = None);
3234+
Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
3235+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
32323236

32333237
/**
32343238
* Attempts to create a property with the given name which behaves like a data
@@ -3241,7 +3245,8 @@ class V8_EXPORT Object : public Value {
32413245
V8_WARN_UNUSED_RESULT Maybe<bool> SetLazyDataProperty(
32423246
Local<Context> context, Local<Name> name,
32433247
AccessorNameGetterCallback getter, Local<Value> data = Local<Value>(),
3244-
PropertyAttribute attributes = None);
3248+
PropertyAttribute attributes = None,
3249+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
32453250

32463251
/**
32473252
* Functionality for private properties.
@@ -3496,7 +3501,7 @@ class V8_EXPORT Object : public Value {
34963501
/**
34973502
* Return the isolate to which the Object belongs to.
34983503
*/
3499-
V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate());
3504+
Isolate* GetIsolate();
35003505

35013506
static Local<Object> New(Isolate* isolate);
35023507

@@ -3833,7 +3838,8 @@ class V8_EXPORT Function : public Object {
38333838
static MaybeLocal<Function> New(
38343839
Local<Context> context, FunctionCallback callback,
38353840
Local<Value> data = Local<Value>(), int length = 0,
3836-
ConstructorBehavior behavior = ConstructorBehavior::kAllow);
3841+
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
3842+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
38373843
static V8_DEPRECATE_SOON(
38383844
"Use maybe version",
38393845
Local<Function> New(Isolate* isolate, FunctionCallback callback,
@@ -4271,13 +4277,6 @@ class V8_EXPORT ArrayBuffer : public Object {
42714277
*/
42724278
virtual void* AllocateUninitialized(size_t length) = 0;
42734279

4274-
/**
4275-
* Reserved |length| bytes, but do not commit the memory. Must call
4276-
* |SetProtection| to make memory accessible.
4277-
*/
4278-
// TODO(eholk): make this pure virtual once blink implements this.
4279-
virtual void* Reserve(size_t length);
4280-
42814280
/**
42824281
* Free the memory block of size |length|, pointed to by |data|.
42834282
* That memory is guaranteed to be previously allocated by |Allocate|.
@@ -4286,27 +4285,6 @@ class V8_EXPORT ArrayBuffer : public Object {
42864285

42874286
enum class AllocationMode { kNormal, kReservation };
42884287

4289-
/**
4290-
* Free the memory block of size |length|, pointed to by |data|.
4291-
* That memory is guaranteed to be previously allocated by |Allocate| or
4292-
* |Reserve|, depending on |mode|.
4293-
*/
4294-
// TODO(eholk): make this pure virtual once blink implements this.
4295-
virtual void Free(void* data, size_t length, AllocationMode mode);
4296-
4297-
enum class Protection { kNoAccess, kReadWrite };
4298-
4299-
/**
4300-
* Change the protection on a region of memory.
4301-
*
4302-
* On platforms that make a distinction between reserving and committing
4303-
* memory, changing the protection to kReadWrite must also ensure the memory
4304-
* is committed.
4305-
*/
4306-
// TODO(eholk): make this pure virtual once blink implements this.
4307-
virtual void SetProtection(void* data, size_t length,
4308-
Protection protection);
4309-
43104288
/**
43114289
* malloc/free based convenience allocator.
43124290
*
@@ -5496,7 +5474,8 @@ class V8_EXPORT FunctionTemplate : public Template {
54965474
Isolate* isolate, FunctionCallback callback = 0,
54975475
Local<Value> data = Local<Value>(),
54985476
Local<Signature> signature = Local<Signature>(), int length = 0,
5499-
ConstructorBehavior behavior = ConstructorBehavior::kAllow);
5477+
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
5478+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
55005479

55015480
/** Get a template included in the snapshot by index. */
55025481
static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
@@ -5508,7 +5487,8 @@ class V8_EXPORT FunctionTemplate : public Template {
55085487
static Local<FunctionTemplate> NewWithCache(
55095488
Isolate* isolate, FunctionCallback callback,
55105489
Local<Private> cache_property, Local<Value> data = Local<Value>(),
5511-
Local<Signature> signature = Local<Signature>(), int length = 0);
5490+
Local<Signature> signature = Local<Signature>(), int length = 0,
5491+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
55125492

55135493
/** Returns the unique function instance in the current execution context.*/
55145494
V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
@@ -5529,8 +5509,9 @@ class V8_EXPORT FunctionTemplate : public Template {
55295509
* callback is called whenever the function created from this
55305510
* FunctionTemplate is called.
55315511
*/
5532-
void SetCallHandler(FunctionCallback callback,
5533-
Local<Value> data = Local<Value>());
5512+
void SetCallHandler(
5513+
FunctionCallback callback, Local<Value> data = Local<Value>(),
5514+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
55345515

55355516
/** Set the predefined length property for the FunctionTemplate. */
55365517
void SetLength(int length);
@@ -5828,7 +5809,7 @@ class V8_EXPORT ObjectTemplate : public Template {
58285809
* \param data A piece of data that will be passed to the callbacks
58295810
* whenever they are invoked.
58305811
*/
5831-
V8_DEPRECATE_SOON(
5812+
V8_DEPRECATED(
58325813
"Use SetHandler(const NamedPropertyHandlerConfiguration) "
58335814
"with the kOnlyInterceptStrings flag set.",
58345815
void SetNamedPropertyHandler(
@@ -6586,8 +6567,11 @@ struct JitCodeEvent {
65866567
// statement, and is used to indicate possible break locations.
65876568
enum PositionType { POSITION, STATEMENT_POSITION };
65886569

6570+
enum CodeType { BYTE_CODE, JIT_CODE };
6571+
65896572
// Type of event.
65906573
EventType type;
6574+
CodeType code_type;
65916575
// Start of the instructions.
65926576
void* code_start;
65936577
// Size of the instructions.
@@ -8025,7 +8009,8 @@ class V8_EXPORT V8 {
80258009
* Enable the default signal handler rather than using one provided by the
80268010
* embedder.
80278011
*/
8028-
static bool RegisterDefaultSignalHandler();
8012+
V8_DEPRECATE_SOON("Use EnableWebAssemblyTrapHandler",
8013+
static bool RegisterDefaultSignalHandler());
80298014

80308015
private:
80318016
V8();

0 commit comments

Comments
 (0)