OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 control = graph()->NewNode(common()->IfSuccess(), effect); | 878 control = graph()->NewNode(common()->IfSuccess(), effect); |
879 break; | 879 break; |
880 } | 880 } |
881 } | 881 } |
882 } else { | 882 } else { |
883 DCHECK(access_info.IsDataField()); | 883 DCHECK(access_info.IsDataField()); |
884 FieldIndex const field_index = access_info.field_index(); | 884 FieldIndex const field_index = access_info.field_index(); |
885 Type* const field_type = access_info.field_type(); | 885 Type* const field_type = access_info.field_type(); |
886 MachineRepresentation const field_representation = | 886 MachineRepresentation const field_representation = |
887 access_info.field_representation(); | 887 access_info.field_representation(); |
888 if (access_mode == AccessMode::kLoad && | 888 if (access_mode == AccessMode::kLoad) { |
889 access_info.holder().ToHandle(&holder)) { | 889 if (access_info.holder().ToHandle(&holder)) { |
890 receiver = jsgraph()->Constant(holder); | 890 receiver = jsgraph()->Constant(holder); |
| 891 } |
| 892 // Optimize immutable property loads. |
| 893 HeapObjectMatcher m(receiver); |
| 894 if (m.HasValue() && m.Value()->IsJSObject()) { |
| 895 // TODO(turbofan): Given that we already have the field_index here, we |
| 896 // might be smarter in the future and not rely on the LookupIterator, |
| 897 // but for now let's just do what Crankshaft does. |
| 898 LookupIterator it(m.Value(), name, |
| 899 LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 900 if (it.IsFound() && it.IsReadOnly() && !it.IsConfigurable()) { |
| 901 Node* value = jsgraph()->Constant(JSReceiver::GetDataProperty(&it)); |
| 902 return ValueEffectControl(value, effect, control); |
| 903 } |
| 904 } |
891 } | 905 } |
892 Node* storage = receiver; | 906 Node* storage = receiver; |
893 if (!field_index.is_inobject()) { | 907 if (!field_index.is_inobject()) { |
894 storage = effect = graph()->NewNode( | 908 storage = effect = graph()->NewNode( |
895 simplified()->LoadField(AccessBuilder::ForJSObjectProperties()), | 909 simplified()->LoadField(AccessBuilder::ForJSObjectProperties()), |
896 storage, effect, control); | 910 storage, effect, control); |
897 } | 911 } |
898 FieldAccess field_access = { | 912 FieldAccess field_access = { |
899 kTaggedBase, | 913 kTaggedBase, |
900 field_index.offset(), | 914 field_index.offset(), |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 } | 1529 } |
1516 | 1530 |
1517 | 1531 |
1518 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1532 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1519 return jsgraph()->simplified(); | 1533 return jsgraph()->simplified(); |
1520 } | 1534 } |
1521 | 1535 |
1522 } // namespace compiler | 1536 } // namespace compiler |
1523 } // namespace internal | 1537 } // namespace internal |
1524 } // namespace v8 | 1538 } // namespace v8 |
OLD | NEW |