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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 field_access.write_barrier_kind = kNoWriteBarrier; | 1190 field_access.write_barrier_kind = kNoWriteBarrier; |
1191 break; | 1191 break; |
1192 } | 1192 } |
1193 case MachineRepresentation::kTaggedPointer: { | 1193 case MachineRepresentation::kTaggedPointer: { |
1194 // Ensure that {value} is a HeapObject. | 1194 // Ensure that {value} is a HeapObject. |
1195 value = BuildCheckHeapObject(value, &effect, control); | 1195 value = BuildCheckHeapObject(value, &effect, control); |
1196 Handle<Map> field_map; | 1196 Handle<Map> field_map; |
1197 if (access_info.field_map().ToHandle(&field_map)) { | 1197 if (access_info.field_map().ToHandle(&field_map)) { |
1198 // Emit a map check for the value. | 1198 // Emit a map check for the value. |
1199 effect = graph()->NewNode( | 1199 effect = graph()->NewNode( |
1200 simplified()->CheckMaps(ZoneHandleSet<Map>(field_map)), value, | 1200 simplified()->CheckMaps(CheckMapsFlag::kNone, |
1201 effect, control); | 1201 ZoneHandleSet<Map>(field_map)), |
| 1202 value, effect, control); |
1202 } | 1203 } |
1203 field_access.write_barrier_kind = kPointerWriteBarrier; | 1204 field_access.write_barrier_kind = kPointerWriteBarrier; |
1204 break; | 1205 break; |
1205 } | 1206 } |
1206 case MachineRepresentation::kTagged: | 1207 case MachineRepresentation::kTagged: |
1207 break; | 1208 break; |
1208 case MachineRepresentation::kNone: | 1209 case MachineRepresentation::kNone: |
1209 case MachineRepresentation::kBit: | 1210 case MachineRepresentation::kBit: |
1210 case MachineRepresentation::kWord8: | 1211 case MachineRepresentation::kWord8: |
1211 case MachineRepresentation::kWord16: | 1212 case MachineRepresentation::kWord16: |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 } else { | 1513 } else { |
1513 // Load the elements for the {receiver}. | 1514 // Load the elements for the {receiver}. |
1514 Node* elements = effect = graph()->NewNode( | 1515 Node* elements = effect = graph()->NewNode( |
1515 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), receiver, | 1516 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), receiver, |
1516 effect, control); | 1517 effect, control); |
1517 | 1518 |
1518 // Don't try to store to a copy-on-write backing store. | 1519 // Don't try to store to a copy-on-write backing store. |
1519 if (access_mode == AccessMode::kStore && | 1520 if (access_mode == AccessMode::kStore && |
1520 IsFastSmiOrObjectElementsKind(elements_kind) && | 1521 IsFastSmiOrObjectElementsKind(elements_kind) && |
1521 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { | 1522 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { |
1522 effect = graph()->NewNode(simplified()->CheckMaps(ZoneHandleSet<Map>( | 1523 effect = graph()->NewNode( |
1523 factory()->fixed_array_map())), | 1524 simplified()->CheckMaps( |
1524 elements, effect, control); | 1525 CheckMapsFlag::kNone, |
| 1526 ZoneHandleSet<Map>(factory()->fixed_array_map())), |
| 1527 elements, effect, control); |
1525 } | 1528 } |
1526 | 1529 |
1527 // Check if the {receiver} is a JSArray. | 1530 // Check if the {receiver} is a JSArray. |
1528 bool receiver_is_jsarray = HasOnlyJSArrayMaps(receiver_maps); | 1531 bool receiver_is_jsarray = HasOnlyJSArrayMaps(receiver_maps); |
1529 | 1532 |
1530 // Load the length of the {receiver}. | 1533 // Load the length of the {receiver}. |
1531 Node* length = effect = | 1534 Node* length = effect = |
1532 receiver_is_jsarray | 1535 receiver_is_jsarray |
1533 ? graph()->NewNode( | 1536 ? graph()->NewNode( |
1534 simplified()->LoadField( | 1537 simplified()->LoadField( |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 if (receiver_map->is_stable()) { | 1744 if (receiver_map->is_stable()) { |
1742 for (Handle<Map> map : receiver_maps) { | 1745 for (Handle<Map> map : receiver_maps) { |
1743 if (map.is_identical_to(receiver_map)) { | 1746 if (map.is_identical_to(receiver_map)) { |
1744 dependencies()->AssumeMapStable(receiver_map); | 1747 dependencies()->AssumeMapStable(receiver_map); |
1745 return effect; | 1748 return effect; |
1746 } | 1749 } |
1747 } | 1750 } |
1748 } | 1751 } |
1749 } | 1752 } |
1750 ZoneHandleSet<Map> maps; | 1753 ZoneHandleSet<Map> maps; |
| 1754 CheckMapsFlags flags = CheckMapsFlag::kNone; |
1751 for (Handle<Map> map : receiver_maps) { | 1755 for (Handle<Map> map : receiver_maps) { |
1752 maps.insert(map, graph()->zone()); | 1756 maps.insert(map, graph()->zone()); |
| 1757 if (map->is_migration_target()) { |
| 1758 flags |= CheckMapsFlag::kTryMigrateInstance; |
| 1759 } |
1753 } | 1760 } |
1754 return graph()->NewNode(simplified()->CheckMaps(maps), receiver, effect, | 1761 return graph()->NewNode(simplified()->CheckMaps(flags, maps), receiver, |
1755 control); | 1762 effect, control); |
1756 } | 1763 } |
1757 | 1764 |
1758 void JSNativeContextSpecialization::AssumePrototypesStable( | 1765 void JSNativeContextSpecialization::AssumePrototypesStable( |
1759 std::vector<Handle<Map>> const& receiver_maps, Handle<JSObject> holder) { | 1766 std::vector<Handle<Map>> const& receiver_maps, Handle<JSObject> holder) { |
1760 // Determine actual holder and perform prototype chain checks. | 1767 // Determine actual holder and perform prototype chain checks. |
1761 for (auto map : receiver_maps) { | 1768 for (auto map : receiver_maps) { |
1762 // Perform the implicit ToObject for primitives here. | 1769 // Perform the implicit ToObject for primitives here. |
1763 // Implemented according to ES6 section 7.3.2 GetV (V, P). | 1770 // Implemented according to ES6 section 7.3.2 GetV (V, P). |
1764 Handle<JSFunction> constructor; | 1771 Handle<JSFunction> constructor; |
1765 if (Map::GetConstructorFunction(map, native_context()) | 1772 if (Map::GetConstructorFunction(map, native_context()) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 return jsgraph()->javascript(); | 1919 return jsgraph()->javascript(); |
1913 } | 1920 } |
1914 | 1921 |
1915 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1922 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1916 return jsgraph()->simplified(); | 1923 return jsgraph()->simplified(); |
1917 } | 1924 } |
1918 | 1925 |
1919 } // namespace compiler | 1926 } // namespace compiler |
1920 } // namespace internal | 1927 } // namespace internal |
1921 } // namespace v8 | 1928 } // namespace v8 |
OLD | NEW |