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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/compiler-source-position-table.h" | 9 #include "src/compiler/compiler-source-position-table.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1051 Node* check = __ Uint32LessThan(index, limit); | 1051 Node* check = __ Uint32LessThan(index, limit); |
1052 __ DeoptimizeUnless(DeoptimizeReason::kOutOfBounds, check, frame_state); | 1052 __ DeoptimizeUnless(DeoptimizeReason::kOutOfBounds, check, frame_state); |
1053 return index; | 1053 return index; |
1054 } | 1054 } |
1055 | 1055 |
1056 Node* EffectControlLinearizer::LowerCheckMaps(Node* node, Node* frame_state) { | 1056 Node* EffectControlLinearizer::LowerCheckMaps(Node* node, Node* frame_state) { |
1057 CheckMapsParameters const& p = CheckMapsParametersOf(node->op()); | 1057 CheckMapsParameters const& p = CheckMapsParametersOf(node->op()); |
1058 Node* value = node->InputAt(0); | 1058 Node* value = node->InputAt(0); |
1059 | 1059 |
1060 ZoneHandleSet<Map> const& maps = p.maps(); | 1060 ZoneHandleSet<Map> const& maps = p.maps(); |
1061 int const map_count = static_cast<int>(maps.size()); | 1061 size_t const map_count = maps.size(); |
1062 | 1062 |
1063 auto done = __ MakeLabelFor(GraphAssemblerLabelType::kNonDeferred, | 1063 if (p.flags() & CheckMapsFlag::kTryMigrateInstance) { |
1064 static_cast<size_t>(map_count)); | 1064 auto done = |
1065 __ MakeLabelFor(GraphAssemblerLabelType::kNonDeferred, map_count * 2); | |
1066 auto migrate = __ MakeDeferredLabel<1>(); | |
1065 | 1067 |
1066 // Load the current map of the {value}. | 1068 // Load the current map of the {value}. |
1067 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); | 1069 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); |
1068 | 1070 |
1069 for (int i = 0; i < map_count; ++i) { | 1071 // Perform the map checks. |
1070 Node* map = __ HeapConstant(maps[i]); | 1072 for (size_t i = 0; i < map_count; ++i) { |
1071 Node* check = __ WordEqual(value_map, map); | 1073 Node* map = __ HeapConstant(maps[i]); |
1072 if (i == map_count - 1) { | 1074 Node* check = __ WordEqual(value_map, map); |
1073 __ DeoptimizeUnless(DeoptimizeReason::kWrongMap, check, frame_state); | 1075 if (i == map_count - 1) { |
1074 } else { | 1076 __ GotoUnless(check, &migrate); |
Jarin
2017/01/13 12:05:38
__ Branch(check, &done, &migrate);
Benedikt Meurer
2017/01/13 12:08:10
Doesn't work with the current template magic, will
| |
1075 __ GotoIf(check, &done); | 1077 __ Goto(&done); |
1078 } else { | |
1079 __ GotoIf(check, &done); | |
1080 } | |
1076 } | 1081 } |
1082 | |
1083 // Perform the (deferred) instance migration. | |
1084 __ Bind(&migrate); | |
1085 { | |
1086 Operator::Properties properties = Operator::kNoDeopt | Operator::kNoThrow; | |
1087 Runtime::FunctionId id = Runtime::kTryMigrateInstance; | |
1088 CallDescriptor const* desc = Linkage::GetRuntimeCallDescriptor( | |
1089 graph()->zone(), id, 1, properties, CallDescriptor::kNoFlags); | |
1090 Node* result = | |
1091 __ Call(desc, __ CEntryStubConstant(1), value, | |
1092 __ ExternalConstant(ExternalReference(id, isolate())), | |
1093 __ Int32Constant(1), __ NoContextConstant()); | |
1094 Node* check = ObjectIsSmi(result); | |
1095 __ DeoptimizeIf(DeoptimizeReason::kInstanceMigrationFailed, check, | |
1096 frame_state); | |
1097 } | |
1098 | |
1099 // Reload the current map of the {value}. | |
1100 value_map = __ LoadField(AccessBuilder::ForMap(), value); | |
1101 | |
1102 // Perform the map checks again. | |
1103 for (size_t i = 0; i < map_count; ++i) { | |
1104 Node* map = __ HeapConstant(maps[i]); | |
1105 Node* check = __ WordEqual(value_map, map); | |
1106 if (i == map_count - 1) { | |
1107 __ DeoptimizeUnless(DeoptimizeReason::kWrongMap, check, frame_state); | |
1108 } else { | |
1109 __ GotoIf(check, &done); | |
1110 } | |
1111 } | |
1112 | |
1113 __ Goto(&done); | |
1114 __ Bind(&done); | |
1115 } else { | |
1116 auto done = | |
1117 __ MakeLabelFor(GraphAssemblerLabelType::kNonDeferred, map_count); | |
1118 | |
1119 // Load the current map of the {value}. | |
1120 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); | |
1121 | |
1122 for (size_t i = 0; i < map_count; ++i) { | |
1123 Node* map = __ HeapConstant(maps[i]); | |
1124 Node* check = __ WordEqual(value_map, map); | |
1125 if (i == map_count - 1) { | |
1126 __ DeoptimizeUnless(DeoptimizeReason::kWrongMap, check, frame_state); | |
1127 } else { | |
1128 __ GotoIf(check, &done); | |
1129 } | |
1130 } | |
1131 __ Goto(&done); | |
1132 __ Bind(&done); | |
1077 } | 1133 } |
1078 __ Goto(&done); | |
1079 __ Bind(&done); | |
1080 return value; | 1134 return value; |
1081 } | 1135 } |
1082 | 1136 |
1083 Node* EffectControlLinearizer::LowerCheckNumber(Node* node, Node* frame_state) { | 1137 Node* EffectControlLinearizer::LowerCheckNumber(Node* node, Node* frame_state) { |
1084 Node* value = node->InputAt(0); | 1138 Node* value = node->InputAt(0); |
1085 | 1139 |
1086 auto if_not_smi = __ MakeDeferredLabel<1>(); | 1140 auto if_not_smi = __ MakeDeferredLabel<1>(); |
1087 auto done = __ MakeLabel<2>(); | 1141 auto done = __ MakeLabel<2>(); |
1088 | 1142 |
1089 Node* check0 = ObjectIsSmi(value); | 1143 Node* check0 = ObjectIsSmi(value); |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2650 return isolate()->factory(); | 2704 return isolate()->factory(); |
2651 } | 2705 } |
2652 | 2706 |
2653 Isolate* EffectControlLinearizer::isolate() const { | 2707 Isolate* EffectControlLinearizer::isolate() const { |
2654 return jsgraph()->isolate(); | 2708 return jsgraph()->isolate(); |
2655 } | 2709 } |
2656 | 2710 |
2657 } // namespace compiler | 2711 } // namespace compiler |
2658 } // namespace internal | 2712 } // namespace internal |
2659 } // namespace v8 | 2713 } // namespace v8 |
OLD | NEW |