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

Unified Diff: src/compiler/js-native-context-specialization.cc

Issue 2442233002: [turbofan] Constant-fold "length" property on strings. (Closed)
Patch Set: Created 4 years, 2 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/compiler/js-native-context-specialization.cc
diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc
index 8e142bfa9d21186af96ad8d7c75c19cc28c82b21..5f48a14b9e9ccc0e1f8a211570d16abd15d56132 100644
--- a/src/compiler/js-native-context-specialization.cc
+++ b/src/compiler/js-native-context-specialization.cc
@@ -360,9 +360,9 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
// Check if we have a constant receiver.
HeapObjectMatcher m(receiver);
if (m.HasValue()) {
- // Optimize "prototype" property of functions.
if (m.Value()->IsJSFunction() &&
p.name().is_identical_to(factory()->prototype_string())) {
+ // Optimize "prototype" property of functions.
Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
if (function->has_initial_map()) {
// We need to add a code dependency on the initial map of the
@@ -378,6 +378,13 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
return Replace(value);
}
}
+ } else if (m.Value()->IsString() &&
+ p.name().is_identical_to(factory()->length_string())) {
+ // Constant-fold "length" property on constant strings.
+ Handle<String> string = Handle<String>::cast(m.Value());
+ Node* value = jsgraph()->Constant(string->length());
+ ReplaceWithValue(node, value);
+ return Replace(value);
}
}
« 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