diff --git a/test/cctest/compiler/test-code-assembler.cc b/test/cctest/compiler/test-code-assembler.cc index 31dde9547a..56628ffde4 100644 --- a/test/cctest/compiler/test-code-assembler.cc +++ b/test/cctest/compiler/test-code-assembler.cc @@ -20,35 +20,31 @@ namespace { using Variable = CodeAssemblerVariable; -Node* SmiTag(CodeAssembler& m, // NOLINT(runtime/references) - Node* value) { +Node* SmiTag(CodeAssembler* m, Node* value) { int32_t constant_value; - if (m.ToInt32Constant(value, &constant_value) && + if (m->ToInt32Constant(value, &constant_value) && Smi::IsValid(constant_value)) { - return m.SmiConstant(Smi::FromInt(constant_value)); + return m->SmiConstant(Smi::FromInt(constant_value)); } - return m.WordShl(value, m.IntPtrConstant(kSmiShiftSize + kSmiTagSize)); + return m->WordShl(value, m->IntPtrConstant(kSmiShiftSize + kSmiTagSize)); } -Node* UndefinedConstant(CodeAssembler& m) { // NOLINT(runtime/references) - return m.LoadRoot(RootIndex::kUndefinedValue); +Node* UndefinedConstant(CodeAssembler* m) { + return m->LoadRoot(RootIndex::kUndefinedValue); } -Node* SmiFromInt32(CodeAssembler& m, // NOLINT(runtime/references) - Node* value) { - value = m.ChangeInt32ToIntPtr(value); - return m.BitcastWordToTaggedSigned( - m.WordShl(value, kSmiShiftSize + kSmiTagSize)); +Node* SmiFromInt32(CodeAssembler* m, Node* value) { + value = m->ChangeInt32ToIntPtr(value); + return m->BitcastWordToTaggedSigned( + m->WordShl(value, kSmiShiftSize + kSmiTagSize)); } -Node* LoadObjectField(CodeAssembler& m, // NOLINT(runtime/references) - Node* object, int offset, +Node* LoadObjectField(CodeAssembler* m, Node* object, int offset, MachineType type = MachineType::AnyTagged()) { - return m.Load(type, object, m.IntPtrConstant(offset - kHeapObjectTag)); + return m->Load(type, object, m->IntPtrConstant(offset - kHeapObjectTag)); } -Node* LoadMap(CodeAssembler& m, // NOLINT(runtime/references) - Node* object) { +Node* LoadMap(CodeAssembler* m, Node* object) { return LoadObjectField(m, object, JSObject::kMapOffset); } @@ -58,7 +54,7 @@ TEST(SimpleSmiReturn) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate); CodeAssembler m(asm_tester.state()); - m.Return(SmiTag(m, m.Int32Constant(37))); + m.Return(SmiTag(&m, m.Int32Constant(37))); FunctionTester ft(asm_tester.GenerateCode()); CHECK_EQ(37, ft.CallChecked()->value()); } @@ -90,7 +86,7 @@ TEST(SimpleCallRuntime1Arg) { CodeAssembler m(asm_tester.state()); TNode context = m.HeapConstant(Handle(isolate->native_context())); - Node* b = SmiTag(m, m.Int32Constant(0)); + Node* b = SmiTag(&m, m.Int32Constant(0)); m.Return(m.CallRuntime(Runtime::kIsSmi, context, b)); FunctionTester ft(asm_tester.GenerateCode()); CHECK(ft.CallChecked().is_identical_to( @@ -103,7 +99,7 @@ TEST(SimpleTailCallRuntime1Arg) { CodeAssembler m(asm_tester.state()); TNode context = m.HeapConstant(Handle(isolate->native_context())); - Node* b = SmiTag(m, m.Int32Constant(0)); + Node* b = SmiTag(&m, m.Int32Constant(0)); m.TailCallRuntime(Runtime::kIsSmi, context, b); FunctionTester ft(asm_tester.GenerateCode()); CHECK(ft.CallChecked().is_identical_to( @@ -116,8 +112,8 @@ TEST(SimpleCallRuntime2Arg) { CodeAssembler m(asm_tester.state()); TNode context = m.HeapConstant(Handle(isolate->native_context())); - Node* a = SmiTag(m, m.Int32Constant(2)); - Node* b = SmiTag(m, m.Int32Constant(4)); + Node* a = SmiTag(&m, m.Int32Constant(2)); + Node* b = SmiTag(&m, m.Int32Constant(4)); m.Return(m.CallRuntime(Runtime::kAdd, context, a, b)); FunctionTester ft(asm_tester.GenerateCode()); CHECK_EQ(6, ft.CallChecked()->value()); @@ -129,8 +125,8 @@ TEST(SimpleTailCallRuntime2Arg) { CodeAssembler m(asm_tester.state()); TNode context = m.HeapConstant(Handle(isolate->native_context())); - Node* a = SmiTag(m, m.Int32Constant(2)); - Node* b = SmiTag(m, m.Int32Constant(4)); + Node* a = SmiTag(&m, m.Int32Constant(2)); + Node* b = SmiTag(&m, m.Int32Constant(4)); m.TailCallRuntime(Runtime::kAdd, context, a, b); FunctionTester ft(asm_tester.GenerateCode()); CHECK_EQ(6, ft.CallChecked()->value()); @@ -138,8 +134,7 @@ TEST(SimpleTailCallRuntime2Arg) { namespace { -Handle CreateSumAllArgumentsFunction( - FunctionTester& ft) { // NOLINT(runtime/references) +Handle CreateSumAllArgumentsFunction(FunctionTester* ft) { const char* source = "(function() {\n" " var sum = 0 + this;\n" @@ -148,7 +143,7 @@ Handle CreateSumAllArgumentsFunction( " }\n" " return sum;\n" "})"; - return ft.NewFunction(source); + return ft->NewFunction(source); } } // namespace @@ -162,7 +157,7 @@ TEST(SimpleCallJSFunction0Arg) { Node* function = m.Parameter(0); Node* context = m.Parameter(kNumParams + 2); - Node* receiver = SmiTag(m, m.Int32Constant(42)); + Node* receiver = SmiTag(&m, m.Int32Constant(42)); Callable callable = CodeFactory::Call(isolate); Node* result = m.CallJS(callable, context, function, receiver); @@ -170,7 +165,7 @@ TEST(SimpleCallJSFunction0Arg) { } FunctionTester ft(asm_tester.GenerateCode(), kNumParams); - Handle sum = CreateSumAllArgumentsFunction(ft); + Handle sum = CreateSumAllArgumentsFunction(&ft); MaybeHandle result = ft.Call(sum); CHECK_EQ(Smi::FromInt(42), *result.ToHandleChecked()); } @@ -184,8 +179,8 @@ TEST(SimpleCallJSFunction1Arg) { Node* function = m.Parameter(0); Node* context = m.Parameter(1); - Node* receiver = SmiTag(m, m.Int32Constant(42)); - Node* a = SmiTag(m, m.Int32Constant(13)); + Node* receiver = SmiTag(&m, m.Int32Constant(42)); + Node* a = SmiTag(&m, m.Int32Constant(13)); Callable callable = CodeFactory::Call(isolate); Node* result = m.CallJS(callable, context, function, receiver, a); @@ -193,7 +188,7 @@ TEST(SimpleCallJSFunction1Arg) { } FunctionTester ft(asm_tester.GenerateCode(), kNumParams); - Handle sum = CreateSumAllArgumentsFunction(ft); + Handle sum = CreateSumAllArgumentsFunction(&ft); MaybeHandle result = ft.Call(sum); CHECK_EQ(Smi::FromInt(55), *result.ToHandleChecked()); } @@ -207,9 +202,9 @@ TEST(SimpleCallJSFunction2Arg) { Node* function = m.Parameter(0); Node* context = m.Parameter(1); - Node* receiver = SmiTag(m, m.Int32Constant(42)); - Node* a = SmiTag(m, m.Int32Constant(13)); - Node* b = SmiTag(m, m.Int32Constant(153)); + Node* receiver = SmiTag(&m, m.Int32Constant(42)); + Node* a = SmiTag(&m, m.Int32Constant(13)); + Node* b = SmiTag(&m, m.Int32Constant(153)); Callable callable = CodeFactory::Call(isolate); Node* result = m.CallJS(callable, context, function, receiver, a, b); @@ -217,7 +212,7 @@ TEST(SimpleCallJSFunction2Arg) { } FunctionTester ft(asm_tester.GenerateCode(), kNumParams); - Handle sum = CreateSumAllArgumentsFunction(ft); + Handle sum = CreateSumAllArgumentsFunction(&ft); MaybeHandle result = ft.Call(sum); CHECK_EQ(Smi::FromInt(208), *result.ToHandleChecked()); } @@ -388,11 +383,11 @@ TEST(TestToConstant) { CHECK(m.ToInt32Constant(a, &value32)); CHECK(m.ToInt64Constant(a, &value64)); - a = UndefinedConstant(m); + a = UndefinedConstant(&m); CHECK(!m.ToInt32Constant(a, &value32)); CHECK(!m.ToInt64Constant(a, &value64)); - a = UndefinedConstant(m); + a = UndefinedConstant(&m); CHECK(!m.ToInt32Constant(a, &value32)); CHECK(!m.ToInt64Constant(a, &value64)); } @@ -411,7 +406,7 @@ TEST(DeferredCodePhiHints) { m.Goto(&loop); m.Bind(&loop); { - Node* map = LoadMap(m, var_object.value()); + Node* map = LoadMap(&m, var_object.value()); var_object.Bind(map); m.Goto(&loop); } @@ -514,20 +509,20 @@ TEST(GotoIfExceptionMultiple) { // try { ToString(param2); return 7 } catch (e) { ... } m.Bind(&exception_handler1); return_value.Bind(m.Int32Constant(7)); - error.Bind(UndefinedConstant(m)); + error.Bind(UndefinedConstant(&m)); string = m.CallStub(to_string, context, second_value); m.GotoIfException(string, &exception_handler2, &error); - m.Return(SmiFromInt32(m, return_value.value())); + m.Return(SmiFromInt32(&m, return_value.value())); // try { ToString(param3); return 7 & ~2; } catch (e) { return e; } m.Bind(&exception_handler2); // Return returnValue & ~2 - error.Bind(UndefinedConstant(m)); + error.Bind(UndefinedConstant(&m)); string = m.CallStub(to_string, context, third_value); m.GotoIfException(string, &exception_handler3, &error); m.Return(SmiFromInt32( - m, m.Word32And(return_value.value(), - m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1))))); + &m, m.Word32And(return_value.value(), + m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1))))); m.Bind(&exception_handler3); m.Return(error.value()); diff --git a/test/cctest/compiler/test-jump-threading.cc b/test/cctest/compiler/test-jump-threading.cc index 44bee022b3..fe4590f404 100644 --- a/test/cctest/compiler/test-jump-threading.cc +++ b/test/cctest/compiler/test-jump-threading.cc @@ -109,12 +109,11 @@ class TestCode : public HandleAndZoneScope { } }; -void VerifyForwarding(TestCode& code, // NOLINT(runtime/references) - int count, int* expected) { +void VerifyForwarding(TestCode* code, int count, int* expected) { v8::internal::AccountingAllocator allocator; Zone local_zone(&allocator, ZONE_NAME); ZoneVector result(&local_zone); - JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_, true); + JumpThreading::ComputeForwarding(&local_zone, result, &code->sequence_, true); CHECK(count == static_cast(result.size())); for (int i = 0; i < count; i++) { @@ -133,7 +132,7 @@ TEST(FwEmpty1) { code.End(); static int expected[] = {2, 2, 2}; - VerifyForwarding(code, 3, expected); + VerifyForwarding(&code, 3, expected); } @@ -150,7 +149,7 @@ TEST(FwEmptyN) { code.End(); static int expected[] = {2, 2, 2}; - VerifyForwarding(code, 3, expected); + VerifyForwarding(&code, 3, expected); } } @@ -162,7 +161,7 @@ TEST(FwNone1) { code.End(); static int expected[] = {0}; - VerifyForwarding(code, 1, expected); + VerifyForwarding(&code, 1, expected); } @@ -174,7 +173,7 @@ TEST(FwMoves1) { code.End(); static int expected[] = {0}; - VerifyForwarding(code, 1, expected); + VerifyForwarding(&code, 1, expected); } @@ -188,7 +187,7 @@ TEST(FwMoves2) { code.End(); static int expected[] = {1, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -202,7 +201,7 @@ TEST(FwMoves2b) { code.End(); static int expected[] = {0, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -216,7 +215,7 @@ TEST(FwOther2) { code.End(); static int expected[] = {0, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -229,7 +228,7 @@ TEST(FwNone2a) { code.End(); static int expected[] = {1, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -242,7 +241,7 @@ TEST(FwNone2b) { code.End(); static int expected[] = {1, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -253,7 +252,7 @@ TEST(FwLoop1) { code.Jump(0); static int expected[] = {0}; - VerifyForwarding(code, 1, expected); + VerifyForwarding(&code, 1, expected); } @@ -266,7 +265,7 @@ TEST(FwLoop2) { code.Jump(0); static int expected[] = {0, 0}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -281,7 +280,7 @@ TEST(FwLoop3) { code.Jump(0); static int expected[] = {0, 0, 0}; - VerifyForwarding(code, 3, expected); + VerifyForwarding(&code, 3, expected); } @@ -294,7 +293,7 @@ TEST(FwLoop1b) { code.Jump(1); static int expected[] = {1, 1}; - VerifyForwarding(code, 2, expected); + VerifyForwarding(&code, 2, expected); } @@ -309,7 +308,7 @@ TEST(FwLoop2b) { code.Jump(1); static int expected[] = {1, 1, 1}; - VerifyForwarding(code, 3, expected); + VerifyForwarding(&code, 3, expected); } @@ -326,7 +325,7 @@ TEST(FwLoop3b) { code.Jump(1); static int expected[] = {1, 1, 1, 1}; - VerifyForwarding(code, 4, expected); + VerifyForwarding(&code, 4, expected); } @@ -345,7 +344,7 @@ TEST(FwLoop2_1a) { code.Jump(2); static int expected[] = {1, 1, 1, 1, 1}; - VerifyForwarding(code, 5, expected); + VerifyForwarding(&code, 5, expected); } @@ -364,7 +363,7 @@ TEST(FwLoop2_1b) { code.Jump(2); static int expected[] = {2, 2, 2, 2, 2}; - VerifyForwarding(code, 5, expected); + VerifyForwarding(&code, 5, expected); } @@ -383,7 +382,7 @@ TEST(FwLoop2_1c) { code.Jump(1); static int expected[] = {1, 1, 1, 1, 1}; - VerifyForwarding(code, 5, expected); + VerifyForwarding(&code, 5, expected); } @@ -402,7 +401,7 @@ TEST(FwLoop2_1d) { code.Jump(1); static int expected[] = {1, 1, 1, 1, 1}; - VerifyForwarding(code, 5, expected); + VerifyForwarding(&code, 5, expected); } @@ -423,7 +422,7 @@ TEST(FwLoop3_1a) { code.Jump(0); static int expected[] = {2, 2, 2, 2, 2, 2}; - VerifyForwarding(code, 6, expected); + VerifyForwarding(&code, 6, expected); } @@ -443,7 +442,7 @@ TEST(FwDiamonds) { code.End(); int expected[] = {0, i ? 1 : 3, j ? 2 : 3, 3}; - VerifyForwarding(code, 4, expected); + VerifyForwarding(&code, 4, expected); } } } @@ -470,7 +469,7 @@ TEST(FwDiamonds2) { int merge = k ? 3 : 4; int expected[] = {0, i ? 1 : merge, j ? 2 : merge, merge, 4}; - VerifyForwarding(code, 5, expected); + VerifyForwarding(&code, 5, expected); } } } @@ -504,7 +503,7 @@ TEST(FwDoubleDiamonds) { int expected[] = {0, i ? 1 : 3, j ? 2 : 3, 3, x ? 4 : 6, y ? 5 : 6, 6}; - VerifyForwarding(code, 7, expected); + VerifyForwarding(&code, 7, expected); } } } @@ -568,7 +567,7 @@ void RunPermutedChain(int* permutation, int size) { int expected[] = {size + 1, size + 1, size + 1, size + 1, size + 1, size + 1, size + 1}; - VerifyForwarding(code, size + 2, expected); + VerifyForwarding(&code, size + 2, expected); } @@ -604,55 +603,50 @@ void RunPermutedDiamond(int* permutation, int size) { int expected[] = {br, 5, 5, 5, 5, 5}; expected[br] = br; - VerifyForwarding(code, 6, expected); + VerifyForwarding(&code, 6, expected); } TEST(FwPermuted_diamond) { RunAllPermutations<4>(RunPermutedDiamond); } -void ApplyForwarding(TestCode& code, // NOLINT(runtime/references) - int size, int* forward) { - code.sequence_.RecomputeAssemblyOrderForTesting(); - ZoneVector vector(code.main_zone()); +void ApplyForwarding(TestCode* code, int size, int* forward) { + code->sequence_.RecomputeAssemblyOrderForTesting(); + ZoneVector vector(code->main_zone()); for (int i = 0; i < size; i++) { vector.push_back(RpoNumber::FromInt(forward[i])); } - JumpThreading::ApplyForwarding(code.main_zone(), vector, &code.sequence_); + JumpThreading::ApplyForwarding(code->main_zone(), vector, &code->sequence_); } -void CheckJump(TestCode& code, // NOLINT(runtime/references) - int pos, int target) { - Instruction* instr = code.sequence_.InstructionAt(pos); +void CheckJump(TestCode* code, int pos, int target) { + Instruction* instr = code->sequence_.InstructionAt(pos); CHECK_EQ(kArchJmp, instr->arch_opcode()); CHECK_EQ(1, static_cast(instr->InputCount())); CHECK_EQ(0, static_cast(instr->OutputCount())); CHECK_EQ(0, static_cast(instr->TempCount())); - CHECK_EQ(target, code.sequence_.InputRpo(instr, 0).ToInt()); + CHECK_EQ(target, code->sequence_.InputRpo(instr, 0).ToInt()); } -void CheckNop(TestCode& code, // NOLINT(runtime/references) - int pos) { - Instruction* instr = code.sequence_.InstructionAt(pos); +void CheckNop(TestCode* code, int pos) { + Instruction* instr = code->sequence_.InstructionAt(pos); CHECK_EQ(kArchNop, instr->arch_opcode()); CHECK_EQ(0, static_cast(instr->InputCount())); CHECK_EQ(0, static_cast(instr->OutputCount())); CHECK_EQ(0, static_cast(instr->TempCount())); } -void CheckBranch(TestCode& code, // NOLINT(runtime/references) - int pos, int t1, int t2) { - Instruction* instr = code.sequence_.InstructionAt(pos); +void CheckBranch(TestCode* code, int pos, int t1, int t2) { + Instruction* instr = code->sequence_.InstructionAt(pos); CHECK_EQ(2, static_cast(instr->InputCount())); CHECK_EQ(0, static_cast(instr->OutputCount())); CHECK_EQ(0, static_cast(instr->TempCount())); - CHECK_EQ(t1, code.sequence_.InputRpo(instr, 0).ToInt()); - CHECK_EQ(t2, code.sequence_.InputRpo(instr, 1).ToInt()); + CHECK_EQ(t1, code->sequence_.InputRpo(instr, 0).ToInt()); + CHECK_EQ(t2, code->sequence_.InputRpo(instr, 1).ToInt()); } -void CheckAssemblyOrder(TestCode& code, // NOLINT(runtime/references) - int size, int* expected) { +void CheckAssemblyOrder(TestCode* code, int size, int* expected) { int i = 0; - for (auto const block : code.sequence_.instruction_blocks()) { + for (auto const block : code->sequence_.instruction_blocks()) { CHECK_EQ(expected[i++], block->ao_number().ToInt()); } } @@ -668,12 +662,12 @@ TEST(Rewire1) { code.End(); static int forward[] = {2, 2, 2}; - ApplyForwarding(code, 3, forward); - CheckJump(code, j1, 2); - CheckNop(code, j2); + ApplyForwarding(&code, 3, forward); + CheckJump(&code, j1, 2); + CheckNop(&code, j2); static int assembly[] = {0, 1, 1}; - CheckAssemblyOrder(code, 3, assembly); + CheckAssemblyOrder(&code, 3, assembly); } @@ -691,13 +685,13 @@ TEST(Rewire1_deferred) { code.End(); static int forward[] = {3, 3, 3, 3}; - ApplyForwarding(code, 4, forward); - CheckJump(code, j1, 3); - CheckNop(code, j2); - CheckNop(code, j3); + ApplyForwarding(&code, 4, forward); + CheckJump(&code, j1, 3); + CheckNop(&code, j2); + CheckNop(&code, j3); static int assembly[] = {0, 1, 2, 1}; - CheckAssemblyOrder(code, 4, assembly); + CheckAssemblyOrder(&code, 4, assembly); } @@ -717,12 +711,12 @@ TEST(Rewire2_deferred) { code.End(); static int forward[] = {0, 1, 2, 3}; - ApplyForwarding(code, 4, forward); - CheckJump(code, j1, 1); - CheckJump(code, j2, 3); + ApplyForwarding(&code, 4, forward); + CheckJump(&code, j1, 1); + CheckJump(&code, j2, 3); static int assembly[] = {0, 2, 3, 1}; - CheckAssemblyOrder(code, 4, assembly); + CheckAssemblyOrder(&code, 4, assembly); } @@ -742,18 +736,18 @@ TEST(Rewire_diamond) { code.End(); int forward[] = {0, 1, i ? 4 : 2, j ? 4 : 3, 4}; - ApplyForwarding(code, 5, forward); - CheckJump(code, j1, 1); - CheckBranch(code, b1, i ? 4 : 2, j ? 4 : 3); + ApplyForwarding(&code, 5, forward); + CheckJump(&code, j1, 1); + CheckBranch(&code, b1, i ? 4 : 2, j ? 4 : 3); if (i) { - CheckNop(code, j2); + CheckNop(&code, j2); } else { - CheckJump(code, j2, 4); + CheckJump(&code, j2, 4); } if (j) { - CheckNop(code, j3); + CheckNop(&code, j3); } else { - CheckJump(code, j3, 4); + CheckJump(&code, j3, 4); } int assembly[] = {0, 1, 2, 3, 4}; @@ -763,7 +757,7 @@ TEST(Rewire_diamond) { if (j) { for (int k = 4; k < 5; k++) assembly[k]--; } - CheckAssemblyOrder(code, 5, assembly); + CheckAssemblyOrder(&code, 5, assembly); } } } diff --git a/test/cctest/compiler/test-loop-analysis.cc b/test/cctest/compiler/test-loop-analysis.cc index 231a3ada5a..38ce2f3463 100644 --- a/test/cctest/compiler/test-loop-analysis.cc +++ b/test/cctest/compiler/test-loop-analysis.cc @@ -201,9 +201,9 @@ struct While { } void chain(Node* control) { loop->ReplaceInput(0, control); } - void nest(While& that) { // NOLINT(runtime/references) - that.loop->ReplaceInput(1, exit); - this->loop->ReplaceInput(0, that.if_true); + void nest(While* that) { + that->loop->ReplaceInput(1, exit); + this->loop->ReplaceInput(0, that->if_true); } }; @@ -214,17 +214,17 @@ struct Counter { Node* phi; Node* add; - Counter(While& w, // NOLINT(runtime/references) - int32_t b, int32_t k) - : base(w.t.jsgraph.Int32Constant(b)), inc(w.t.jsgraph.Int32Constant(k)) { + Counter(While* w, int32_t b, int32_t k) + : base(w->t.jsgraph.Int32Constant(b)), + inc(w->t.jsgraph.Int32Constant(k)) { Build(w); } - Counter(While& w, Node* b, Node* k) : base(b), inc(k) { Build(w); } + Counter(While* w, Node* b, Node* k) : base(b), inc(k) { Build(w); } - void Build(While& w) { - phi = w.t.graph.NewNode(w.t.op(2, false), base, base, w.loop); - add = w.t.graph.NewNode(&kIntAdd, phi, inc); + void Build(While* w) { + phi = w->t.graph.NewNode(w->t.op(2, false), base, base, w->loop); + add = w->t.graph.NewNode(&kIntAdd, phi, inc); phi->ReplaceInput(1, add); } }; @@ -236,16 +236,16 @@ struct StoreLoop { Node* phi; Node* store; - explicit StoreLoop(While& w) // NOLINT(runtime/references) - : base(w.t.graph.start()), val(w.t.jsgraph.Int32Constant(13)) { + explicit StoreLoop(While* w) + : base(w->t.graph.start()), val(w->t.jsgraph.Int32Constant(13)) { Build(w); } - StoreLoop(While& w, Node* b, Node* v) : base(b), val(v) { Build(w); } + StoreLoop(While* w, Node* b, Node* v) : base(b), val(v) { Build(w); } - void Build(While& w) { - phi = w.t.graph.NewNode(w.t.op(2, true), base, base, w.loop); - store = w.t.graph.NewNode(&kStore, val, phi, w.loop); + void Build(While* w) { + phi = w->t.graph.NewNode(w->t.op(2, true), base, base, w->loop); + store = w->t.graph.NewNode(&kStore, val, phi, w->loop); phi->ReplaceInput(1, store); } }; @@ -287,7 +287,7 @@ TEST(LaLoop1c) { // One loop with a counter. LoopFinderTester t; While w(t, t.p0); - Counter c(w, 0, 1); + Counter c(&w, 0, 1); t.Return(c.phi, t.start, w.exit); Node* chain[] = {w.loop}; @@ -303,7 +303,7 @@ TEST(LaLoop1e) { // One loop with an effect phi. LoopFinderTester t; While w(t, t.p0); - StoreLoop c(w); + StoreLoop c(&w); t.Return(t.p0, c.phi, w.exit); Node* chain[] = {w.loop}; @@ -319,8 +319,8 @@ TEST(LaLoop1d) { // One loop with two counters. LoopFinderTester t; While w(t, t.p0); - Counter c1(w, 0, 1); - Counter c2(w, 1, 1); + Counter c1(&w, 0, 1); + Counter c2(&w, 1, 1); t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w.exit); Node* chain[] = {w.loop}; @@ -365,8 +365,8 @@ TEST(LaLoop2c) { LoopFinderTester t; While w1(t, t.p0); While w2(t, t.p0); - Counter c1(w1, 0, 1); - Counter c2(w2, 0, 1); + Counter c1(&w1, 0, 1); + Counter c2(&w2, 0, 1); w2.chain(w1.exit); t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w2.exit); @@ -396,10 +396,10 @@ TEST(LaLoop2cc) { LoopFinderTester t; While w1(t, t.p0); While w2(t, t.p0); - Counter c1(w1, 0, 1); + Counter c1(&w1, 0, 1); // various usage scenarios for the second loop. - Counter c2(w2, i & 1 ? t.p0 : c1.phi, i & 2 ? t.p0 : c1.phi); + Counter c2(&w2, i & 1 ? t.p0 : c1.phi, i & 2 ? t.p0 : c1.phi); if (i & 3) w2.branch->ReplaceInput(0, c1.phi); w2.chain(w1.exit); @@ -431,7 +431,7 @@ TEST(LaNestedLoop1) { LoopFinderTester t; While w1(t, t.p0); While w2(t, t.p0); - w2.nest(w1); + w2.nest(&w1); t.Return(t.p0, t.start, w1.exit); Node* chain[] = {w1.loop, w2.loop}; @@ -452,10 +452,10 @@ TEST(LaNestedLoop1c) { LoopFinderTester t; While w1(t, t.p0); While w2(t, t.p0); - Counter c1(w1, 0, 1); - Counter c2(w2, 0, 1); + Counter c1(&w1, 0, 1); + Counter c2(&w2, 0, 1); w2.branch->ReplaceInput(0, c2.phi); - w2.nest(w1); + w2.nest(&w1); t.Return(c1.phi, t.start, w1.exit); Node* chain[] = {w1.loop, w2.loop}; @@ -477,7 +477,7 @@ TEST(LaNestedLoop1x) { LoopFinderTester t; While w1(t, t.p0); While w2(t, t.p0); - w2.nest(w1); + w2.nest(&w1); const Operator* op = t.common.Phi(MachineRepresentation::kWord32, 2); Node* p1a = t.graph.NewNode(op, t.p0, t.p0, w1.loop); @@ -513,8 +513,8 @@ TEST(LaNestedLoop2) { While w1(t, t.p0); While w2(t, t.p0); While w3(t, t.p0); - w2.nest(w1); - w3.nest(w1); + w2.nest(&w1); + w3.nest(&w1); w3.chain(w2.exit); t.Return(t.p0, t.start, w1.exit); @@ -573,11 +573,11 @@ TEST(LaNestedLoop3c) { // Three nested loops with counters. LoopFinderTester t; While w1(t, t.p0); - Counter c1(w1, 0, 1); + Counter c1(&w1, 0, 1); While w2(t, t.p0); - Counter c2(w2, 0, 1); + Counter c2(&w2, 0, 1); While w3(t, t.p0); - Counter c3(w3, 0, 1); + Counter c3(&w3, 0, 1); w2.loop->ReplaceInput(0, w1.if_true); w3.loop->ReplaceInput(0, w2.if_true); w2.loop->ReplaceInput(1, w3.exit); diff --git a/test/cctest/compiler/test-multiple-return.cc b/test/cctest/compiler/test-multiple-return.cc index c054e7654a..5d6acd77b0 100644 --- a/test/cctest/compiler/test-multiple-return.cc +++ b/test/cctest/compiler/test-multiple-return.cc @@ -43,81 +43,76 @@ CallDescriptor* CreateCallDescriptor(Zone* zone, int return_count, return compiler::GetWasmCallDescriptor(zone, builder.Build()); } -Node* MakeConstant(RawMachineAssembler& m, // NOLINT(runtime/references) - MachineType type, int value) { +Node* MakeConstant(RawMachineAssembler* m, MachineType type, int value) { switch (type.representation()) { case MachineRepresentation::kWord32: - return m.Int32Constant(static_cast(value)); + return m->Int32Constant(static_cast(value)); case MachineRepresentation::kWord64: - return m.Int64Constant(static_cast(value)); + return m->Int64Constant(static_cast(value)); case MachineRepresentation::kFloat32: - return m.Float32Constant(static_cast(value)); + return m->Float32Constant(static_cast(value)); case MachineRepresentation::kFloat64: - return m.Float64Constant(static_cast(value)); + return m->Float64Constant(static_cast(value)); default: UNREACHABLE(); } } -Node* Add(RawMachineAssembler& m, // NOLINT(runtime/references) - MachineType type, Node* a, Node* b) { +Node* Add(RawMachineAssembler* m, MachineType type, Node* a, Node* b) { switch (type.representation()) { case MachineRepresentation::kWord32: - return m.Int32Add(a, b); + return m->Int32Add(a, b); case MachineRepresentation::kWord64: - return m.Int64Add(a, b); + return m->Int64Add(a, b); case MachineRepresentation::kFloat32: - return m.Float32Add(a, b); + return m->Float32Add(a, b); case MachineRepresentation::kFloat64: - return m.Float64Add(a, b); + return m->Float64Add(a, b); default: UNREACHABLE(); } } -Node* Sub(RawMachineAssembler& m, // NOLINT(runtime/references) - MachineType type, Node* a, Node* b) { +Node* Sub(RawMachineAssembler* m, MachineType type, Node* a, Node* b) { switch (type.representation()) { case MachineRepresentation::kWord32: - return m.Int32Sub(a, b); + return m->Int32Sub(a, b); case MachineRepresentation::kWord64: - return m.Int64Sub(a, b); + return m->Int64Sub(a, b); case MachineRepresentation::kFloat32: - return m.Float32Sub(a, b); + return m->Float32Sub(a, b); case MachineRepresentation::kFloat64: - return m.Float64Sub(a, b); + return m->Float64Sub(a, b); default: UNREACHABLE(); } } -Node* Mul(RawMachineAssembler& m, // NOLINT(runtime/references) - MachineType type, Node* a, Node* b) { +Node* Mul(RawMachineAssembler* m, MachineType type, Node* a, Node* b) { switch (type.representation()) { case MachineRepresentation::kWord32: - return m.Int32Mul(a, b); + return m->Int32Mul(a, b); case MachineRepresentation::kWord64: - return m.Int64Mul(a, b); + return m->Int64Mul(a, b); case MachineRepresentation::kFloat32: - return m.Float32Mul(a, b); + return m->Float32Mul(a, b); case MachineRepresentation::kFloat64: - return m.Float64Mul(a, b); + return m->Float64Mul(a, b); default: UNREACHABLE(); } } -Node* ToInt32(RawMachineAssembler& m, // NOLINT(runtime/references) - MachineType type, Node* a) { +Node* ToInt32(RawMachineAssembler* m, MachineType type, Node* a) { switch (type.representation()) { case MachineRepresentation::kWord32: return a; case MachineRepresentation::kWord64: - return m.TruncateInt64ToInt32(a); + return m->TruncateInt64ToInt32(a); case MachineRepresentation::kFloat32: - return m.TruncateFloat32ToInt32(a); + return m->TruncateFloat32ToInt32(a); case MachineRepresentation::kFloat64: - return m.RoundFloat64ToInt32(a); + return m->RoundFloat64ToInt32(a); default: UNREACHABLE(); } @@ -159,9 +154,9 @@ void TestReturnMultipleValues(MachineType type) { using Node_ptr = Node*; std::unique_ptr returns(new Node_ptr[count]); for (int i = 0; i < count; ++i) { - if (i % 3 == 0) returns[i] = Add(m, type, p0, p1); - if (i % 3 == 1) returns[i] = Sub(m, type, p0, p1); - if (i % 3 == 2) returns[i] = Mul(m, type, p0, p1); + if (i % 3 == 0) returns[i] = Add(&m, type, p0, p1); + if (i % 3 == 1) returns[i] = Sub(&m, type, p0, p1); + if (i % 3 == 2) returns[i] = Mul(&m, type, p0, p1); } m.Return(count, returns.get()); @@ -201,24 +196,24 @@ void TestReturnMultipleValues(MachineType type) { // WasmContext dummy call_inputs[1] = mt.PointerConstant(nullptr); // Special inputs for the test. - call_inputs[2] = MakeConstant(mt, type, a); - call_inputs[3] = MakeConstant(mt, type, b); + call_inputs[2] = MakeConstant(&mt, type, a); + call_inputs[3] = MakeConstant(&mt, type, b); for (int i = 2; i < param_count; i++) { - call_inputs[2 + i] = MakeConstant(mt, type, i); + call_inputs[2 + i] = MakeConstant(&mt, type, i); } Node* ret_multi = mt.AddNode(mt.common()->Call(desc), input_count, call_inputs); - Node* ret = MakeConstant(mt, type, 0); + Node* ret = MakeConstant(&mt, type, 0); bool sign = false; for (int i = 0; i < count; ++i) { Node* x = (count == 1) ? ret_multi : mt.AddNode(mt.common()->Projection(i), ret_multi); - ret = sign ? Sub(mt, type, ret, x) : Add(mt, type, ret, x); + ret = sign ? Sub(&mt, type, ret, x) : Add(&mt, type, ret, x); if (i % 4 == 0) sign = !sign; } - mt.Return(ToInt32(mt, type, ret)); + mt.Return(ToInt32(&mt, type, ret)); #ifdef ENABLE_DISASSEMBLER Handle code2 = mt.GetCode(); if (FLAG_print_code) { @@ -265,7 +260,7 @@ void ReturnLastValue(MachineType type) { std::unique_ptr returns(new Node*[return_count]); for (int i = 0; i < return_count; ++i) { - returns[i] = MakeConstant(m, type, i); + returns[i] = MakeConstant(&m, type, i); } m.Return(return_count, returns.get()); @@ -292,8 +287,9 @@ void ReturnLastValue(MachineType type) { Node* call = mt.AddNode(mt.common()->Call(desc), 2, inputs); - mt.Return(ToInt32( - mt, type, mt.AddNode(mt.common()->Projection(return_count - 1), call))); + mt.Return( + ToInt32(&mt, type, + mt.AddNode(mt.common()->Projection(return_count - 1), call))); CHECK_EQ(expect, mt.Call()); } @@ -327,7 +323,7 @@ void ReturnSumOfReturns(MachineType type) { std::unique_ptr returns(new Node*[return_count]); for (int i = 0; i < return_count; ++i) { - returns[i] = MakeConstant(m, type, i); + returns[i] = MakeConstant(&m, type, i); } m.Return(return_count, returns.get()); @@ -360,7 +356,7 @@ void ReturnSumOfReturns(MachineType type) { expect += i; result = mt.Int32Add( result, - ToInt32(mt, type, mt.AddNode(mt.common()->Projection(i), call))); + ToInt32(&mt, type, mt.AddNode(mt.common()->Projection(i), call))); } mt.Return(result); diff --git a/test/cctest/compiler/test-run-native-calls.cc b/test/cctest/compiler/test-run-native-calls.cc index 026e8307ae..159e5d5d2c 100644 --- a/test/cctest/compiler/test-run-native-calls.cc +++ b/test/cctest/compiler/test-run-native-calls.cc @@ -327,38 +327,32 @@ class ArgsBuffer { return kTypes; } - Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) - int32_t value) { - return raw.Int32Constant(value); + Node* MakeConstant(RawMachineAssembler* raw, int32_t value) { + return raw->Int32Constant(value); } - Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) - int64_t value) { - return raw.Int64Constant(value); + Node* MakeConstant(RawMachineAssembler* raw, int64_t value) { + return raw->Int64Constant(value); } - Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) - float32 value) { - return raw.Float32Constant(value); + Node* MakeConstant(RawMachineAssembler* raw, float32 value) { + return raw->Float32Constant(value); } - Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) - float64 value) { - return raw.Float64Constant(value); + Node* MakeConstant(RawMachineAssembler* raw, float64 value) { + return raw->Float64Constant(value); } - Node* LoadInput(RawMachineAssembler& raw, // NOLINT(runtime/references) - Node* base, int index) { - Node* offset = raw.Int32Constant(index * sizeof(CType)); - return raw.Load(MachineTypeForC(), base, offset); + Node* LoadInput(RawMachineAssembler* raw, Node* base, int index) { + Node* offset = raw->Int32Constant(index * sizeof(CType)); + return raw->Load(MachineTypeForC(), base, offset); } - Node* StoreOutput(RawMachineAssembler& raw, // NOLINT(runtime/references) - Node* value) { - Node* base = raw.PointerConstant(&output); - Node* offset = raw.Int32Constant(0); - return raw.Store(MachineTypeForC().representation(), base, offset, - value, kNoWriteBarrier); + Node* StoreOutput(RawMachineAssembler* raw, Node* value) { + Node* base = raw->PointerConstant(&output); + Node* offset = raw->Int32Constant(0); + return raw->Store(MachineTypeForC().representation(), base, offset, + value, kNoWriteBarrier); } // Computes the next set of inputs by updating the {input} array. @@ -425,7 +419,7 @@ template class Computer { public: static void Run(CallDescriptor* desc, - void (*build)(CallDescriptor*, RawMachineAssembler&), + void (*build)(CallDescriptor*, RawMachineAssembler*), CType (*compute)(CallDescriptor*, CType* inputs), int seed = 1) { int num_params = ParamCount(desc); @@ -438,7 +432,7 @@ class Computer { Zone zone(isolate->allocator(), ZONE_NAME); Graph graph(&zone); RawMachineAssembler raw(isolate, &graph, desc); - build(desc, raw); + build(desc, &raw); inner = CompileGraph("Compute", desc, &graph, raw.ExportForTest()); } @@ -459,11 +453,11 @@ class Computer { int input_count = 0; inputs[input_count++] = target; for (int i = 0; i < num_params; i++) { - inputs[input_count++] = io.MakeConstant(raw, io.input[i]); + inputs[input_count++] = io.MakeConstant(&raw, io.input[i]); } Node* call = raw.CallN(desc, input_count, inputs); - Node* store = io.StoreOutput(raw, call); + Node* store = io.StoreOutput(&raw, call); USE(store); raw.Return(raw.Int32Constant(seed)); wrapper = CompileGraph("Compute-wrapper-const", cdesc, &graph, @@ -494,11 +488,11 @@ class Computer { int input_count = 0; inputs[input_count++] = target; for (int i = 0; i < num_params; i++) { - inputs[input_count++] = io.LoadInput(raw, base, i); + inputs[input_count++] = io.LoadInput(&raw, base, i); } Node* call = raw.CallN(desc, input_count, inputs); - Node* store = io.StoreOutput(raw, call); + Node* store = io.StoreOutput(&raw, call); USE(store); raw.Return(raw.Int32Constant(seed)); wrapper = @@ -704,28 +698,25 @@ TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { } } - template static void Run_Computation( - CallDescriptor* desc, void (*build)(CallDescriptor*, RawMachineAssembler&), + CallDescriptor* desc, void (*build)(CallDescriptor*, RawMachineAssembler*), CType (*compute)(CallDescriptor*, CType* inputs), int seed = 1) { Computer::Run(desc, build, compute, seed); } - static uint32_t coeff[] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113}; -static void Build_Int32_WeightedSum( - CallDescriptor* desc, - RawMachineAssembler& raw) { // NOLINT(runtime/references) - Node* result = raw.Int32Constant(0); +static void Build_Int32_WeightedSum(CallDescriptor* desc, + RawMachineAssembler* raw) { + Node* result = raw->Int32Constant(0); for (int i = 0; i < ParamCount(desc); i++) { - Node* term = raw.Int32Mul(raw.Parameter(i), raw.Int32Constant(coeff[i])); - result = raw.Int32Add(result, term); + Node* term = raw->Int32Mul(raw->Parameter(i), raw->Int32Constant(coeff[i])); + result = raw->Int32Add(result, term); } - raw.Return(result); + raw->Return(result); } static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) { @@ -774,10 +765,8 @@ TEST_INT32_WEIGHTEDSUM(17) TEST_INT32_WEIGHTEDSUM(19) template -static void Build_Select( - CallDescriptor* desc, - RawMachineAssembler& raw) { // NOLINT(runtime/references) - raw.Return(raw.Parameter(which)); +static void Build_Select(CallDescriptor* desc, RawMachineAssembler* raw) { + raw->Return(raw->Parameter(which)); } template @@ -950,9 +939,8 @@ TEST(Float64Select_stack_params_return_reg) { } template -static void Build_Select_With_Call( - CallDescriptor* desc, - RawMachineAssembler& raw) { // NOLINT(runtime/references) +static void Build_Select_With_Call(CallDescriptor* desc, + RawMachineAssembler* raw) { Handle inner = Handle::null(); int num_params = ParamCount(desc); CHECK_LE(num_params, kMaxParamCount); @@ -971,16 +959,16 @@ static void Build_Select_With_Call( { // Build a call to the function that does the select. - Node* target = raw.HeapConstant(inner); - Node** inputs = raw.zone()->NewArray(num_params + 1); + Node* target = raw->HeapConstant(inner); + Node** inputs = raw->zone()->NewArray(num_params + 1); int input_count = 0; inputs[input_count++] = target; for (int i = 0; i < num_params; i++) { - inputs[input_count++] = raw.Parameter(i); + inputs[input_count++] = raw->Parameter(i); } - Node* call = raw.CallN(desc, input_count, inputs); - raw.Return(call); + Node* call = raw->CallN(desc, input_count, inputs); + raw->Return(call); } } diff --git a/test/cctest/heap/test-compaction.cc b/test/cctest/heap/test-compaction.cc index 35bd9225ea..354b380234 100644 --- a/test/cctest/heap/test-compaction.cc +++ b/test/cctest/heap/test-compaction.cc @@ -31,9 +31,8 @@ void CheckInvariantsOfAbortedPage(Page* page) { CHECK(!page->IsFlagSet(Page::COMPACTION_WAS_ABORTED)); } -void CheckAllObjectsOnPage( - std::vector>& handles, // NOLINT(runtime/references) - Page* page) { +void CheckAllObjectsOnPage(const std::vector>& handles, + Page* page) { for (Handle fixed_array : handles) { CHECK(Page::FromHeapObject(*fixed_array) == page); } diff --git a/test/cctest/heap/test-page-promotion.cc b/test/cctest/heap/test-page-promotion.cc index 5d4a543719..c31fc39c2e 100644 --- a/test/cctest/heap/test-page-promotion.cc +++ b/test/cctest/heap/test-page-promotion.cc @@ -43,8 +43,7 @@ v8::Isolate* NewIsolateForPagePromotion(int min_semi_space_size = 8, return isolate; } -Page* FindLastPageInNewSpace( - std::vector>& handles) { // NOLINT(runtime/references) +Page* FindLastPageInNewSpace(const std::vector>& handles) { for (auto rit = handles.rbegin(); rit != handles.rend(); ++rit) { // One deref gets the Handle, the second deref gets the FixedArray. Page* candidate = Page::FromHeapObject(**rit); diff --git a/test/cctest/interpreter/bytecode-expectations-printer.cc b/test/cctest/interpreter/bytecode-expectations-printer.cc index 370c5d8131..a271df4f67 100644 --- a/test/cctest/interpreter/bytecode-expectations-printer.cc +++ b/test/cctest/interpreter/bytecode-expectations-printer.cc @@ -132,24 +132,24 @@ BytecodeExpectationsPrinter::GetBytecodeArrayOfCallee( } void BytecodeExpectationsPrinter::PrintEscapedString( - std::ostream& stream, const std::string& string) const { + std::ostream* stream, const std::string& string) const { for (char c : string) { switch (c) { case '"': - stream << "\\\""; + *stream << "\\\""; break; case '\\': - stream << "\\\\"; + *stream << "\\\\"; break; default: - stream << c; + *stream << c; break; } } } void BytecodeExpectationsPrinter::PrintBytecodeOperand( - std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, + std::ostream* stream, const BytecodeArrayIterator& bytecode_iterator, const Bytecode& bytecode, int op_index, int parameter_count) const { OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index); OperandSize op_size = Bytecodes::GetOperandSize( @@ -172,207 +172,207 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( if (Bytecodes::IsRegisterOperandType(op_type)) { Register register_value = bytecode_iterator.GetRegisterOperand(op_index); - stream << 'R'; - if (op_size != OperandSize::kByte) stream << size_tag; + *stream << 'R'; + if (op_size != OperandSize::kByte) *stream << size_tag; if (register_value.is_current_context()) { - stream << "(context)"; + *stream << "(context)"; } else if (register_value.is_function_closure()) { - stream << "(closure)"; + *stream << "(closure)"; } else if (register_value.is_parameter()) { int parameter_index = register_value.ToParameterIndex(parameter_count); if (parameter_index == 0) { - stream << "(this)"; + *stream << "(this)"; } else { - stream << "(arg" << (parameter_index - 1) << ')'; + *stream << "(arg" << (parameter_index - 1) << ')'; } } else { - stream << '(' << register_value.index() << ')'; + *stream << '(' << register_value.index() << ')'; } } else { switch (op_type) { case OperandType::kFlag8: - stream << 'U' << size_tag << '('; - stream << bytecode_iterator.GetFlagOperand(op_index); + *stream << 'U' << size_tag << '('; + *stream << bytecode_iterator.GetFlagOperand(op_index); break; case OperandType::kIdx: { - stream << 'U' << size_tag << '('; - stream << bytecode_iterator.GetIndexOperand(op_index); + *stream << 'U' << size_tag << '('; + *stream << bytecode_iterator.GetIndexOperand(op_index); break; } case OperandType::kUImm: - stream << 'U' << size_tag << '('; - stream << bytecode_iterator.GetUnsignedImmediateOperand(op_index); + *stream << 'U' << size_tag << '('; + *stream << bytecode_iterator.GetUnsignedImmediateOperand(op_index); break; case OperandType::kImm: - stream << 'I' << size_tag << '('; - stream << bytecode_iterator.GetImmediateOperand(op_index); + *stream << 'I' << size_tag << '('; + *stream << bytecode_iterator.GetImmediateOperand(op_index); break; case OperandType::kRegCount: - stream << 'U' << size_tag << '('; - stream << bytecode_iterator.GetRegisterCountOperand(op_index); + *stream << 'U' << size_tag << '('; + *stream << bytecode_iterator.GetRegisterCountOperand(op_index); break; case OperandType::kRuntimeId: { - stream << 'U' << size_tag << '('; + *stream << 'U' << size_tag << '('; Runtime::FunctionId id = bytecode_iterator.GetRuntimeIdOperand(op_index); - stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; + *stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; break; } case OperandType::kIntrinsicId: { - stream << 'U' << size_tag << '('; + *stream << 'U' << size_tag << '('; Runtime::FunctionId id = bytecode_iterator.GetIntrinsicIdOperand(op_index); - stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; + *stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; break; } case OperandType::kNativeContextIndex: { - stream << 'U' << size_tag << '('; + *stream << 'U' << size_tag << '('; uint32_t idx = bytecode_iterator.GetNativeContextIndexOperand(op_index); - stream << "%" << NameForNativeContextIntrinsicIndex(idx); + *stream << "%" << NameForNativeContextIntrinsicIndex(idx); break; } default: UNREACHABLE(); } - stream << ')'; + *stream << ')'; } } void BytecodeExpectationsPrinter::PrintBytecode( - std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, + std::ostream* stream, const BytecodeArrayIterator& bytecode_iterator, int parameter_count) const { Bytecode bytecode = bytecode_iterator.current_bytecode(); OperandScale operand_scale = bytecode_iterator.current_operand_scale(); if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale)) { Bytecode prefix = Bytecodes::OperandScaleToPrefixBytecode(operand_scale); - stream << "B(" << Bytecodes::ToString(prefix) << "), "; + *stream << "B(" << Bytecodes::ToString(prefix) << "), "; } - stream << "B(" << Bytecodes::ToString(bytecode) << ')'; + *stream << "B(" << Bytecodes::ToString(bytecode) << ')'; int operands_count = Bytecodes::NumberOfOperands(bytecode); for (int op_index = 0; op_index < operands_count; ++op_index) { - stream << ", "; + *stream << ", "; PrintBytecodeOperand(stream, bytecode_iterator, bytecode, op_index, parameter_count); } } void BytecodeExpectationsPrinter::PrintSourcePosition( - std::ostream& stream, SourcePositionTableIterator& source_iterator, + std::ostream* stream, SourcePositionTableIterator* source_iterator, int bytecode_offset) const { static const size_t kPositionWidth = 4; - if (!source_iterator.done() && - source_iterator.code_offset() == bytecode_offset) { - stream << "/* " << std::setw(kPositionWidth) - << source_iterator.source_position().ScriptOffset(); - if (source_iterator.is_statement()) { - stream << " S> */ "; + if (!source_iterator->done() && + source_iterator->code_offset() == bytecode_offset) { + *stream << "/* " << std::setw(kPositionWidth) + << source_iterator->source_position().ScriptOffset(); + if (source_iterator->is_statement()) { + *stream << " S> */ "; } else { - stream << " E> */ "; + *stream << " E> */ "; } - source_iterator.Advance(); + source_iterator->Advance(); } else { - stream << " " << std::setw(kPositionWidth) << ' ' << " "; + *stream << " " << std::setw(kPositionWidth) << ' ' << " "; } } -void BytecodeExpectationsPrinter::PrintV8String(std::ostream& stream, +void BytecodeExpectationsPrinter::PrintV8String(std::ostream* stream, i::String string) const { - stream << '"'; + *stream << '"'; for (int i = 0, length = string.length(); i < length; ++i) { - stream << i::AsEscapedUC16ForJSON(string.Get(i)); + *stream << i::AsEscapedUC16ForJSON(string.Get(i)); } - stream << '"'; + *stream << '"'; } void BytecodeExpectationsPrinter::PrintConstant( - std::ostream& stream, i::Handle constant) const { + std::ostream* stream, i::Handle constant) const { if (constant->IsSmi()) { - stream << "Smi ["; - i::Smi::cast(*constant).SmiPrint(stream); - stream << "]"; + *stream << "Smi ["; + i::Smi::cast(*constant).SmiPrint(*stream); + *stream << "]"; } else { - stream << i::HeapObject::cast(*constant).map().instance_type(); + *stream << i::HeapObject::cast(*constant).map().instance_type(); if (constant->IsHeapNumber()) { - stream << " ["; - i::HeapNumber::cast(*constant).HeapNumberPrint(stream); - stream << "]"; + *stream << " ["; + i::HeapNumber::cast(*constant).HeapNumberPrint(*stream); + *stream << "]"; } else if (constant->IsString()) { - stream << " ["; + *stream << " ["; PrintV8String(stream, i::String::cast(*constant)); - stream << "]"; + *stream << "]"; } } } void BytecodeExpectationsPrinter::PrintFrameSize( - std::ostream& stream, i::Handle bytecode_array) const { + std::ostream* stream, i::Handle bytecode_array) const { int32_t frame_size = bytecode_array->frame_size(); DCHECK(IsAligned(frame_size, kSystemPointerSize)); - stream << "frame size: " << frame_size / kSystemPointerSize - << "\nparameter count: " << bytecode_array->parameter_count() << '\n'; + *stream << "frame size: " << frame_size / kSystemPointerSize + << "\nparameter count: " << bytecode_array->parameter_count() << '\n'; } void BytecodeExpectationsPrinter::PrintBytecodeSequence( - std::ostream& stream, i::Handle bytecode_array) const { - stream << "bytecode array length: " << bytecode_array->length() - << "\nbytecodes: [\n"; + std::ostream* stream, i::Handle bytecode_array) const { + *stream << "bytecode array length: " << bytecode_array->length() + << "\nbytecodes: [\n"; SourcePositionTableIterator source_iterator( bytecode_array->SourcePositionTable()); BytecodeArrayIterator bytecode_iterator(bytecode_array); for (; !bytecode_iterator.done(); bytecode_iterator.Advance()) { - stream << kIndent; - PrintSourcePosition(stream, source_iterator, + *stream << kIndent; + PrintSourcePosition(stream, &source_iterator, bytecode_iterator.current_offset()); PrintBytecode(stream, bytecode_iterator, bytecode_array->parameter_count()); - stream << ",\n"; + *stream << ",\n"; } - stream << "]\n"; + *stream << "]\n"; } void BytecodeExpectationsPrinter::PrintConstantPool( - std::ostream& stream, i::FixedArray constant_pool) const { - stream << "constant pool: [\n"; + std::ostream* stream, i::FixedArray constant_pool) const { + *stream << "constant pool: [\n"; int num_constants = constant_pool.length(); if (num_constants > 0) { for (int i = 0; i < num_constants; ++i) { - stream << kIndent; + *stream << kIndent; PrintConstant(stream, i::FixedArray::get(constant_pool, i, i_isolate())); - stream << ",\n"; + *stream << ",\n"; } } - stream << "]\n"; + *stream << "]\n"; } void BytecodeExpectationsPrinter::PrintCodeSnippet( - std::ostream& stream, const std::string& body) const { - stream << "snippet: \"\n"; + std::ostream* stream, const std::string& body) const { + *stream << "snippet: \"\n"; std::stringstream body_stream(body); std::string body_line; while (std::getline(body_stream, body_line)) { - stream << kIndent; + *stream << kIndent; PrintEscapedString(stream, body_line); - stream << '\n'; + *stream << '\n'; } - stream << "\"\n"; + *stream << "\"\n"; } void BytecodeExpectationsPrinter::PrintHandlers( - std::ostream& stream, i::Handle bytecode_array) const { - stream << "handlers: [\n"; + std::ostream* stream, i::Handle bytecode_array) const { + *stream << "handlers: [\n"; HandlerTable table(*bytecode_array); for (int i = 0, num_entries = table.NumberOfRangeEntries(); i < num_entries; ++i) { - stream << " [" << table.GetRangeStart(i) << ", " << table.GetRangeEnd(i) - << ", " << table.GetRangeHandler(i) << "],\n"; + *stream << " [" << table.GetRangeStart(i) << ", " << table.GetRangeEnd(i) + << ", " << table.GetRangeHandler(i) << "],\n"; } - stream << "]\n"; + *stream << "]\n"; } void BytecodeExpectationsPrinter::PrintBytecodeArray( - std::ostream& stream, i::Handle bytecode_array) const { + std::ostream* stream, i::Handle bytecode_array) const { PrintFrameSize(stream, bytecode_array); PrintBytecodeSequence(stream, bytecode_array); PrintConstantPool(stream, bytecode_array->constant_pool()); @@ -380,7 +380,7 @@ void BytecodeExpectationsPrinter::PrintBytecodeArray( } void BytecodeExpectationsPrinter::PrintExpectation( - std::ostream& stream, const std::string& snippet) const { + std::ostream* stream, const std::string& snippet) const { std::string source_code = wrap_ ? WrapCodeInFunction(test_function_name_.c_str(), snippet) : snippet; @@ -404,10 +404,10 @@ void BytecodeExpectationsPrinter::PrintExpectation( } } - stream << "---\n"; + *stream << "---\n"; PrintCodeSnippet(stream, snippet); PrintBytecodeArray(stream, bytecode_array); - stream << '\n'; + *stream << '\n'; } } // namespace interpreter diff --git a/test/cctest/interpreter/bytecode-expectations-printer.h b/test/cctest/interpreter/bytecode-expectations-printer.h index dc51e5fb7a..6a469461d5 100644 --- a/test/cctest/interpreter/bytecode-expectations-printer.h +++ b/test/cctest/interpreter/bytecode-expectations-printer.h @@ -36,8 +36,7 @@ class BytecodeExpectationsPrinter final { oneshot_opt_(false), test_function_name_(kDefaultTopFunctionName) {} - void PrintExpectation(std::ostream& stream, // NOLINT - const std::string& snippet) const; + void PrintExpectation(std::ostream* stream, const std::string& snippet) const; void set_module(bool module) { module_ = module; } bool module() const { return module_; } @@ -60,34 +59,30 @@ class BytecodeExpectationsPrinter final { std::string test_function_name() const { return test_function_name_; } private: - void PrintEscapedString(std::ostream& stream, // NOLINT + void PrintEscapedString(std::ostream* stream, const std::string& string) const; - void PrintBytecodeOperand(std::ostream& stream, // NOLINT + void PrintBytecodeOperand(std::ostream* stream, const BytecodeArrayIterator& bytecode_iterator, const Bytecode& bytecode, int op_index, int parameter_count) const; - void PrintBytecode(std::ostream& stream, // NOLINT + void PrintBytecode(std::ostream* stream, const BytecodeArrayIterator& bytecode_iterator, int parameter_count) const; - void PrintSourcePosition(std::ostream& stream, // NOLINT - SourcePositionTableIterator& - source_iterator, // NOLINT(runtime/references) + void PrintSourcePosition(std::ostream* stream, + SourcePositionTableIterator* source_iterator, int bytecode_offset) const; - void PrintV8String(std::ostream& stream, // NOLINT - i::String string) const; - void PrintConstant(std::ostream& stream, // NOLINT - i::Handle constant) const; - void PrintFrameSize(std::ostream& stream, // NOLINT + void PrintV8String(std::ostream* stream, i::String string) const; + void PrintConstant(std::ostream* stream, i::Handle constant) const; + void PrintFrameSize(std::ostream* stream, i::Handle bytecode_array) const; - void PrintBytecodeSequence(std::ostream& stream, // NOLINT + void PrintBytecodeSequence(std::ostream* stream, i::Handle bytecode_array) const; - void PrintConstantPool(std::ostream& stream, // NOLINT + void PrintConstantPool(std::ostream* stream, i::FixedArray constant_pool) const; - void PrintCodeSnippet(std::ostream& stream, // NOLINT - const std::string& body) const; - void PrintBytecodeArray(std::ostream& stream, // NOLINT + void PrintCodeSnippet(std::ostream* stream, const std::string& body) const; + void PrintBytecodeArray(std::ostream* stream, i::Handle bytecode_array) const; - void PrintHandlers(std::ostream& stream, // NOLINT + void PrintHandlers(std::ostream* stream, i::Handle bytecode_array) const; v8::Local V8StringFromUTF8(const char* data) const; diff --git a/test/cctest/interpreter/generate-bytecode-expectations.cc b/test/cctest/interpreter/generate-bytecode-expectations.cc index 746c554087..a571e37fe6 100644 --- a/test/cctest/interpreter/generate-bytecode-expectations.cc +++ b/test/cctest/interpreter/generate-bytecode-expectations.cc @@ -50,8 +50,8 @@ class ProgramOptions final { verbose_(false) {} bool Validate() const; - void UpdateFromHeader(std::istream& stream); // NOLINT - void PrintHeader(std::ostream& stream) const; // NOLINT + void UpdateFromHeader(std::istream* stream); + void PrintHeader(std::ostream* stream) const; bool parsing_failed() const { return parsing_failed_; } bool print_help() const { return print_help_; } @@ -291,17 +291,17 @@ bool ProgramOptions::Validate() const { return true; } -void ProgramOptions::UpdateFromHeader(std::istream& stream) { +void ProgramOptions::UpdateFromHeader(std::istream* stream) { std::string line; const char* kPrintCallee = "print callee: "; const char* kOneshotOpt = "oneshot opt: "; // Skip to the beginning of the options header - while (std::getline(stream, line)) { + while (std::getline(*stream, line)) { if (line == "---") break; } - while (std::getline(stream, line)) { + while (std::getline(*stream, line)) { if (line.compare(0, 8, "module: ") == 0) { module_ = ParseBoolean(line.c_str() + 8); } else if (line.compare(0, 6, "wrap: ") == 0) { @@ -328,22 +328,22 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) { } } -void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT - stream << "---" - << "\nwrap: " << BooleanToString(wrap_); +void ProgramOptions::PrintHeader(std::ostream* stream) const { + *stream << "---" + << "\nwrap: " << BooleanToString(wrap_); if (!test_function_name_.empty()) { - stream << "\ntest function name: " << test_function_name_; + *stream << "\ntest function name: " << test_function_name_; } - if (module_) stream << "\nmodule: yes"; - if (top_level_) stream << "\ntop level: yes"; - if (print_callee_) stream << "\nprint callee: yes"; - if (oneshot_opt_) stream << "\noneshot opt: yes"; - if (async_iteration_) stream << "\nasync iteration: yes"; - if (private_methods_) stream << "\nprivate methods: yes"; + if (module_) *stream << "\nmodule: yes"; + if (top_level_) *stream << "\ntop level: yes"; + if (print_callee_) *stream << "\nprint callee: yes"; + if (oneshot_opt_) *stream << "\noneshot opt: yes"; + if (async_iteration_) *stream << "\nasync iteration: yes"; + if (private_methods_) *stream << "\nprivate methods: yes"; - stream << "\n\n"; + *stream << "\n\n"; } V8InitializationScope::V8InitializationScope(const char* exec_path) @@ -370,17 +370,17 @@ V8InitializationScope::~V8InitializationScope() { v8::V8::ShutdownPlatform(); } -std::string ReadRawJSSnippet(std::istream& stream) { // NOLINT +std::string ReadRawJSSnippet(std::istream* stream) { std::stringstream body_buffer; - CHECK(body_buffer << stream.rdbuf()); + CHECK(body_buffer << stream->rdbuf()); return body_buffer.str(); } -bool ReadNextSnippet(std::istream& stream, std::string* string_out) { // NOLINT +bool ReadNextSnippet(std::istream* stream, std::string* string_out) { std::string line; bool found_begin_snippet = false; string_out->clear(); - while (std::getline(stream, line)) { + while (std::getline(*stream, line)) { if (line == "snippet: \"") { found_begin_snippet = true; continue; @@ -420,8 +420,7 @@ std::string UnescapeString(const std::string& escaped_string) { } void ExtractSnippets(std::vector* snippet_list, - std::istream& body_stream, // NOLINT - bool read_raw_js_snippet) { + std::istream* body_stream, bool read_raw_js_snippet) { if (read_raw_js_snippet) { snippet_list->push_back(ReadRawJSSnippet(body_stream)); } else { @@ -432,7 +431,7 @@ void ExtractSnippets(std::vector* snippet_list, } } -void GenerateExpectationsFile(std::ostream& stream, // NOLINT +void GenerateExpectationsFile(std::ostream* stream, const std::vector& snippet_list, const V8InitializationScope& platform, const ProgramOptions& options) { @@ -453,7 +452,7 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT if (options.private_methods()) i::FLAG_harmony_private_methods = true; - stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; + *stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; options.PrintHeader(stream); for (const std::string& snippet : snippet_list) { printer.PrintExpectation(stream, snippet); @@ -477,7 +476,7 @@ bool WriteExpectationsFile(const std::vector& snippet_list, std::ostream& output_stream = options.write_to_stdout() ? std::cout : output_file_handle; - GenerateExpectationsFile(output_stream, snippet_list, platform, options); + GenerateExpectationsFile(&output_stream, snippet_list, platform, options); return true; } @@ -487,7 +486,7 @@ std::string WriteExpectationsToString( const V8InitializationScope& platform, const ProgramOptions& options) { std::stringstream output_string; - GenerateExpectationsFile(output_string, snippet_list, platform, options); + GenerateExpectationsFile(&output_string, snippet_list, platform, options); return output_string.str(); } @@ -612,7 +611,7 @@ int main(int argc, char** argv) { // Rebaseline will never get here, so we will always take the // GenerateExpectationsFile at the end of this function. DCHECK(!options.rebaseline() && !options.check_baseline()); - ExtractSnippets(&snippet_list, std::cin, options.read_raw_js_snippet()); + ExtractSnippets(&snippet_list, &std::cin, options.read_raw_js_snippet()); } else { bool check_failed = false; for (const std::string& input_filename : options.input_filenames()) { @@ -628,11 +627,11 @@ int main(int argc, char** argv) { ProgramOptions updated_options = options; if (options.baseline()) { - updated_options.UpdateFromHeader(input_stream); + updated_options.UpdateFromHeader(&input_stream); CHECK(updated_options.Validate()); } - ExtractSnippets(&snippet_list, input_stream, + ExtractSnippets(&snippet_list, &input_stream, options.read_raw_js_snippet()); input_stream.close(); diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc index fda02933aa..1583866c30 100644 --- a/test/cctest/interpreter/test-bytecode-generator.cc +++ b/test/cctest/interpreter/test-bytecode-generator.cc @@ -95,10 +95,10 @@ class InitializedIgnitionHandleScope : public InitializedHandleScope { } }; -void SkipGoldenFileHeader(std::istream& stream) { // NOLINT +void SkipGoldenFileHeader(std::istream* stream) { std::string line; int separators_seen = 0; - while (std::getline(stream, line)) { + while (std::getline(*stream, line)) { if (line == "---") separators_seen += 1; if (separators_seen == 2) return; } @@ -107,7 +107,7 @@ void SkipGoldenFileHeader(std::istream& stream) { // NOLINT std::string LoadGolden(const std::string& golden_filename) { std::ifstream expected_file((kGoldenFileDirectory + golden_filename).c_str()); CHECK(expected_file.is_open()); - SkipGoldenFileHeader(expected_file); + SkipGoldenFileHeader(&expected_file); std::ostringstream expected_stream; // Restore the first separator, which was consumed by SkipGoldenFileHeader expected_stream << "---\n" << expected_file.rdbuf(); @@ -125,31 +125,30 @@ std::string BuildActual(const BytecodeExpectationsPrinter& printer, if (prologue) source_code += prologue; source_code += snippet; if (epilogue) source_code += epilogue; - printer.PrintExpectation(actual_stream, source_code); + printer.PrintExpectation(&actual_stream, source_code); } return actual_stream.str(); } // inplace left trim -static inline void ltrim(std::string& str) { // NOLINT(runtime/references) - str.erase(str.begin(), - std::find_if(str.begin(), str.end(), - [](unsigned char ch) { return !std::isspace(ch); })); +static inline void ltrim(std::string* str) { + str->erase(str->begin(), + std::find_if(str->begin(), str->end(), + [](unsigned char ch) { return !std::isspace(ch); })); } // inplace right trim -static inline void rtrim(std::string& str) { // NOLINT(runtime/references) - str.erase(std::find_if(str.rbegin(), str.rend(), - [](unsigned char ch) { return !std::isspace(ch); }) - .base(), - str.end()); +static inline void rtrim(std::string* str) { + str->erase(std::find_if(str->rbegin(), str->rend(), + [](unsigned char ch) { return !std::isspace(ch); }) + .base(), + str->end()); } -static inline std::string trim( - std::string& str) { // NOLINT(runtime/references) +static inline std::string trim(std::string* str) { ltrim(str); rtrim(str); - return str; + return *str; } bool CompareTexts(const std::string& generated, const std::string& expected) { @@ -181,7 +180,7 @@ bool CompareTexts(const std::string& generated, const std::string& expected) { return false; } - if (trim(generated_line) != trim(expected_line)) { + if (trim(&generated_line) != trim(&expected_line)) { std::cerr << "Inputs differ at line " << line_number << "\n"; std::cerr << " Generated: '" << generated_line << "'\n"; std::cerr << " Expected: '" << expected_line << "'\n"; diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc index 466e768d7d..0ddc8fe608 100644 --- a/test/cctest/interpreter/test-interpreter.cc +++ b/test/cctest/interpreter/test-interpreter.cc @@ -1485,19 +1485,20 @@ TEST(InterpreterCall) { } } -static BytecodeArrayBuilder& SetRegister( - BytecodeArrayBuilder& builder, // NOLINT(runtime/references) - Register reg, int value, Register scratch) { - return builder.StoreAccumulatorInRegister(scratch) +static BytecodeArrayBuilder& SetRegister(BytecodeArrayBuilder* builder, + Register reg, int value, + Register scratch) { + return builder->StoreAccumulatorInRegister(scratch) .LoadLiteral(Smi::FromInt(value)) .StoreAccumulatorInRegister(reg) .LoadAccumulatorWithRegister(scratch); } -static BytecodeArrayBuilder& IncrementRegister( - BytecodeArrayBuilder& builder, // NOLINT(runtime/references) - Register reg, int value, Register scratch, int slot_index) { - return builder.StoreAccumulatorInRegister(scratch) +static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder* builder, + Register reg, int value, + Register scratch, + int slot_index) { + return builder->StoreAccumulatorInRegister(scratch) .LoadLiteral(Smi::FromInt(value)) .BinaryOperation(Token::Value::ADD, reg, slot_index) .StoreAccumulatorInRegister(reg) @@ -1525,13 +1526,13 @@ TEST(InterpreterJumps) { builder.LoadLiteral(Smi::zero()) .StoreAccumulatorInRegister(reg) .Jump(&label[0]); - SetRegister(builder, reg, 1024, scratch).Bind(&loop_header); - IncrementRegister(builder, reg, 1, scratch, GetIndex(slot)).Jump(&label[1]); - SetRegister(builder, reg, 2048, scratch).Bind(&label[0]); - IncrementRegister(builder, reg, 2, scratch, GetIndex(slot1)) + SetRegister(&builder, reg, 1024, scratch).Bind(&loop_header); + IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot)).Jump(&label[1]); + SetRegister(&builder, reg, 2048, scratch).Bind(&label[0]); + IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot1)) .JumpLoop(&loop_header, 0); - SetRegister(builder, reg, 4096, scratch).Bind(&label[1]); - IncrementRegister(builder, reg, 4, scratch, GetIndex(slot2)) + SetRegister(&builder, reg, 4096, scratch).Bind(&label[1]); + IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot2)) .LoadAccumulatorWithRegister(reg) .Return(); @@ -1566,19 +1567,19 @@ TEST(InterpreterConditionalJumps) { .StoreAccumulatorInRegister(reg) .LoadFalse() .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]); - IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot)) + IncrementRegister(&builder, reg, 1024, scratch, GetIndex(slot)) .Bind(&label[0]) .LoadTrue() .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done); - IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1)) + IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot1)) .LoadTrue() .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]); - IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2)) + IncrementRegister(&builder, reg, 2048, scratch, GetIndex(slot2)) .Bind(&label[1]); - IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3)) + IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot3)) .LoadFalse() .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1); - IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4)) + IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot4)) .LoadAccumulatorWithRegister(reg) .Bind(&done) .Bind(&done1) @@ -1616,19 +1617,19 @@ TEST(InterpreterConditionalJumps2) { .StoreAccumulatorInRegister(reg) .LoadFalse() .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]); - IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot)) + IncrementRegister(&builder, reg, 1024, scratch, GetIndex(slot)) .Bind(&label[0]) .LoadTrue() .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done); - IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1)) + IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot1)) .LoadTrue() .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]); - IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2)) + IncrementRegister(&builder, reg, 2048, scratch, GetIndex(slot2)) .Bind(&label[1]); - IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3)) + IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot3)) .LoadFalse() .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1); - IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4)) + IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot4)) .LoadAccumulatorWithRegister(reg) .Bind(&done) .Bind(&done1) diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc index c96a0199bb..bae39ba2ad 100644 --- a/test/cctest/test-assembler-arm.cc +++ b/test/cctest/test-assembler-arm.cc @@ -3391,7 +3391,9 @@ TEST(ARMv8_vminmax_f32) { template static GeneratedCode GenerateMacroFloatMinMax( - MacroAssembler& assm) { // NOLINT(runtime/references) + MacroAssembler* assm_ptr) { + MacroAssembler& assm = *assm_ptr; + T a = T::from_code(0); // d0/s0 T b = T::from_code(1); // d1/s1 T c = T::from_code(2); // d2/s2 @@ -3509,7 +3511,7 @@ TEST(macro_float_minmax_f64) { double max_aba_; }; - auto f = GenerateMacroFloatMinMax(assm); + auto f = GenerateMacroFloatMinMax(&assm); #define CHECK_MINMAX(left, right, min, max) \ do { \ @@ -3574,7 +3576,7 @@ TEST(macro_float_minmax_f32) { float max_aba_; }; - auto f = GenerateMacroFloatMinMax(assm); + auto f = GenerateMacroFloatMinMax(&assm); #define CHECK_MINMAX(left, right, min, max) \ do { \ diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc index 1cc1aa3213..1dd771551f 100644 --- a/test/cctest/test-assembler-mips.cc +++ b/test/cctest/test-assembler-mips.cc @@ -4825,9 +4825,10 @@ TEST(r6_beqzc) { } } -void load_elements_of_vector( - MacroAssembler& assm, // NOLINT(runtime/references) - const uint64_t elements[], MSARegister w, Register t0, Register t1) { +void load_elements_of_vector(MacroAssembler* assm_ptr, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + MacroAssembler& assm = *assm_ptr; __ li(t0, static_cast(elements[0] & 0xFFFFFFFF)); __ li(t1, static_cast((elements[0] >> 32) & 0xFFFFFFFF)); __ insert_w(w, 0, t0); @@ -4838,9 +4839,9 @@ void load_elements_of_vector( __ insert_w(w, 3, t1); } -inline void store_elements_of_vector( - MacroAssembler& assm, // NOLINT(runtime/references) - MSARegister w, Register a) { +inline void store_elements_of_vector(MacroAssembler* assm_ptr, MSARegister w, + Register a) { + MacroAssembler& assm = *assm_ptr; __ st_d(w, MemOperand(a, 0)); } @@ -4876,15 +4877,15 @@ void run_bz_bnz(TestCaseMsaBranch* input, Branch GenerateBranch, msa_reg_t res; Label do_not_move_w0_to_w2; - load_elements_of_vector(assm, &t.ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t.wd_lo, w2, t0, t1); - load_elements_of_vector(assm, &input->wt_lo, w1, t0, t1); + load_elements_of_vector(&assm, &t.ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t.wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &input->wt_lo, w1, t0, t1); GenerateBranch(assm, do_not_move_w0_to_w2); __ nop(); __ move_v(w2, w0); __ bind(&do_not_move_w0_to_w2); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -5841,7 +5842,7 @@ void run_msa_insert(int32_t rs_value, int n, msa_reg_t* w) { UNREACHABLE(); } - store_elements_of_vector(assm, w0, a0); + store_elements_of_vector(&assm, w0, a0); __ jr(ra); __ nop(); @@ -5937,10 +5938,10 @@ TEST(MSA_move_v) { MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); CpuFeatureScope fscope(&assm, MIPS_SIMD); - load_elements_of_vector(assm, &t[i].ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t[i].wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &t[i].ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1); __ move_v(w2, w0); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -5981,10 +5982,10 @@ void run_msa_sldi(OperFunc GenerateOperation, for (unsigned i = 0; i < arraysize(t); ++i) { MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); CpuFeatureScope fscope(&assm, MIPS_SIMD); - load_elements_of_vector(assm, &t[i].ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t[i].wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &t[i].ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1); GenerateOperation(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -6175,7 +6176,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, UNREACHABLE(); } - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -6460,11 +6461,11 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext, int32_t i5 = i5_sign_ext ? static_cast(input->i5 << 27) >> 27 : input->i5; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); GenerateI5InstructionFunc(assm, i5); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -6880,10 +6881,10 @@ void run_msa_2r(const struct TestCaseMsa2R* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, reinterpret_cast(input), w0, + load_elements_of_vector(&assm, reinterpret_cast(input), w0, t0, t1); Generate2RInstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -7926,13 +7927,13 @@ void run_msa_vector(struct TestCaseMsaVector* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->wt_lo), w2, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->wt_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w4, t0, t1); GenerateVectorInstructionFunc(assm); - store_elements_of_vector(assm, w4, a0); + store_elements_of_vector(&assm, w4, a0); __ jr(ra); __ nop(); @@ -8014,12 +8015,12 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1); GenerateInstructionFunc(assm, input->m); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -8491,7 +8492,7 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc, GenerateVectorInstructionFunc(assm, input); - store_elements_of_vector(assm, w0, a0); + store_elements_of_vector(&assm, w0, a0); __ jr(ra); __ nop(); @@ -8640,13 +8641,13 @@ void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->wt_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->ws_lo), w1, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->wt_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w1, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1); GenerateI5InstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -9645,13 +9646,13 @@ void run_msa_3rf(const struct TestCaseMsa3RF* input, msa_reg_t res; load_elements_of_vector( - assm, reinterpret_cast(&input->ws_lo), w0, t0, t1); + &assm, reinterpret_cast(&input->ws_lo), w0, t0, t1); load_elements_of_vector( - assm, reinterpret_cast(&input->wt_lo), w1, t0, t1); + &assm, reinterpret_cast(&input->wt_lo), w1, t0, t1); load_elements_of_vector( - assm, reinterpret_cast(&input->wd_lo), w2, t0, t1); + &assm, reinterpret_cast(&input->wd_lo), w2, t0, t1); Generate2RInstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); diff --git a/test/cctest/test-assembler-mips64.cc b/test/cctest/test-assembler-mips64.cc index f337fdfcac..e46d6155a8 100644 --- a/test/cctest/test-assembler-mips64.cc +++ b/test/cctest/test-assembler-mips64.cc @@ -5430,9 +5430,10 @@ TEST(r6_beqzc) { } } -void load_elements_of_vector( - MacroAssembler& assm, // NOLINT(runtime/references) - const uint64_t elements[], MSARegister w, Register t0, Register t1) { +void load_elements_of_vector(MacroAssembler* assm_ptr, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + MacroAssembler& assm = *assm_ptr; __ li(t0, static_cast(elements[0] & 0xFFFFFFFF)); __ li(t1, static_cast((elements[0] >> 32) & 0xFFFFFFFF)); __ insert_w(w, 0, t0); @@ -5443,9 +5444,9 @@ void load_elements_of_vector( __ insert_w(w, 3, t1); } -inline void store_elements_of_vector( - MacroAssembler& assm, // NOLINT(runtime/references) - MSARegister w, Register a) { +inline void store_elements_of_vector(MacroAssembler* assm_ptr, MSARegister w, + Register a) { + MacroAssembler& assm = *assm_ptr; __ st_d(w, MemOperand(a, 0)); } @@ -5481,15 +5482,15 @@ void run_bz_bnz(TestCaseMsaBranch* input, Branch GenerateBranch, msa_reg_t res; Label do_not_move_w0_to_w2; - load_elements_of_vector(assm, &t.ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t.wd_lo, w2, t0, t1); - load_elements_of_vector(assm, &input->wt_lo, w1, t0, t1); + load_elements_of_vector(&assm, &t.ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t.wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &input->wt_lo, w1, t0, t1); GenerateBranch(assm, do_not_move_w0_to_w2); __ nop(); __ move_v(w2, w0); __ bind(&do_not_move_w0_to_w2); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -6799,7 +6800,7 @@ void run_msa_insert(int64_t rs_value, int n, msa_reg_t* w) { UNREACHABLE(); } - store_elements_of_vector(assm, w0, a0); + store_elements_of_vector(&assm, w0, a0); __ jr(ra); __ nop(); @@ -6953,10 +6954,10 @@ TEST(MSA_move_v) { MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); CpuFeatureScope fscope(&assm, MIPS_SIMD); - load_elements_of_vector(assm, &t[i].ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t[i].wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &t[i].ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1); __ move_v(w2, w0); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -6997,10 +6998,10 @@ void run_msa_sldi(OperFunc GenerateOperation, for (unsigned i = 0; i < arraysize(t); ++i) { MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); CpuFeatureScope fscope(&assm, MIPS_SIMD); - load_elements_of_vector(assm, &t[i].ws_lo, w0, t0, t1); - load_elements_of_vector(assm, &t[i].wd_lo, w2, t0, t1); + load_elements_of_vector(&assm, &t[i].ws_lo, w0, t0, t1); + load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1); GenerateOperation(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -7157,7 +7158,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, UNREACHABLE(); } - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -7358,11 +7359,11 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext, int32_t i5 = i5_sign_ext ? static_cast(input->i5 << 27) >> 27 : input->i5; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); GenerateI5InstructionFunc(assm, i5); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -7784,10 +7785,10 @@ void run_msa_2r(const struct TestCaseMsa2R* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, reinterpret_cast(input), w0, + load_elements_of_vector(&assm, reinterpret_cast(input), w0, t0, t1); Generate2RInstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -8830,13 +8831,13 @@ void run_msa_vector(struct TestCaseMsaVector* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->wt_lo), w2, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->wt_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w4, t0, t1); GenerateVectorInstructionFunc(assm); - store_elements_of_vector(assm, w4, a0); + store_elements_of_vector(&assm, w4, a0); __ jr(ra); __ nop(); @@ -8918,12 +8919,12 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1); GenerateInstructionFunc(assm, input->m); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -9395,7 +9396,7 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc, GenerateVectorInstructionFunc(assm, input); - store_elements_of_vector(assm, w0, a0); + store_elements_of_vector(&assm, w0, a0); __ jr(ra); __ nop(); @@ -9544,13 +9545,13 @@ void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - load_elements_of_vector(assm, &(input->wt_lo), w0, t0, t1); - load_elements_of_vector(assm, &(input->ws_lo), w1, t0, t1); - load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + load_elements_of_vector(&assm, &(input->wt_lo), w0, t0, t1); + load_elements_of_vector(&assm, &(input->ws_lo), w1, t0, t1); + load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1); GenerateI5InstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); @@ -10554,7 +10555,7 @@ void run_msa_3rf(const struct TestCaseMsa3RF* input, load_elements_of_vector( assm, reinterpret_cast(&input->wd_lo), w2, t0, t1); Generate2RInstructionFunc(assm); - store_elements_of_vector(assm, w2, a0); + store_elements_of_vector(&assm, w2, a0); __ jr(ra); __ nop(); diff --git a/test/cctest/test-field-type-tracking.cc b/test/cctest/test-field-type-tracking.cc index 8bc81647e4..27efdc28da 100644 --- a/test/cctest/test-field-type-tracking.cc +++ b/test/cctest/test-field-type-tracking.cc @@ -1438,8 +1438,7 @@ struct CheckNormalize { // template static void TestReconfigureProperty_CustomPropertyAfterTargetMap( - TestConfig& config, // NOLINT(runtime/references) - Checker& checker) { // NOLINT(runtime/references) + TestConfig* config, Checker* checker) { Isolate* isolate = CcTest::i_isolate(); Handle any_type = FieldType::Any(isolate); @@ -1471,7 +1470,7 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( map1 = expectations1.AddDataField(map1, NONE, constness, representation, any_type); } - map1 = config.AddPropertyAtBranch(1, expectations1, map1); + map1 = config->AddPropertyAtBranch(1, &expectations1, map1); for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { map1 = expectations1.AddDataField(map1, NONE, constness, representation, any_type); @@ -1491,7 +1490,7 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( map2 = expectations2.AddDataField(map2, NONE, constness, representation, any_type); } - map2 = config.AddPropertyAtBranch(2, expectations2, map2); + map2 = config->AddPropertyAtBranch(2, &expectations2, map2); for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { map2 = expectations2.AddDataField(map2, NONE, constness, representation, any_type); @@ -1512,8 +1511,8 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( CHECK_NE(*map2, *new_map); CHECK(expectations2.Check(*map2)); - config.UpdateExpectations(kCustomPropIndex, expectations1); - checker.Check(isolate, map1, new_map, expectations1); + config->UpdateExpectations(kCustomPropIndex, &expectations1); + checker->Check(isolate, map1, new_map, expectations1); } TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { @@ -1528,18 +1527,14 @@ TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { js_func_ = factory->NewFunctionForTest(factory->empty_string()); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); // Add the same data constant property at both transition tree branches. - return expectations.AddDataConstant(map, NONE, js_func_); + return expectations->AddDataConstant(map, NONE, js_func_); } - void UpdateExpectations( - int property_index, - Expectations& expectations) { // NOLINT(runtime/references) + void UpdateExpectations(int property_index, Expectations* expectations) { // Expectations stay the same. } }; @@ -1547,7 +1542,7 @@ TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { TestConfig config; // Two branches are "compatible" so the |map1| should NOT be deprecated. CheckSameMap checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } @@ -1577,26 +1572,22 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { factory->NewFunction(sloppy_map, info, isolate->native_context()); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); Handle js_func = branch_id == 1 ? js_func1_ : js_func2_; - return expectations.AddDataConstant(map, NONE, js_func); + return expectations->AddDataConstant(map, NONE, js_func); } - void UpdateExpectations( - int property_index, - Expectations& expectations) { // NOLINT(runtime/references) - expectations.SetDataField(property_index, PropertyConstness::kConst, - Representation::HeapObject(), function_type_); + void UpdateExpectations(int property_index, Expectations* expectations) { + expectations->SetDataField(property_index, PropertyConstness::kConst, + Representation::HeapObject(), function_type_); } }; TestConfig config; CheckSameMap checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } @@ -1614,28 +1605,23 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { pair_ = CreateAccessorPair(true, true); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); if (branch_id == 1) { - return expectations.AddDataConstant(map, NONE, js_func_); + return expectations->AddDataConstant(map, NONE, js_func_); } else { - return expectations.AddAccessorConstant(map, NONE, pair_); + return expectations->AddAccessorConstant(map, NONE, pair_); } } - void UpdateExpectations( - int property_index, - Expectations& expectations // NOLINT(runtime/references) - ) {} + void UpdateExpectations(int property_index, Expectations* expectations) {} }; TestConfig config; // These are completely separate branches in transition tree. CheckUnrelated checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } @@ -1647,26 +1633,22 @@ TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { Handle pair_; TestConfig() { pair_ = CreateAccessorPair(true, true); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); // Add the same accessor constant property at both transition tree // branches. - return expectations.AddAccessorConstant(map, NONE, pair_); + return expectations->AddAccessorConstant(map, NONE, pair_); } - void UpdateExpectations( - int property_index, - Expectations& expectations) { // NOLINT(runtime/references) + void UpdateExpectations(int property_index, Expectations* expectations) { // Two branches are "compatible" so the |map1| should NOT be deprecated. } }; TestConfig config; CheckSameMap checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } @@ -1682,24 +1664,20 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { pair2_ = CreateAccessorPair(true, true); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); Handle pair = branch_id == 1 ? pair1_ : pair2_; - return expectations.AddAccessorConstant(map, NONE, pair); + return expectations->AddAccessorConstant(map, NONE, pair); } - void UpdateExpectations( - int property_index, - Expectations& expectations) { // NOLINT(runtime/references) + void UpdateExpectations(int property_index, Expectations* expectations) { if (IS_ACCESSOR_FIELD_SUPPORTED) { - expectations.SetAccessorField(property_index); + expectations->SetAccessorField(property_index); } else { // Currently we have a normalize case and ACCESSOR property becomes // ACCESSOR_CONSTANT. - expectations.SetAccessorConstant(property_index, pair2_); + expectations->SetAccessorConstant(property_index, pair2_); } } }; @@ -1707,11 +1685,11 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { TestConfig config; if (IS_ACCESSOR_FIELD_SUPPORTED) { CheckSameMap checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } else { // Currently we have a normalize case. CheckNormalize checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } } @@ -1724,31 +1702,26 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { Handle pair_; TestConfig() { pair_ = CreateAccessorPair(true, true); } - Handle AddPropertyAtBranch( - int branch_id, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { + Handle AddPropertyAtBranch(int branch_id, Expectations* expectations, + Handle map) { CHECK(branch_id == 1 || branch_id == 2); if (branch_id == 1) { - return expectations.AddAccessorConstant(map, NONE, pair_); + return expectations->AddAccessorConstant(map, NONE, pair_); } else { Isolate* isolate = CcTest::i_isolate(); Handle any_type = FieldType::Any(isolate); - return expectations.AddDataField(map, NONE, PropertyConstness::kConst, - Representation::Smi(), any_type); + return expectations->AddDataField(map, NONE, PropertyConstness::kConst, + Representation::Smi(), any_type); } } - void UpdateExpectations( - int property_index, - Expectations& expectations // NOLINT(runtime/references) - ) {} + void UpdateExpectations(int property_index, Expectations* expectations) {} }; TestConfig config; // These are completely separate branches in transition tree. CheckUnrelated checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker); } @@ -2143,9 +2116,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { // fixed. template static void TestGeneralizeFieldWithSpecialTransition( - TestConfig& config, // NOLINT(runtime/references) - const CRFTData& from, const CRFTData& to, const CRFTData& expected, - bool expected_deprecation) { + TestConfig* config, const CRFTData& from, const CRFTData& to, + const CRFTData& expected, bool expected_deprecation) { Isolate* isolate = CcTest::i_isolate(); Expectations expectations(isolate); @@ -2165,13 +2137,13 @@ static void TestGeneralizeFieldWithSpecialTransition( // Apply some special transition to |map|. CHECK(map->owns_descriptors()); - Handle map2 = config.Transition(map, expectations2); + Handle map2 = config->Transition(map, &expectations2); // |map| should still match expectations. CHECK(!map->is_deprecated()); CHECK(expectations.Check(*map)); - if (config.generalizes_representations()) { + if (config->generalizes_representations()) { for (int i = 0; i < kPropCount; i++) { expectations2.GeneralizeField(i); } @@ -2208,10 +2180,10 @@ static void TestGeneralizeFieldWithSpecialTransition( CHECK_EQ(*new_map2, *tmp_map); } else { // Equivalent transitions should always find the updated map. - CHECK(config.is_non_equivalent_transition()); + CHECK(config->is_non_equivalent_transition()); } - if (config.is_non_equivalent_transition()) { + if (config->is_non_equivalent_transition()) { // In case of non-equivalent transition currently we generalize all // representations. for (int i = 0; i < kPropCount; i++) { @@ -2262,9 +2234,9 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) { ElementsKind kind) : attributes(attributes), symbol(symbol), elements_kind(kind) {} - Handle Transition(Handle map, Expectations& expectations) { - expectations.SetElementsKind(elements_kind); - expectations.ChangeAttributesForAllProperties(attributes); + Handle Transition(Handle map, Expectations* expectations) { + expectations->SetElementsKind(elements_kind); + expectations->ChangeAttributesForAllProperties(attributes); return Map::CopyForPreventExtensions(CcTest::i_isolate(), map, attributes, symbol, "CopyForPreventExtensions"); } @@ -2289,13 +2261,13 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) { : DICTIONARY_ELEMENTS}}; for (size_t i = 0; i < arraysize(configs); i++) { TestGeneralizeFieldWithSpecialTransition( - configs[i], + &configs[i], {PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, !FLAG_modify_field_representation_inplace); TestGeneralizeFieldWithSpecialTransition( - configs[i], + &configs[i], {PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, @@ -2318,7 +2290,7 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { ElementsKind kind) : attributes(attributes), symbol(symbol), elements_kind(kind) {} - Handle Transition(Handle map, Expectations& expectations) { + Handle Transition(Handle map, Expectations* expectations) { Isolate* isolate = CcTest::i_isolate(); Handle any_type = FieldType::Any(isolate); @@ -2331,8 +2303,8 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { .ToHandleChecked(); CHECK(!map->owns_descriptors()); - expectations.SetElementsKind(elements_kind); - expectations.ChangeAttributesForAllProperties(attributes); + expectations->SetElementsKind(elements_kind); + expectations->ChangeAttributesForAllProperties(attributes); return Map::CopyForPreventExtensions(isolate, map, attributes, symbol, "CopyForPreventExtensions"); } @@ -2357,13 +2329,13 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { : DICTIONARY_ELEMENTS}}; for (size_t i = 0; i < arraysize(configs); i++) { TestGeneralizeFieldWithSpecialTransition( - configs[i], + &configs[i], {PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, !FLAG_modify_field_representation_inplace); TestGeneralizeFieldWithSpecialTransition( - configs[i], + &configs[i], {PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, @@ -2390,9 +2362,7 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) { prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); } - Handle Transition( - Handle map, - Expectations& expectations) { // NOLINT(runtime/references) + Handle Transition(Handle map, Expectations* expectations) { return Map::TransitionToPrototype(CcTest::i_isolate(), map, prototype_); } // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. @@ -2403,12 +2373,13 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) { }; TestConfig config; TestGeneralizeFieldWithSpecialTransition( - config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, + &config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, !FLAG_modify_field_representation_inplace); TestGeneralizeFieldWithSpecialTransition( - config, {PropertyConstness::kMutable, Representation::Double(), any_type}, + &config, + {PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace); @@ -2432,9 +2403,7 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); } - Handle Transition( - Handle map, - Expectations& expectations) { // NOLINT(runtime/references) + Handle Transition(Handle map, Expectations* expectations) { Isolate* isolate = CcTest::i_isolate(); Handle any_type = FieldType::Any(isolate); @@ -2457,12 +2426,13 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { }; TestConfig config; TestGeneralizeFieldWithSpecialTransition( - config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, + &config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, !FLAG_modify_field_representation_inplace); TestGeneralizeFieldWithSpecialTransition( - config, {PropertyConstness::kMutable, Representation::Double(), any_type}, + &config, + {PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type}, FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace); @@ -2490,10 +2460,8 @@ struct TransitionToDataFieldOperator { heap_type_(heap_type), value_(value) {} - Handle DoTransition( - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { - return expectations.TransitionToDataField( + Handle DoTransition(Expectations* expectations, Handle map) { + return expectations->TransitionToDataField( map, attributes_, constness_, representation_, heap_type_, value_); } }; @@ -2507,8 +2475,8 @@ struct TransitionToDataConstantOperator { PropertyAttributes attributes = NONE) : attributes_(attributes), value_(value) {} - Handle DoTransition(Expectations& expectations, Handle map) { - return expectations.TransitionToDataConstant(map, attributes_, value_); + Handle DoTransition(Expectations* expectations, Handle map) { + return expectations->TransitionToDataConstant(map, attributes_, value_); } }; @@ -2521,8 +2489,8 @@ struct TransitionToAccessorConstantOperator { PropertyAttributes attributes = NONE) : attributes_(attributes), pair_(pair) {} - Handle DoTransition(Expectations& expectations, Handle map) { - return expectations.TransitionToAccessorConstant(map, attributes_, pair_); + Handle DoTransition(Expectations* expectations, Handle map) { + return expectations->TransitionToAccessorConstant(map, attributes_, pair_); } }; @@ -2542,12 +2510,10 @@ struct ReconfigureAsDataPropertyOperator { attributes_(attributes), heap_type_(heap_type) {} - Handle DoTransition( - Isolate* isolate, - Expectations& expectations, // NOLINT(runtime/references) - Handle map) { - expectations.SetDataField(descriptor_, PropertyConstness::kMutable, - representation_, heap_type_); + Handle DoTransition(Isolate* isolate, Expectations* expectations, + Handle map) { + expectations->SetDataField(descriptor_, PropertyConstness::kMutable, + representation_, heap_type_); return Map::ReconfigureExistingProperty(isolate, map, descriptor_, kData, attributes_, PropertyConstness::kConst); @@ -2563,9 +2529,9 @@ struct ReconfigureAsAccessorPropertyOperator { PropertyAttributes attributes = NONE) : descriptor_(descriptor), attributes_(attributes) {} - Handle DoTransition(Isolate* isolate, Expectations& expectations, + Handle DoTransition(Isolate* isolate, Expectations* expectations, Handle map) { - expectations.SetAccessorField(descriptor_); + expectations->SetAccessorField(descriptor_); return Map::ReconfigureExistingProperty(isolate, map, descriptor_, kAccessor, attributes_, PropertyConstness::kConst); @@ -2590,9 +2556,8 @@ struct FieldGeneralizationChecker { attributes_(attributes), heap_type_(heap_type) {} - void Check(Isolate* isolate, - Expectations& expectations2, // NOLINT(runtime/references) - Handle map1, Handle map2) { + void Check(Isolate* isolate, Expectations* expectations, Handle map1, + Handle map2) { CHECK(!map2->is_deprecated()); CHECK(map1->is_deprecated()); @@ -2601,21 +2566,20 @@ struct FieldGeneralizationChecker { CHECK_EQ(*map2, *updated_map); CheckMigrationTarget(isolate, *map1, *updated_map); - expectations2.SetDataField(descriptor_, attributes_, constness_, + expectations->SetDataField(descriptor_, attributes_, constness_, representation_, heap_type_); - CHECK(expectations2.Check(*map2)); + CHECK(expectations->Check(*map2)); } }; // Checks that existing transition was taken as is. struct SameMapChecker { - void Check(Isolate* isolate, - Expectations& expectations, // NOLINT(runtime/references) - Handle map1, Handle map2) { + void Check(Isolate* isolate, Expectations* expectations, Handle map1, + Handle map2) { CHECK(!map2->is_deprecated()); CHECK_EQ(*map1, *map2); - CHECK(expectations.Check(*map2)); + CHECK(expectations->Check(*map2)); } }; @@ -2623,12 +2587,11 @@ struct SameMapChecker { // Checks that both |map1| and |map2| should stays non-deprecated, this is // the case when property kind is change. struct PropertyKindReconfigurationChecker { - void Check(Expectations& expectations, // NOLINT(runtime/references) - Handle map1, Handle map2) { + void Check(Expectations* expectations, Handle map1, Handle map2) { CHECK(!map1->is_deprecated()); CHECK(!map2->is_deprecated()); CHECK_NE(*map1, *map2); - CHECK(expectations.Check(*map2)); + CHECK(expectations->Check(*map2)); } }; @@ -2649,10 +2612,8 @@ struct PropertyKindReconfigurationChecker { // where "p4A" and "p4B" differ only in the attributes. // template -static void TestTransitionTo( - TransitionOp1& transition_op1, // NOLINT(runtime/references) - TransitionOp2& transition_op2, // NOLINT(runtime/references) - Checker& checker) { // NOLINT(runtime/references) +static void TestTransitionTo(TransitionOp1* transition_op1, + TransitionOp2* transition_op2, Checker* checker) { Isolate* isolate = CcTest::i_isolate(); Handle any_type = FieldType::Any(isolate); @@ -2668,14 +2629,14 @@ static void TestTransitionTo( CHECK(expectations.Check(*map)); Expectations expectations1 = expectations; - Handle map1 = transition_op1.DoTransition(expectations1, map); + Handle map1 = transition_op1->DoTransition(&expectations1, map); CHECK(expectations1.Check(*map1)); Expectations expectations2 = expectations; - Handle map2 = transition_op2.DoTransition(expectations2, map); + Handle map2 = transition_op2->DoTransition(&expectations2, map); // Let the test customization do the check. - checker.Check(isolate, expectations2, map1, map2); + checker->Check(isolate, &expectations2, map1, map2); } TEST(TransitionDataFieldToDataField) { @@ -2696,7 +2657,7 @@ TEST(TransitionDataFieldToDataField) { FieldGeneralizationChecker checker(kPropCount - 1, PropertyConstness::kMutable, Representation::Double(), any_type); - TestTransitionTo(transition_op1, transition_op2, checker); + TestTransitionTo(&transition_op1, &transition_op2, &checker); } TEST(TransitionDataConstantToSameDataConstant) { @@ -2710,7 +2671,7 @@ TEST(TransitionDataConstantToSameDataConstant) { TransitionToDataConstantOperator transition_op(js_func); SameMapChecker checker; - TestTransitionTo(transition_op, transition_op, checker); + TestTransitionTo(&transition_op, &transition_op, &checker); } @@ -2736,7 +2697,7 @@ TEST(TransitionDataConstantToAnotherDataConstant) { TransitionToDataConstantOperator transition_op2(js_func2); SameMapChecker checker; - TestTransitionTo(transition_op1, transition_op2, checker); + TestTransitionTo(&transition_op1, &transition_op2, &checker); } @@ -2758,12 +2719,12 @@ TEST(TransitionDataConstantToDataField) { if (FLAG_modify_field_representation_inplace) { SameMapChecker checker; - TestTransitionTo(transition_op1, transition_op2, checker); + TestTransitionTo(&transition_op1, &transition_op2, &checker); } else { FieldGeneralizationChecker checker(kPropCount - 1, PropertyConstness::kMutable, Representation::Tagged(), any_type); - TestTransitionTo(transition_op1, transition_op2, checker); + TestTransitionTo(&transition_op1, &transition_op2, &checker); } } @@ -2776,7 +2737,7 @@ TEST(TransitionAccessorConstantToSameAccessorConstant) { TransitionToAccessorConstantOperator transition_op(pair); SameMapChecker checker; - TestTransitionTo(transition_op, transition_op, checker); + TestTransitionTo(&transition_op, &transition_op, &checker); } // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index d931cc91e0..7784a7f855 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -3578,10 +3578,9 @@ TEST(AddressToTraceMap) { } static const v8::AllocationProfile::Node* FindAllocationProfileNode( - v8::Isolate* isolate, - v8::AllocationProfile& profile, // NOLINT(runtime/references) + v8::Isolate* isolate, v8::AllocationProfile* profile, const Vector& names) { - v8::AllocationProfile::Node* node = profile.GetRootNode(); + v8::AllocationProfile::Node* node = profile->GetRootNode(); for (int i = 0; node != nullptr && i < names.length(); ++i) { const char* name = names[i]; auto children = node->children; @@ -3651,7 +3650,7 @@ TEST(SamplingHeapProfiler) { CHECK(profile); const char* names[] = {"", "foo", "bar"}; - auto node_bar = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_bar = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names)); CHECK(node_bar); @@ -3675,12 +3674,12 @@ TEST(SamplingHeapProfiler) { CHECK(profile); const char* names1[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"}; - auto node1 = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node1 = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names1)); CHECK(node1); const char* names2[] = {"", "generateFunctions"}; - auto node2 = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node2 = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names2)); CHECK(node2); @@ -3738,11 +3737,11 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) { CHECK(profile); const char* path_to_foo[] = {"", "foo"}; - auto node_foo = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_foo = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(path_to_foo)); CHECK(node_foo); const char* path_to_bar[] = {"", "foo", "bar"}; - auto node_bar = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_bar = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(path_to_bar)); CHECK(node_bar); @@ -3762,11 +3761,11 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) { CHECK(profile); const char* path_to_foo[] = {"", "foo"}; - auto node_foo = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_foo = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(path_to_foo)); CHECK(node_foo); const char* path_to_bar[] = {"", "foo", "bar"}; - auto node_bar = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_bar = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(path_to_bar)); CHECK(node_bar); @@ -3805,7 +3804,7 @@ TEST(SamplingHeapProfilerApiAllocation) { heap_profiler->GetAllocationProfile()); CHECK(profile); const char* names[] = {"(V8 API)"}; - auto node = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names)); CHECK(node); @@ -3945,7 +3944,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) { heap_profiler->StopSamplingHeapProfiler(); const char* names[] = {"f"}; - auto node_f = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node_f = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names)); CHECK(node_f); @@ -3975,7 +3974,7 @@ TEST(SamplingHeapProfilerLargeInterval) { heap_profiler->GetAllocationProfile()); CHECK(profile); const char* names[] = {"(EXTERNAL)"}; - auto node = FindAllocationProfileNode(env->GetIsolate(), *profile, + auto node = FindAllocationProfileNode(env->GetIsolate(), profile.get(), ArrayVector(names)); CHECK(node); diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index ccebabec30..5cfc4df2a3 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -674,13 +674,12 @@ static const char* line_number_test_source_profile_time_functions = "bar_at_the_second_line();\n" "function lazy_func_at_6th_line() {}"; -int GetFunctionLineNumber(CpuProfiler& profiler, // NOLINT(runtime/references) - LocalContext& env, // NOLINT(runtime/references) +int GetFunctionLineNumber(CpuProfiler* profiler, LocalContext* env, const char* name) { - CodeMap* code_map = profiler.generator()->code_map(); + CodeMap* code_map = profiler->generator()->code_map(); i::Handle func = i::Handle::cast( v8::Utils::OpenHandle(*v8::Local::Cast( - env->Global()->Get(env.local(), v8_str(name)).ToLocalChecked()))); + (*env)->Global()->Get(env->local(), v8_str(name)).ToLocalChecked()))); CodeEntry* func_entry = code_map->FindEntry(func->abstract_code().InstructionStart()); if (!func_entry) FATAL("%s", name); @@ -705,12 +704,12 @@ TEST(LineNumber) { profiler.processor()->StopSynchronously(); bool is_lazy = i::FLAG_lazy; - CHECK_EQ(1, GetFunctionLineNumber(profiler, env, "foo_at_the_first_line")); + CHECK_EQ(1, GetFunctionLineNumber(&profiler, &env, "foo_at_the_first_line")); CHECK_EQ(is_lazy ? 0 : 4, - GetFunctionLineNumber(profiler, env, "lazy_func_at_forth_line")); - CHECK_EQ(2, GetFunctionLineNumber(profiler, env, "bar_at_the_second_line")); + GetFunctionLineNumber(&profiler, &env, "lazy_func_at_forth_line")); + CHECK_EQ(2, GetFunctionLineNumber(&profiler, &env, "bar_at_the_second_line")); CHECK_EQ(is_lazy ? 0 : 6, - GetFunctionLineNumber(profiler, env, "lazy_func_at_6th_line")); + GetFunctionLineNumber(&profiler, &env, "lazy_func_at_6th_line")); profiler.StopProfiling("LineNumber"); } diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 407437c4b1..820e603c10 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -98,8 +98,7 @@ class TestSerializer { return v8_isolate; } - static v8::Isolate* NewIsolateFromBlob( - StartupBlobs& blobs) { // NOLINT(runtime/references) + static v8::Isolate* NewIsolateFromBlob(const StartupBlobs& blobs) { SnapshotData startup_snapshot(blobs.startup); SnapshotData read_only_snapshot(blobs.read_only); ReadOnlyDeserializer read_only_deserializer(&read_only_snapshot); @@ -204,8 +203,7 @@ Vector ConstructSource(Vector head, source_length); } -static v8::Isolate* Deserialize( - StartupBlobs& blobs) { // NOLINT(runtime/references) +static v8::Isolate* Deserialize(const StartupBlobs& blobs) { v8::Isolate* isolate = TestSerializer::NewIsolateFromBlob(blobs); CHECK(isolate); return isolate; diff --git a/test/cctest/test-smi-lexicographic-compare.cc b/test/cctest/test-smi-lexicographic-compare.cc index 914444c634..7b3e600c14 100644 --- a/test/cctest/test-smi-lexicographic-compare.cc +++ b/test/cctest/test-smi-lexicographic-compare.cc @@ -14,11 +14,11 @@ namespace internal { namespace { -void AddSigned(std::set& smis, int64_t x) { // NOLINT(runtime/references) +void AddSigned(std::set* smis, int64_t x) { if (!Smi::IsValid(x)) return; - smis.insert(Smi::FromInt(static_cast(x))); - smis.insert(Smi::FromInt(static_cast(-x))); + smis->insert(Smi::FromInt(static_cast(x))); + smis->insert(Smi::FromInt(static_cast(-x))); } // Uses std::lexicographical_compare twice to convert the result to -1, 0 or 1. @@ -58,14 +58,14 @@ TEST(TestSmiLexicographicCompare) { for (int64_t xb = 1; xb <= Smi::kMaxValue; xb *= 10) { for (int64_t xf = 0; xf <= 9; ++xf) { for (int64_t xo = -1; xo <= 1; ++xo) { - AddSigned(smis, xb * xf + xo); + AddSigned(&smis, xb * xf + xo); } } } for (int64_t yb = 1; yb <= Smi::kMaxValue; yb *= 2) { for (int64_t yo = -2; yo <= 2; ++yo) { - AddSigned(smis, yb + yo); + AddSigned(&smis, yb + yo); } } diff --git a/test/cctest/test-typedarrays.cc b/test/cctest/test-typedarrays.cc index 29a04ca05d..7b16a9305e 100644 --- a/test/cctest/test-typedarrays.cc +++ b/test/cctest/test-typedarrays.cc @@ -15,12 +15,11 @@ namespace v8 { namespace internal { -void TestArrayBufferViewContents( - LocalContext& env, // NOLINT(runtime/references) - bool should_use_buffer) { +void TestArrayBufferViewContents(LocalContext* env, bool should_use_buffer) { v8::Local obj_a = v8::Local::Cast( - env->Global() - ->Get(env->GetIsolate()->GetCurrentContext(), v8_str("a")) + (*env) + ->Global() + ->Get((*env)->GetIsolate()->GetCurrentContext(), v8_str("a")) .ToLocalChecked()); CHECK(obj_a->IsArrayBufferView()); v8::Local array_buffer_view = @@ -44,7 +43,7 @@ TEST(CopyContentsTypedArray) { "a[1] = 1;" "a[2] = 2;" "a[3] = 3;"); - TestArrayBufferViewContents(env, false); + TestArrayBufferViewContents(&env, false); } @@ -52,7 +51,7 @@ TEST(CopyContentsArray) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); CompileRun("var a = new Uint8Array([0, 1, 2, 3]);"); - TestArrayBufferViewContents(env, false); + TestArrayBufferViewContents(&env, false); } @@ -69,7 +68,7 @@ TEST(CopyContentsView) { "c[4] = 2;" "c[5] = 3;" "var a = new DataView(b, 2);"); - TestArrayBufferViewContents(env, true); + TestArrayBufferViewContents(&env, true); } diff --git a/test/cctest/wasm/test-run-wasm-bulk-memory.cc b/test/cctest/wasm/test-run-wasm-bulk-memory.cc index e794c00ece..d2ac3434df 100644 --- a/test/cctest/wasm/test-run-wasm-bulk-memory.cc +++ b/test/cctest/wasm/test-run-wasm-bulk-memory.cc @@ -13,11 +13,10 @@ namespace wasm { namespace test_run_wasm_bulk_memory { namespace { -void CheckMemoryEquals( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - size_t index, const std::vector& expected) { - const byte* mem_start = builder.raw_mem_start(); - const byte* mem_end = builder.raw_mem_end(); +void CheckMemoryEquals(TestingModuleBuilder* builder, size_t index, + const std::vector& expected) { + const byte* mem_start = builder->raw_mem_start(); + const byte* mem_end = builder->raw_mem_end(); size_t mem_size = mem_end - mem_start; CHECK_LE(index, mem_size); CHECK_LE(index + expected.size(), mem_size); @@ -26,11 +25,10 @@ void CheckMemoryEquals( } } -void CheckMemoryEqualsZero( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - size_t index, size_t length) { - const byte* mem_start = builder.raw_mem_start(); - const byte* mem_end = builder.raw_mem_end(); +void CheckMemoryEqualsZero(TestingModuleBuilder* builder, size_t index, + size_t length) { + const byte* mem_start = builder->raw_mem_start(); + const byte* mem_end = builder->raw_mem_end(); size_t mem_size = mem_end - mem_start; CHECK_LE(index, mem_size); CHECK_LE(index + length, mem_size); @@ -39,12 +37,11 @@ void CheckMemoryEqualsZero( } } -void CheckMemoryEqualsFollowedByZeroes( - TestingModuleBuilder& builder, // NOLINT(runtime/references) - const std::vector& expected) { +void CheckMemoryEqualsFollowedByZeroes(TestingModuleBuilder* builder, + const std::vector& expected) { CheckMemoryEquals(builder, 0, expected); CheckMemoryEqualsZero(builder, expected.size(), - builder.mem_size() - expected.size()); + builder->mem_size() - expected.size()); } } // namespace @@ -60,24 +57,24 @@ WASM_EXEC_TEST(MemoryInit) { kExprI32Const, 0); // All zeroes. - CheckMemoryEqualsZero(r.builder(), 0, kWasmPageSize); + CheckMemoryEqualsZero(&r.builder(), 0, kWasmPageSize); // Copy all bytes from data segment 0, to memory at [10, 20). CHECK_EQ(0, r.Call(10, 0, 10)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy bytes in range [5, 10) from data segment 0, to memory at [0, 5). CHECK_EQ(0, r.Call(0, 5, 5)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy 0 bytes does nothing. CHECK_EQ(0, r.Call(10, 1, 0)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // Copy 0 at end of memory region or data segment is OK. @@ -100,12 +97,12 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) { // Write all values up to the out-of-bounds write. CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, 0, 6)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 1, 2, 3, 4}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 1, 2, 3, 4}); // Write all values up to the out-of-bounds read. r.builder().BlankMemory(); CHECK_EQ(0xDEADBEEF, r.Call(0, 5, 6)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {5, 6, 7, 8, 9}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {5, 6, 7, 8, 9}); } WASM_EXEC_TEST(MemoryInitOutOfBounds) { @@ -155,13 +152,13 @@ WASM_EXEC_TEST(MemoryCopy) { // Copy from [1, 8] to [10, 16]. CHECK_EQ(0, r.Call(10, 1, 8)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); // Copy 0 bytes does nothing. CHECK_EQ(0, r.Call(10, 2, 0)); CheckMemoryEqualsFollowedByZeroes( - r.builder(), + &r.builder(), {0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); // Copy 0 at end of memory region is OK. @@ -184,12 +181,12 @@ WASM_EXEC_TEST(MemoryCopyOverlapping) { // Copy from [0, 3] -> [2, 5]. The copy must not overwrite 30 before copying // it (i.e. cannot copy forward in this case). CHECK_EQ(0, r.Call(2, 0, 3)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {10, 20, 10, 20, 30}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {10, 20, 10, 20, 30}); // Copy from [2, 5] -> [0, 3]. The copy must not write the first 10 (i.e. // cannot copy backward in this case). CHECK_EQ(0, r.Call(0, 2, 3)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {10, 20, 30, 20, 30}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {10, 20, 30, 20, 30}); } WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) { @@ -209,21 +206,21 @@ WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) { // Copy with source < destination. Copy would happen backwards, // but the first byte to copy is out-of-bounds, so no data should be written. CHECK_EQ(0xDEADBEEF, r.Call(last_5_bytes, 0, 6)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); // Copy overlapping with destination < source. Copy will happen forwards, up // to the out-of-bounds access. r.builder().BlankMemory(); memcpy(mem + last_5_bytes, data, 5); CHECK_EQ(0xDEADBEEF, r.Call(0, last_5_bytes, kWasmPageSize)); - CheckMemoryEquals(r.builder(), 0, {11, 22, 33, 44, 55}); + CheckMemoryEquals(&r.builder(), 0, {11, 22, 33, 44, 55}); // Copy overlapping with source < destination. Copy would happen backwards, // but the first byte to copy is out-of-bounds, so no data should be written. r.builder().BlankMemory(); memcpy(mem, data, 5); CHECK_EQ(0xDEADBEEF, r.Call(last_5_bytes, 0, kWasmPageSize)); - CheckMemoryEquals(r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); + CheckMemoryEquals(&r.builder(), last_5_bytes, {0, 0, 0, 0, 0}); } WASM_EXEC_TEST(MemoryCopyOutOfBounds) { @@ -265,15 +262,15 @@ WASM_EXEC_TEST(MemoryFill) { WASM_MEMORY_FILL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)), kExprI32Const, 0); CHECK_EQ(0, r.Call(1, 33, 5)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), {0, 33, 33, 33, 33, 33}); + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 33, 33}); CHECK_EQ(0, r.Call(4, 66, 4)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 66, 66, 66, 66}); // Fill 0 bytes does nothing. CHECK_EQ(0, r.Call(4, 66, 0)); - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 66, 66, 66, 66}); // Fill 0 at end of memory region is OK. @@ -290,7 +287,7 @@ WASM_EXEC_TEST(MemoryFillValueWrapsToByte) { kExprI32Const, 0); CHECK_EQ(0, r.Call(0, 1000, 3)); const byte expected = 1000 & 255; - CheckMemoryEqualsFollowedByZeroes(r.builder(), + CheckMemoryEqualsFollowedByZeroes(&r.builder(), {expected, expected, expected}); } @@ -304,7 +301,7 @@ WASM_EXEC_TEST(MemoryFillOutOfBoundsData) { kExprI32Const, 0); const byte v = 123; CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, v, 999)); - CheckMemoryEquals(r.builder(), kWasmPageSize - 6, {0, v, v, v, v, v}); + CheckMemoryEquals(&r.builder(), kWasmPageSize - 6, {0, v, v, v, v, v}); } WASM_EXEC_TEST(MemoryFillOutOfBounds) { @@ -408,14 +405,13 @@ void CheckTable(Isolate* isolate, Handle table, Args... args) { template void CheckTableCall(Isolate* isolate, Handle table, - WasmRunner& r, // NOLINT(runtime/references) - uint32_t function_index, Args... args) { + WasmRunner* r, uint32_t function_index, Args... args) { uint32_t args_length = static_cast(sizeof...(args)); CHECK_EQ(table->current_length(), args_length); double expected[] = {args...}; for (uint32_t i = 0; i < args_length; ++i) { Handle buffer[] = {isolate->factory()->NewNumber(i)}; - r.CheckCallApplyViaJS(expected[i], function_index, buffer, 1); + r->CheckCallApplyViaJS(expected[i], function_index, buffer, 1); } } } // namespace @@ -462,7 +458,7 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) { isolate); const double null = 0xDEADBEEF; - CheckTableCall(isolate, table, r, call_index, null, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, null, null, null, null, null); // 0 count is ok in bounds, and at end of regions. r.CheckCallViaJS(0, 0, 0, 0); @@ -471,19 +467,19 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) { // Test actual writes. r.CheckCallViaJS(0, 0, 0, 1); - CheckTableCall(isolate, table, r, call_index, 0, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, null, null, null, null); r.CheckCallViaJS(0, 0, 0, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, null, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, 1, null, null, null); r.CheckCallViaJS(0, 0, 0, 3); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, null, null); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, null, null); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 0, 1); r.CheckCallViaJS(0, 3, 1, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 1, 2); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 1, 2); r.CheckCallViaJS(0, 3, 2, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 2, 3); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 2, 3); r.CheckCallViaJS(0, 3, 3, 2); - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); } WASM_EXEC_TEST(TableInitElems0) { TestTableInitElems(execution_tier, 0); } @@ -534,15 +530,15 @@ void TestTableInitOob(ExecutionTier execution_tier, int table_index) { isolate); const double null = 0xDEADBEEF; - CheckTableCall(isolate, table, r, call_index, null, null, null, null, null); + CheckTableCall(isolate, table, &r, call_index, null, null, null, null, null); // Write all values up to the out-of-bounds write. r.CheckCallViaJS(0xDEADBEEF, 3, 0, 3); - CheckTableCall(isolate, table, r, call_index, null, null, null, 0, 1); + CheckTableCall(isolate, table, &r, call_index, null, null, null, 0, 1); // Write all values up to the out-of-bounds read. r.CheckCallViaJS(0xDEADBEEF, 0, 3, 3); - CheckTableCall(isolate, table, r, call_index, 3, 4, null, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 3, 4, null, 0, 1); // 0-count is never oob. r.CheckCallViaJS(0, kTableSize + 1, 0, 0); @@ -696,21 +692,21 @@ void TestTableCopyCalls(ExecutionTier execution_tier, int table_dst, isolate); if (table_dst == table_src) { - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 1); - CheckTableCall(isolate, table, r, call_index, 1, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 3, 4); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 1, 2); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 1, 2); } else { - CheckTableCall(isolate, table, r, call_index, 0, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 0, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 1); - CheckTableCall(isolate, table, r, call_index, 1, 1, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 1, 2, 3, 4); r.CheckCallViaJS(0, 0, 1, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 3, 4); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 3, 4); r.CheckCallViaJS(0, 3, 0, 2); - CheckTableCall(isolate, table, r, call_index, 1, 2, 2, 0, 1); + CheckTableCall(isolate, table, &r, call_index, 1, 2, 2, 0, 1); } } diff --git a/test/cctest/wasm/test-run-wasm-simd.cc b/test/cctest/wasm/test-run-wasm-simd.cc index ff16f1d810..d334b427af 100644 --- a/test/cctest/wasm/test-run-wasm-simd.cc +++ b/test/cctest/wasm/test-run-wasm-simd.cc @@ -2487,7 +2487,7 @@ void AppendShuffle(const Shuffle& shuffle, std::vector* buffer) { for (size_t i = 0; i < kSimd128Size; ++i) buffer->push_back((shuffle[i])); } -void BuildShuffle(std::vector& shuffles, // NOLINT(runtime/references) +void BuildShuffle(const std::vector& shuffles, std::vector* buffer) { // Perform the leaf shuffles on globals 0 and 1. size_t row_index = (shuffles.size() - 1) / 2; diff --git a/test/cctest/wasm/test-wasm-breakpoints.cc b/test/cctest/wasm/test-wasm-breakpoints.cc index e287b1139e..29bcba0b9a 100644 --- a/test/cctest/wasm/test-wasm-breakpoints.cc +++ b/test/cctest/wasm/test-wasm-breakpoints.cc @@ -112,20 +112,19 @@ class BreakHandler : public debug::DebugDelegate { } }; -void SetBreakpoint(WasmRunnerBase& runner, // NOLINT(runtime/references) - int function_index, int byte_offset, +void SetBreakpoint(WasmRunnerBase* runner, int function_index, int byte_offset, int expected_set_byte_offset = -1) { int func_offset = - runner.builder().GetFunctionAt(function_index)->code.offset(); + runner->builder().GetFunctionAt(function_index)->code.offset(); int code_offset = func_offset + byte_offset; if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset; - Handle instance = runner.builder().instance_object(); + Handle instance = runner->builder().instance_object(); Handle module_object(instance->module_object(), - runner.main_isolate()); + runner->main_isolate()); static int break_index = 0; Handle break_point = - runner.main_isolate()->factory()->NewBreakPoint( - break_index++, runner.main_isolate()->factory()->empty_string()); + runner->main_isolate()->factory()->NewBreakPoint( + break_index++, runner->main_isolate()->factory()->empty_string()); CHECK(WasmModuleObject::SetBreakPoint(module_object, &code_offset, break_point)); int set_byte_offset = code_offset - func_offset; @@ -276,7 +275,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) { Handle main_fun_wrapper = runner.builder().WrapCode(runner.function_index()); - SetBreakpoint(runner, runner.function_index(), 4, 4); + SetBreakpoint(&runner, runner.function_index(), 4, 4); BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}}); @@ -298,7 +297,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) { runner.builder().WrapCode(runner.function_index()); // Set breakpoint at the first I32Const. - SetBreakpoint(runner, runner.function_index(), 1, 1); + SetBreakpoint(&runner, runner.function_index(), 1, 1); BreakHandler count_breaks(isolate, { @@ -341,7 +340,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) { runner.builder().WrapCode(f2.function_index()); // Set first breakpoint on the GetLocal (offset 19) before the Call. - SetBreakpoint(runner, f2.function_index(), 19, 19); + SetBreakpoint(&runner, f2.function_index(), 19, 19); BreakHandler count_breaks(isolate, { @@ -377,7 +376,7 @@ WASM_COMPILED_EXEC_TEST(WasmGetLocalsAndStack) { // Set breakpoint at the first instruction (7 bytes for local decls: num // entries + 3x). - SetBreakpoint(runner, runner.function_index(), 7, 7); + SetBreakpoint(&runner, runner.function_index(), 7, 7); CollectValuesBreakHandler break_handler( isolate, diff --git a/test/cctest/wasm/test-wasm-interpreter-entry.cc b/test/cctest/wasm/test-wasm-interpreter-entry.cc index 736475ff55..75e927fafe 100644 --- a/test/cctest/wasm/test-wasm-interpreter-entry.cc +++ b/test/cctest/wasm/test-wasm-interpreter-entry.cc @@ -32,28 +32,27 @@ namespace { template class ArgPassingHelper { public: - ArgPassingHelper( - WasmRunnerBase& runner, // NOLINT(runtime/references) - WasmFunctionCompiler& inner_compiler, // NOLINT(runtime/references) - std::initializer_list bytes_inner_function, - std::initializer_list bytes_outer_function, - const T& expected_lambda) - : isolate_(runner.main_isolate()), + ArgPassingHelper(WasmRunnerBase* runner, WasmFunctionCompiler* inner_compiler, + std::initializer_list bytes_inner_function, + std::initializer_list bytes_outer_function, + const T& expected_lambda) + : isolate_(runner->main_isolate()), expected_lambda_(expected_lambda), debug_info_(WasmInstanceObject::GetOrCreateDebugInfo( - runner.builder().instance_object())) { + runner->builder().instance_object())) { std::vector inner_code{bytes_inner_function}; - inner_compiler.Build(inner_code.data(), - inner_code.data() + inner_code.size()); + inner_compiler->Build(inner_code.data(), + inner_code.data() + inner_code.size()); std::vector outer_code{bytes_outer_function}; - runner.Build(outer_code.data(), outer_code.data() + outer_code.size()); + runner->Build(outer_code.data(), outer_code.data() + outer_code.size()); - int funcs_to_redict[] = {static_cast(inner_compiler.function_index())}; - runner.builder().SetExecutable(); + int funcs_to_redict[] = { + static_cast(inner_compiler->function_index())}; + runner->builder().SetExecutable(); WasmDebugInfo::RedirectToInterpreter(debug_info_, ArrayVector(funcs_to_redict)); - main_fun_wrapper_ = runner.builder().WrapCode(runner.function_index()); + main_fun_wrapper_ = runner->builder().WrapCode(runner->function_index()); } template @@ -82,8 +81,7 @@ class ArgPassingHelper { template static ArgPassingHelper GetHelper( - WasmRunnerBase& runner, // NOLINT(runtime/references) - WasmFunctionCompiler& inner_compiler, // NOLINT(runtime/references) + WasmRunnerBase* runner, WasmFunctionCompiler* inner_compiler, std::initializer_list bytes_inner_function, std::initializer_list bytes_outer_function, const T& expected_lambda) { @@ -99,7 +97,7 @@ TEST(TestArgumentPassing_int32) { WasmFunctionCompiler& f2 = runner.NewFunction(); auto helper = GetHelper( - runner, f2, + &runner, &f2, {// Return 2*<0> + 1. WASM_I32_ADD(WASM_I32_MUL(WASM_I32V_1(2), WASM_GET_LOCAL(0)), WASM_ONE)}, {// Call f2 with param <0>. @@ -117,7 +115,7 @@ TEST(TestArgumentPassing_double_int64) { WasmFunctionCompiler& f2 = runner.NewFunction(); auto helper = GetHelper( - runner, f2, + &runner, &f2, {// Return (double)<0>. WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))}, {// Call f2 with param (<0> | (<1> << 32)). @@ -150,7 +148,7 @@ TEST(TestArgumentPassing_int64_double) { WasmFunctionCompiler& f2 = runner.NewFunction(); auto helper = GetHelper( - runner, f2, + &runner, &f2, {// Return (int64_t)<0>. WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))}, {// Call f2 with param <0>, convert returned value back to double. @@ -169,7 +167,7 @@ TEST(TestArgumentPassing_float_double) { WasmFunctionCompiler& f2 = runner.NewFunction(); auto helper = GetHelper( - runner, f2, + &runner, &f2, {// Return 2*(double)<0> + 1. WASM_F64_ADD( WASM_F64_MUL(WASM_F64(2), WASM_F64_CONVERT_F32(WASM_GET_LOCAL(0))), @@ -186,7 +184,7 @@ TEST(TestArgumentPassing_double_double) { WasmRunner runner(ExecutionTier::kTurbofan); WasmFunctionCompiler& f2 = runner.NewFunction(); - auto helper = GetHelper(runner, f2, + auto helper = GetHelper(&runner, &f2, {// Return <0> + <1>. WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}, {// Call f2 with params <0>, <1>. @@ -208,7 +206,7 @@ TEST(TestArgumentPassing_AllTypes) { runner.NewFunction(); auto helper = GetHelper( - runner, f2, + &runner, &f2, { // Convert all arguments to double, add them and return the sum. WASM_F64_ADD( // <0+1+2> + <3> diff --git a/test/cctest/wasm/test-wasm-shared-engine.cc b/test/cctest/wasm/test-wasm-shared-engine.cc index b5bacf57d4..8344ef6852 100644 --- a/test/cctest/wasm/test-wasm-shared-engine.cc +++ b/test/cctest/wasm/test-wasm-shared-engine.cc @@ -112,19 +112,19 @@ class SharedEngineIsolate { class SharedEngineThread : public v8::base::Thread { public: SharedEngineThread(SharedEngine* engine, - std::function callback) + std::function callback) : Thread(Options("SharedEngineThread")), engine_(engine), callback_(callback) {} void Run() override { SharedEngineIsolate isolate(engine_); - callback_(isolate); + callback_(&isolate); } private: SharedEngine* engine_; - std::function callback_; + std::function callback_; }; namespace { @@ -159,13 +159,12 @@ class MockInstantiationResolver : public InstantiationResultResolver { class MockCompilationResolver : public CompilationResultResolver { public: - MockCompilationResolver( - SharedEngineIsolate& isolate, // NOLINT(runtime/references) - Handle* out_instance) + MockCompilationResolver(SharedEngineIsolate* isolate, + Handle* out_instance) : isolate_(isolate), out_instance_(out_instance) {} void OnCompilationSucceeded(Handle result) override { - isolate_.isolate()->wasm_engine()->AsyncInstantiate( - isolate_.isolate(), + isolate_->isolate()->wasm_engine()->AsyncInstantiate( + isolate_->isolate(), base::make_unique(out_instance_), result, {}); } @@ -174,27 +173,25 @@ class MockCompilationResolver : public CompilationResultResolver { } private: - SharedEngineIsolate& isolate_; + SharedEngineIsolate* isolate_; Handle* out_instance_; }; -void PumpMessageLoop( - SharedEngineIsolate& isolate) { // NOLINT(runtime/references) +void PumpMessageLoop(SharedEngineIsolate* isolate) { v8::platform::PumpMessageLoop(i::V8::GetCurrentPlatform(), - isolate.v8_isolate(), + isolate->v8_isolate(), platform::MessageLoopBehavior::kWaitForWork); - isolate.isolate()->default_microtask_queue()->RunMicrotasks( - isolate.isolate()); + isolate->isolate()->default_microtask_queue()->RunMicrotasks( + isolate->isolate()); } Handle CompileAndInstantiateAsync( - SharedEngineIsolate& isolate, // NOLINT(runtime/references) - ZoneBuffer* buffer) { - Handle maybe_instance = handle(Smi::kZero, isolate.isolate()); - auto enabled_features = WasmFeaturesFromIsolate(isolate.isolate()); + SharedEngineIsolate* isolate, ZoneBuffer* buffer) { + Handle maybe_instance = handle(Smi::kZero, isolate->isolate()); + auto enabled_features = WasmFeaturesFromIsolate(isolate->isolate()); constexpr const char* kAPIMethodName = "Test.CompileAndInstantiateAsync"; - isolate.isolate()->wasm_engine()->AsyncCompile( - isolate.isolate(), enabled_features, + isolate->isolate()->wasm_engine()->AsyncCompile( + isolate->isolate(), enabled_features, base::make_unique(isolate, &maybe_instance), ModuleWireBytes(buffer->begin(), buffer->end()), true, kAPIMethodName); while (!maybe_instance->IsWasmInstanceObject()) PumpMessageLoop(isolate); @@ -261,17 +258,19 @@ TEST(SharedEngineRunImported) { TEST(SharedEngineRunThreadedBuildingSync) { SharedEngine engine; - SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); - Handle instance = isolate.CompileAndInstantiate(buffer); - CHECK_EQ(23, isolate.Run(instance)); + SharedEngineThread thread1(&engine, [](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 23); + Handle instance = + isolate->CompileAndInstantiate(buffer); + CHECK_EQ(23, isolate->Run(instance)); }); - SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); - Handle instance = isolate.CompileAndInstantiate(buffer); - CHECK_EQ(42, isolate.Run(instance)); + SharedEngineThread thread2(&engine, [](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 42); + Handle instance = + isolate->CompileAndInstantiate(buffer); + CHECK_EQ(42, isolate->Run(instance)); }); CHECK(thread1.Start()); CHECK(thread2.Start()); @@ -281,19 +280,19 @@ TEST(SharedEngineRunThreadedBuildingSync) { TEST(SharedEngineRunThreadedBuildingAsync) { SharedEngine engine; - SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); + SharedEngineThread thread1(&engine, [](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 23); Handle instance = CompileAndInstantiateAsync(isolate, buffer); - CHECK_EQ(23, isolate.Run(instance)); + CHECK_EQ(23, isolate->Run(instance)); }); - SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); + SharedEngineThread thread2(&engine, [](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 42); Handle instance = CompileAndInstantiateAsync(isolate, buffer); - CHECK_EQ(42, isolate.Run(instance)); + CHECK_EQ(42, isolate->Run(instance)); }); CHECK(thread1.Start()); CHECK(thread2.Start()); @@ -311,15 +310,15 @@ TEST(SharedEngineRunThreadedExecution) { Handle instance = isolate.CompileAndInstantiate(buffer); module = isolate.ExportInstance(instance); } - SharedEngineThread thread1(&engine, [module](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - Handle instance = isolate.ImportInstance(module); - CHECK_EQ(23, isolate.Run(instance)); + SharedEngineThread thread1(&engine, [module](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + Handle instance = isolate->ImportInstance(module); + CHECK_EQ(23, isolate->Run(instance)); }); - SharedEngineThread thread2(&engine, [module](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - Handle instance = isolate.ImportInstance(module); - CHECK_EQ(23, isolate.Run(instance)); + SharedEngineThread thread2(&engine, [module](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + Handle instance = isolate->ImportInstance(module); + CHECK_EQ(23, isolate->Run(instance)); }); CHECK(thread1.Start()); CHECK(thread2.Start()); @@ -340,23 +339,23 @@ TEST(SharedEngineRunThreadedTierUp) { constexpr int kNumberOfThreads = 5; std::list threads; for (int i = 0; i < kNumberOfThreads; ++i) { - threads.emplace_back(&engine, [module](SharedEngineIsolate& isolate) { + threads.emplace_back(&engine, [module](SharedEngineIsolate* isolate) { constexpr int kNumberOfIterations = 100; - HandleScope scope(isolate.isolate()); - Handle instance = isolate.ImportInstance(module); + HandleScope scope(isolate->isolate()); + Handle instance = isolate->ImportInstance(module); for (int j = 0; j < kNumberOfIterations; ++j) { - CHECK_EQ(23, isolate.Run(instance)); + CHECK_EQ(23, isolate->Run(instance)); } }); } - threads.emplace_back(&engine, [module](SharedEngineIsolate& isolate) { - HandleScope scope(isolate.isolate()); - Handle instance = isolate.ImportInstance(module); + threads.emplace_back(&engine, [module](SharedEngineIsolate* isolate) { + HandleScope scope(isolate->isolate()); + Handle instance = isolate->ImportInstance(module); WasmFeatures detected = kNoWasmFeatures; WasmCompilationUnit::CompileWasmFunction( - isolate.isolate(), module.get(), &detected, + isolate->isolate(), module.get(), &detected, &module->module()->functions[0], ExecutionTier::kTurbofan); - CHECK_EQ(23, isolate.Run(instance)); + CHECK_EQ(23, isolate->Run(instance)); }); for (auto& thread : threads) CHECK(thread.Start()); for (auto& thread : threads) thread.Join();