| 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-global-object-specialization.h" | 5 #include "src/compiler/js-global-object-specialization.h" |
| 6 | 6 |
| 7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Store to constant property cell requires deoptimization support, | 181 // Store to constant property cell requires deoptimization support, |
| 182 // because we might even need to eager deoptimize for mismatch. | 182 // because we might even need to eager deoptimize for mismatch. |
| 183 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); | 183 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
| 184 dependencies()->AssumePropertyCell(property_cell); | 184 dependencies()->AssumePropertyCell(property_cell); |
| 185 Node* check = | 185 Node* check = |
| 186 graph()->NewNode(simplified()->ReferenceEqual(Type::Tagged()), value, | 186 graph()->NewNode(simplified()->ReferenceEqual(Type::Tagged()), value, |
| 187 jsgraph()->Constant(property_cell_value)); | 187 jsgraph()->Constant(property_cell_value)); |
| 188 Node* branch = | 188 Node* branch = |
| 189 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 189 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 190 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 190 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 191 Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state, | 191 Node* deoptimize = |
| 192 effect, if_false); | 192 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 193 frame_state, effect, if_false); |
| 193 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 194 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 194 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 195 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 195 control = graph()->NewNode(common()->IfTrue(), branch); | 196 control = graph()->NewNode(common()->IfTrue(), branch); |
| 196 break; | 197 break; |
| 197 } | 198 } |
| 198 case PropertyCellType::kConstantType: { | 199 case PropertyCellType::kConstantType: { |
| 199 // Store to constant-type property cell requires deoptimization support, | 200 // Store to constant-type property cell requires deoptimization support, |
| 200 // because we might even need to eager deoptimize for mismatch. | 201 // because we might even need to eager deoptimize for mismatch. |
| 201 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); | 202 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
| 202 dependencies()->AssumePropertyCell(property_cell); | 203 dependencies()->AssumePropertyCell(property_cell); |
| 203 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); | 204 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 204 Type* property_cell_value_type = Type::TaggedSigned(); | 205 Type* property_cell_value_type = Type::TaggedSigned(); |
| 205 if (property_cell_value->IsHeapObject()) { | 206 if (property_cell_value->IsHeapObject()) { |
| 206 // Deoptimize if the {value} is a Smi. | 207 // Deoptimize if the {value} is a Smi. |
| 207 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), | 208 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), |
| 208 check, control); | 209 check, control); |
| 209 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 210 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 210 Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state, | 211 Node* deoptimize = |
| 211 effect, if_true); | 212 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 213 frame_state, effect, if_true); |
| 212 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 214 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 213 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 215 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 214 control = graph()->NewNode(common()->IfFalse(), branch); | 216 control = graph()->NewNode(common()->IfFalse(), branch); |
| 215 | 217 |
| 216 // Load the {value} map check against the {property_cell} map. | 218 // Load the {value} map check against the {property_cell} map. |
| 217 Node* value_map = effect = | 219 Node* value_map = effect = |
| 218 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), | 220 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), |
| 219 value, effect, control); | 221 value, effect, control); |
| 220 Handle<Map> property_cell_value_map( | 222 Handle<Map> property_cell_value_map( |
| 221 Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); | 223 Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); |
| 222 check = graph()->NewNode( | 224 check = graph()->NewNode( |
| 223 simplified()->ReferenceEqual(Type::Any()), value_map, | 225 simplified()->ReferenceEqual(Type::Any()), value_map, |
| 224 jsgraph()->HeapConstant(property_cell_value_map)); | 226 jsgraph()->HeapConstant(property_cell_value_map)); |
| 225 property_cell_value_type = Type::TaggedPointer(); | 227 property_cell_value_type = Type::TaggedPointer(); |
| 226 } | 228 } |
| 227 Node* branch = | 229 Node* branch = |
| 228 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 230 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 229 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 231 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 230 Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state, | 232 Node* deoptimize = |
| 231 effect, if_false); | 233 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 234 frame_state, effect, if_false); |
| 232 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 235 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 233 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 236 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 234 control = graph()->NewNode(common()->IfTrue(), branch); | 237 control = graph()->NewNode(common()->IfTrue(), branch); |
| 235 effect = graph()->NewNode( | 238 effect = graph()->NewNode( |
| 236 simplified()->StoreField( | 239 simplified()->StoreField( |
| 237 AccessBuilder::ForPropertyCellValue(property_cell_value_type)), | 240 AccessBuilder::ForPropertyCellValue(property_cell_value_type)), |
| 238 jsgraph()->HeapConstant(property_cell), value, effect, control); | 241 jsgraph()->HeapConstant(property_cell), value, effect, control); |
| 239 break; | 242 break; |
| 240 } | 243 } |
| 241 case PropertyCellType::kMutable: { | 244 case PropertyCellType::kMutable: { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 311 } |
| 309 | 312 |
| 310 | 313 |
| 311 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { | 314 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { |
| 312 return jsgraph()->simplified(); | 315 return jsgraph()->simplified(); |
| 313 } | 316 } |
| 314 | 317 |
| 315 } // namespace compiler | 318 } // namespace compiler |
| 316 } // namespace internal | 319 } // namespace internal |
| 317 } // namespace v8 | 320 } // namespace v8 |
| OLD | NEW |