Commit 17512c37 authored by jgruber's avatar jgruber Committed by Commit bot

[string] Deduplicate in String.p.toLowerCase

Restore original behavior in that strings are deduplicated in lower-case
conversion (i.e. if the string is already lower-case, the original
string is returned).

BUG=v8:6353,v8:6412

Review-Url: https://codereview.chromium.org/2891853004
Cr-Commit-Position: refs/heads/master@{#45391}
parent 5e9fd385
......@@ -61,19 +61,30 @@ TF_BUILTIN(StringPrototypeToLowerCaseIntl, IntlBuiltinsAssembler) {
Node* const to_lower_table_addr = ExternalConstant(
ExternalReference::intl_to_latin1_lower_table(isolate()));
VariableList push_vars({&var_cursor}, zone());
VARIABLE(var_did_change, MachineRepresentation::kWord32, Int32Constant(0));
VariableList push_vars({&var_cursor, &var_did_change}, zone());
BuildFastLoop(
push_vars, start_address, end_address,
[=, &var_cursor](Node* current) {
Node* c = ChangeInt32ToIntPtr(Load(MachineType::Uint8(), current));
Node* lower = Load(MachineType::Uint8(), to_lower_table_addr, c);
[=, &var_cursor, &var_did_change](Node* current) {
Node* c = Load(MachineType::Uint8(), current);
Node* lower = Load(MachineType::Uint8(), to_lower_table_addr,
ChangeInt32ToIntPtr(c));
StoreNoWriteBarrier(MachineRepresentation::kWord8, dst_ptr,
var_cursor.value(), lower);
var_did_change.Bind(
Word32Or(Word32NotEqual(c, lower), var_did_change.value()));
Increment(var_cursor);
},
kCharSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
// All lower-case.
// Return the original string if it remained unchanged in order to preserve
// e.g. internalization and private symbols (such as the preserved object
// hash) on the source string.
GotoIfNot(var_did_change.value(), &return_string);
Return(dst);
}
......
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