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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/change-lowering.h" | 8 #include "src/compiler/change-lowering.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 CHECK_EQ(t.p0, load->InputAt(0)); | 1434 CHECK_EQ(t.p0, load->InputAt(0)); |
1435 CheckFieldAccessArithmetic(access, load); | 1435 CheckFieldAccessArithmetic(access, load); |
1436 | 1436 |
1437 MachineType rep = OpParameter<MachineType>(load); | 1437 MachineType rep = OpParameter<MachineType>(load); |
1438 CHECK_EQ(kMachineReps[i], rep); | 1438 CHECK_EQ(kMachineReps[i], rep); |
1439 } | 1439 } |
1440 } | 1440 } |
1441 | 1441 |
1442 | 1442 |
1443 TEST(LowerStoreField_to_store) { | 1443 TEST(LowerStoreField_to_store) { |
1444 TestingGraph t(Type::Any(), Type::Signed32()); | 1444 { |
| 1445 TestingGraph t(Type::Any(), Type::Signed32()); |
1445 | 1446 |
1446 for (size_t i = 0; i < arraysize(kMachineReps); i++) { | 1447 for (size_t i = 0; i < arraysize(kMachineReps); i++) { |
1447 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1448 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1448 Handle<Name>::null(), Type::Any(), kMachineReps[i]}; | 1449 Handle<Name>::null(), Type::Any(), kMachineReps[i]}; |
1449 | 1450 |
1450 | 1451 |
1451 Node* val = t.ExampleWithOutput(kMachineReps[i]); | 1452 Node* val = t.ExampleWithOutput(kMachineReps[i]); |
| 1453 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, |
| 1454 val, t.start, t.start); |
| 1455 t.Effect(store); |
| 1456 t.Lower(); |
| 1457 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
| 1458 CHECK_EQ(val, store->InputAt(2)); |
| 1459 CheckFieldAccessArithmetic(access, store); |
| 1460 |
| 1461 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); |
| 1462 if (kMachineReps[i] & kRepTagged) { |
| 1463 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); |
| 1464 } |
| 1465 CHECK_EQ(kMachineReps[i], rep.machine_type()); |
| 1466 } |
| 1467 } |
| 1468 { |
| 1469 TestingGraph t(Type::Any(), |
| 1470 Type::Intersect(Type::SignedSmall(), Type::TaggedSigned())); |
| 1471 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
| 1472 Handle<Name>::null(), Type::Any(), kMachAnyTagged}; |
1452 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, | 1473 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, |
1453 val, t.start, t.start); | 1474 t.p1, t.start, t.start); |
1454 t.Effect(store); | 1475 t.Effect(store); |
1455 t.Lower(); | 1476 t.Lower(); |
1456 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1477 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1457 CHECK_EQ(val, store->InputAt(2)); | 1478 CHECK_EQ(t.p1, store->InputAt(2)); |
1458 CheckFieldAccessArithmetic(access, store); | |
1459 | |
1460 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); | |
1461 if (kMachineReps[i] & kRepTagged) { | |
1462 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); | |
1463 } | |
1464 CHECK_EQ(kMachineReps[i], rep.machine_type()); | |
1465 } | |
1466 | |
1467 if (t.machine()->Is64()) { | |
1468 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | |
1469 Handle<Name>::null(), Type::Any(), kMachAnyTagged}; | |
1470 Node* val = t.graph()->NewNode(t.simplified()->ChangeInt32ToTagged(), t.p0); | |
1471 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, | |
1472 val, t.start, t.start); | |
1473 t.Effect(store); | |
1474 t.Lower(); | |
1475 CHECK_EQ(IrOpcode::kStore, store->opcode()); | |
1476 CHECK_EQ(val, store->InputAt(2)); | |
1477 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); | 1479 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); |
1478 CHECK_EQ(kNoWriteBarrier, rep.write_barrier_kind()); | 1480 CHECK_EQ(kNoWriteBarrier, rep.write_barrier_kind()); |
1479 } | 1481 } |
1480 } | 1482 } |
1481 | 1483 |
1482 | 1484 |
1483 TEST(LowerLoadElement_to_load) { | 1485 TEST(LowerLoadElement_to_load) { |
1484 TestingGraph t(Type::Any(), Type::Signed32()); | 1486 TestingGraph t(Type::Any(), Type::Signed32()); |
1485 | 1487 |
1486 for (size_t i = 0; i < arraysize(kMachineReps); i++) { | 1488 for (size_t i = 0; i < arraysize(kMachineReps); i++) { |
1487 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1489 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1488 Type::Any(), kMachineReps[i]}; | 1490 Type::Any(), kMachineReps[i]}; |
1489 | 1491 |
1490 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, | 1492 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, |
1491 t.p1, t.start, t.start); | 1493 t.p1, t.start, t.start); |
1492 Node* use = t.Use(load, kMachineReps[i]); | 1494 Node* use = t.Use(load, kMachineReps[i]); |
1493 t.Return(use); | 1495 t.Return(use); |
1494 t.Lower(); | 1496 t.Lower(); |
1495 CHECK_EQ(IrOpcode::kLoad, load->opcode()); | 1497 CHECK_EQ(IrOpcode::kLoad, load->opcode()); |
1496 CHECK_EQ(t.p0, load->InputAt(0)); | 1498 CHECK_EQ(t.p0, load->InputAt(0)); |
1497 CheckElementAccessArithmetic(access, load); | 1499 CheckElementAccessArithmetic(access, load); |
1498 | 1500 |
1499 MachineType rep = OpParameter<MachineType>(load); | 1501 MachineType rep = OpParameter<MachineType>(load); |
1500 CHECK_EQ(kMachineReps[i], rep); | 1502 CHECK_EQ(kMachineReps[i], rep); |
1501 } | 1503 } |
1502 } | 1504 } |
1503 | 1505 |
1504 | 1506 |
1505 TEST(LowerStoreElement_to_store) { | 1507 TEST(LowerStoreElement_to_store) { |
1506 TestingGraph t(Type::Any(), Type::Signed32()); | 1508 { |
| 1509 TestingGraph t(Type::Any(), Type::Signed32()); |
1507 | 1510 |
1508 for (size_t i = 0; i < arraysize(kMachineReps); i++) { | 1511 for (size_t i = 0; i < arraysize(kMachineReps); i++) { |
| 1512 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
| 1513 Type::Any(), kMachineReps[i]}; |
| 1514 |
| 1515 Node* val = t.ExampleWithOutput(kMachineReps[i]); |
| 1516 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), |
| 1517 t.p0, t.p1, val, t.start, t.start); |
| 1518 t.Effect(store); |
| 1519 t.Lower(); |
| 1520 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
| 1521 CHECK_EQ(val, store->InputAt(2)); |
| 1522 CheckElementAccessArithmetic(access, store); |
| 1523 |
| 1524 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); |
| 1525 if (kMachineReps[i] & kRepTagged) { |
| 1526 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); |
| 1527 } |
| 1528 CHECK_EQ(kMachineReps[i], rep.machine_type()); |
| 1529 } |
| 1530 } |
| 1531 { |
| 1532 TestingGraph t(Type::Any(), Type::Signed32(), |
| 1533 Type::Intersect(Type::SignedSmall(), Type::TaggedSigned())); |
1509 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1534 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1510 Type::Any(), kMachineReps[i]}; | 1535 Type::Any(), kMachAnyTagged}; |
1511 | |
1512 Node* val = t.ExampleWithOutput(kMachineReps[i]); | |
1513 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, | 1536 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, |
1514 t.p1, val, t.start, t.start); | 1537 t.p1, t.p2, t.start, t.start); |
1515 t.Effect(store); | 1538 t.Effect(store); |
1516 t.Lower(); | 1539 t.Lower(); |
1517 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1540 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1518 CHECK_EQ(val, store->InputAt(2)); | 1541 CHECK_EQ(t.p2, store->InputAt(2)); |
1519 CheckElementAccessArithmetic(access, store); | |
1520 | |
1521 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); | 1542 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); |
1522 if (kMachineReps[i] & kRepTagged) { | 1543 CHECK_EQ(kNoWriteBarrier, rep.write_barrier_kind()); |
1523 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); | |
1524 } | |
1525 CHECK_EQ(kMachineReps[i], rep.machine_type()); | |
1526 } | 1544 } |
1527 } | 1545 } |
1528 | 1546 |
1529 | 1547 |
1530 TEST(InsertChangeForLoadElementIndex) { | 1548 TEST(InsertChangeForLoadElementIndex) { |
1531 // LoadElement(obj: Tagged, index: kTypeInt32 | kRepTagged, length) => | 1549 // LoadElement(obj: Tagged, index: kTypeInt32 | kRepTagged, length) => |
1532 // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k)) | 1550 // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k)) |
1533 TestingGraph t(Type::Any(), Type::Signed32()); | 1551 TestingGraph t(Type::Any(), Type::Signed32()); |
1534 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), | 1552 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), |
1535 kMachAnyTagged}; | 1553 kMachAnyTagged}; |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); | 2072 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); |
2055 NodeProperties::SetBounds(phi, phi_bounds); | 2073 NodeProperties::SetBounds(phi, phi_bounds); |
2056 | 2074 |
2057 Node* use = t.Use(phi, d.use); | 2075 Node* use = t.Use(phi, d.use); |
2058 t.Return(use); | 2076 t.Return(use); |
2059 t.Lower(); | 2077 t.Lower(); |
2060 | 2078 |
2061 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); | 2079 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); |
2062 } | 2080 } |
2063 } | 2081 } |
OLD | NEW |