DCHECK_EQ(0, reservations_[NEW_SPACE].length());
STATIC_ASSERT(NEW_SPACE == 0);
int current_space = NEW_SPACE;
- for (int i = 0; i < res.length(); i++) {
- SerializedData::Reservation r(0);
- memcpy(&r, res.start() + i, sizeof(r));
+ for (auto& r : res) {
reservations_[current_space].Add({r.chunk_size(), NULL, NULL});
if (r.is_last()) current_space++;
}
namespace v8 {
namespace internal {
-int32_t SnapshotByteSource::GetUnalignedInt() {
- DCHECK(position_ < length_); // Require at least one byte left.
- int32_t answer = data_[position_];
- answer |= data_[position_ + 1] << 8;
- answer |= data_[position_ + 2] << 16;
- answer |= data_[position_ + 3] << 24;
- return answer;
-}
-
-
void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
MemCopy(to, data_ + position_, number_of_bytes);
position_ += number_of_bytes;
return data_[position_++];
}
- int32_t GetUnalignedInt();
-
void Advance(int by) { position_ += by; }
void CopyRaw(byte* to, int number_of_bytes);
inline int GetInt() {
- // This way of variable-length encoding integers does not suffer from branch
- // mispredictions.
- uint32_t answer = GetUnalignedInt();
+ // This way of decoding variable-length encoded integers does not
+ // suffer from branch mispredictions.
+ DCHECK(position_ + 3 < length_);
+ uint32_t answer = data_[position_];
+ answer |= data_[position_ + 1] << 8;
+ answer |= data_[position_ + 2] << 16;
+ answer |= data_[position_ + 3] << 24;
int bytes = (answer & 3) + 1;
Advance(bytes);
uint32_t mask = 0xffffffffu;