Commit faa0b50d authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[cleanup] Eliminate non-const reference parameters

- Eliminates non-const reference parameters in test/unittests.

Bug: v8:9429
Change-Id: Ia7b41482811183324a62859d27fc263e4032219a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1794802Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63643}
parent 859b2d77
......@@ -37,11 +37,10 @@ static void CheckSlowSample(const std::vector<uint64_t>& sample, uint64_t max,
}
}
static void TestNextSample(
RandomNumberGenerator& rng, // NOLINT(runtime/references)
uint64_t max, size_t size, bool slow = false) {
static void TestNextSample(RandomNumberGenerator* rng, uint64_t max,
size_t size, bool slow = false) {
std::vector<uint64_t> sample =
slow ? rng.NextSampleSlow(max, size) : rng.NextSample(max, size);
slow ? rng->NextSampleSlow(max, size) : rng->NextSample(max, size);
CheckSample(sample, max, size);
}
......@@ -100,14 +99,14 @@ TEST_P(RandomNumberGeneratorTest, NextSample0) {
size_t m = 1;
RandomNumberGenerator rng(GetParam());
TestNextSample(rng, m, 0);
TestNextSample(&rng, m, 0);
}
TEST_P(RandomNumberGeneratorTest, NextSampleSlow0) {
size_t m = 1;
RandomNumberGenerator rng(GetParam());
TestNextSample(rng, m, 0, true);
TestNextSample(&rng, m, 0, true);
}
TEST_P(RandomNumberGeneratorTest, NextSample1) {
......@@ -115,7 +114,7 @@ TEST_P(RandomNumberGeneratorTest, NextSample1) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, 1);
TestNextSample(&rng, m, 1);
}
}
......@@ -124,7 +123,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleSlow1) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, 1, true);
TestNextSample(&rng, m, 1, true);
}
}
......@@ -133,7 +132,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleMax) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, m);
TestNextSample(&rng, m, m);
}
}
......@@ -142,7 +141,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleSlowMax) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, m, true);
TestNextSample(&rng, m, m, true);
}
}
......@@ -152,7 +151,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n);
TestNextSample(&rng, m, n);
}
}
......@@ -162,7 +161,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleSlowHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n, true);
TestNextSample(&rng, m, n, true);
}
}
......@@ -172,7 +171,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleMoreThanHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n);
TestNextSample(&rng, m, n);
}
}
......@@ -182,7 +181,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleSlowMoreThanHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n, true);
TestNextSample(&rng, m, n, true);
}
}
......@@ -192,7 +191,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleLessThanHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n);
TestNextSample(&rng, m, n);
}
}
......@@ -202,7 +201,7 @@ TEST_P(RandomNumberGeneratorTest, NextSampleSlowLessThanHalf) {
RandomNumberGenerator rng(GetParam());
for (int k = 0; k < kMaxRuns; ++k) {
TestNextSample(rng, m, n, true);
TestNextSample(&rng, m, n, true);
}
}
......
......@@ -41,16 +41,15 @@ std::ostream& operator<<(std::ostream& os, const Shift& shift) {
// Helper to build Int32Constant or Int64Constant depending on the given
// machine type.
Node* BuildConstant(
InstructionSelectorTest::StreamBuilder& m, // NOLINT(runtime/references)
MachineType type, int64_t value) {
Node* BuildConstant(InstructionSelectorTest::StreamBuilder* m, MachineType type,
int64_t value) {
switch (type.representation()) {
case MachineRepresentation::kWord32:
return m.Int32Constant(static_cast<int32_t>(value));
return m->Int32Constant(static_cast<int32_t>(value));
break;
case MachineRepresentation::kWord64:
return m.Int64Constant(value);
return m->Int64Constant(value);
break;
default:
......@@ -464,9 +463,8 @@ TEST_P(InstructionSelectorLogicalTest, ShiftByImmediate) {
TRACED_FORRANGE(int, imm, 0, ((type == MachineType::Int32()) ? 31 : 63)) {
StreamBuilder m(this, type, type, type);
m.Return((m.*dpi.constructor)(
m.Parameter(0),
(m.*shift.mi.constructor)(m.Parameter(1),
BuildConstant(m, type, imm))));
m.Parameter(0), (m.*shift.mi.constructor)(
m.Parameter(1), BuildConstant(&m, type, imm))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
......@@ -480,7 +478,7 @@ TEST_P(InstructionSelectorLogicalTest, ShiftByImmediate) {
StreamBuilder m(this, type, type, type);
m.Return((m.*dpi.constructor)(
(m.*shift.mi.constructor)(m.Parameter(1),
BuildConstant(m, type, imm)),
BuildConstant(&m, type, imm)),
m.Parameter(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
......@@ -521,7 +519,7 @@ TEST_P(InstructionSelectorAddSubTest, ImmediateOnRight) {
TRACED_FOREACH(int32_t, imm, kAddSubImmediates) {
StreamBuilder m(this, type, type);
m.Return(
(m.*dpi.mi.constructor)(m.Parameter(0), BuildConstant(m, type, imm)));
(m.*dpi.mi.constructor)(m.Parameter(0), BuildConstant(&m, type, imm)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode());
......@@ -540,7 +538,7 @@ TEST_P(InstructionSelectorAddSubTest, NegImmediateOnRight) {
if (imm == 0) continue;
StreamBuilder m(this, type, type);
m.Return(
(m.*dpi.mi.constructor)(m.Parameter(0), BuildConstant(m, type, -imm)));
(m.*dpi.mi.constructor)(m.Parameter(0), BuildConstant(&m, type, -imm)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(dpi.negate_arch_opcode, s[0]->arch_opcode());
......@@ -568,9 +566,8 @@ TEST_P(InstructionSelectorAddSubTest, ShiftByImmediateOnRight) {
TRACED_FORRANGE(int, imm, 0, ((type == MachineType::Int32()) ? 31 : 63)) {
StreamBuilder m(this, type, type, type);
m.Return((m.*dpi.mi.constructor)(
m.Parameter(0),
(m.*shift.mi.constructor)(m.Parameter(1),
BuildConstant(m, type, imm))));
m.Parameter(0), (m.*shift.mi.constructor)(
m.Parameter(1), BuildConstant(&m, type, imm))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode());
......@@ -2035,7 +2032,7 @@ TEST_P(InstructionSelectorIntDPWithIntMulTest, NegativeMul) {
{
StreamBuilder m(this, type, type, type);
Node* n =
(m.*mdpi.sub_constructor)(BuildConstant(m, type, 0), m.Parameter(0));
(m.*mdpi.sub_constructor)(BuildConstant(&m, type, 0), m.Parameter(0));
m.Return((m.*mdpi.mul_constructor)(n, m.Parameter(1)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
......@@ -2046,7 +2043,7 @@ TEST_P(InstructionSelectorIntDPWithIntMulTest, NegativeMul) {
{
StreamBuilder m(this, type, type, type);
Node* n =
(m.*mdpi.sub_constructor)(BuildConstant(m, type, 0), m.Parameter(1));
(m.*mdpi.sub_constructor)(BuildConstant(&m, type, 0), m.Parameter(1));
m.Return((m.*mdpi.mul_constructor)(m.Parameter(0), n));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
......@@ -2938,7 +2935,8 @@ TEST_P(InstructionSelectorComparisonTest, WithImmediate) {
// Compare with 0 are turned into tst instruction.
if (imm == 0) continue;
StreamBuilder m(this, type, type);
m.Return((m.*cmp.constructor)(m.Parameter(0), BuildConstant(m, type, imm)));
m.Return(
(m.*cmp.constructor)(m.Parameter(0), BuildConstant(&m, type, imm)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(cmp.arch_opcode, s[0]->arch_opcode());
......@@ -2953,7 +2951,8 @@ TEST_P(InstructionSelectorComparisonTest, WithImmediate) {
// Compare with 0 are turned into tst instruction.
if (imm == 0) continue;
StreamBuilder m(this, type, type);
m.Return((m.*cmp.constructor)(BuildConstant(m, type, imm), m.Parameter(0)));
m.Return(
(m.*cmp.constructor)(BuildConstant(&m, type, imm), m.Parameter(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(cmp.arch_opcode, s[0]->arch_opcode());
......@@ -4615,18 +4614,18 @@ namespace {
// Then checks that the correct number of kArm64Poke and kArm64PokePair were
// generated.
void TestPokePair(
InstructionSelectorTest::StreamBuilder& m, // NOLINT(runtime/references)
InstructionSelectorTest::StreamBuilder* m, // NOLINT(runtime/references)
Zone* zone,
MachineSignature::Builder& builder, // NOLINT(runtime/references)
MachineSignature::Builder* builder, // NOLINT(runtime/references)
Node* nodes[], int num_nodes, int expected_poke_pair, int expected_poke) {
auto call_descriptor =
InstructionSelectorTest::StreamBuilder::MakeSimpleCallDescriptor(
zone, builder.Build());
zone, builder->Build());
m.CallN(call_descriptor, num_nodes, nodes);
m.Return(m.UndefinedConstant());
m->CallN(call_descriptor, num_nodes, nodes);
m->Return(m->UndefinedConstant());
auto s = m.Build();
auto s = m->Build();
int num_poke_pair = 0;
int num_poke = 0;
for (size_t i = 0; i < s.size(); ++i) {
......@@ -4664,7 +4663,7 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsInt32) {
// EmitPrepareArguments.
const int expected_poke = 1 + 1;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes),
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
......@@ -4684,7 +4683,7 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsInt32) {
const int expected_poke_pair = 2;
const int expected_poke = 0;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes),
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
}
......@@ -4705,8 +4704,8 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsInt64) {
const int expected_poke_pair = 2;
const int expected_poke = 0;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes), expected_poke_pair,
expected_poke);
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsFloat32) {
......@@ -4725,8 +4724,8 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsFloat32) {
const int expected_poke_pair = 2;
const int expected_poke = 0;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes), expected_poke_pair,
expected_poke);
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsFloat64) {
......@@ -4745,8 +4744,8 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsFloat64) {
const int expected_poke_pair = 2;
const int expected_poke = 0;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes), expected_poke_pair,
expected_poke);
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsIntFloatMixed) {
......@@ -4766,7 +4765,7 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsIntFloatMixed) {
const int expected_poke_pair = 0;
const int expected_poke = 4;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes),
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
......@@ -4792,7 +4791,7 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsIntFloatMixed) {
// EmitPrepareArguments.
const int expected_poke = 3 + 1;
TestPokePair(m, zone(), builder, nodes, arraysize(nodes),
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
}
......@@ -4811,8 +4810,8 @@ TEST_F(InstructionSelectorTest, PokePairPrepareArgumentsSimd128) {
const int expected_poke = 2;
// Using kArm64PokePair is not currently supported for Simd128.
TestPokePair(m, zone(), builder, nodes, arraysize(nodes), expected_poke_pair,
expected_poke);
TestPokePair(&m, zone(), &builder, nodes, arraysize(nodes),
expected_poke_pair, expected_poke);
}
} // namespace compiler
......
......@@ -87,8 +87,7 @@ class ControlTransferTest : public TestWithZone {
}
void CheckNoOtherTargets(
const byte* start, const byte* end,
ControlTransferMap& map, // NOLINT(runtime/references)
const byte* start, const byte* end, const ControlTransferMap& map,
std::initializer_list<ExpectedControlTransfer> targets) {
// Check there are no other control targets.
for (pc_t pc = 0; start + pc < end; pc++) {
......
......@@ -439,17 +439,15 @@ TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {
}
}
static void AppendUint32v(
std::vector<byte>& buffer, // NOLINT(runtime/references)
uint32_t val) {
static void AppendUint32v(std::vector<byte>* buffer, uint32_t val) {
while (true) {
uint32_t next = val >> 7;
uint32_t out = val & 0x7F;
if (next) {
buffer.push_back(static_cast<byte>(0x80 | out));
buffer->push_back(static_cast<byte>(0x80 | out));
val = next;
} else {
buffer.push_back(static_cast<byte>(out));
buffer->push_back(static_cast<byte>(out));
break;
}
}
......@@ -469,7 +467,7 @@ TEST_F(WasmModuleVerifyTest, NGlobals) {
for (size_t g = 0; g != sizeof(globals); ++g) {
buffer.push_back(globals[g]);
}
AppendUint32v(buffer, i); // Number of globals.
AppendUint32v(&buffer, i); // Number of globals.
for (uint32_t j = 0; j < i; j++) {
buffer.insert(buffer.end(), data, data + sizeof(data));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment