Commit f6874c73 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[globals] Change uc32 to be unsigned

Prior to this change, uc16 was typedef'd to (unsigned) uint16_t while
uc32 was typedef'd to (signed) int32_t.

For consistency, and to avoid unexpected behavior around
signed/unsigned comparisons, this changes uc32 to the unsigned
uint32_t type.

As part of this change, old-style error passing (return -1, check for
negative return values) was updated to use named error values.

Bug: v8:10568
Change-Id: I8524e66ee20e8738749cd34c4fe82c14e885dcb3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235533Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68282}
parent d8c9ae52
...@@ -99,7 +99,7 @@ void AsmJsScanner::Next() { ...@@ -99,7 +99,7 @@ void AsmJsScanner::Next() {
preceded_by_newline_ = true; preceded_by_newline_ = true;
break; break;
case kEndOfInput: case kEndOfInputU:
token_ = kEndOfInput; token_ = kEndOfInput;
return; return;
...@@ -354,7 +354,7 @@ bool AsmJsScanner::ConsumeCComment() { ...@@ -354,7 +354,7 @@ bool AsmJsScanner::ConsumeCComment() {
if (ch == '\n') { if (ch == '\n') {
preceded_by_newline_ = true; preceded_by_newline_ = true;
} }
if (ch == kEndOfInput) { if (ch == kEndOfInputU) {
return false; return false;
} }
} }
...@@ -367,7 +367,7 @@ void AsmJsScanner::ConsumeCPPComment() { ...@@ -367,7 +367,7 @@ void AsmJsScanner::ConsumeCPPComment() {
preceded_by_newline_ = true; preceded_by_newline_ = true;
return; return;
} }
if (ch == kEndOfInput) { if (ch == kEndOfInputU) {
return; return;
} }
} }
...@@ -377,7 +377,7 @@ void AsmJsScanner::ConsumeString(uc32 quote) { ...@@ -377,7 +377,7 @@ void AsmJsScanner::ConsumeString(uc32 quote) {
// Only string allowed is 'use asm' / "use asm". // Only string allowed is 'use asm' / "use asm".
const char* expected = "use asm"; const char* expected = "use asm";
for (; *expected != '\0'; ++expected) { for (; *expected != '\0'; ++expected) {
if (stream_->Advance() != *expected) { if (stream_->Advance() != static_cast<uc32>(*expected)) {
token_ = kParseError; token_ = kParseError;
return; return;
} }
......
...@@ -135,6 +135,8 @@ class V8_EXPORT_PRIVATE AsmJsScanner { ...@@ -135,6 +135,8 @@ class V8_EXPORT_PRIVATE AsmJsScanner {
}; };
// clang-format on // clang-format on
static constexpr uc32 kEndOfInputU = static_cast<uc32>(kEndOfInput);
private: private:
Utf16CharacterStream* stream_; Utf16CharacterStream* stream_;
token_t token_; token_t token_;
......
...@@ -40,14 +40,16 @@ bool IsValidCodePoint(Isolate* isolate, Handle<Object> value) { ...@@ -40,14 +40,16 @@ bool IsValidCodePoint(Isolate* isolate, Handle<Object> value) {
return true; return true;
} }
static constexpr uc32 kInvalidCodePoint = static_cast<uc32>(-1);
uc32 NextCodePoint(Isolate* isolate, BuiltinArguments args, int index) { uc32 NextCodePoint(Isolate* isolate, BuiltinArguments args, int index) {
Handle<Object> value = args.at(1 + index); Handle<Object> value = args.at(1 + index);
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, value, ASSIGN_RETURN_ON_EXCEPTION_VALUE(
Object::ToNumber(isolate, value), -1); isolate, value, Object::ToNumber(isolate, value), kInvalidCodePoint);
if (!IsValidCodePoint(isolate, value)) { if (!IsValidCodePoint(isolate, value)) {
isolate->Throw(*isolate->factory()->NewRangeError( isolate->Throw(*isolate->factory()->NewRangeError(
MessageTemplate::kInvalidCodePoint, value)); MessageTemplate::kInvalidCodePoint, value));
return -1; return kInvalidCodePoint;
} }
return DoubleToUint32(value->Number()); return DoubleToUint32(value->Number());
} }
...@@ -69,7 +71,7 @@ BUILTIN(StringFromCodePoint) { ...@@ -69,7 +71,7 @@ BUILTIN(StringFromCodePoint) {
int index; int index;
for (index = 0; index < length; index++) { for (index = 0; index < length; index++) {
code = NextCodePoint(isolate, args, index); code = NextCodePoint(isolate, args, index);
if (code < 0) { if (code == kInvalidCodePoint) {
return ReadOnlyRoots(isolate).exception(); return ReadOnlyRoots(isolate).exception();
} }
if (code > String::kMaxOneByteCharCode) { if (code > String::kMaxOneByteCharCode) {
...@@ -99,7 +101,7 @@ BUILTIN(StringFromCodePoint) { ...@@ -99,7 +101,7 @@ BUILTIN(StringFromCodePoint) {
break; break;
} }
code = NextCodePoint(isolate, args, index); code = NextCodePoint(isolate, args, index);
if (code < 0) { if (code == kInvalidCodePoint) {
return ReadOnlyRoots(isolate).exception(); return ReadOnlyRoots(isolate).exception();
} }
} }
......
...@@ -329,7 +329,7 @@ constexpr uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51; ...@@ -329,7 +329,7 @@ constexpr uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
// Code-point values in Unicode 4.0 are 21 bits wide. // Code-point values in Unicode 4.0 are 21 bits wide.
// Code units in UTF-16 are 16 bits wide. // Code units in UTF-16 are 16 bits wide.
using uc16 = uint16_t; using uc16 = uint16_t;
using uc32 = int32_t; using uc32 = uint32_t;
constexpr int kOneByteSize = kCharSize; constexpr int kOneByteSize = kCharSize;
constexpr int kUC16Size = sizeof(uc16); // NOLINT constexpr int kUC16Size = sizeof(uc16); // NOLINT
......
...@@ -335,7 +335,7 @@ uc32 JsonParser<Char>::ScanUnicodeCharacter() { ...@@ -335,7 +335,7 @@ uc32 JsonParser<Char>::ScanUnicodeCharacter() {
uc32 value = 0; uc32 value = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int digit = HexValue(NextCharacter()); int digit = HexValue(NextCharacter());
if (V8_UNLIKELY(digit < 0)) return -1; if (V8_UNLIKELY(digit < 0)) return kInvalidUnicodeCharacter;
value = value * 16 + digit; value = value * 16 + digit;
} }
return value; return value;
...@@ -1173,7 +1173,7 @@ JsonString JsonParser<Char>::ScanJsonString(bool needs_internalization) { ...@@ -1173,7 +1173,7 @@ JsonString JsonParser<Char>::ScanJsonString(bool needs_internalization) {
case EscapeKind::kUnicode: { case EscapeKind::kUnicode: {
uc32 value = ScanUnicodeCharacter(); uc32 value = ScanUnicodeCharacter();
if (value == -1) { if (value == kInvalidUnicodeCharacter) {
AllowHeapAllocation allow_before_exception; AllowHeapAllocation allow_before_exception;
ReportUnexpectedCharacter(CurrentCharacter()); ReportUnexpectedCharacter(CurrentCharacter());
return JsonString(); return JsonString();
......
...@@ -151,7 +151,8 @@ class JsonParser final { ...@@ -151,7 +151,8 @@ class JsonParser final {
return result; return result;
} }
static const int kEndOfString = -1; static constexpr uc32 kEndOfString = static_cast<uc32>(-1);
static constexpr uc32 kInvalidUnicodeCharacter = static_cast<uc32>(-1);
private: private:
struct JsonContinuation { struct JsonContinuation {
......
...@@ -305,7 +305,7 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() { ...@@ -305,7 +305,7 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() {
// Special case for escapes at the start of an identifier. // Special case for escapes at the start of an identifier.
escaped = true; escaped = true;
uc32 c = ScanIdentifierUnicodeEscape(); uc32 c = ScanIdentifierUnicodeEscape();
DCHECK(!IsIdentifierStart(-1)); DCHECK(!IsIdentifierStart(Invalid()));
if (c == '\\' || !IsIdentifierStart(c)) { if (c == '\\' || !IsIdentifierStart(c)) {
return Token::ILLEGAL; return Token::ILLEGAL;
} }
......
...@@ -107,6 +107,12 @@ void Scanner::Initialize() { ...@@ -107,6 +107,12 @@ void Scanner::Initialize() {
Scan(); Scan();
} }
// static
bool Scanner::IsInvalid(uc32 c) {
DCHECK(c == Invalid() || base::IsInRange(c, 0u, String::kMaxCodePoint));
return c == Scanner::Invalid();
}
template <bool capture_raw, bool unicode> template <bool capture_raw, bool unicode>
uc32 Scanner::ScanHexNumber(int expected_length) { uc32 Scanner::ScanHexNumber(int expected_length) {
DCHECK_LE(expected_length, 4); // prevent overflow DCHECK_LE(expected_length, 4); // prevent overflow
...@@ -120,7 +126,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) { ...@@ -120,7 +126,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) {
unicode unicode
? MessageTemplate::kInvalidUnicodeEscapeSequence ? MessageTemplate::kInvalidUnicodeEscapeSequence
: MessageTemplate::kInvalidHexEscapeSequence); : MessageTemplate::kInvalidHexEscapeSequence);
return -1; return Invalid();
} }
x = x * 16 + d; x = x * 16 + d;
Advance<capture_raw>(); Advance<capture_raw>();
...@@ -130,17 +136,17 @@ uc32 Scanner::ScanHexNumber(int expected_length) { ...@@ -130,17 +136,17 @@ uc32 Scanner::ScanHexNumber(int expected_length) {
} }
template <bool capture_raw> template <bool capture_raw>
uc32 Scanner::ScanUnlimitedLengthHexNumber(int max_value, int beg_pos) { uc32 Scanner::ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos) {
uc32 x = 0; uc32 x = 0;
int d = HexValue(c0_); int d = HexValue(c0_);
if (d < 0) return -1; if (d < 0) return Invalid();
while (d >= 0) { while (d >= 0) {
x = x * 16 + d; x = x * 16 + d;
if (x > max_value) { if (x > max_value) {
ReportScannerError(Location(beg_pos, source_pos() + 1), ReportScannerError(Location(beg_pos, source_pos() + 1),
MessageTemplate::kUndefinedUnicodeCodePoint); MessageTemplate::kUndefinedUnicodeCodePoint);
return -1; return Invalid();
} }
Advance<capture_raw>(); Advance<capture_raw>();
d = HexValue(c0_); d = HexValue(c0_);
...@@ -386,7 +392,7 @@ bool Scanner::ScanEscape() { ...@@ -386,7 +392,7 @@ bool Scanner::ScanEscape() {
case 't' : c = '\t'; break; case 't' : c = '\t'; break;
case 'u' : { case 'u' : {
c = ScanUnicodeEscape<capture_raw>(); c = ScanUnicodeEscape<capture_raw>();
if (c < 0) return false; if (IsInvalid(c)) return false;
break; break;
} }
case 'v': case 'v':
...@@ -394,7 +400,7 @@ bool Scanner::ScanEscape() { ...@@ -394,7 +400,7 @@ bool Scanner::ScanEscape() {
break; break;
case 'x': { case 'x': {
c = ScanHexNumber<capture_raw>(2); c = ScanHexNumber<capture_raw>(2);
if (c < 0) return false; if (IsInvalid(c)) return false;
break; break;
} }
case '0': // Fall through. case '0': // Fall through.
...@@ -416,6 +422,7 @@ bool Scanner::ScanEscape() { ...@@ -416,6 +422,7 @@ bool Scanner::ScanEscape() {
template <bool capture_raw> template <bool capture_raw>
uc32 Scanner::ScanOctalEscape(uc32 c, int length) { uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
DCHECK('0' <= c && c <= '7');
uc32 x = c - '0'; uc32 x = c - '0';
int i = 0; int i = 0;
for (; i < length; i++) { for (; i < length; i++) {
...@@ -553,7 +560,7 @@ Token::Value Scanner::ScanTemplateSpan() { ...@@ -553,7 +560,7 @@ Token::Value Scanner::ScanTemplateSpan() {
scanner_error_state.MoveErrorTo(next_); scanner_error_state.MoveErrorTo(next_);
octal_error_state.MoveErrorTo(next_); octal_error_state.MoveErrorTo(next_);
} }
} else if (c < 0) { } else if (c == kEndOfInput) {
// Unterminated template literal // Unterminated template literal
break; break;
} else { } else {
...@@ -861,7 +868,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { ...@@ -861,7 +868,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
uc32 Scanner::ScanIdentifierUnicodeEscape() { uc32 Scanner::ScanIdentifierUnicodeEscape() {
Advance(); Advance();
if (c0_ != 'u') return -1; if (c0_ != 'u') return Invalid();
Advance(); Advance();
return ScanUnicodeEscape<false>(); return ScanUnicodeEscape<false>();
} }
...@@ -873,11 +880,12 @@ uc32 Scanner::ScanUnicodeEscape() { ...@@ -873,11 +880,12 @@ uc32 Scanner::ScanUnicodeEscape() {
if (c0_ == '{') { if (c0_ == '{') {
int begin = source_pos() - 2; int begin = source_pos() - 2;
Advance<capture_raw>(); Advance<capture_raw>();
uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10FFFF, begin); uc32 cp =
if (cp < 0 || c0_ != '}') { ScanUnlimitedLengthHexNumber<capture_raw>(String::kMaxCodePoint, begin);
if (cp == kInvalidSequence || c0_ != '}') {
ReportScannerError(source_pos(), ReportScannerError(source_pos(),
MessageTemplate::kInvalidUnicodeEscapeSequence); MessageTemplate::kInvalidUnicodeEscapeSequence);
return -1; return Invalid();
} }
Advance<capture_raw>(); Advance<capture_raw>();
return cp; return cp;
...@@ -895,7 +903,7 @@ Token::Value Scanner::ScanIdentifierOrKeywordInnerSlow(bool escaped, ...@@ -895,7 +903,7 @@ Token::Value Scanner::ScanIdentifierOrKeywordInnerSlow(bool escaped,
// Only allow legal identifier part characters. // Only allow legal identifier part characters.
// TODO(verwaest): Make this true. // TODO(verwaest): Make this true.
// DCHECK(!IsIdentifierPart('\')); // DCHECK(!IsIdentifierPart('\'));
DCHECK(!IsIdentifierPart(-1)); DCHECK(!IsIdentifierPart(Invalid()));
if (c == '\\' || !IsIdentifierPart(c)) { if (c == '\\' || !IsIdentifierPart(c)) {
return Token::ILLEGAL; return Token::ILLEGAL;
} }
......
...@@ -39,7 +39,7 @@ class Zone; ...@@ -39,7 +39,7 @@ class Zone;
// or one part of a surrogate pair that make a single 21 bit code point. // or one part of a surrogate pair that make a single 21 bit code point.
class Utf16CharacterStream { class Utf16CharacterStream {
public: public:
static const uc32 kEndOfInput = -1; static constexpr uc32 kEndOfInput = static_cast<uc32>(-1);
virtual ~Utf16CharacterStream() = default; virtual ~Utf16CharacterStream() = default;
...@@ -267,8 +267,11 @@ class V8_EXPORT_PRIVATE Scanner { ...@@ -267,8 +267,11 @@ class V8_EXPORT_PRIVATE Scanner {
}; };
// -1 is outside of the range of any real source code. // -1 is outside of the range of any real source code.
static const int kNoOctalLocation = -1; static constexpr uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput;
static const uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput; static constexpr uc32 kInvalidSequence = static_cast<uc32>(-1);
static constexpr uc32 Invalid() { return Scanner::kInvalidSequence; }
static bool IsInvalid(uc32 c);
explicit Scanner(Utf16CharacterStream* source, UnoptimizedCompileFlags flags); explicit Scanner(Utf16CharacterStream* source, UnoptimizedCompileFlags flags);
...@@ -623,7 +626,7 @@ class V8_EXPORT_PRIVATE Scanner { ...@@ -623,7 +626,7 @@ class V8_EXPORT_PRIVATE Scanner {
// number can be 000000001, so it's very long in characters but its value is // number can be 000000001, so it's very long in characters but its value is
// small. // small.
template <bool capture_raw> template <bool capture_raw>
uc32 ScanUnlimitedLengthHexNumber(int max_value, int beg_pos); uc32 ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos);
// Scans a single JavaScript token. // Scans a single JavaScript token.
V8_INLINE Token::Value ScanSingleToken(); V8_INLINE Token::Value ScanSingleToken();
......
...@@ -55,8 +55,9 @@ void PrintSpecial(std::ofstream& out) { ...@@ -55,8 +55,9 @@ void PrintSpecial(std::ofstream& out) {
CHECK(U_SUCCESS(status)); CHECK(U_SUCCESS(status));
// Iterate through all chars in BMP except surrogates. // Iterate through all chars in BMP except surrogates.
for (UChar32 i = 0; i < kNonBmpStart; i++) { for (UChar32 i = 0; i < static_cast<UChar32>(kNonBmpStart); i++) {
if (i >= kSurrogateStart && i <= kSurrogateEnd) { if (i >= static_cast<UChar32>(kSurrogateStart) &&
i <= static_cast<UChar32>(kSurrogateEnd)) {
continue; // Ignore surrogate range continue; // Ignore surrogate range
} }
current.set(i, i); current.set(i, i);
......
...@@ -56,11 +56,11 @@ static bool CompareInverseRanges(ZoneList<CharacterRange>* ranges, ...@@ -56,11 +56,11 @@ static bool CompareInverseRanges(ZoneList<CharacterRange>* ranges,
return false; return false;
} }
for (int i = 0; i < length; i += 2) { for (int i = 0; i < length; i += 2) {
if (special_class[i] != (range.to() + 1)) { if (static_cast<uc32>(special_class[i]) != (range.to() + 1)) {
return false; return false;
} }
range = ranges->at((i >> 1) + 1); range = ranges->at((i >> 1) + 1);
if (special_class[i + 1] != range.from()) { if (static_cast<uc32>(special_class[i + 1]) != range.from()) {
return false; return false;
} }
} }
...@@ -79,8 +79,8 @@ static bool CompareRanges(ZoneList<CharacterRange>* ranges, ...@@ -79,8 +79,8 @@ static bool CompareRanges(ZoneList<CharacterRange>* ranges,
} }
for (int i = 0; i < length; i += 2) { for (int i = 0; i < length; i += 2) {
CharacterRange range = ranges->at(i >> 1); CharacterRange range = ranges->at(i >> 1);
if (range.from() != special_class[i] || if (range.from() != static_cast<uc32>(special_class[i]) ||
range.to() != special_class[i + 1] - 1) { range.to() != static_cast<uc32>(special_class[i + 1] - 1)) {
return false; return false;
} }
} }
...@@ -1154,7 +1154,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone, ...@@ -1154,7 +1154,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
CharacterRange range = ranges->at(i); CharacterRange range = ranges->at(i);
uc32 from = range.from(); uc32 from = range.from();
if (from > String::kMaxUtf16CodeUnit) continue; if (from > String::kMaxUtf16CodeUnit) continue;
uc32 to = Min(range.to(), String::kMaxUtf16CodeUnit); uc32 to = Min(range.to(), String::kMaxUtf16CodeUnitU);
// Nothing to be done for surrogates. // Nothing to be done for surrogates.
if (from >= kLeadSurrogateStart && to <= kTrailSurrogateEnd) continue; if (from >= kLeadSurrogateStart && to <= kTrailSurrogateEnd) continue;
if (is_one_byte && !RangeContainsLatin1Equivalents(range)) { if (is_one_byte && !RangeContainsLatin1Equivalents(range)) {
...@@ -1197,7 +1197,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone, ...@@ -1197,7 +1197,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
CharacterRange range = ranges->at(i); CharacterRange range = ranges->at(i);
uc32 bottom = range.from(); uc32 bottom = range.from();
if (bottom > String::kMaxUtf16CodeUnit) continue; if (bottom > String::kMaxUtf16CodeUnit) continue;
uc32 top = Min(range.to(), String::kMaxUtf16CodeUnit); uc32 top = Min(range.to(), String::kMaxUtf16CodeUnitU);
// Nothing to be done for surrogates. // Nothing to be done for surrogates.
if (bottom >= kLeadSurrogateStart && top <= kTrailSurrogateEnd) continue; if (bottom >= kLeadSurrogateStart && top <= kTrailSurrogateEnd) continue;
if (is_one_byte && !RangeContainsLatin1Equivalents(range)) { if (is_one_byte && !RangeContainsLatin1Equivalents(range)) {
...@@ -1232,7 +1232,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone, ...@@ -1232,7 +1232,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
// block we do this for all the blocks covered by the range (handling // block we do this for all the blocks covered by the range (handling
// characters that is not in a block as a "singleton block"). // characters that is not in a block as a "singleton block").
unibrow::uchar equivalents[unibrow::Ecma262UnCanonicalize::kMaxWidth]; unibrow::uchar equivalents[unibrow::Ecma262UnCanonicalize::kMaxWidth];
int pos = bottom; uc32 pos = bottom;
while (pos <= top) { while (pos <= top) {
int length = int length =
isolate->jsregexp_canonrange()->get(pos, '\0', equivalents); isolate->jsregexp_canonrange()->get(pos, '\0', equivalents);
...@@ -1265,7 +1265,7 @@ bool CharacterRange::IsCanonical(ZoneList<CharacterRange>* ranges) { ...@@ -1265,7 +1265,7 @@ bool CharacterRange::IsCanonical(ZoneList<CharacterRange>* ranges) {
DCHECK_NOT_NULL(ranges); DCHECK_NOT_NULL(ranges);
int n = ranges->length(); int n = ranges->length();
if (n <= 1) return true; if (n <= 1) return true;
int max = ranges->at(0).to(); uc32 max = ranges->at(0).to();
for (int i = 1; i < n; i++) { for (int i = 1; i < n; i++) {
CharacterRange next_range = ranges->at(i); CharacterRange next_range = ranges->at(i);
if (next_range.from() <= max + 1) return false; if (next_range.from() <= max + 1) return false;
...@@ -1366,7 +1366,7 @@ void CharacterRange::Canonicalize(ZoneList<CharacterRange>* character_ranges) { ...@@ -1366,7 +1366,7 @@ void CharacterRange::Canonicalize(ZoneList<CharacterRange>* character_ranges) {
// Check whether ranges are already canonical (increasing, non-overlapping, // Check whether ranges are already canonical (increasing, non-overlapping,
// non-adjacent). // non-adjacent).
int n = character_ranges->length(); int n = character_ranges->length();
int max = character_ranges->at(0).to(); uc32 max = character_ranges->at(0).to();
int i = 1; int i = 1;
while (i < n) { while (i < n) {
CharacterRange current = character_ranges->at(i); CharacterRange current = character_ranges->at(i);
......
...@@ -1126,7 +1126,7 @@ static void GenerateBranches(RegExpMacroAssembler* masm, ZoneList<int>* ranges, ...@@ -1126,7 +1126,7 @@ static void GenerateBranches(RegExpMacroAssembler* masm, ZoneList<int>* ranges,
return; return;
} }
if ((min_char >> kBits) != (first >> kBits)) { if ((min_char >> kBits) != static_cast<uc32>(first >> kBits)) {
masm->CheckCharacterLT(first, odd_label); masm->CheckCharacterLT(first, odd_label);
GenerateBranches(masm, ranges, start_index + 1, end_index, first, max_char, GenerateBranches(masm, ranges, start_index + 1, end_index, first, max_char,
fall_through, odd_label, even_label); fall_through, odd_label, even_label);
...@@ -1197,7 +1197,7 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler, ...@@ -1197,7 +1197,7 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
int last_valid_range = range_count - 1; int last_valid_range = range_count - 1;
while (last_valid_range >= 0) { while (last_valid_range >= 0) {
CharacterRange& range = ranges->at(last_valid_range); CharacterRange& range = ranges->at(last_valid_range);
if (range.from() <= max_char) { if (static_cast<int>(range.from()) <= max_char) {
break; break;
} }
last_valid_range--; last_valid_range--;
...@@ -1240,6 +1240,7 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler, ...@@ -1240,6 +1240,7 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
// entry at zero which goes to the failure label, but if there // entry at zero which goes to the failure label, but if there
// was already one there we fall through for success on that entry. // was already one there we fall through for success on that entry.
// Subsequent entries have alternating meaning (success/failure). // Subsequent entries have alternating meaning (success/failure).
// TODO(jgruber,v8:10568): Change `range_boundaries` to a ZoneList<uc32>.
ZoneList<int>* range_boundaries = ZoneList<int>* range_boundaries =
new (zone) ZoneList<int>(last_valid_range, zone); new (zone) ZoneList<int>(last_valid_range, zone);
...@@ -1636,7 +1637,7 @@ void TextNode::GetQuickCheckDetails(QuickCheckDetails* details, ...@@ -1636,7 +1637,7 @@ void TextNode::GetQuickCheckDetails(QuickCheckDetails* details,
pos->value = 0; pos->value = 0;
} else { } else {
int first_range = 0; int first_range = 0;
while (ranges->at(first_range).from() > char_mask) { while (static_cast<int>(ranges->at(first_range).from()) > char_mask) {
first_range++; first_range++;
if (first_range == ranges->length()) { if (first_range == ranges->length()) {
details->set_cannot_match(); details->set_cannot_match();
...@@ -3788,7 +3789,7 @@ void TextNode::FillInBMInfo(Isolate* isolate, int initial_offset, int budget, ...@@ -3788,7 +3789,7 @@ void TextNode::FillInBMInfo(Isolate* isolate, int initial_offset, int budget,
} else { } else {
for (int k = 0; k < ranges->length(); k++) { for (int k = 0; k < ranges->length(); k++) {
CharacterRange& range = ranges->at(k); CharacterRange& range = ranges->at(k);
if (range.from() > max_char) continue; if (static_cast<int>(range.from()) > max_char) continue;
int to = Min(max_char, static_cast<int>(range.to())); int to = Min(max_char, static_cast<int>(range.to()));
bm->SetInterval(offset, Interval(range.from(), to)); bm->SetInterval(offset, Interval(range.from(), to));
} }
......
...@@ -1550,7 +1550,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) { ...@@ -1550,7 +1550,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) {
} }
while (d >= 0) { while (d >= 0) {
x = x * 16 + d; x = x * 16 + d;
if (x > max_value) { if (x > static_cast<uc32>(max_value)) {
return false; return false;
} }
Advance(); Advance();
......
...@@ -448,17 +448,17 @@ void TestCharacterStream(const char* reference, i::Utf16CharacterStream* stream, ...@@ -448,17 +448,17 @@ void TestCharacterStream(const char* reference, i::Utf16CharacterStream* stream,
CHECK_EQU(reference[i], stream->Advance()); CHECK_EQU(reference[i], stream->Advance());
} }
CHECK_EQU(i, stream->pos()); CHECK_EQU(i, stream->pos());
CHECK_LT(stream->Advance(), 0); CHECK(i::Scanner::IsInvalid(stream->Advance()));
// Seek back, then seek beyond end of stream. // Seek back, then seek beyond end of stream.
stream->Seek(start); stream->Seek(start);
if (start < length) { if (start < length) {
CHECK_EQU(stream->Advance(), reference[start]); CHECK_EQU(stream->Advance(), reference[start]);
} else { } else {
CHECK_LT(stream->Advance(), 0); CHECK(i::Scanner::IsInvalid(stream->Advance()));
} }
stream->Seek(length + 5); stream->Seek(length + 5);
CHECK_LT(stream->Advance(), 0); CHECK(i::Scanner::IsInvalid(stream->Advance()));
} }
void TestCloneCharacterStream(const char* reference, void TestCloneCharacterStream(const char* reference,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment