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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 Bounds Typer::Visitor::TypeJSLoadProperty(Node* node) { | 1331 Bounds Typer::Visitor::TypeJSLoadProperty(Node* node) { |
1332 return TypeBinaryOp(node, JSLoadPropertyTyper); | 1332 return TypeBinaryOp(node, JSLoadPropertyTyper); |
1333 } | 1333 } |
1334 | 1334 |
1335 | 1335 |
1336 Bounds Typer::Visitor::TypeJSLoadNamed(Node* node) { | 1336 Bounds Typer::Visitor::TypeJSLoadNamed(Node* node) { |
1337 return Bounds::Unbounded(zone()); | 1337 return Bounds::Unbounded(zone()); |
1338 } | 1338 } |
1339 | 1339 |
1340 | 1340 |
| 1341 Bounds Typer::Visitor::TypeJSLoadGlobal(Node* node) { |
| 1342 return Bounds::Unbounded(zone()); |
| 1343 } |
| 1344 |
| 1345 |
1341 // Returns a somewhat larger range if we previously assigned | 1346 // Returns a somewhat larger range if we previously assigned |
1342 // a (smaller) range to this node. This is used to speed up | 1347 // a (smaller) range to this node. This is used to speed up |
1343 // the fixpoint calculation in case there appears to be a loop | 1348 // the fixpoint calculation in case there appears to be a loop |
1344 // in the graph. In the current implementation, we are | 1349 // in the graph. In the current implementation, we are |
1345 // increasing the limits to the closest power of two. | 1350 // increasing the limits to the closest power of two. |
1346 Type* Typer::Visitor::Weaken(Node* node, Type* current_type, | 1351 Type* Typer::Visitor::Weaken(Node* node, Type* current_type, |
1347 Type* previous_type) { | 1352 Type* previous_type) { |
1348 static const double kWeakenMinLimits[] = { | 1353 static const double kWeakenMinLimits[] = { |
1349 0.0, -1073741824.0, -2147483648.0, -4294967296.0, -8589934592.0, | 1354 0.0, -1073741824.0, -2147483648.0, -4294967296.0, -8589934592.0, |
1350 -17179869184.0, -34359738368.0, -68719476736.0, -137438953472.0, | 1355 -17179869184.0, -34359738368.0, -68719476736.0, -137438953472.0, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 return Bounds(); | 1429 return Bounds(); |
1425 } | 1430 } |
1426 | 1431 |
1427 | 1432 |
1428 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { | 1433 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { |
1429 UNREACHABLE(); | 1434 UNREACHABLE(); |
1430 return Bounds(); | 1435 return Bounds(); |
1431 } | 1436 } |
1432 | 1437 |
1433 | 1438 |
| 1439 Bounds Typer::Visitor::TypeJSStoreGlobal(Node* node) { |
| 1440 UNREACHABLE(); |
| 1441 return Bounds(); |
| 1442 } |
| 1443 |
| 1444 |
1434 Bounds Typer::Visitor::TypeJSDeleteProperty(Node* node) { | 1445 Bounds Typer::Visitor::TypeJSDeleteProperty(Node* node) { |
1435 return Bounds(Type::None(zone()), Type::Boolean(zone())); | 1446 return Bounds(Type::None(zone()), Type::Boolean(zone())); |
1436 } | 1447 } |
1437 | 1448 |
1438 | 1449 |
1439 Bounds Typer::Visitor::TypeJSHasProperty(Node* node) { | 1450 Bounds Typer::Visitor::TypeJSHasProperty(Node* node) { |
1440 return Bounds(Type::None(zone()), Type::Boolean(zone())); | 1451 return Bounds(Type::None(zone()), Type::Boolean(zone())); |
1441 } | 1452 } |
1442 | 1453 |
1443 | 1454 |
1444 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) { | 1455 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) { |
1445 return Bounds(Type::None(zone()), Type::Boolean(zone())); | 1456 return Bounds(Type::None(zone()), Type::Boolean(zone())); |
1446 } | 1457 } |
1447 | 1458 |
1448 | 1459 |
1449 // JS context operators. | 1460 // JS context operators. |
1450 | 1461 |
1451 | 1462 |
1452 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) { | 1463 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) { |
1453 ContextAccess access = OpParameter<ContextAccess>(node); | 1464 ContextAccess access = OpParameter<ContextAccess>(node); |
1454 Bounds outer = Operand(node, 0); | 1465 Bounds outer = Operand(node, 0); |
1455 Type* context_type = outer.upper; | 1466 Type* context_type = outer.upper; |
1456 Type* upper = (access.index() == Context::GLOBAL_OBJECT_INDEX) | |
1457 ? Type::GlobalObject() | |
1458 : Type::Any(); | |
1459 if (context_type->Is(Type::None())) { | 1467 if (context_type->Is(Type::None())) { |
1460 // Upper bound of context is not yet known. | 1468 // Upper bound of context is not yet known. |
1461 return Bounds(Type::None(), upper); | 1469 return Bounds(Type::None(), Type::Any()); |
1462 } | 1470 } |
1463 | 1471 |
1464 DCHECK(context_type->Maybe(Type::Internal())); | 1472 DCHECK(context_type->Maybe(Type::Internal())); |
1465 // TODO(rossberg): More precisely, instead of the above assertion, we should | 1473 // TODO(rossberg): More precisely, instead of the above assertion, we should |
1466 // back-propagate the constraint that it has to be a subtype of Internal. | 1474 // back-propagate the constraint that it has to be a subtype of Internal. |
1467 | 1475 |
1468 MaybeHandle<Context> context; | 1476 MaybeHandle<Context> context; |
1469 if (context_type->IsConstant()) { | 1477 if (context_type->IsConstant()) { |
1470 context = Handle<Context>::cast(context_type->AsConstant()->Value()); | 1478 context = Handle<Context>::cast(context_type->AsConstant()->Value()); |
1471 } | 1479 } |
1472 // Walk context chain (as far as known), mirroring dynamic lookup. | 1480 // Walk context chain (as far as known), mirroring dynamic lookup. |
1473 // Since contexts are mutable, the information is only useful as a lower | 1481 // Since contexts are mutable, the information is only useful as a lower |
1474 // bound. | 1482 // bound. |
1475 for (size_t i = access.depth(); i > 0; --i) { | 1483 for (size_t i = access.depth(); i > 0; --i) { |
1476 if (context_type->IsContext()) { | 1484 if (context_type->IsContext()) { |
1477 context_type = context_type->AsContext()->Outer(); | 1485 context_type = context_type->AsContext()->Outer(); |
1478 if (context_type->IsConstant()) { | 1486 if (context_type->IsConstant()) { |
1479 context = Handle<Context>::cast(context_type->AsConstant()->Value()); | 1487 context = Handle<Context>::cast(context_type->AsConstant()->Value()); |
1480 } | 1488 } |
1481 } else if (!context.is_null()) { | 1489 } else if (!context.is_null()) { |
1482 context = handle(context.ToHandleChecked()->previous(), isolate()); | 1490 context = handle(context.ToHandleChecked()->previous(), isolate()); |
1483 } | 1491 } |
1484 } | 1492 } |
1485 Type* lower = Type::None(); | 1493 Type* lower = Type::None(); |
1486 if (!context.is_null()) { | 1494 if (!context.is_null()) { |
1487 lower = TypeConstant( | 1495 lower = TypeConstant( |
1488 handle(context.ToHandleChecked()->get(static_cast<int>(access.index())), | 1496 handle(context.ToHandleChecked()->get(static_cast<int>(access.index())), |
1489 isolate())); | 1497 isolate())); |
1490 } | 1498 } |
1491 return Bounds(lower, upper); | 1499 return Bounds(lower, Type::Any()); |
1492 } | 1500 } |
1493 | 1501 |
1494 | 1502 |
1495 Bounds Typer::Visitor::TypeJSStoreContext(Node* node) { | 1503 Bounds Typer::Visitor::TypeJSStoreContext(Node* node) { |
1496 UNREACHABLE(); | 1504 UNREACHABLE(); |
1497 return Bounds(); | 1505 return Bounds(); |
1498 } | 1506 } |
1499 | 1507 |
1500 | 1508 |
1501 Bounds Typer::Visitor::TypeJSLoadDynamicGlobal(Node* node) { | 1509 Bounds Typer::Visitor::TypeJSLoadDynamicGlobal(Node* node) { |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2421 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2414 #undef TYPED_ARRAY_CASE | 2422 #undef TYPED_ARRAY_CASE |
2415 } | 2423 } |
2416 } | 2424 } |
2417 return Type::Constant(value, zone()); | 2425 return Type::Constant(value, zone()); |
2418 } | 2426 } |
2419 | 2427 |
2420 } // namespace compiler | 2428 } // namespace compiler |
2421 } // namespace internal | 2429 } // namespace internal |
2422 } // namespace v8 | 2430 } // namespace v8 |
OLD | NEW |