| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/flags.h" | 5 #include "src/base/flags.h" |
| 6 #include "src/bootstrapper.h" | 6 #include "src/bootstrapper.h" |
| 7 #include "src/compiler/graph-reducer.h" | 7 #include "src/compiler/graph-reducer.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 #undef DECLARE_METHOD | 358 #undef DECLARE_METHOD |
| 359 | 359 |
| 360 static Type* JSUnaryNotTyper(Type*, Typer*); | 360 static Type* JSUnaryNotTyper(Type*, Typer*); |
| 361 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); | 361 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); |
| 362 static Type* JSCallFunctionTyper(Type*, Typer*); | 362 static Type* JSCallFunctionTyper(Type*, Typer*); |
| 363 | 363 |
| 364 Reduction UpdateBounds(Node* node, Bounds current) { | 364 Reduction UpdateBounds(Node* node, Bounds current) { |
| 365 if (NodeProperties::IsTyped(node)) { | 365 if (NodeProperties::IsTyped(node)) { |
| 366 // Widen the bounds of a previously typed node. | 366 // Widen the bounds of a previously typed node. |
| 367 Bounds previous = NodeProperties::GetBounds(node); | 367 Bounds previous = NodeProperties::GetBounds(node); |
| 368 // Speed up termination in the presence of range types: | 368 if (node->opcode() == IrOpcode::kPhi) { |
| 369 current.upper = Weaken(current.upper, previous.upper); | 369 // Speed up termination in the presence of range types: |
| 370 current.lower = Weaken(current.lower, previous.lower); | 370 current.upper = Weaken(current.upper, previous.upper); |
| 371 current.lower = Weaken(current.lower, previous.lower); |
| 372 } |
| 371 | 373 |
| 372 // Types should not get less precise. | 374 // Types should not get less precise. |
| 373 DCHECK(previous.lower->Is(current.lower)); | 375 DCHECK(previous.lower->Is(current.lower)); |
| 374 DCHECK(previous.upper->Is(current.upper)); | 376 DCHECK(previous.upper->Is(current.upper)); |
| 375 | 377 |
| 376 NodeProperties::SetBounds(node, current); | 378 NodeProperties::SetBounds(node, current); |
| 377 if (!(previous.Narrows(current) && current.Narrows(previous))) { | 379 if (!(previous.Narrows(current) && current.Narrows(previous))) { |
| 378 // If something changed, revisit all uses. | 380 // If something changed, revisit all uses. |
| 379 return Changed(node); | 381 return Changed(node); |
| 380 } | 382 } |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 // the fixpoint calculation in case there appears to be a loop | 1304 // the fixpoint calculation in case there appears to be a loop |
| 1303 // in the graph. In the current implementation, we are | 1305 // in the graph. In the current implementation, we are |
| 1304 // increasing the limits to the closest power of two. | 1306 // increasing the limits to the closest power of two. |
| 1305 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { | 1307 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { |
| 1306 // If the types have nothing to do with integers, return the types. | 1308 // If the types have nothing to do with integers, return the types. |
| 1307 if (!current_type->Maybe(typer_->integer) || | 1309 if (!current_type->Maybe(typer_->integer) || |
| 1308 !previous_type->Maybe(typer_->integer)) { | 1310 !previous_type->Maybe(typer_->integer)) { |
| 1309 return current_type; | 1311 return current_type; |
| 1310 } | 1312 } |
| 1311 | 1313 |
| 1312 Type* previous_number = | 1314 Type::RangeType* previous = |
| 1313 Type::Intersect(previous_type, typer_->integer, zone()); | 1315 Type::Intersect(previous_type, typer_->integer, zone())->GetRange(); |
| 1314 Type* current_number = Type::Intersect(current_type, typer_->integer, zone()); | 1316 Type::RangeType* current = |
| 1315 if (!current_number->IsRange() || !previous_number->IsRange()) { | 1317 Type::Intersect(current_type, typer_->integer, zone())->GetRange(); |
| 1318 if (current == nullptr || previous == nullptr) { |
| 1316 return current_type; | 1319 return current_type; |
| 1317 } | 1320 } |
| 1318 | 1321 |
| 1319 Type::RangeType* previous = previous_number->AsRange(); | |
| 1320 Type::RangeType* current = current_number->AsRange(); | |
| 1321 | |
| 1322 double current_min = current->Min(); | 1322 double current_min = current->Min(); |
| 1323 double new_min = current_min; | 1323 double new_min = current_min; |
| 1324 // Find the closest lower entry in the list of allowed | 1324 // Find the closest lower entry in the list of allowed |
| 1325 // minima (or negative infinity if there is no such entry). | 1325 // minima (or negative infinity if there is no such entry). |
| 1326 if (current_min != previous->Min()) { | 1326 if (current_min != previous->Min()) { |
| 1327 new_min = typer_->integer->AsRange()->Min(); | 1327 new_min = typer_->integer->AsRange()->Min(); |
| 1328 for (const auto val : typer_->weaken_min_limits_) { | 1328 for (const auto val : typer_->weaken_min_limits_) { |
| 1329 if (val <= current_min) { | 1329 if (val <= current_min) { |
| 1330 new_min = val; | 1330 new_min = val; |
| 1331 break; | 1331 break; |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2223 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 2224 #undef TYPED_ARRAY_CASE | 2224 #undef TYPED_ARRAY_CASE |
| 2225 } | 2225 } |
| 2226 } | 2226 } |
| 2227 return Type::Constant(value, zone()); | 2227 return Type::Constant(value, zone()); |
| 2228 } | 2228 } |
| 2229 | 2229 |
| 2230 } // namespace compiler | 2230 } // namespace compiler |
| 2231 } // namespace internal | 2231 } // namespace internal |
| 2232 } // namespace v8 | 2232 } // namespace v8 |
| OLD | NEW |