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); |
} |
} |