Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: src/runtime.cc

Issue 559913002: Rename ascii to one-byte where applicable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/jsregexp.cc ('K') | « src/runtime.h ('k') | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index ce2d51c82a77cc9c2f37bad70764bdadb0aa7b21..d18c22cffc97c436f3b6bab4d27f37c6ba1455bc 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -3238,14 +3238,13 @@ typedef BitField<int,
class ReplacementStringBuilder {
public:
- ReplacementStringBuilder(Heap* heap,
- Handle<String> subject,
+ ReplacementStringBuilder(Heap* heap, Handle<String> subject,
int estimated_part_count)
: heap_(heap),
array_builder_(heap->isolate(), estimated_part_count),
subject_(subject),
character_count_(0),
- is_ascii_(subject->IsOneByteRepresentation()) {
+ is_one_byte_(subject->IsOneByteRepresentation()) {
// Require a non-zero initial size. Ensures that doubling the size to
// extend the array will work.
DCHECK(estimated_part_count > 0);
@@ -3286,7 +3285,7 @@ class ReplacementStringBuilder {
DCHECK(length > 0);
AddElement(*string);
if (!string->IsOneByteRepresentation()) {
- is_ascii_ = false;
+ is_one_byte_ = false;
}
IncrementCharacterCount(length);
}
@@ -3299,7 +3298,7 @@ class ReplacementStringBuilder {
}
Handle<String> joined_string;
- if (is_ascii_) {
+ if (is_one_byte_) {
Handle<SeqOneByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
@@ -3314,7 +3313,7 @@ class ReplacementStringBuilder {
array_builder_.length());
joined_string = Handle<String>::cast(seq);
} else {
- // Non-ASCII.
+ // Two-byte.
Handle<SeqTwoByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
@@ -3353,7 +3352,7 @@ class ReplacementStringBuilder {
FixedArrayBuilder array_builder_;
Handle<String> subject_;
int character_count_;
- bool is_ascii_;
+ bool is_one_byte_;
};
@@ -3559,7 +3558,7 @@ bool CompiledReplacement::Compile(Handle<String> replacement,
String::FlatContent content = replacement->GetFlatContent();
DCHECK(content.IsFlat());
bool simple = false;
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
simple = ParseReplacementPattern(&parts_,
content.ToOneByteVector(),
capture_count,
@@ -3637,11 +3636,9 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
}
-void FindAsciiStringIndices(Vector<const uint8_t> subject,
- char pattern,
- ZoneList<int>* indices,
- unsigned int limit,
- Zone* zone) {
+void FindOneByteStringIndices(Vector<const uint8_t> subject, char pattern,
+ ZoneList<int>* indices, unsigned int limit,
+ Zone* zone) {
DCHECK(limit > 0);
// Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values.
@@ -3711,17 +3708,14 @@ void FindStringIndicesDispatch(Isolate* isolate,
String::FlatContent pattern_content = pattern->GetFlatContent();
DCHECK(subject_content.IsFlat());
DCHECK(pattern_content.IsFlat());
- if (subject_content.IsAscii()) {
+ if (subject_content.IsOneByte()) {
Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector();
- if (pattern_content.IsAscii()) {
+ if (pattern_content.IsOneByte()) {
Vector<const uint8_t> pattern_vector =
pattern_content.ToOneByteVector();
if (pattern_vector.length() == 1) {
- FindAsciiStringIndices(subject_vector,
- pattern_vector[0],
- indices,
- limit,
- zone);
+ FindOneByteStringIndices(subject_vector, pattern_vector[0], indices,
+ limit, zone);
} else {
FindStringIndices(isolate,
subject_vector,
@@ -3740,7 +3734,7 @@ void FindStringIndicesDispatch(Isolate* isolate,
}
} else {
Vector<const uc16> subject_vector = subject_content.ToUC16Vector();
- if (pattern_content.IsAscii()) {
+ if (pattern_content.IsOneByte()) {
Vector<const uint8_t> pattern_vector =
pattern_content.ToOneByteVector();
if (pattern_vector.length() == 1) {
@@ -3822,7 +3816,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
int result_pos = 0;
MaybeHandle<SeqString> maybe_res;
- if (ResultSeqString::kHasAsciiEncoding) {
+ if (ResultSeqString::kHasOneByteEncoding) {
maybe_res = isolate->factory()->NewRawOneByteString(result_len);
} else {
maybe_res = isolate->factory()->NewRawTwoByteString(result_len);
@@ -4002,7 +3996,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
if (new_length == 0) return isolate->heap()->empty_string();
Handle<ResultSeqString> answer;
- if (ResultSeqString::kHasAsciiEncoding) {
+ if (ResultSeqString::kHasOneByteEncoding) {
answer = Handle<ResultSeqString>::cast(
isolate->factory()->NewRawOneByteString(new_length).ToHandleChecked());
} else {
@@ -4193,14 +4187,14 @@ int Runtime::StringMatch(Isolate* isolate,
pat = String::Flatten(pat);
DisallowHeapAllocation no_gc; // ensure vectors stay valid
- // Extract flattened substrings of cons strings before determining asciiness.
+ // Extract flattened substrings of cons strings before getting encoding.
String::FlatContent seq_sub = sub->GetFlatContent();
String::FlatContent seq_pat = pat->GetFlatContent();
// dispatch on type of strings
- if (seq_pat.IsAscii()) {
+ if (seq_pat.IsOneByte()) {
Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector();
- if (seq_sub.IsAscii()) {
+ if (seq_sub.IsOneByte()) {
return SearchString(isolate,
seq_sub.ToOneByteVector(),
pat_vector,
@@ -4212,7 +4206,7 @@ int Runtime::StringMatch(Isolate* isolate,
start_index);
}
Vector<const uc16> pat_vector = seq_pat.ToUC16Vector();
- if (seq_sub.IsAscii()) {
+ if (seq_sub.IsOneByte()) {
return SearchString(isolate,
seq_sub.ToOneByteVector(),
pat_vector,
@@ -4308,9 +4302,9 @@ RUNTIME_FUNCTION(Runtime_StringLastIndexOf) {
String::FlatContent sub_content = sub->GetFlatContent();
String::FlatContent pat_content = pat->GetFlatContent();
- if (pat_content.IsAscii()) {
+ if (pat_content.IsOneByte()) {
Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector();
- if (sub_content.IsAscii()) {
+ if (sub_content.IsOneByte()) {
position = StringMatchBackwards(sub_content.ToOneByteVector(),
pat_vector,
start_index);
@@ -4321,7 +4315,7 @@ RUNTIME_FUNCTION(Runtime_StringLastIndexOf) {
}
} else {
Vector<const uc16> pat_vector = pat_content.ToUC16Vector();
- if (sub_content.IsAscii()) {
+ if (sub_content.IsOneByte()) {
position = StringMatchBackwards(sub_content.ToOneByteVector(),
pat_vector,
start_index);
@@ -6346,7 +6340,7 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
String::FlatContent flat = subject->GetFlatContent();
// ECMA-262 section 15.1.2.3, empty string is NaN
- if (flat.IsAscii()) {
+ if (flat.IsOneByte()) {
value = StringToInt(
isolate->unicode_cache(), flat.ToOneByteVector(), radix);
} else {
@@ -6804,21 +6798,19 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
}
-// Copies ASCII characters to the given fixed array looking up
+// Copies Latin1 characters to the given fixed array looking up
// one-char strings in the cache. Gives up on the first char that is
// 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 uint8_t* chars,
- FixedArray* elements,
- int length) {
+static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars,
+ FixedArray* elements, int length) {
DisallowHeapAllocation no_gc;
- FixedArray* ascii_cache = heap->single_character_string_cache();
+ FixedArray* one_byte_cache = heap->single_character_string_cache();
Object* undefined = heap->undefined_value();
int i;
WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
for (i = 0; i < length; ++i) {
- Object* value = ascii_cache->get(chars[i]);
+ Object* value = one_byte_cache->get(chars[i]);
if (value == undefined) break;
elements->set(i, value, mode);
}
@@ -6856,14 +6848,12 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
DisallowHeapAllocation no_gc;
String::FlatContent content = s->GetFlatContent();
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
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(),
- chars.start(),
- *elements,
- length);
+ position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
+ *elements, length);
} else {
MemsetPointer(elements->data_start(),
isolate->heap()->undefined_value(),
@@ -7320,7 +7310,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
}
DCHECK(sink == end);
- // Use %_FastAsciiArrayJoin instead.
+ // Use %_FastOneByteArrayJoin instead.
DCHECK(!answer->IsOneByteRepresentation());
return *answer;
}
@@ -7382,7 +7372,7 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
// Find total length of join result.
int string_length = 0;
- bool is_ascii = separator->IsOneByteRepresentation();
+ bool is_one_byte = separator->IsOneByteRepresentation();
bool overflow = false;
CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length());
RUNTIME_ASSERT(elements_length <= elements_array->elements()->length());
@@ -7399,8 +7389,8 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
for (int i = 0; i < elements_length; i += 2) {
String* string = String::cast(elements->get(i + 1));
int length = string->length();
- if (is_ascii && !string->IsOneByteRepresentation()) {
- is_ascii = false;
+ if (is_one_byte && !string->IsOneByteRepresentation()) {
+ is_one_byte = false;
}
if (length > String::kMaxLength ||
String::kMaxLength - length < string_length) {
@@ -7436,7 +7426,7 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError());
}
- if (is_ascii) {
+ if (is_one_byte) {
Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString(
string_length).ToHandleChecked();
JoinSparseArrayWithSeparator<uint8_t>(
@@ -7687,9 +7677,9 @@ RUNTIME_FUNCTION(Runtime_StringCompare) {
int r;
String::FlatContent x_content = x->GetFlatContent();
String::FlatContent y_content = y->GetFlatContent();
- if (x_content.IsAscii()) {
+ if (x_content.IsOneByte()) {
Vector<const uint8_t> x_chars = x_content.ToOneByteVector();
- if (y_content.IsAscii()) {
+ if (y_content.IsOneByte()) {
Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
} else {
@@ -7698,7 +7688,7 @@ RUNTIME_FUNCTION(Runtime_StringCompare) {
}
} else {
Vector<const uc16> x_chars = x_content.ToUC16Vector();
- if (y_content.IsAscii()) {
+ if (y_content.IsOneByte()) {
Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
} else {
@@ -8657,12 +8647,12 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
if (args.length() == 2 &&
unoptimized->kind() == Code::FUNCTION) {
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
- if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr")) && FLAG_use_osr) {
+ if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("osr")) && FLAG_use_osr) {
// Start patching from the currently patched loop nesting level.
DCHECK(BackEdgeTable::Verify(isolate, unoptimized));
isolate->runtime_profiler()->AttemptOnStackReplacement(
*function, Code::kMaxLoopNestingMarker);
- } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) &&
+ } else if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) &&
isolate->concurrent_recompilation_enabled()) {
function->MarkForConcurrentOptimization();
}
@@ -8690,7 +8680,7 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
bool sync_with_compiler_thread = true;
if (args.length() == 2) {
CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
- if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) {
+ if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
sync_with_compiler_thread = false;
}
}
@@ -9691,7 +9681,7 @@ RUNTIME_FUNCTION(Runtime_DateParseString) {
bool result;
String::FlatContent str_content = str->GetFlatContent();
- if (str_content.IsAscii()) {
+ if (str_content.IsOneByte()) {
result = DateParser::Parse(str_content.ToOneByteVector(),
*output_array,
isolate->unicode_cache());
@@ -9784,7 +9774,7 @@ RUNTIME_FUNCTION(Runtime_ParseJson) {
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
source = String::Flatten(source);
- // Optimized fast case where we only have ASCII characters.
+ // Optimized fast case where we only have Latin1 characters.
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
@@ -13890,7 +13880,7 @@ RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
return *factory->NewStringFromAsciiChecked(result);
}
- return *factory->NewStringFromStaticAscii("und");
+ return *factory->NewStringFromStaticChars("und");
}
@@ -13907,8 +13897,8 @@ RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) {
// Can be bumped when callers' requirements change.
RUNTIME_ASSERT(length < 100);
Handle<FixedArray> output = factory->NewFixedArray(length);
- Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized");
- Handle<Name> base = factory->NewStringFromStaticAscii("base");
+ Handle<Name> maximized = factory->NewStringFromStaticChars("maximized");
+ Handle<Name> base = factory->NewStringFromStaticChars("base");
for (unsigned int i = 0; i < length; ++i) {
Handle<Object> locale_id;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
@@ -14085,8 +14075,8 @@ RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("dateFormat");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("dateFormat");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the data format once GC kicks in.
@@ -14182,8 +14172,8 @@ RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("numberFormat");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("numberFormat");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
@@ -14288,8 +14278,8 @@ RUNTIME_FUNCTION(Runtime_CreateCollator) {
local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("collator");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("collator");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
@@ -14392,8 +14382,8 @@ RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("breakIterator");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("breakIterator");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the break iterator once GC kicks
@@ -14495,17 +14485,17 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
int32_t status = rule_based_iterator->getRuleStatus();
// Keep return values in sync with JavaScript BreakType enum.
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("none");
+ return *isolate->factory()->NewStringFromStaticChars("none");
} else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
return *isolate->factory()->number_string();
} else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("letter");
+ return *isolate->factory()->NewStringFromStaticChars("letter");
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("kana");
+ return *isolate->factory()->NewStringFromStaticChars("kana");
} else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("ideo");
+ return *isolate->factory()->NewStringFromStaticChars("ideo");
} else {
- return *isolate->factory()->NewStringFromStaticAscii("unknown");
+ return *isolate->factory()->NewStringFromStaticChars("unknown");
}
}
#endif // V8_I18N_SUPPORT
@@ -14800,21 +14790,21 @@ RUNTIME_FUNCTION(Runtime_ListNatives) {
Handle<FixedArray> elements = factory->NewFixedArray(entry_count);
int index = 0;
bool inline_runtime_functions = false;
-#define ADD_ENTRY(Name, argc, ressize) \
- { \
- HandleScope inner(isolate); \
- Handle<String> name; \
- /* Inline runtime functions have an underscore in front of the name. */ \
- if (inline_runtime_functions) { \
- name = factory->NewStringFromStaticAscii("_" #Name); \
- } else { \
- name = factory->NewStringFromStaticAscii(#Name); \
- } \
- Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
- pair_elements->set(0, *name); \
- pair_elements->set(1, Smi::FromInt(argc)); \
- Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
- elements->set(index++, *pair); \
+#define ADD_ENTRY(Name, argc, ressize) \
+ { \
+ HandleScope inner(isolate); \
+ Handle<String> name; \
+ /* Inline runtime functions have an underscore in front of the name. */ \
+ if (inline_runtime_functions) { \
+ name = factory->NewStringFromStaticChars("_" #Name); \
+ } else { \
+ name = factory->NewStringFromStaticChars(#Name); \
+ } \
+ Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
+ pair_elements->set(0, *name); \
+ pair_elements->set(1, Smi::FromInt(argc)); \
+ Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
+ elements->set(index++, *pair); \
}
inline_runtime_functions = false;
RUNTIME_FUNCTION_LIST(ADD_ENTRY)
@@ -15500,7 +15490,7 @@ RUNTIME_FUNCTION(RuntimeReference_GetCachedArrayIndex) {
}
-RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) {
+RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 2);
return isolate->heap()->undefined_value();
« src/jsregexp.cc ('K') | « src/runtime.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698