Fix -Wsign-compare warnings in parser, scanner, regexp, runtime.
BUG=v8:5614 Review-Url: https://codereview.chromium.org/2493553002 Cr-Commit-Position: refs/heads/master@{#40892}
This commit is contained in:
parent
3505406bc7
commit
d5f22440a2
@ -512,7 +512,7 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (position == boilerplate_properties_ * 2) {
|
||||
if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) {
|
||||
DCHECK(property->is_computed_name());
|
||||
is_simple = false;
|
||||
break;
|
||||
|
@ -415,7 +415,7 @@ CPU::CPU()
|
||||
}
|
||||
|
||||
// Check if CPU has non stoppable time stamp counter.
|
||||
const int parameter_containing_non_stop_time_stamp_counter = 0x80000007;
|
||||
const unsigned parameter_containing_non_stop_time_stamp_counter = 0x80000007;
|
||||
if (num_ext_ids >= parameter_containing_non_stop_time_stamp_counter) {
|
||||
__cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter);
|
||||
has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0;
|
||||
|
@ -1312,7 +1312,7 @@ MaybeHandle<JSArray> RegExpSplit(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
elems = FixedArray::SetAndGrow(elems, num_elems++, substr);
|
||||
}
|
||||
|
||||
if (num_elems == limit) break;
|
||||
if (static_cast<uint32_t>(num_elems) == limit) break;
|
||||
|
||||
for (int i = 2; i < match_indices->NumberOfCaptureRegisters(); i += 2) {
|
||||
const int start = match_indices->Capture(i);
|
||||
@ -1326,7 +1326,7 @@ MaybeHandle<JSArray> RegExpSplit(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
factory->undefined_value());
|
||||
}
|
||||
|
||||
if (num_elems == limit) {
|
||||
if (static_cast<uint32_t>(num_elems) == limit) {
|
||||
return NewJSArrayWithElements(isolate, elems, num_elems);
|
||||
}
|
||||
}
|
||||
@ -1500,7 +1500,7 @@ BUILTIN(RegExpPrototypeSplit) {
|
||||
Handle<String> substr =
|
||||
factory->NewSubString(string, prev_string_index, string_index);
|
||||
elems = FixedArray::SetAndGrow(elems, num_elems++, substr);
|
||||
if (num_elems == limit) {
|
||||
if (static_cast<uint32_t>(num_elems) == limit) {
|
||||
return *NewJSArrayWithElements(isolate, elems, num_elems);
|
||||
}
|
||||
}
|
||||
@ -1522,7 +1522,7 @@ BUILTIN(RegExpPrototypeSplit) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, capture, Object::GetElement(isolate, result, i));
|
||||
elems = FixedArray::SetAndGrow(elems, num_elems++, capture);
|
||||
if (num_elems == limit) {
|
||||
if (static_cast<uint32_t>(num_elems) == limit) {
|
||||
return *NewJSArrayWithElements(isolate, elems, num_elems);
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ BUILTIN(StringFromCodePoint) {
|
||||
List<uc16> two_byte_buffer(length - index);
|
||||
|
||||
while (true) {
|
||||
if (code <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
|
||||
if (code <= static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
|
||||
two_byte_buffer.Add(code);
|
||||
} else {
|
||||
two_byte_buffer.Add(unibrow::Utf16::LeadSurrogate(code));
|
||||
|
@ -281,7 +281,7 @@ class SamplerManager {
|
||||
if (!entry) return;
|
||||
SamplerList& samplers = *static_cast<SamplerList*>(entry->value);
|
||||
|
||||
for (int i = 0; i < samplers.size(); ++i) {
|
||||
for (size_t i = 0; i < samplers.size(); ++i) {
|
||||
Sampler* sampler = samplers[i];
|
||||
Isolate* isolate = sampler->isolate();
|
||||
// We require a fully initialized and entered isolate.
|
||||
|
@ -369,14 +369,15 @@ class Scanner {
|
||||
INLINE(void AddChar(uc32 code_unit)) {
|
||||
if (position_ >= backing_store_.length()) ExpandBuffer();
|
||||
if (is_one_byte_) {
|
||||
if (code_unit <= unibrow::Latin1::kMaxChar) {
|
||||
if (code_unit <= static_cast<uc32>(unibrow::Latin1::kMaxChar)) {
|
||||
backing_store_[position_] = static_cast<byte>(code_unit);
|
||||
position_ += kOneByteSize;
|
||||
return;
|
||||
}
|
||||
ConvertToTwoByte();
|
||||
}
|
||||
if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
|
||||
if (code_unit <=
|
||||
static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
|
||||
*reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
|
||||
position_ += kUC16Size;
|
||||
} else {
|
||||
|
@ -1607,7 +1607,7 @@ void RegExpBuilder::AddCharacter(uc16 c) {
|
||||
|
||||
|
||||
void RegExpBuilder::AddUnicodeCharacter(uc32 c) {
|
||||
if (c > unibrow::Utf16::kMaxNonSurrogateCharCode) {
|
||||
if (c > static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
|
||||
DCHECK(unicode());
|
||||
AddLeadSurrogate(unibrow::Utf16::LeadSurrogate(c));
|
||||
AddTrailSurrogate(unibrow::Utf16::TrailSurrogate(c));
|
||||
|
@ -1138,7 +1138,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseI18N) {
|
||||
s = String::Flatten(s);
|
||||
// First scan the string for uppercase and non-ASCII characters:
|
||||
if (s->HasOnlyOneByteChars()) {
|
||||
unsigned first_index_to_lower = length;
|
||||
int first_index_to_lower = length;
|
||||
for (int index = 0; index < length; ++index) {
|
||||
// Blink specializes this path for one-byte strings, so it
|
||||
// does not need to do a generic get, but can do the equivalent
|
||||
@ -1165,14 +1165,16 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseI18N) {
|
||||
String::FlatContent flat = s->GetFlatContent();
|
||||
if (flat.IsOneByte()) {
|
||||
const uint8_t* src = flat.ToOneByteVector().start();
|
||||
CopyChars(result->GetChars(), src, first_index_to_lower);
|
||||
CopyChars(result->GetChars(), src,
|
||||
static_cast<size_t>(first_index_to_lower));
|
||||
for (int index = first_index_to_lower; index < length; ++index) {
|
||||
uint16_t ch = static_cast<uint16_t>(src[index]);
|
||||
result->SeqOneByteStringSet(index, ToLatin1Lower(ch));
|
||||
}
|
||||
} else {
|
||||
const uint16_t* src = flat.ToUC16Vector().start();
|
||||
CopyChars(result->GetChars(), src, first_index_to_lower);
|
||||
CopyChars(result->GetChars(), src,
|
||||
static_cast<size_t>(first_index_to_lower));
|
||||
for (int index = first_index_to_lower; index < length; ++index) {
|
||||
uint16_t ch = src[index];
|
||||
result->SeqOneByteStringSet(index, ToLatin1Lower(ch));
|
||||
|
@ -391,7 +391,7 @@ List<int>* GetRewoundRegexpIndicesList(Isolate* isolate) {
|
||||
void TruncateRegexpIndicesList(Isolate* isolate) {
|
||||
// Same size as smallest zone segment, preserving behavior from the
|
||||
// runtime zone.
|
||||
static const size_t kMaxRegexpIndicesListCapacity = 8 * KB;
|
||||
static const int kMaxRegexpIndicesListCapacity = 8 * KB;
|
||||
if (isolate->regexp_indices()->capacity() > kMaxRegexpIndicesListCapacity) {
|
||||
isolate->regexp_indices()->Clear(); // Throw away backing storage
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ bool DecodeOctets(const uint8_t* octets, int length, List<uc16>* buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
|
||||
if (value <= static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
|
||||
buffer->Add(value);
|
||||
} else {
|
||||
buffer->Add(unibrow::Utf16::LeadSurrogate(value));
|
||||
|
@ -1139,7 +1139,7 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
|
||||
// is successfully consumed.
|
||||
if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) {
|
||||
Vector<const uint8_t> chars = flat.ToOneByteVector();
|
||||
if (byte_length == chars.length() &&
|
||||
if (byte_length == static_cast<size_t>(chars.length()) &&
|
||||
String::IsAscii(chars.begin(), chars.length()) &&
|
||||
memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
|
||||
return true;
|
||||
|
@ -1317,9 +1317,9 @@ void TestStubCacheOffsetCalculation(StubCache::Table table) {
|
||||
factory->sloppy_arguments_elements_map(),
|
||||
};
|
||||
|
||||
for (int name_index = 0; name_index < arraysize(names); name_index++) {
|
||||
for (size_t name_index = 0; name_index < arraysize(names); name_index++) {
|
||||
Handle<Name> name = names[name_index];
|
||||
for (int map_index = 0; map_index < arraysize(maps); map_index++) {
|
||||
for (size_t map_index = 0; map_index < arraysize(maps); map_index++) {
|
||||
Handle<Map> map = maps[map_index];
|
||||
|
||||
int expected_result;
|
||||
@ -1665,7 +1665,7 @@ TEST(AllocateJSObjectFromMap) {
|
||||
|
||||
{
|
||||
Handle<Object> empty_fixed_array = factory->empty_fixed_array();
|
||||
for (int i = 0; i < arraysize(maps); i++) {
|
||||
for (size_t i = 0; i < arraysize(maps); i++) {
|
||||
Handle<Map> map = maps[i];
|
||||
Handle<JSObject> result = Handle<JSObject>::cast(
|
||||
ft.Call(map, empty_fixed_array, empty_fixed_array).ToHandleChecked());
|
||||
|
@ -25,7 +25,7 @@ static int offsets[] = {0, 1, 2, 3, 4, 30, 31, 32,
|
||||
|
||||
TEST_F(SourcePositionTableTest, EncodeStatement) {
|
||||
SourcePositionTableBuilder builder(zone());
|
||||
for (int i = 0; i < arraysize(offsets); i++) {
|
||||
for (size_t i = 0; i < arraysize(offsets); i++) {
|
||||
builder.AddPosition(offsets[i], offsets[i], true);
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ TEST_F(SourcePositionTableTest, EncodeStatement) {
|
||||
|
||||
TEST_F(SourcePositionTableTest, EncodeStatementDuplicates) {
|
||||
SourcePositionTableBuilder builder(zone());
|
||||
for (int i = 0; i < arraysize(offsets); i++) {
|
||||
for (size_t i = 0; i < arraysize(offsets); i++) {
|
||||
builder.AddPosition(offsets[i], offsets[i], true);
|
||||
builder.AddPosition(offsets[i], offsets[i] + 1, true);
|
||||
}
|
||||
@ -50,7 +50,7 @@ TEST_F(SourcePositionTableTest, EncodeStatementDuplicates) {
|
||||
|
||||
TEST_F(SourcePositionTableTest, EncodeExpression) {
|
||||
SourcePositionTableBuilder builder(zone());
|
||||
for (int i = 0; i < arraysize(offsets); i++) {
|
||||
for (size_t i = 0; i < arraysize(offsets); i++) {
|
||||
builder.AddPosition(offsets[i], offsets[i], false);
|
||||
}
|
||||
CHECK(!builder.ToSourcePositionTable(isolate(), Handle<AbstractCode>())
|
||||
@ -62,7 +62,7 @@ TEST_F(SourcePositionTableTest, EncodeAscending) {
|
||||
|
||||
int code_offset = 0;
|
||||
int source_position = 0;
|
||||
for (int i = 0; i < arraysize(offsets); i++) {
|
||||
for (size_t i = 0; i < arraysize(offsets); i++) {
|
||||
code_offset += offsets[i];
|
||||
source_position += offsets[i];
|
||||
if (i % 2) {
|
||||
@ -73,7 +73,7 @@ TEST_F(SourcePositionTableTest, EncodeAscending) {
|
||||
}
|
||||
|
||||
// Also test negative offsets for source positions:
|
||||
for (int i = 0; i < arraysize(offsets); i++) {
|
||||
for (size_t i = 0; i < arraysize(offsets); i++) {
|
||||
code_offset += offsets[i];
|
||||
source_position -= offsets[i];
|
||||
if (i % 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user