Skip to content

Commit 81ab540

Browse files
addaleaxtargos
authored andcommitted
src: mark generated snapshot_data as const
This renders the mutex protecting it unnecessary, since mutexes only need to protect concurrent accesses to mutable data. PR-URL: #45786 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 302c524 commit 81ab540

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/node_snapshot_builder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class NODE_EXTERN_PRIVATE SnapshotBuilder {
3232
v8::Isolate::CreateParams* params);
3333

3434
private:
35-
// Used to synchronize access to the snapshot data
36-
static Mutex snapshot_data_mutex_;
3735
static const std::vector<intptr_t>& CollectExternalReferences();
3836

3937
static std::unique_ptr<ExternalReferenceRegistry> registry_;

src/node_snapshotable.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static void WriteCodeCacheInitializer(std::ostream* ss, const std::string& id) {
978978
*ss << " },\n";
979979
}
980980

981-
void FormatBlob(std::ostream& ss, SnapshotData* data) {
981+
void FormatBlob(std::ostream& ss, const SnapshotData* data) {
982982
ss << R"(#include <cstddef>
983983
#include "env.h"
984984
#include "node_snapshot_builder.h"
@@ -1004,7 +1004,7 @@ static const int v8_snapshot_blob_size = )"
10041004
WriteStaticCodeCacheData(&ss, item);
10051005
}
10061006

1007-
ss << R"(SnapshotData snapshot_data {
1007+
ss << R"(const SnapshotData snapshot_data {
10081008
// -- data_ownership begins --
10091009
SnapshotData::DataOwnership::kNotOwned,
10101010
// -- data_ownership ends --
@@ -1036,7 +1036,6 @@ static const int v8_snapshot_blob_size = )"
10361036
};
10371037
10381038
const SnapshotData* SnapshotBuilder::GetEmbeddedSnapshotData() {
1039-
Mutex::ScopedLock lock(snapshot_data_mutex_);
10401039
return &snapshot_data;
10411040
}
10421041
} // namespace node
@@ -1053,8 +1052,6 @@ static void ResetContextSettingsBeforeSnapshot(Local<Context> context) {
10531052
context->AllowCodeGenerationFromStrings(true);
10541053
}
10551054

1056-
Mutex SnapshotBuilder::snapshot_data_mutex_;
1057-
10581055
const std::vector<intptr_t>& SnapshotBuilder::CollectExternalReferences() {
10591056
static auto registry = std::make_unique<ExternalReferenceRegistry>();
10601057
return registry->external_references();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy