[serializer] Fix missing changes to bytecode value encoding

https://crrev.com/c/2369172 had a few remaining comments that
accidentally weren't addressed in the final submitted patch.

Tbr: jgruber@chromium.org
Change-Id: If0cff18f5078f17a6f70d27c71090dcc64f23ddd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2388114
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69662}
This commit is contained in:
Leszek Swirski 2020-09-02 10:08:57 +02:00 committed by Commit Bot
parent 42d2cd757d
commit 88619ce5cd

View File

@ -217,6 +217,14 @@ class SerializerDeserializer : public RootVisitor {
};
// Helper class for encoding and decoding a value into and from a bytecode.
//
// The value is encoded by allocating an entire bytecode range, and encoding
// the value as an index in that range, starting at kMinValue; thus the range
// of values
// [kMinValue, kMinValue + 1, ... , kMaxValue]
// is encoded as
// [kBytecode, kBytecode + 1, ... , kBytecode + (N - 1)]
// where N is the number of values, i.e. kMaxValue - kMinValue + 1.
template <Bytecode kBytecode, int kMinValue, int kMaxValue,
typename TValue = int>
struct BytecodeValueEncoder {
@ -241,7 +249,7 @@ class SerializerDeserializer : public RootVisitor {
template <Bytecode bytecode>
using SpaceEncoder =
BytecodeValueEncoder<bytecode, 0, kNumberOfSpaces, SnapshotSpace>;
BytecodeValueEncoder<bytecode, 0, kNumberOfSpaces - 1, SnapshotSpace>;
using NewObject = SpaceEncoder<kNewObject>;
using BackRef = SpaceEncoder<kBackref>;