mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
[vm] Remove undefined shifts from ReadStream.
Change-Id: I3570739b77d431e412af94c87fa544805f6dbbcb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146028 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
fb5ebf6a09
commit
60493d58fb
|
@ -120,11 +120,11 @@ class ReadStream : public ValueObject {
|
|||
}
|
||||
|
||||
private:
|
||||
int16_t Read16() { return Read16(kEndByteMarker); }
|
||||
uint16_t Read16() { return Read16(kEndByteMarker); }
|
||||
|
||||
int32_t Read32() { return Read32(kEndByteMarker); }
|
||||
uint32_t Read32() { return Read32(kEndByteMarker); }
|
||||
|
||||
int64_t Read64() { return Read64(kEndByteMarker); }
|
||||
uint64_t Read64() { return Read64(kEndByteMarker); }
|
||||
|
||||
template <typename T>
|
||||
T Read(uint8_t end_byte_marker) {
|
||||
|
@ -147,153 +147,153 @@ class ReadStream : public ValueObject {
|
|||
return r | ((static_cast<T>(b) - end_byte_marker) << s);
|
||||
}
|
||||
|
||||
int16_t Read16(uint8_t end_byte_marker) {
|
||||
uint16_t Read16(uint8_t end_byte_marker) {
|
||||
const uint8_t* c = current_;
|
||||
ASSERT(c < end_);
|
||||
uint8_t b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return static_cast<int16_t>(b) - end_byte_marker;
|
||||
return static_cast<uint16_t>(b) - end_byte_marker;
|
||||
}
|
||||
int16_t r = 0;
|
||||
r |= static_cast<int16_t>(b);
|
||||
uint16_t r = 0;
|
||||
r |= static_cast<uint16_t>(b);
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int16_t>(b) - end_byte_marker) << 7);
|
||||
return r | ((static_cast<uint16_t>(b) - end_byte_marker) << 7);
|
||||
}
|
||||
|
||||
r |= static_cast<int16_t>(b) << 7;
|
||||
r |= static_cast<uint16_t>(b) << 7;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
ASSERT(b > kMaxUnsignedDataPerByte);
|
||||
current_ = c;
|
||||
return r | ((static_cast<int16_t>(b) - end_byte_marker) << 14);
|
||||
return r | ((static_cast<uint16_t>(b) - end_byte_marker) << 14);
|
||||
}
|
||||
|
||||
int32_t Read32(uint8_t end_byte_marker) {
|
||||
uint32_t Read32(uint8_t end_byte_marker) {
|
||||
const uint8_t* c = current_;
|
||||
ASSERT(c < end_);
|
||||
uint8_t b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return static_cast<int32_t>(b) - end_byte_marker;
|
||||
return static_cast<uint32_t>(b) - end_byte_marker;
|
||||
}
|
||||
|
||||
int32_t r = 0;
|
||||
r |= static_cast<int32_t>(b);
|
||||
uint32_t r = 0;
|
||||
r |= static_cast<uint32_t>(b);
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int32_t>(b) - end_byte_marker) << 7);
|
||||
return r | ((static_cast<uint32_t>(b) - end_byte_marker) << 7);
|
||||
}
|
||||
|
||||
r |= static_cast<int32_t>(b) << 7;
|
||||
r |= static_cast<uint32_t>(b) << 7;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int32_t>(b) - end_byte_marker) << 14);
|
||||
return r | ((static_cast<uint32_t>(b) - end_byte_marker) << 14);
|
||||
}
|
||||
|
||||
r |= static_cast<int32_t>(b) << 14;
|
||||
r |= static_cast<uint32_t>(b) << 14;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int32_t>(b) - end_byte_marker) << 21);
|
||||
return r | ((static_cast<uint32_t>(b) - end_byte_marker) << 21);
|
||||
}
|
||||
|
||||
r |= static_cast<int32_t>(b) << 21;
|
||||
r |= static_cast<uint32_t>(b) << 21;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
ASSERT(b > kMaxUnsignedDataPerByte);
|
||||
current_ = c;
|
||||
return r | ((static_cast<int32_t>(b) - end_byte_marker) << 28);
|
||||
return r | ((static_cast<uint32_t>(b) - end_byte_marker) << 28);
|
||||
}
|
||||
|
||||
int64_t Read64(uint8_t end_byte_marker) {
|
||||
uint64_t Read64(uint8_t end_byte_marker) {
|
||||
const uint8_t* c = current_;
|
||||
ASSERT(c < end_);
|
||||
uint8_t b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return static_cast<int64_t>(b) - end_byte_marker;
|
||||
return static_cast<uint64_t>(b) - end_byte_marker;
|
||||
}
|
||||
int64_t r = 0;
|
||||
uint64_t r = 0;
|
||||
|
||||
r |= static_cast<int64_t>(b);
|
||||
r |= static_cast<uint64_t>(b);
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 7);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 7);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 7;
|
||||
r |= static_cast<uint64_t>(b) << 7;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 14);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 14);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 14;
|
||||
r |= static_cast<uint64_t>(b) << 14;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 21);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 21);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 21;
|
||||
r |= static_cast<uint64_t>(b) << 21;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 28);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 28);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 28;
|
||||
r |= static_cast<uint64_t>(b) << 28;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 35);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 35);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 35;
|
||||
r |= static_cast<uint64_t>(b) << 35;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 42);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 42);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 42;
|
||||
r |= static_cast<uint64_t>(b) << 42;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 49);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 49);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 49;
|
||||
r |= static_cast<uint64_t>(b) << 49;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
if (b > kMaxUnsignedDataPerByte) {
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 56);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 56);
|
||||
}
|
||||
|
||||
r |= static_cast<int64_t>(b) << 56;
|
||||
r |= static_cast<uint64_t>(b) << 56;
|
||||
ASSERT(c < end_);
|
||||
b = *c++;
|
||||
ASSERT(b > kMaxUnsignedDataPerByte);
|
||||
current_ = c;
|
||||
return r | ((static_cast<int64_t>(b) - end_byte_marker) << 63);
|
||||
return r | ((static_cast<uint64_t>(b) - end_byte_marker) << 63);
|
||||
}
|
||||
|
||||
uint8_t ReadByte() {
|
||||
|
|
Loading…
Reference in a new issue