Skip to content

Commit fa5a701

Browse files
committed
Update for nodejs v24
Fixes #531
1 parent a7736dd commit fa5a701

File tree

15 files changed

+23
-38
lines changed

15 files changed

+23
-38
lines changed

binding.gyp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
'default_configuration': 'Release',
44
'configurations': {
55
'Common': {
6-
'cflags_cc': [ '-std=c++17', '-g', '-Wno-unknown-pragmas' ],
6+
'cflags_cc': [ '-std=c++20', '-g', '-Wno-unknown-pragmas' ],
77
'cflags_cc!': [ '-fno-exceptions' ],
88
'include_dirs': [ './src', './vendor' ],
99
'xcode_settings': {
1010
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
1111
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
12-
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
12+
'CLANG_CXX_LANGUAGE_STANDARD': 'c++20',
1313
'MACOSX_DEPLOYMENT_TARGET': '10.12',
1414
},
1515
'msvs_settings': {
1616
'VCCLCompilerTool': {
17-
'AdditionalOptions': [ '-std:c++17', '/GR' ],
17+
'AdditionalOptions': [ '-std:c++20', '/GR' ],
1818
'ExceptionHandling': '1',
1919
},
2020
},

src/isolate/allocator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ class LimitedAllocator : public v8::ArrayBuffer::Allocator {
1313
size_t next_check;
1414
int failures = 0;
1515

16-
1716
public:
1817
auto Check(size_t length) -> bool;
1918
explicit LimitedAllocator(class IsolateEnvironment& env, size_t limit);
2019
auto Allocate(size_t length) -> void* final;
2120
auto AllocateUninitialized(size_t length) -> void* final;
2221
void Free(void* data, size_t length) final;
23-
auto Reallocate(void* data, size_t old_length, size_t new_length) -> void* final;
2422

2523
// This is used by ExternalCopy when an ArrayBuffer is transferred. The memory is not freed but
2624
// we should no longer count it against the isolate

src/isolate/allocator_nortti.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ void LimitedAllocator::Free(void* data, size_t length) {
115115
std::free(data);
116116
}
117117

118-
auto LimitedAllocator::Reallocate(void* data, size_t old_length, size_t new_length) -> void* {
119-
auto delta = static_cast<ssize_t>(new_length) - static_cast<ssize_t>(old_length);
120-
if (delta > 0) {
121-
if (!Check(delta)) {
122-
return nullptr;
123-
}
124-
}
125-
env.extra_allocated_memory += delta;
126-
return ArrayBuffer::Allocator::Reallocate(data, old_length, new_length);
127-
}
128-
129118
void LimitedAllocator::AdjustAllocatedSize(ptrdiff_t length) {
130119
env.extra_allocated_memory += length;
131120
}

src/isolate/class_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ClassHandle {
9292
template <typename... Args>
9393
void Add(const char* name, detail::MemberAccessorHolder impl, Args... args) {
9494
v8::Local<v8::String> name_handle = v8_symbol(name);
95-
proto->SetAccessor(name_handle, impl.getter.callback, impl.setter.callback);
95+
proto->SetNativeDataProperty(name_handle, impl.getter.callback, impl.setter.callback);
9696
Add(args...);
9797
}
9898

src/isolate/environment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class IsolateEnvironment {
108108
std::atomic<unsigned int> remotes_count{0};
109109
v8::HeapStatistics last_heap {};
110110
// Copyable traits used to opt into destructor handle reset
111-
std::deque<v8::Persistent<v8::Promise, v8::CopyablePersistentTraits<v8::Promise>>> unhandled_promise_rejections;
111+
std::deque<v8::Global<v8::Promise>> unhandled_promise_rejections;
112112
StringTable string_table;
113113

114114
std::vector<v8::Eternal<v8::Data>> specifics;

src/isolate/holder.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ void IsolateHolder::ScheduleTask(std::unique_ptr<Runnable> task, bool run_inline
6363
}
6464

6565
// Methods for v8::TaskRunner
66-
void IsolateTaskRunner::PostTask(std::unique_ptr<v8::Task> task) {
66+
void IsolateTaskRunner::PostTaskImpl(std::unique_ptr<v8::Task> task, const v8::SourceLocation& /*location*/) {
6767
auto env = weak_env.lock();
6868
if (env) {
6969
env->GetScheduler().Lock()->tasks.push(std::move(task));
7070
}
7171
}
7272

73-
void IsolateTaskRunner::PostDelayedTask(std::unique_ptr<v8::Task> task, double delay_in_seconds) {
73+
void IsolateTaskRunner::PostDelayedTaskImpl(std::unique_ptr<v8::Task> task, double delay_in_seconds, const v8::SourceLocation& /*location*/) {
7474
// wait_detached erases the type of the lambda into a std::function which must be
7575
// copyable. The unique_ptr is stored in a shared pointer so ownership can be handled correctly.
7676
auto shared_task = std::make_shared<std::unique_ptr<v8::Task>>(std::move(task));

src/isolate/holder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class IsolateTaskRunner final : public TaskRunner {
5252
auto operator=(const IsolateTaskRunner&) = delete;
5353

5454
// Methods for v8::TaskRunner
55-
void PostTask(std::unique_ptr<v8::Task> task) final;
56-
void PostDelayedTask(std::unique_ptr<v8::Task> task, double delay_in_seconds) final;
57-
void PostNonNestableTask(std::unique_ptr<v8::Task> task) final { PostTask(std::move(task)); }
55+
void PostTaskImpl(std::unique_ptr<v8::Task> task, const v8::SourceLocation& /*location*/) final;
56+
void PostDelayedTaskImpl(std::unique_ptr<v8::Task> task, double delay_in_seconds, const v8::SourceLocation& /*location*/) final;
57+
void PostNonNestableTaskImpl(std::unique_ptr<v8::Task> task, const v8::SourceLocation& /*location*/) final { PostTask(std::move(task)); }
5858

5959
private:
6060
std::weak_ptr<IsolateEnvironment> weak_env;

src/isolate/platform_delegate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ namespace ivm {
1212
class TaskRunner : public v8::TaskRunner {
1313
public:
1414
// Methods for v8::TaskRunner
15-
void PostTask(std::unique_ptr<v8::Task> task) override = 0;
16-
void PostDelayedTask(std::unique_ptr<v8::Task> task, double delay_in_seconds) override = 0;
17-
void PostIdleTask(std::unique_ptr<v8::IdleTask> /*task*/) final { std::terminate(); }
15+
void PostTaskImpl(std::unique_ptr<v8::Task> task, const v8::SourceLocation& location) override = 0;
16+
void PostDelayedTaskImpl(std::unique_ptr<v8::Task> task, double delay_in_seconds, const v8::SourceLocation& location) override = 0;
17+
void PostIdleTaskImpl(std::unique_ptr<v8::IdleTask> /*task*/, const v8::SourceLocation& /*location*/) final { std::terminate(); }
1818
// Can't be final because symbol is also used in IsolatePlatformDelegate
1919
auto IdleTasksEnabled() -> bool override { return false; };
2020
auto NonNestableTasksEnabled() const -> bool final { return true; }
21-
void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> /*task*/, double /*delay_in_seconds*/) final { std::terminate(); }
21+
// void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> /*task*/, double /*delay_in_seconds*/) final { std::terminate(); }
2222
auto NonNestableDelayedTasksEnabled() const -> bool final { return false; }
2323
};
2424

src/isolate/remote_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace detail {
1717
template <size_t Index, class Type>
1818
struct HandleTupleElement {
1919
HandleTupleElement(v8::Isolate* isolate, v8::Local<Type> local) : persistent{isolate, local} {}
20-
v8::Persistent<Type, v8::NonCopyablePersistentTraits<Type>> persistent;
20+
v8::Persistent<Type> persistent;
2121
};
2222

2323
template <class Indices, class ...Types>

src/isolate/stack_trace.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ void ErrorStackGetter(Local<Name> /*property*/, const PropertyCallbackInfo<Value
100100
void AttachStackGetter(Local<Object> error, Local<Value> data) {
101101
Local<Context> context = Isolate::GetCurrent()->GetCurrentContext();
102102
Unmaybe(error->SetPrivate(context, GetPrivateStackSymbol(), data));
103-
Unmaybe(error->SetAccessor(
103+
Unmaybe(error->SetNativeDataProperty(
104104
context,
105105
StringTable::Get().stack,
106106
ErrorStackGetter, nullptr,
107107
Local<Value>(),
108-
AccessControl::DEFAULT,
109108
PropertyAttribute::DontEnum
110109
));
111110
}

0 commit comments

Comments
 (0)