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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 field_access.write_barrier_kind = kNoWriteBarrier; | 990 field_access.write_barrier_kind = kNoWriteBarrier; |
991 break; | 991 break; |
992 } | 992 } |
993 case MachineRepresentation::kTaggedPointer: { | 993 case MachineRepresentation::kTaggedPointer: { |
994 // Ensure that {value} is a HeapObject. | 994 // Ensure that {value} is a HeapObject. |
995 value = effect = graph()->NewNode(simplified()->CheckHeapObject(), | 995 value = effect = graph()->NewNode(simplified()->CheckHeapObject(), |
996 value, effect, control); | 996 value, effect, control); |
997 Handle<Map> field_map; | 997 Handle<Map> field_map; |
998 if (access_info.field_map().ToHandle(&field_map)) { | 998 if (access_info.field_map().ToHandle(&field_map)) { |
999 // Emit a map check for the value. | 999 // Emit a map check for the value. |
1000 effect = graph()->NewNode(simplified()->CheckMaps(1), value, | 1000 effect = graph()->NewNode( |
1001 jsgraph()->HeapConstant(field_map), | 1001 simplified()->CheckMaps(ZoneHandleSet<Map>(field_map)), value, |
1002 effect, control); | 1002 effect, control); |
1003 } | 1003 } |
1004 field_access.write_barrier_kind = kPointerWriteBarrier; | 1004 field_access.write_barrier_kind = kPointerWriteBarrier; |
1005 break; | 1005 break; |
1006 } | 1006 } |
1007 case MachineRepresentation::kTagged: | 1007 case MachineRepresentation::kTagged: |
1008 break; | 1008 break; |
1009 case MachineRepresentation::kNone: | 1009 case MachineRepresentation::kNone: |
1010 case MachineRepresentation::kBit: | 1010 case MachineRepresentation::kBit: |
1011 case MachineRepresentation::kWord8: | 1011 case MachineRepresentation::kWord8: |
1012 case MachineRepresentation::kWord16: | 1012 case MachineRepresentation::kWord16: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 | 1067 |
1068 // Load the elements for the {receiver}. | 1068 // Load the elements for the {receiver}. |
1069 Node* elements = effect = graph()->NewNode( | 1069 Node* elements = effect = graph()->NewNode( |
1070 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), receiver, | 1070 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), receiver, |
1071 effect, control); | 1071 effect, control); |
1072 | 1072 |
1073 // Don't try to store to a copy-on-write backing store. | 1073 // Don't try to store to a copy-on-write backing store. |
1074 if (access_mode == AccessMode::kStore && | 1074 if (access_mode == AccessMode::kStore && |
1075 IsFastSmiOrObjectElementsKind(elements_kind) && | 1075 IsFastSmiOrObjectElementsKind(elements_kind) && |
1076 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { | 1076 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { |
1077 effect = | 1077 effect = graph()->NewNode(simplified()->CheckMaps(ZoneHandleSet<Map>( |
1078 graph()->NewNode(simplified()->CheckMaps(1), elements, | 1078 factory()->fixed_array_map())), |
1079 jsgraph()->FixedArrayMapConstant(), effect, control); | 1079 elements, effect, control); |
1080 } | 1080 } |
1081 | 1081 |
1082 if (IsFixedTypedArrayElementsKind(elements_kind)) { | 1082 if (IsFixedTypedArrayElementsKind(elements_kind)) { |
1083 // Load the {receiver}s length. | 1083 // Load the {receiver}s length. |
1084 Node* length = effect = graph()->NewNode( | 1084 Node* length = effect = graph()->NewNode( |
1085 simplified()->LoadField(AccessBuilder::ForJSTypedArrayLength()), | 1085 simplified()->LoadField(AccessBuilder::ForJSTypedArrayLength()), |
1086 receiver, effect, control); | 1086 receiver, effect, control); |
1087 | 1087 |
1088 // Check if the {receiver}s buffer was neutered. | 1088 // Check if the {receiver}s buffer was neutered. |
1089 Node* buffer = effect = graph()->NewNode( | 1089 Node* buffer = effect = graph()->NewNode( |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 effect = graph()->NewNode(simplified()->StoreElement(element_access), | 1296 effect = graph()->NewNode(simplified()->StoreElement(element_access), |
1297 elements, index, value, effect, control); | 1297 elements, index, value, effect, control); |
1298 } | 1298 } |
1299 } | 1299 } |
1300 | 1300 |
1301 return ValueEffectControl(value, effect, control); | 1301 return ValueEffectControl(value, effect, control); |
1302 } | 1302 } |
1303 | 1303 |
1304 Node* JSNativeContextSpecialization::BuildCheckMaps( | 1304 Node* JSNativeContextSpecialization::BuildCheckMaps( |
1305 Node* receiver, Node* effect, Node* control, | 1305 Node* receiver, Node* effect, Node* control, |
1306 std::vector<Handle<Map>> const& maps) { | 1306 std::vector<Handle<Map>> const& receiver_maps) { |
1307 HeapObjectMatcher m(receiver); | 1307 HeapObjectMatcher m(receiver); |
1308 if (m.HasValue()) { | 1308 if (m.HasValue()) { |
1309 Handle<Map> receiver_map(m.Value()->map(), isolate()); | 1309 Handle<Map> receiver_map(m.Value()->map(), isolate()); |
1310 if (receiver_map->is_stable()) { | 1310 if (receiver_map->is_stable()) { |
1311 for (Handle<Map> map : maps) { | 1311 for (Handle<Map> map : receiver_maps) { |
1312 if (map.is_identical_to(receiver_map)) { | 1312 if (map.is_identical_to(receiver_map)) { |
1313 dependencies()->AssumeMapStable(receiver_map); | 1313 dependencies()->AssumeMapStable(receiver_map); |
1314 return effect; | 1314 return effect; |
1315 } | 1315 } |
1316 } | 1316 } |
1317 } | 1317 } |
1318 } | 1318 } |
1319 int const map_input_count = static_cast<int>(maps.size()); | 1319 // TODO(turbofan): This could be more efficient. |
1320 int const input_count = 1 + map_input_count + 1 + 1; | 1320 ZoneHandleSet<Map> maps; |
1321 Node** inputs = zone()->NewArray<Node*>(input_count); | 1321 for (Handle<Map> map : receiver_maps) { |
1322 inputs[0] = receiver; | 1322 maps.insert(map, graph()->zone()); |
1323 for (int i = 0; i < map_input_count; ++i) { | |
1324 inputs[1 + i] = jsgraph()->HeapConstant(maps[i]); | |
1325 } | 1323 } |
1326 inputs[input_count - 2] = effect; | 1324 return graph()->NewNode(simplified()->CheckMaps(maps), receiver, effect, |
1327 inputs[input_count - 1] = control; | 1325 control); |
1328 return graph()->NewNode(simplified()->CheckMaps(map_input_count), input_count, | |
1329 inputs); | |
1330 } | 1326 } |
1331 | 1327 |
1332 Node* JSNativeContextSpecialization::BuildCheckHeapObject(Node* receiver, | 1328 Node* JSNativeContextSpecialization::BuildCheckHeapObject(Node* receiver, |
1333 Node* effect, | 1329 Node* effect, |
1334 Node* control) { | 1330 Node* control) { |
1335 switch (receiver->opcode()) { | 1331 switch (receiver->opcode()) { |
1336 case IrOpcode::kHeapConstant: | 1332 case IrOpcode::kHeapConstant: |
1337 case IrOpcode::kJSCreate: | 1333 case IrOpcode::kJSCreate: |
1338 case IrOpcode::kJSCreateArguments: | 1334 case IrOpcode::kJSCreateArguments: |
1339 case IrOpcode::kJSCreateArray: | 1335 case IrOpcode::kJSCreateArray: |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 } | 1525 } |
1530 | 1526 |
1531 | 1527 |
1532 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1528 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1533 return jsgraph()->simplified(); | 1529 return jsgraph()->simplified(); |
1534 } | 1530 } |
1535 | 1531 |
1536 } // namespace compiler | 1532 } // namespace compiler |
1537 } // namespace internal | 1533 } // namespace internal |
1538 } // namespace v8 | 1534 } // namespace v8 |
OLD | NEW |