Commit d5f22440 authored by ulan's avatar ulan Committed by Commit bot

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