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

Unified Diff: src/builtins/builtins-intl-gen.cc

Issue 2891853004: [string] Deduplicate in String.p.toLowerCase (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-intl-gen.cc
diff --git a/src/builtins/builtins-intl-gen.cc b/src/builtins/builtins-intl-gen.cc
index 4cf48c6419132432b5c70a552ff1272358ca60f5..3782d43a9a1b71a43fcf1fe1befdda9b9680c120 100644
--- a/src/builtins/builtins-intl-gen.cc
+++ b/src/builtins/builtins-intl-gen.cc
@@ -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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698