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

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

Issue 2376033002: [turbofan] Properly optimize immutable property loads. (Closed)
Patch Set: Now with green bots. Created 4 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
« 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 b5da47068e9749121bf8ef304d8ee485bb90b9c9..6de3fa1282439b3fe556415f2385ca62429e3c1d 100644
--- a/src/compiler/js-native-context-specialization.cc
+++ b/src/compiler/js-native-context-specialization.cc
@@ -885,9 +885,23 @@ JSNativeContextSpecialization::BuildPropertyAccess(
Type* const field_type = access_info.field_type();
MachineRepresentation const field_representation =
access_info.field_representation();
- if (access_mode == AccessMode::kLoad &&
- access_info.holder().ToHandle(&holder)) {
- receiver = jsgraph()->Constant(holder);
+ if (access_mode == AccessMode::kLoad) {
+ if (access_info.holder().ToHandle(&holder)) {
+ receiver = jsgraph()->Constant(holder);
+ }
+ // Optimize immutable property loads.
+ HeapObjectMatcher m(receiver);
+ if (m.HasValue() && m.Value()->IsJSObject()) {
+ // TODO(turbofan): Given that we already have the field_index here, we
+ // might be smarter in the future and not rely on the LookupIterator,
+ // but for now let's just do what Crankshaft does.
+ LookupIterator it(m.Value(), name,
+ LookupIterator::OWN_SKIP_INTERCEPTOR);
+ if (it.IsFound() && it.IsReadOnly() && !it.IsConfigurable()) {
+ Node* value = jsgraph()->Constant(JSReceiver::GetDataProperty(&it));
+ return ValueEffectControl(value, effect, control);
+ }
+ }
}
Node* storage = receiver;
if (!field_index.is_inobject()) {
« 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