[api] mark readonly usage of StartupData as const

This doesn’t have much practical effect, since the actual
byte contents referred to by `StartupData` are already marked
`const`, but adding the qualifier communicates more clearly
to users that V8 does not perform modifications on the object.

Practically speaking, this also allows for cases in which the
startup data is included as readonly data in the current executable
without requiring a `const_cast`.

Refs: https://github.com/nodejs/node/pull/45786#discussion_r1043489245
Change-Id: I53075ebb493c3617e470decb601b803f5294848d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4089203
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84764}
This commit is contained in:
Anna Henningsen 2022-12-08 19:07:00 +01:00 committed by V8 LUCI CQ
parent 748e6d7c45
commit ccddea063b
3 changed files with 5 additions and 5 deletions

View File

@ -233,7 +233,7 @@ class V8_EXPORT Isolate {
* Explicitly specify a startup snapshot blob. The embedder owns the blob.
* The embedder *must* ensure that the snapshot is from a trusted source.
*/
StartupData* snapshot_blob = nullptr;
const StartupData* snapshot_blob = nullptr;
/**
* Enables the host application to provide a mechanism for recording

View File

@ -91,7 +91,7 @@ class V8_EXPORT SnapshotCreator {
*/
SnapshotCreator(Isolate* isolate,
const intptr_t* external_references = nullptr,
StartupData* existing_blob = nullptr);
const StartupData* existing_blob = nullptr);
/**
* Create and enter an isolate, and set it up for serialization.
@ -102,7 +102,7 @@ class V8_EXPORT SnapshotCreator {
* that must be equivalent to CreateParams::external_references.
*/
SnapshotCreator(const intptr_t* external_references = nullptr,
StartupData* existing_blob = nullptr);
const StartupData* existing_blob = nullptr);
/**
* Destroy the snapshot creator, and exit and dispose of the Isolate

View File

@ -546,7 +546,7 @@ struct SnapshotCreatorData {
SnapshotCreator::SnapshotCreator(Isolate* v8_isolate,
const intptr_t* external_references,
StartupData* existing_snapshot) {
const StartupData* existing_snapshot) {
SnapshotCreatorData* data = new SnapshotCreatorData(v8_isolate);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
i_isolate->set_array_buffer_allocator(&data->allocator_);
@ -568,7 +568,7 @@ SnapshotCreator::SnapshotCreator(Isolate* v8_isolate,
}
SnapshotCreator::SnapshotCreator(const intptr_t* external_references,
StartupData* existing_snapshot)
const StartupData* existing_snapshot)
: SnapshotCreator(Isolate::Allocate(), external_references,
existing_snapshot) {}