Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 76138e440d5d4852e2b90b7b1b9fca53d87b9a58..d2fafaa8407a6c2229de97365a9e5bd398d505af 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -2405,7 +2405,7 @@ class ReplacementStringBuilder { |
if (is_ascii_) { |
Handle<SeqOneByteString> seq = NewRawOneByteString(character_count_); |
AssertNoAllocation no_alloc; |
- char* char_buffer = seq->GetChars(); |
+ uint8_t* char_buffer = seq->GetChars(); |
StringBuilderConcatHelper(*subject_, |
char_buffer, |
*array_builder_.array(), |
@@ -2662,7 +2662,7 @@ bool CompiledReplacement::Compile(Handle<String> replacement, |
bool simple = false; |
if (content.IsAscii()) { |
simple = ParseReplacementPattern(&parts_, |
- content.ToAsciiVector(), |
+ content.ToOneByteVector(), |
capture_count, |
subject_length, |
zone()); |
@@ -2738,7 +2738,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder, |
} |
-void FindAsciiStringIndices(Vector<const char> subject, |
+void FindAsciiStringIndices(Vector<const uint8_t> subject, |
char pattern, |
ZoneList<int>* indices, |
unsigned int limit, |
@@ -2746,11 +2746,11 @@ void FindAsciiStringIndices(Vector<const char> subject, |
ASSERT(limit > 0); |
// Collect indices of pattern in subject using memchr. |
// Stop after finding at most limit values. |
- const char* subject_start = reinterpret_cast<const char*>(subject.start()); |
- const char* subject_end = subject_start + subject.length(); |
- const char* pos = subject_start; |
+ const uint8_t* subject_start = subject.start(); |
+ const uint8_t* subject_end = subject_start + subject.length(); |
+ const uint8_t* pos = subject_start; |
while (limit > 0) { |
- pos = reinterpret_cast<const char*>( |
+ pos = reinterpret_cast<const uint8_t*>( |
memchr(pos, pattern, subject_end - pos)); |
if (pos == NULL) return; |
indices->Add(static_cast<int>(pos - subject_start), zone); |
@@ -2813,9 +2813,10 @@ void FindStringIndicesDispatch(Isolate* isolate, |
ASSERT(subject_content.IsFlat()); |
ASSERT(pattern_content.IsFlat()); |
if (subject_content.IsAscii()) { |
- Vector<const char> subject_vector = subject_content.ToAsciiVector(); |
+ Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); |
if (pattern_content.IsAscii()) { |
- Vector<const char> pattern_vector = pattern_content.ToAsciiVector(); |
+ Vector<const uint8_t> pattern_vector = |
+ pattern_content.ToOneByteVector(); |
if (pattern_vector.length() == 1) { |
FindAsciiStringIndices(subject_vector, |
pattern_vector[0], |
@@ -2841,7 +2842,8 @@ void FindStringIndicesDispatch(Isolate* isolate, |
} else { |
Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); |
if (pattern_content.IsAscii()) { |
- Vector<const char> pattern_vector = pattern_content.ToAsciiVector(); |
+ Vector<const uint8_t> pattern_vector = |
+ pattern_content.ToOneByteVector(); |
if (pattern_vector.length() == 1) { |
FindTwoByteStringIndices(subject_vector, |
pattern_vector[0], |
@@ -3323,10 +3325,10 @@ int Runtime::StringMatch(Isolate* isolate, |
// dispatch on type of strings |
if (seq_pat.IsAscii()) { |
- Vector<const char> pat_vector = seq_pat.ToAsciiVector(); |
+ Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector(); |
if (seq_sub.IsAscii()) { |
return SearchString(isolate, |
- seq_sub.ToAsciiVector(), |
+ seq_sub.ToOneByteVector(), |
pat_vector, |
start_index); |
} |
@@ -3338,7 +3340,7 @@ int Runtime::StringMatch(Isolate* isolate, |
Vector<const uc16> pat_vector = seq_pat.ToUC16Vector(); |
if (seq_sub.IsAscii()) { |
return SearchString(isolate, |
- seq_sub.ToAsciiVector(), |
+ seq_sub.ToOneByteVector(), |
pat_vector, |
start_index); |
} |
@@ -3433,9 +3435,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { |
String::FlatContent pat_content = pat->GetFlatContent(); |
if (pat_content.IsAscii()) { |
- Vector<const char> pat_vector = pat_content.ToAsciiVector(); |
+ Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector(); |
if (sub_content.IsAscii()) { |
- position = StringMatchBackwards(sub_content.ToAsciiVector(), |
+ position = StringMatchBackwards(sub_content.ToOneByteVector(), |
pat_vector, |
start_index); |
} else { |
@@ -3446,7 +3448,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { |
} else { |
Vector<const uc16> pat_vector = pat_content.ToUC16Vector(); |
if (sub_content.IsAscii()) { |
- position = StringMatchBackwards(sub_content.ToAsciiVector(), |
+ position = StringMatchBackwards(sub_content.ToOneByteVector(), |
pat_vector, |
start_index); |
} else { |
@@ -5000,7 +5002,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
} |
-static bool AreDigits(const char*s, int from, int to) { |
+static bool AreDigits(const uint8_t*s, int from, int to) { |
for (int i = from; i < to; i++) { |
if (s[i] < '0' || s[i] > '9') return false; |
} |
@@ -5009,7 +5011,7 @@ static bool AreDigits(const char*s, int from, int to) { |
} |
-static int ParseDecimalInteger(const char*s, int from, int to) { |
+static int ParseDecimalInteger(const uint8_t*s, int from, int to) { |
ASSERT(to - from < 10); // Overflow is not possible. |
ASSERT(from < to); |
int d = s[from] - '0'; |
@@ -5033,7 +5035,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
if (subject->IsSeqOneByteString()) { |
if (len == 0) return Smi::FromInt(0); |
- char const* data = SeqOneByteString::cast(subject)->GetChars(); |
+ uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); |
bool minus = (data[0] == '-'); |
int start_pos = (minus ? 1 : 0); |
@@ -5528,8 +5530,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { |
return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, |
flat.ToUC16Vector()); |
} else { |
- return QuoteJsonString<char, SeqOneByteString, false>(isolate, |
- flat.ToAsciiVector()); |
+ return QuoteJsonString<uint8_t, SeqOneByteString, false>( |
+ isolate, |
+ flat.ToOneByteVector()); |
} |
} |
@@ -5551,8 +5554,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { |
return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate, |
flat.ToUC16Vector()); |
} else { |
- return QuoteJsonString<char, SeqOneByteString, true>(isolate, |
- flat.ToAsciiVector()); |
+ return QuoteJsonString<uint8_t, SeqOneByteString, true>( |
+ isolate, |
+ flat.ToOneByteVector()); |
} |
} |
@@ -5593,9 +5597,10 @@ static MaybeObject* QuoteJsonStringArray(Isolate* isolate, |
write_cursor, |
content.ToUC16Vector()); |
} else { |
- write_cursor = WriteQuoteJsonString<Char, char>(isolate, |
- write_cursor, |
- content.ToAsciiVector()); |
+ write_cursor = |
+ WriteQuoteJsonString<Char, uint8_t>(isolate, |
+ write_cursor, |
+ content.ToOneByteVector()); |
} |
} |
*(write_cursor++) = ']'; |
@@ -5948,7 +5953,9 @@ MUST_USE_RESULT static MaybeObject* ConvertCase( |
} |
SeqOneByteString* result = SeqOneByteString::cast(o); |
bool has_changed_character = ConvertTraits::AsciiConverter::Convert( |
- result->GetChars(), SeqOneByteString::cast(s)->GetChars(), length); |
+ reinterpret_cast<char*>(result->GetChars()), |
+ reinterpret_cast<char*>(SeqOneByteString::cast(s)->GetChars()), |
+ length); |
return has_changed_character ? result : s; |
} |
#endif |
@@ -6110,7 +6117,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { |
// not in the cache and fills the remainder with smi zeros. Returns |
// the length of the successfully copied prefix. |
static int CopyCachedAsciiCharsToArray(Heap* heap, |
- const char* chars, |
+ const uint8_t* chars, |
FixedArray* elements, |
int length) { |
AssertNoAllocation no_gc; |
@@ -6161,7 +6168,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) { |
elements = Handle<FixedArray>(FixedArray::cast(obj), isolate); |
String::FlatContent content = s->GetFlatContent(); |
if (content.IsAscii()) { |
- Vector<const char> chars = content.ToAsciiVector(); |
+ Vector<const uint8_t> chars = content.ToOneByteVector(); |
// Note, this will initialize all elements (not only the prefix) |
// to prevent GC from seeing partially initialized array. |
position = CopyCachedAsciiCharsToArray(isolate->heap(), |
@@ -6744,12 +6751,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { |
if (result_allocation->IsFailure()) return result_allocation; |
SeqOneByteString* result_string = |
SeqOneByteString::cast(result_allocation->ToObjectUnchecked()); |
- JoinSparseArrayWithSeparator<char>(elements, |
- elements_length, |
- array_length, |
- separator, |
- Vector<char>(result_string->GetChars(), |
- string_length)); |
+ JoinSparseArrayWithSeparator<uint8_t>(elements, |
+ elements_length, |
+ array_length, |
+ separator, |
+ Vector<uint8_t>( |
+ result_string->GetChars(), |
+ string_length)); |
return result_string; |
} else { |
MaybeObject* result_allocation = |
@@ -6997,9 +7005,9 @@ static Object* FlatStringCompare(String* x, String* y) { |
String::FlatContent x_content = x->GetFlatContent(); |
String::FlatContent y_content = y->GetFlatContent(); |
if (x_content.IsAscii()) { |
- Vector<const char> x_chars = x_content.ToAsciiVector(); |
+ Vector<const uint8_t> x_chars = x_content.ToOneByteVector(); |
if (y_content.IsAscii()) { |
- Vector<const char> y_chars = y_content.ToAsciiVector(); |
+ Vector<const uint8_t> y_chars = y_content.ToOneByteVector(); |
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); |
} else { |
Vector<const uc16> y_chars = y_content.ToUC16Vector(); |
@@ -7008,7 +7016,7 @@ static Object* FlatStringCompare(String* x, String* y) { |
} else { |
Vector<const uc16> x_chars = x_content.ToUC16Vector(); |
if (y_content.IsAscii()) { |
- Vector<const char> y_chars = y_content.ToAsciiVector(); |
+ Vector<const uint8_t> y_chars = y_content.ToOneByteVector(); |
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); |
} else { |
Vector<const uc16> y_chars = y_content.ToUC16Vector(); |
@@ -8958,7 +8966,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { |
bool result; |
String::FlatContent str_content = str->GetFlatContent(); |
if (str_content.IsAscii()) { |
- result = DateParser::Parse(str_content.ToAsciiVector(), |
+ result = DateParser::Parse(str_content.ToOneByteVector(), |
output_array, |
isolate->unicode_cache()); |
} else { |
@@ -13416,8 +13424,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { |
CONVERT_ARG_CHECKED(JSArray, elms, 1); |
String::FlatContent format_content = format->GetFlatContent(); |
RUNTIME_ASSERT(format_content.IsAscii()); |
- Vector<const char> chars = format_content.ToAsciiVector(); |
- LOGGER->LogRuntime(chars, elms); |
+ Vector<const uint8_t> chars = format_content.ToOneByteVector(); |
+ LOGGER->LogRuntime(Vector<const char>::cast(chars), elms); |
return isolate->heap()->undefined_value(); |
} |