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

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

Issue 2290233002: [turbofan] Introduce MachineRepresentation to PropertyAccessInfo. (Closed)
Patch Set: REBASE and comments. 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 unified diff | Download patch
« no previous file with comments | « src/compiler/access-info.cc ('k') | src/compiler/type-cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 3, VectorSlotPair(), ConvertReceiverMode::kNotNullOrUndefined), 874 3, VectorSlotPair(), ConvertReceiverMode::kNotNullOrUndefined),
875 target, receiver, value, context, frame_state0, effect, control); 875 target, receiver, value, context, frame_state0, effect, control);
876 control = graph()->NewNode(common()->IfSuccess(), effect); 876 control = graph()->NewNode(common()->IfSuccess(), effect);
877 break; 877 break;
878 } 878 }
879 } 879 }
880 } else { 880 } else {
881 DCHECK(access_info.IsDataField()); 881 DCHECK(access_info.IsDataField());
882 FieldIndex const field_index = access_info.field_index(); 882 FieldIndex const field_index = access_info.field_index();
883 Type* const field_type = access_info.field_type(); 883 Type* const field_type = access_info.field_type();
884 MachineRepresentation const rep = access_info.field_representation();
884 if (access_mode == AccessMode::kLoad && 885 if (access_mode == AccessMode::kLoad &&
885 access_info.holder().ToHandle(&holder)) { 886 access_info.holder().ToHandle(&holder)) {
886 receiver = jsgraph()->Constant(holder); 887 receiver = jsgraph()->Constant(holder);
887 } 888 }
888 Node* storage = receiver; 889 Node* storage = receiver;
889 if (!field_index.is_inobject()) { 890 if (!field_index.is_inobject()) {
890 storage = effect = graph()->NewNode( 891 storage = effect = graph()->NewNode(
891 simplified()->LoadField(AccessBuilder::ForJSObjectProperties()), 892 simplified()->LoadField(AccessBuilder::ForJSObjectProperties()),
892 storage, effect, control); 893 storage, effect, control);
893 } 894 }
894 FieldAccess field_access = { 895 FieldAccess field_access = {
895 kTaggedBase, field_index.offset(), name, 896 kTaggedBase, field_index.offset(), name,
896 field_type, MachineType::AnyTagged(), kFullWriteBarrier}; 897 field_type, MachineType::AnyTagged(), kFullWriteBarrier};
897 if (access_mode == AccessMode::kLoad) { 898 if (access_mode == AccessMode::kLoad) {
898 if (field_type->Is(Type::UntaggedFloat64())) { 899 if (rep == MachineRepresentation::kFloat64) {
899 // TODO(turbofan): We remove the representation axis from the type to
900 // avoid uninhabited representation types. This is a workaround until
901 // the {PropertyAccessInfo} is using {MachineRepresentation} instead.
902 field_access.type = Type::Union(
903 field_type, Type::Representation(Type::Number(), zone()), zone());
904 if (!field_index.is_inobject() || field_index.is_hidden_field() || 900 if (!field_index.is_inobject() || field_index.is_hidden_field() ||
905 !FLAG_unbox_double_fields) { 901 !FLAG_unbox_double_fields) {
906 storage = effect = graph()->NewNode( 902 storage = effect = graph()->NewNode(
907 simplified()->LoadField(field_access), storage, effect, control); 903 simplified()->LoadField(field_access), storage, effect, control);
908 field_access.offset = HeapNumber::kValueOffset; 904 field_access.offset = HeapNumber::kValueOffset;
909 field_access.name = MaybeHandle<Name>(); 905 field_access.name = MaybeHandle<Name>();
910 } 906 }
911 field_access.machine_type = MachineType::Float64(); 907 field_access.machine_type = MachineType::Float64();
912 } 908 }
913 value = effect = graph()->NewNode(simplified()->LoadField(field_access), 909 value = effect = graph()->NewNode(simplified()->LoadField(field_access),
914 storage, effect, control); 910 storage, effect, control);
915 } else { 911 } else {
916 DCHECK_EQ(AccessMode::kStore, access_mode); 912 DCHECK_EQ(AccessMode::kStore, access_mode);
917 if (field_type->Is(Type::UntaggedFloat64())) { 913 if (rep == MachineRepresentation::kFloat64) {
918 // TODO(turbofan): We remove the representation axis from the type to
919 // avoid uninhabited representation types. This is a workaround until
920 // the {PropertyAccessInfo} is using {MachineRepresentation} instead.
921 field_access.type = Type::Union(
922 field_type, Type::Representation(Type::Number(), zone()), zone());
923 value = effect = graph()->NewNode(simplified()->CheckNumber(), value, 914 value = effect = graph()->NewNode(simplified()->CheckNumber(), value,
924 effect, control); 915 effect, control);
925 916
926 if (!field_index.is_inobject() || field_index.is_hidden_field() || 917 if (!field_index.is_inobject() || field_index.is_hidden_field() ||
927 !FLAG_unbox_double_fields) { 918 !FLAG_unbox_double_fields) {
928 if (access_info.HasTransitionMap()) { 919 if (access_info.HasTransitionMap()) {
929 // Allocate a MutableHeapNumber for the new property. 920 // Allocate a MutableHeapNumber for the new property.
930 effect = graph()->NewNode( 921 effect = graph()->NewNode(
931 common()->BeginRegion(RegionObservability::kNotObservable), 922 common()->BeginRegion(RegionObservability::kNotObservable),
932 effect); 923 effect);
933 Node* box = effect = graph()->NewNode( 924 Node* box = effect = graph()->NewNode(
934 simplified()->Allocate(NOT_TENURED), 925 simplified()->Allocate(NOT_TENURED),
935 jsgraph()->Constant(HeapNumber::kSize), effect, control); 926 jsgraph()->Constant(HeapNumber::kSize), effect, control);
936 effect = graph()->NewNode( 927 effect = graph()->NewNode(
937 simplified()->StoreField(AccessBuilder::ForMap()), box, 928 simplified()->StoreField(AccessBuilder::ForMap()), box,
938 jsgraph()->HeapConstant(factory()->mutable_heap_number_map()), 929 jsgraph()->HeapConstant(factory()->mutable_heap_number_map()),
939 effect, control); 930 effect, control);
940 effect = graph()->NewNode( 931 effect = graph()->NewNode(
941 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), 932 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()),
942 box, value, effect, control); 933 box, value, effect, control);
943 value = effect = 934 value = effect =
944 graph()->NewNode(common()->FinishRegion(), box, effect); 935 graph()->NewNode(common()->FinishRegion(), box, effect);
945 936
946 field_access.type = Type::TaggedPointer(); 937 field_access.type = Type::TaggedPointer();
938 field_access.machine_type = MachineType::TaggedPointer();
947 } else { 939 } else {
948 // We just store directly to the MutableHeapNumber. 940 // We just store directly to the MutableHeapNumber.
949 storage = effect = 941 storage = effect =
950 graph()->NewNode(simplified()->LoadField(field_access), storage, 942 graph()->NewNode(simplified()->LoadField(field_access), storage,
951 effect, control); 943 effect, control);
952 field_access.offset = HeapNumber::kValueOffset; 944 field_access.offset = HeapNumber::kValueOffset;
953 field_access.name = MaybeHandle<Name>(); 945 field_access.name = MaybeHandle<Name>();
954 field_access.machine_type = MachineType::Float64(); 946 field_access.machine_type = MachineType::Float64();
955 } 947 }
956 } else { 948 } else {
957 // Unboxed double field, we store directly to the field. 949 // Unboxed double field, we store directly to the field.
958 field_access.machine_type = MachineType::Float64(); 950 field_access.machine_type = MachineType::Float64();
959 } 951 }
960 } else if (field_type->Is(Type::TaggedSigned())) { 952 } else if (rep == MachineRepresentation::kTaggedSigned) {
961 value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(), 953 value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
962 value, effect, control); 954 value, effect, control);
963 } else if (field_type->Is(Type::TaggedPointer())) { 955 } else if (rep == MachineRepresentation::kTaggedPointer) {
964 // Ensure that {value} is a HeapObject. 956 // Ensure that {value} is a HeapObject.
965 value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(), 957 value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
966 value, effect, control); 958 value, effect, control);
967 if (field_type->NumClasses() == 1) { 959 if (field_type->NumClasses() == 1) {
968 // Emit a map check for the value. 960 // Emit a map check for the value.
969 Node* field_map = 961 Node* field_map =
970 jsgraph()->Constant(field_type->Classes().Current()); 962 jsgraph()->Constant(field_type->Classes().Current());
971 effect = graph()->NewNode(simplified()->CheckMaps(1), value, 963 effect = graph()->NewNode(simplified()->CheckMaps(1), value,
972 field_map, effect, control); 964 field_map, effect, control);
973 } else { 965 } else {
974 DCHECK_EQ(0, field_type->NumClasses()); 966 DCHECK_EQ(0, field_type->NumClasses());
975 } 967 }
976 } else { 968 } else {
977 DCHECK(field_type->Is(Type::Tagged())); 969 // DCHECK(field_type->Is(Type::Tagged()));
970 DCHECK(rep == MachineRepresentation::kTagged);
978 } 971 }
979 Handle<Map> transition_map; 972 Handle<Map> transition_map;
980 if (access_info.transition_map().ToHandle(&transition_map)) { 973 if (access_info.transition_map().ToHandle(&transition_map)) {
981 effect = graph()->NewNode( 974 effect = graph()->NewNode(
982 common()->BeginRegion(RegionObservability::kObservable), effect); 975 common()->BeginRegion(RegionObservability::kObservable), effect);
983 effect = graph()->NewNode( 976 effect = graph()->NewNode(
984 simplified()->StoreField(AccessBuilder::ForMap()), receiver, 977 simplified()->StoreField(AccessBuilder::ForMap()), receiver,
985 jsgraph()->Constant(transition_map), effect, control); 978 jsgraph()->Constant(transition_map), effect, control);
986 } 979 }
987 effect = graph()->NewNode(simplified()->StoreField(field_access), storage, 980 effect = graph()->NewNode(simplified()->StoreField(field_access), storage,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 } 1154 }
1162 1155
1163 // Compute the element access. 1156 // Compute the element access.
1164 Type* element_type = Type::NonInternal(); 1157 Type* element_type = Type::NonInternal();
1165 MachineType element_machine_type = MachineType::AnyTagged(); 1158 MachineType element_machine_type = MachineType::AnyTagged();
1166 if (IsFastDoubleElementsKind(elements_kind)) { 1159 if (IsFastDoubleElementsKind(elements_kind)) {
1167 element_type = Type::Number(); 1160 element_type = Type::Number();
1168 element_machine_type = MachineType::Float64(); 1161 element_machine_type = MachineType::Float64();
1169 } else if (IsFastSmiElementsKind(elements_kind)) { 1162 } else if (IsFastSmiElementsKind(elements_kind)) {
1170 element_type = type_cache_.kSmi; 1163 element_type = type_cache_.kSmi;
1164 element_machine_type = MachineType::TaggedSigned();
1171 } 1165 }
1172 ElementAccess element_access = {kTaggedBase, FixedArray::kHeaderSize, 1166 ElementAccess element_access = {kTaggedBase, FixedArray::kHeaderSize,
1173 element_type, element_machine_type, 1167 element_type, element_machine_type,
1174 kFullWriteBarrier}; 1168 kFullWriteBarrier};
1175 1169
1176 // Access the actual element. 1170 // Access the actual element.
1177 if (access_mode == AccessMode::kLoad) { 1171 if (access_mode == AccessMode::kLoad) {
1178 // Compute the real element access type, which includes the hole in case 1172 // Compute the real element access type, which includes the hole in case
1179 // of holey backing stores. 1173 // of holey backing stores.
1180 if (elements_kind == FAST_HOLEY_ELEMENTS || 1174 if (elements_kind == FAST_HOLEY_ELEMENTS ||
1181 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { 1175 elements_kind == FAST_HOLEY_SMI_ELEMENTS) {
1182 element_access.type = 1176 element_access.type =
1183 Type::Union(element_type, Type::Hole(), graph()->zone()); 1177 Type::Union(element_type, Type::Hole(), graph()->zone());
1178 element_access.machine_type = MachineType::AnyTagged();
1184 } 1179 }
1185 // Perform the actual backing store access. 1180 // Perform the actual backing store access.
1186 value = effect = 1181 value = effect =
1187 graph()->NewNode(simplified()->LoadElement(element_access), elements, 1182 graph()->NewNode(simplified()->LoadElement(element_access), elements,
1188 index, effect, control); 1183 index, effect, control);
1189 // Handle loading from holey backing stores correctly, by either mapping 1184 // Handle loading from holey backing stores correctly, by either mapping
1190 // the hole to undefined if possible, or deoptimizing otherwise. 1185 // the hole to undefined if possible, or deoptimizing otherwise.
1191 if (elements_kind == FAST_HOLEY_ELEMENTS || 1186 if (elements_kind == FAST_HOLEY_ELEMENTS ||
1192 elements_kind == FAST_HOLEY_SMI_ELEMENTS) { 1187 elements_kind == FAST_HOLEY_SMI_ELEMENTS) {
1193 // Check if we are allowed to turn the hole into undefined. 1188 // Check if we are allowed to turn the hole into undefined.
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 } 1481 }
1487 1482
1488 1483
1489 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 1484 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
1490 return jsgraph()->simplified(); 1485 return jsgraph()->simplified();
1491 } 1486 }
1492 1487
1493 } // namespace compiler 1488 } // namespace compiler
1494 } // namespace internal 1489 } // namespace internal
1495 } // namespace v8 1490 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-info.cc ('k') | src/compiler/type-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698