Skip to content

Commit a16c3c9

Browse files
jeremyromanCommit bot
authored andcommitted
Expose the ValueSerializer data format version as a compile-time constant.
BUG=chromium:704293 Review-Url: https://codereview.chromium.org/2804643006 Cr-Commit-Position: refs/heads/master@{#44945}
1 parent 5317d43 commit a16c3c9

File tree

7 files changed

+29
-14
lines changed

7 files changed

+29
-14
lines changed

BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ v8_header_set("v8_version") {
10121012
configs = [ ":internal_config" ]
10131013

10141014
sources = [
1015+
"include/v8-value-serializer-version.h",
10151016
"include/v8-version-string.h",
10161017
"include/v8-version.h",
10171018
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/**
6+
* Compile-time constants.
7+
*
8+
* This header provides access to information about the value serializer at
9+
* compile time, without declaring or defining any symbols that require linking
10+
* to V8.
11+
*/
12+
13+
#ifndef INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
14+
#define INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
15+
16+
#include <stdint.h>
17+
18+
namespace v8 {
19+
20+
constexpr uint32_t CurrentValueSerializerFormatVersion() { return 13; }
21+
22+
} // namespace v8
23+
24+
#endif // INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_

include/v8.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,8 +1793,6 @@ class V8_EXPORT ValueSerializer {
17931793
virtual void FreeBufferMemory(void* buffer);
17941794
};
17951795

1796-
static uint32_t GetCurrentDataFormatVersion();
1797-
17981796
explicit ValueSerializer(Isolate* isolate);
17991797
ValueSerializer(Isolate* isolate, Delegate* delegate);
18001798
~ValueSerializer();

src/api.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,11 +3215,6 @@ struct ValueSerializer::PrivateData {
32153215
i::ValueSerializer serializer;
32163216
};
32173217

3218-
// static
3219-
uint32_t ValueSerializer::GetCurrentDataFormatVersion() {
3220-
return i::ValueSerializer::GetCurrentDataFormatVersion();
3221-
}
3222-
32233218
ValueSerializer::ValueSerializer(Isolate* isolate)
32243219
: ValueSerializer(isolate, nullptr) {}
32253220

src/v8.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
'../include/v8-profiler.h',
390390
'../include/v8-testing.h',
391391
'../include/v8-util.h',
392+
'../include/v8-value-serializer-version.h',
392393
'../include/v8-version-string.h',
393394
'../include/v8-version.h',
394395
'../include/v8.h',

src/value-serializer.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <type_traits>
88

9+
#include "include/v8-value-serializer-version.h"
910
#include "src/base/logging.h"
1011
#include "src/conversions.h"
1112
#include "src/factory.h"
@@ -30,6 +31,8 @@ namespace internal {
3031
// Version 13: host objects have an explicit tag (rather than handling all
3132
// unknown tags)
3233
static const uint32_t kLatestVersion = 13;
34+
static_assert(kLatestVersion == v8::CurrentValueSerializerFormatVersion(),
35+
"Exported format version must match latest version.");
3336

3437
static const int kPretenureThreshold = 100 * KB;
3538

@@ -154,11 +157,6 @@ enum class WasmEncodingTag : uint8_t {
154157

155158
} // namespace
156159

157-
// static
158-
uint32_t ValueSerializer::GetCurrentDataFormatVersion() {
159-
return kLatestVersion;
160-
}
161-
162160
ValueSerializer::ValueSerializer(Isolate* isolate,
163161
v8::ValueSerializer::Delegate* delegate)
164162
: isolate_(isolate),

src/value-serializer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ enum class SerializationTag : uint8_t;
4343
*/
4444
class ValueSerializer {
4545
public:
46-
static uint32_t GetCurrentDataFormatVersion();
47-
4846
ValueSerializer(Isolate* isolate, v8::ValueSerializer::Delegate* delegate);
4947
~ValueSerializer();
5048

0 commit comments

Comments
 (0)