From e8bddac3e94866f2ca2ff5d064cd96c72be2d03c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 20 Feb 2023 11:34:49 +0100 Subject: [PATCH] src: apply ABI-breaking API simplifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c566a04c8675, 06bb6b42b3e76 and 3aaeb309b348 included recent modifications of the C++ API that had mechanisms for ABI compatibility in place so that they would not be breaking changes. This commit removes these compatibility mechanisms. PR-URL: https://github.com/nodejs/node/pull/46705 Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Chengzhong Wu --- src/api/environment.cc | 22 +--------------------- src/node.cc | 4 ---- src/node.h | 34 ++++++++++------------------------ 3 files changed, 11 insertions(+), 49 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 389c6666dc6966..3d3f864d4e956c 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -269,8 +269,7 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { auto* modify_code_generation_from_strings_callback = ModifyCodeGenerationFromStrings; - if (s.flags & ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK && - s.modify_code_generation_from_strings_callback) { + if (s.modify_code_generation_from_strings_callback != nullptr) { modify_code_generation_from_strings_callback = s.modify_code_generation_from_strings_callback; } @@ -382,18 +381,6 @@ Isolate* NewIsolate(std::shared_ptr allocator, settings); } -Isolate* NewIsolate(ArrayBufferAllocator* allocator, - uv_loop_t* event_loop, - MultiIsolatePlatform* platform) { - return NewIsolate(allocator, event_loop, platform, nullptr); -} - -Isolate* NewIsolate(std::shared_ptr allocator, - uv_loop_t* event_loop, - MultiIsolatePlatform* platform) { - return NewIsolate(allocator, event_loop, platform, nullptr); -} - IsolateData* CreateIsolateData( Isolate* isolate, uv_loop_t* loop, @@ -405,13 +392,6 @@ IsolateData* CreateIsolateData( return new IsolateData(isolate, loop, platform, allocator, snapshot_data); } -IsolateData* CreateIsolateData(Isolate* isolate, - uv_loop_t* loop, - MultiIsolatePlatform* platform, - ArrayBufferAllocator* allocator) { - return CreateIsolateData(isolate, loop, platform, allocator, nullptr); -} - void FreeIsolateData(IsolateData* isolate_data) { delete isolate_data; } diff --git a/src/node.cc b/src/node.cc index f79f4421f8e347..0d5162dde5da88 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1270,10 +1270,6 @@ int Start(int argc, char** argv) { return static_cast(StartInternal(argc, argv)); } -int Stop(Environment* env) { - return Stop(env, StopFlags::kNoFlags); -} - int Stop(Environment* env, StopFlags::Flags flags) { env->ExitEnv(flags); return 0; diff --git a/src/node.h b/src/node.h index 3a11d0378bfed8..635e5349f4ee88 100644 --- a/src/node.h +++ b/src/node.h @@ -317,8 +317,8 @@ NODE_EXTERN int Start(int argc, char* argv[]); // Tear down Node.js while it is running (there are active handles // in the loop and / or actively executing JavaScript code). -NODE_EXTERN int Stop(Environment* env); -NODE_EXTERN int Stop(Environment* env, StopFlags::Flags flags); +NODE_EXTERN int Stop(Environment* env, + StopFlags::Flags flags = StopFlags::kNoFlags); // Set up per-process state needed to run Node.js. This will consume arguments // from argv, fill exec_argv, and possibly add errors resulting from parsing @@ -463,7 +463,7 @@ enum IsolateSettingsFlags { DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1, SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2, SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3, - ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK = 1 << 4, + ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK = 0, /* legacy no-op */ }; struct IsolateSettings { @@ -565,25 +565,17 @@ NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate); // This is a convenience method equivalent to using SetIsolateCreateParams(), // Isolate::Allocate(), MultiIsolatePlatform::RegisterIsolate(), // Isolate::Initialize(), and SetIsolateUpForNode(). -NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator, - struct uv_loop_s* event_loop, - MultiIsolatePlatform* platform = nullptr); -// TODO(addaleax): Merge with the function definition above. -NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator, - struct uv_loop_s* event_loop, - MultiIsolatePlatform* platform, - const EmbedderSnapshotData* snapshot_data, - const IsolateSettings& settings = {}); NODE_EXTERN v8::Isolate* NewIsolate( - std::shared_ptr allocator, + ArrayBufferAllocator* allocator, struct uv_loop_s* event_loop, - MultiIsolatePlatform* platform); -// TODO(addaleax): Merge with the function definition above. + MultiIsolatePlatform* platform, + const EmbedderSnapshotData* snapshot_data = nullptr, + const IsolateSettings& settings = {}); NODE_EXTERN v8::Isolate* NewIsolate( std::shared_ptr allocator, struct uv_loop_s* event_loop, MultiIsolatePlatform* platform, - const EmbedderSnapshotData* snapshot_data, + const EmbedderSnapshotData* snapshot_data = nullptr, const IsolateSettings& settings = {}); // Creates a new context with Node.js-specific tweaks. @@ -603,14 +595,8 @@ NODE_EXTERN IsolateData* CreateIsolateData( v8::Isolate* isolate, struct uv_loop_s* loop, MultiIsolatePlatform* platform = nullptr, - ArrayBufferAllocator* allocator = nullptr); -// TODO(addaleax): Merge with the function definition above. -NODE_EXTERN IsolateData* CreateIsolateData( - v8::Isolate* isolate, - struct uv_loop_s* loop, - MultiIsolatePlatform* platform, - ArrayBufferAllocator* allocator, - const EmbedderSnapshotData* snapshot_data); + ArrayBufferAllocator* allocator = nullptr, + const EmbedderSnapshotData* snapshot_data = nullptr); NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data); struct ThreadId {