Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 1149563004: [turbofan] Add bounds check to Node::InputAt(index) and fix tests that go out of bounds. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } // namespace 1436 } // namespace
1437 1437
1438 1438
1439 TEST(LowerLoadField_to_load) { 1439 TEST(LowerLoadField_to_load) {
1440 TestingGraph t(Type::Any(), Type::Signed32()); 1440 TestingGraph t(Type::Any(), Type::Signed32());
1441 1441
1442 for (size_t i = 0; i < arraysize(kMachineReps); i++) { 1442 for (size_t i = 0; i < arraysize(kMachineReps); i++) {
1443 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1443 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1444 Handle<Name>::null(), Type::Any(), kMachineReps[i]}; 1444 Handle<Name>::null(), Type::Any(), kMachineReps[i]};
1445 1445
1446 Node* load = 1446 Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
1447 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); 1447 t.start, t.start);
1448 Node* use = t.Use(load, kMachineReps[i]); 1448 Node* use = t.Use(load, kMachineReps[i]);
1449 t.Return(use); 1449 t.Return(use);
1450 t.Lower(); 1450 t.Lower();
1451 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1451 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1452 CHECK_EQ(t.p0, load->InputAt(0)); 1452 CHECK_EQ(t.p0, load->InputAt(0));
1453 CheckFieldAccessArithmetic(access, load); 1453 CheckFieldAccessArithmetic(access, load);
1454 1454
1455 MachineType rep = OpParameter<MachineType>(load); 1455 MachineType rep = OpParameter<MachineType>(load);
1456 CHECK_EQ(kMachineReps[i], rep); 1456 CHECK_EQ(kMachineReps[i], rep);
1457 } 1457 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0)); 1617 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0));
1618 } 1618 }
1619 1619
1620 1620
1621 TEST(InsertChangeForLoadField) { 1621 TEST(InsertChangeForLoadField) {
1622 // TODO(titzer): test all load/store representation change insertions. 1622 // TODO(titzer): test all load/store representation change insertions.
1623 TestingGraph t(Type::Any(), Type::Signed32()); 1623 TestingGraph t(Type::Any(), Type::Signed32());
1624 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1624 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1625 Handle<Name>::null(), Type::Any(), kMachFloat64}; 1625 Handle<Name>::null(), Type::Any(), kMachFloat64};
1626 1626
1627 Node* load = 1627 Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
1628 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); 1628 t.start, t.start);
1629 t.Return(load); 1629 t.Return(load);
1630 t.Lower(); 1630 t.Lower();
1631 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1631 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1632 CHECK_EQ(t.p0, load->InputAt(0)); 1632 CHECK_EQ(t.p0, load->InputAt(0));
1633 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0)); 1633 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0));
1634 } 1634 }
1635 1635
1636 1636
1637 TEST(InsertChangeForStoreElement) { 1637 TEST(InsertChangeForStoreElement) {
1638 // TODO(titzer): test all load/store representation change insertions. 1638 // TODO(titzer): test all load/store representation change insertions.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 TEST(UpdatePhi) { 1672 TEST(UpdatePhi) {
1673 TestingGraph t(Type::Any(), Type::Signed32()); 1673 TestingGraph t(Type::Any(), Type::Signed32());
1674 static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, 1674 static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32,
1675 kMachFloat64}; 1675 kMachFloat64};
1676 Type* kTypes[] = {Type::Signed32(), Type::Unsigned32(), Type::Number()}; 1676 Type* kTypes[] = {Type::Signed32(), Type::Unsigned32(), Type::Number()};
1677 1677
1678 for (size_t i = 0; i < arraysize(kMachineTypes); i++) { 1678 for (size_t i = 0; i < arraysize(kMachineTypes); i++) {
1679 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1679 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1680 Handle<Name>::null(), kTypes[i], kMachineTypes[i]}; 1680 Handle<Name>::null(), kTypes[i], kMachineTypes[i]};
1681 1681
1682 Node* load0 = 1682 Node* load0 = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
1683 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); 1683 t.start, t.start);
1684 Node* load1 = 1684 Node* load1 = t.graph()->NewNode(t.simplified()->LoadField(access), t.p1,
1685 t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start); 1685 t.start, t.start);
1686 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, 1686 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0,
1687 load1, t.start); 1687 load1, t.start);
1688 t.Return(t.Use(phi, kMachineTypes[i])); 1688 t.Return(t.Use(phi, kMachineTypes[i]));
1689 t.Lower(); 1689 t.Lower();
1690 1690
1691 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); 1691 CHECK_EQ(IrOpcode::kPhi, phi->opcode());
1692 CHECK_EQ(RepresentationOf(kMachineTypes[i]), 1692 CHECK_EQ(RepresentationOf(kMachineTypes[i]),
1693 RepresentationOf(OpParameter<MachineType>(phi))); 1693 RepresentationOf(OpParameter<MachineType>(phi)));
1694 } 1694 }
1695 } 1695 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); 2090 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z);
2091 NodeProperties::SetBounds(phi, phi_bounds); 2091 NodeProperties::SetBounds(phi, phi_bounds);
2092 2092
2093 Node* use = t.Use(phi, d.use); 2093 Node* use = t.Use(phi, d.use);
2094 t.Return(use); 2094 t.Return(use);
2095 t.Lower(); 2095 t.Lower();
2096 2096
2097 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); 2097 CHECK_EQ(d.expected, OpParameter<MachineType>(phi));
2098 } 2098 }
2099 } 2099 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-osr.cc ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698