[cleanup] Eliminate non-const reference parameters

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

Bug: v8:9429
Change-Id: I9b3f06d6dda447285673269819bdb405ebac2187
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1793064
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63636}
This commit is contained in:
Bill Budge 2019-09-09 18:19:59 -07:00 committed by Commit Bot
parent 6f17f5d1ae
commit ab0f971091
26 changed files with 732 additions and 815 deletions

View File

@ -20,35 +20,31 @@ namespace {
using Variable = CodeAssemblerVariable; using Variable = CodeAssemblerVariable;
Node* SmiTag(CodeAssembler& m, // NOLINT(runtime/references) Node* SmiTag(CodeAssembler* m, Node* value) {
Node* value) {
int32_t constant_value; int32_t constant_value;
if (m.ToInt32Constant(value, &constant_value) && if (m->ToInt32Constant(value, &constant_value) &&
Smi::IsValid(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) Node* UndefinedConstant(CodeAssembler* m) {
return m.LoadRoot(RootIndex::kUndefinedValue); return m->LoadRoot(RootIndex::kUndefinedValue);
} }
Node* SmiFromInt32(CodeAssembler& m, // NOLINT(runtime/references) Node* SmiFromInt32(CodeAssembler* m, Node* value) {
Node* value) { value = m->ChangeInt32ToIntPtr(value);
value = m.ChangeInt32ToIntPtr(value); return m->BitcastWordToTaggedSigned(
return m.BitcastWordToTaggedSigned( m->WordShl(value, kSmiShiftSize + kSmiTagSize));
m.WordShl(value, kSmiShiftSize + kSmiTagSize));
} }
Node* LoadObjectField(CodeAssembler& m, // NOLINT(runtime/references) Node* LoadObjectField(CodeAssembler* m, Node* object, int offset,
Node* object, int offset,
MachineType type = MachineType::AnyTagged()) { 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* LoadMap(CodeAssembler* m, Node* object) {
Node* object) {
return LoadObjectField(m, object, JSObject::kMapOffset); return LoadObjectField(m, object, JSObject::kMapOffset);
} }
@ -58,7 +54,7 @@ TEST(SimpleSmiReturn) {
Isolate* isolate(CcTest::InitIsolateOnce()); Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate); CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state()); CodeAssembler m(asm_tester.state());
m.Return(SmiTag(m, m.Int32Constant(37))); m.Return(SmiTag(&m, m.Int32Constant(37)));
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
CHECK_EQ(37, ft.CallChecked<Smi>()->value()); CHECK_EQ(37, ft.CallChecked<Smi>()->value());
} }
@ -90,7 +86,7 @@ TEST(SimpleCallRuntime1Arg) {
CodeAssembler m(asm_tester.state()); CodeAssembler m(asm_tester.state());
TNode<Context> context = TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context())); m.HeapConstant(Handle<Context>(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)); m.Return(m.CallRuntime(Runtime::kIsSmi, context, b));
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
CHECK(ft.CallChecked<Oddball>().is_identical_to( CHECK(ft.CallChecked<Oddball>().is_identical_to(
@ -103,7 +99,7 @@ TEST(SimpleTailCallRuntime1Arg) {
CodeAssembler m(asm_tester.state()); CodeAssembler m(asm_tester.state());
TNode<Context> context = TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context())); m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* b = SmiTag(m, m.Int32Constant(0)); Node* b = SmiTag(&m, m.Int32Constant(0));
m.TailCallRuntime(Runtime::kIsSmi, context, b); m.TailCallRuntime(Runtime::kIsSmi, context, b);
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
CHECK(ft.CallChecked<Oddball>().is_identical_to( CHECK(ft.CallChecked<Oddball>().is_identical_to(
@ -116,8 +112,8 @@ TEST(SimpleCallRuntime2Arg) {
CodeAssembler m(asm_tester.state()); CodeAssembler m(asm_tester.state());
TNode<Context> context = TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context())); m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* a = SmiTag(m, m.Int32Constant(2)); Node* a = SmiTag(&m, m.Int32Constant(2));
Node* b = SmiTag(m, m.Int32Constant(4)); Node* b = SmiTag(&m, m.Int32Constant(4));
m.Return(m.CallRuntime(Runtime::kAdd, context, a, b)); m.Return(m.CallRuntime(Runtime::kAdd, context, a, b));
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
CHECK_EQ(6, ft.CallChecked<Smi>()->value()); CHECK_EQ(6, ft.CallChecked<Smi>()->value());
@ -129,8 +125,8 @@ TEST(SimpleTailCallRuntime2Arg) {
CodeAssembler m(asm_tester.state()); CodeAssembler m(asm_tester.state());
TNode<Context> context = TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context())); m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* a = SmiTag(m, m.Int32Constant(2)); Node* a = SmiTag(&m, m.Int32Constant(2));
Node* b = SmiTag(m, m.Int32Constant(4)); Node* b = SmiTag(&m, m.Int32Constant(4));
m.TailCallRuntime(Runtime::kAdd, context, a, b); m.TailCallRuntime(Runtime::kAdd, context, a, b);
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
CHECK_EQ(6, ft.CallChecked<Smi>()->value()); CHECK_EQ(6, ft.CallChecked<Smi>()->value());
@ -138,8 +134,7 @@ TEST(SimpleTailCallRuntime2Arg) {
namespace { namespace {
Handle<JSFunction> CreateSumAllArgumentsFunction( Handle<JSFunction> CreateSumAllArgumentsFunction(FunctionTester* ft) {
FunctionTester& ft) { // NOLINT(runtime/references)
const char* source = const char* source =
"(function() {\n" "(function() {\n"
" var sum = 0 + this;\n" " var sum = 0 + this;\n"
@ -148,7 +143,7 @@ Handle<JSFunction> CreateSumAllArgumentsFunction(
" }\n" " }\n"
" return sum;\n" " return sum;\n"
"})"; "})";
return ft.NewFunction(source); return ft->NewFunction(source);
} }
} // namespace } // namespace
@ -162,7 +157,7 @@ TEST(SimpleCallJSFunction0Arg) {
Node* function = m.Parameter(0); Node* function = m.Parameter(0);
Node* context = m.Parameter(kNumParams + 2); 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); Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver); Node* result = m.CallJS(callable, context, function, receiver);
@ -170,7 +165,7 @@ TEST(SimpleCallJSFunction0Arg) {
} }
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft); Handle<JSFunction> sum = CreateSumAllArgumentsFunction(&ft);
MaybeHandle<Object> result = ft.Call(sum); MaybeHandle<Object> result = ft.Call(sum);
CHECK_EQ(Smi::FromInt(42), *result.ToHandleChecked()); CHECK_EQ(Smi::FromInt(42), *result.ToHandleChecked());
} }
@ -184,8 +179,8 @@ TEST(SimpleCallJSFunction1Arg) {
Node* function = m.Parameter(0); Node* function = m.Parameter(0);
Node* context = m.Parameter(1); Node* context = m.Parameter(1);
Node* receiver = SmiTag(m, m.Int32Constant(42)); Node* receiver = SmiTag(&m, m.Int32Constant(42));
Node* a = SmiTag(m, m.Int32Constant(13)); Node* a = SmiTag(&m, m.Int32Constant(13));
Callable callable = CodeFactory::Call(isolate); Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver, a); Node* result = m.CallJS(callable, context, function, receiver, a);
@ -193,7 +188,7 @@ TEST(SimpleCallJSFunction1Arg) {
} }
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft); Handle<JSFunction> sum = CreateSumAllArgumentsFunction(&ft);
MaybeHandle<Object> result = ft.Call(sum); MaybeHandle<Object> result = ft.Call(sum);
CHECK_EQ(Smi::FromInt(55), *result.ToHandleChecked()); CHECK_EQ(Smi::FromInt(55), *result.ToHandleChecked());
} }
@ -207,9 +202,9 @@ TEST(SimpleCallJSFunction2Arg) {
Node* function = m.Parameter(0); Node* function = m.Parameter(0);
Node* context = m.Parameter(1); Node* context = m.Parameter(1);
Node* receiver = SmiTag(m, m.Int32Constant(42)); Node* receiver = SmiTag(&m, m.Int32Constant(42));
Node* a = SmiTag(m, m.Int32Constant(13)); Node* a = SmiTag(&m, m.Int32Constant(13));
Node* b = SmiTag(m, m.Int32Constant(153)); Node* b = SmiTag(&m, m.Int32Constant(153));
Callable callable = CodeFactory::Call(isolate); Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver, a, b); Node* result = m.CallJS(callable, context, function, receiver, a, b);
@ -217,7 +212,7 @@ TEST(SimpleCallJSFunction2Arg) {
} }
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft); Handle<JSFunction> sum = CreateSumAllArgumentsFunction(&ft);
MaybeHandle<Object> result = ft.Call(sum); MaybeHandle<Object> result = ft.Call(sum);
CHECK_EQ(Smi::FromInt(208), *result.ToHandleChecked()); CHECK_EQ(Smi::FromInt(208), *result.ToHandleChecked());
} }
@ -388,11 +383,11 @@ TEST(TestToConstant) {
CHECK(m.ToInt32Constant(a, &value32)); CHECK(m.ToInt32Constant(a, &value32));
CHECK(m.ToInt64Constant(a, &value64)); CHECK(m.ToInt64Constant(a, &value64));
a = UndefinedConstant(m); a = UndefinedConstant(&m);
CHECK(!m.ToInt32Constant(a, &value32)); CHECK(!m.ToInt32Constant(a, &value32));
CHECK(!m.ToInt64Constant(a, &value64)); CHECK(!m.ToInt64Constant(a, &value64));
a = UndefinedConstant(m); a = UndefinedConstant(&m);
CHECK(!m.ToInt32Constant(a, &value32)); CHECK(!m.ToInt32Constant(a, &value32));
CHECK(!m.ToInt64Constant(a, &value64)); CHECK(!m.ToInt64Constant(a, &value64));
} }
@ -411,7 +406,7 @@ TEST(DeferredCodePhiHints) {
m.Goto(&loop); m.Goto(&loop);
m.Bind(&loop); m.Bind(&loop);
{ {
Node* map = LoadMap(m, var_object.value()); Node* map = LoadMap(&m, var_object.value());
var_object.Bind(map); var_object.Bind(map);
m.Goto(&loop); m.Goto(&loop);
} }
@ -514,20 +509,20 @@ TEST(GotoIfExceptionMultiple) {
// try { ToString(param2); return 7 } catch (e) { ... } // try { ToString(param2); return 7 } catch (e) { ... }
m.Bind(&exception_handler1); m.Bind(&exception_handler1);
return_value.Bind(m.Int32Constant(7)); return_value.Bind(m.Int32Constant(7));
error.Bind(UndefinedConstant(m)); error.Bind(UndefinedConstant(&m));
string = m.CallStub(to_string, context, second_value); string = m.CallStub(to_string, context, second_value);
m.GotoIfException(string, &exception_handler2, &error); 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; } // try { ToString(param3); return 7 & ~2; } catch (e) { return e; }
m.Bind(&exception_handler2); m.Bind(&exception_handler2);
// Return returnValue & ~2 // Return returnValue & ~2
error.Bind(UndefinedConstant(m)); error.Bind(UndefinedConstant(&m));
string = m.CallStub(to_string, context, third_value); string = m.CallStub(to_string, context, third_value);
m.GotoIfException(string, &exception_handler3, &error); m.GotoIfException(string, &exception_handler3, &error);
m.Return(SmiFromInt32( m.Return(SmiFromInt32(
m, m.Word32And(return_value.value(), &m, m.Word32And(return_value.value(),
m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1))))); m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1)))));
m.Bind(&exception_handler3); m.Bind(&exception_handler3);
m.Return(error.value()); m.Return(error.value());

View File

@ -109,12 +109,11 @@ class TestCode : public HandleAndZoneScope {
} }
}; };
void VerifyForwarding(TestCode& code, // NOLINT(runtime/references) void VerifyForwarding(TestCode* code, int count, int* expected) {
int count, int* expected) {
v8::internal::AccountingAllocator allocator; v8::internal::AccountingAllocator allocator;
Zone local_zone(&allocator, ZONE_NAME); Zone local_zone(&allocator, ZONE_NAME);
ZoneVector<RpoNumber> result(&local_zone); ZoneVector<RpoNumber> result(&local_zone);
JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_, true); JumpThreading::ComputeForwarding(&local_zone, result, &code->sequence_, true);
CHECK(count == static_cast<int>(result.size())); CHECK(count == static_cast<int>(result.size()));
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -133,7 +132,7 @@ TEST(FwEmpty1) {
code.End(); code.End();
static int expected[] = {2, 2, 2}; static int expected[] = {2, 2, 2};
VerifyForwarding(code, 3, expected); VerifyForwarding(&code, 3, expected);
} }
@ -150,7 +149,7 @@ TEST(FwEmptyN) {
code.End(); code.End();
static int expected[] = {2, 2, 2}; static int expected[] = {2, 2, 2};
VerifyForwarding(code, 3, expected); VerifyForwarding(&code, 3, expected);
} }
} }
@ -162,7 +161,7 @@ TEST(FwNone1) {
code.End(); code.End();
static int expected[] = {0}; static int expected[] = {0};
VerifyForwarding(code, 1, expected); VerifyForwarding(&code, 1, expected);
} }
@ -174,7 +173,7 @@ TEST(FwMoves1) {
code.End(); code.End();
static int expected[] = {0}; static int expected[] = {0};
VerifyForwarding(code, 1, expected); VerifyForwarding(&code, 1, expected);
} }
@ -188,7 +187,7 @@ TEST(FwMoves2) {
code.End(); code.End();
static int expected[] = {1, 1}; static int expected[] = {1, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -202,7 +201,7 @@ TEST(FwMoves2b) {
code.End(); code.End();
static int expected[] = {0, 1}; static int expected[] = {0, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -216,7 +215,7 @@ TEST(FwOther2) {
code.End(); code.End();
static int expected[] = {0, 1}; static int expected[] = {0, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -229,7 +228,7 @@ TEST(FwNone2a) {
code.End(); code.End();
static int expected[] = {1, 1}; static int expected[] = {1, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -242,7 +241,7 @@ TEST(FwNone2b) {
code.End(); code.End();
static int expected[] = {1, 1}; static int expected[] = {1, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -253,7 +252,7 @@ TEST(FwLoop1) {
code.Jump(0); code.Jump(0);
static int expected[] = {0}; static int expected[] = {0};
VerifyForwarding(code, 1, expected); VerifyForwarding(&code, 1, expected);
} }
@ -266,7 +265,7 @@ TEST(FwLoop2) {
code.Jump(0); code.Jump(0);
static int expected[] = {0, 0}; static int expected[] = {0, 0};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -281,7 +280,7 @@ TEST(FwLoop3) {
code.Jump(0); code.Jump(0);
static int expected[] = {0, 0, 0}; static int expected[] = {0, 0, 0};
VerifyForwarding(code, 3, expected); VerifyForwarding(&code, 3, expected);
} }
@ -294,7 +293,7 @@ TEST(FwLoop1b) {
code.Jump(1); code.Jump(1);
static int expected[] = {1, 1}; static int expected[] = {1, 1};
VerifyForwarding(code, 2, expected); VerifyForwarding(&code, 2, expected);
} }
@ -309,7 +308,7 @@ TEST(FwLoop2b) {
code.Jump(1); code.Jump(1);
static int expected[] = {1, 1, 1}; static int expected[] = {1, 1, 1};
VerifyForwarding(code, 3, expected); VerifyForwarding(&code, 3, expected);
} }
@ -326,7 +325,7 @@ TEST(FwLoop3b) {
code.Jump(1); code.Jump(1);
static int expected[] = {1, 1, 1, 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); code.Jump(2);
static int expected[] = {1, 1, 1, 1, 1}; 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); code.Jump(2);
static int expected[] = {2, 2, 2, 2, 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); code.Jump(1);
static int expected[] = {1, 1, 1, 1, 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); code.Jump(1);
static int expected[] = {1, 1, 1, 1, 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); code.Jump(0);
static int expected[] = {2, 2, 2, 2, 2, 2}; 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(); code.End();
int expected[] = {0, i ? 1 : 3, j ? 2 : 3, 3}; 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 merge = k ? 3 : 4;
int expected[] = {0, i ? 1 : merge, j ? 2 : merge, merge, 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, int expected[] = {0, i ? 1 : 3, j ? 2 : 3, 3,
x ? 4 : 6, y ? 5 : 6, 6}; 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, int expected[] = {size + 1, size + 1, size + 1, 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}; int expected[] = {br, 5, 5, 5, 5, 5};
expected[br] = br; expected[br] = br;
VerifyForwarding(code, 6, expected); VerifyForwarding(&code, 6, expected);
} }
TEST(FwPermuted_diamond) { RunAllPermutations<4>(RunPermutedDiamond); } TEST(FwPermuted_diamond) { RunAllPermutations<4>(RunPermutedDiamond); }
void ApplyForwarding(TestCode& code, // NOLINT(runtime/references) void ApplyForwarding(TestCode* code, int size, int* forward) {
int size, int* forward) { code->sequence_.RecomputeAssemblyOrderForTesting();
code.sequence_.RecomputeAssemblyOrderForTesting(); ZoneVector<RpoNumber> vector(code->main_zone());
ZoneVector<RpoNumber> vector(code.main_zone());
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
vector.push_back(RpoNumber::FromInt(forward[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) void CheckJump(TestCode* code, int pos, int target) {
int pos, int target) { Instruction* instr = code->sequence_.InstructionAt(pos);
Instruction* instr = code.sequence_.InstructionAt(pos);
CHECK_EQ(kArchJmp, instr->arch_opcode()); CHECK_EQ(kArchJmp, instr->arch_opcode());
CHECK_EQ(1, static_cast<int>(instr->InputCount())); CHECK_EQ(1, static_cast<int>(instr->InputCount()));
CHECK_EQ(0, static_cast<int>(instr->OutputCount())); CHECK_EQ(0, static_cast<int>(instr->OutputCount()));
CHECK_EQ(0, static_cast<int>(instr->TempCount())); CHECK_EQ(0, static_cast<int>(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) void CheckNop(TestCode* code, int pos) {
int pos) { Instruction* instr = code->sequence_.InstructionAt(pos);
Instruction* instr = code.sequence_.InstructionAt(pos);
CHECK_EQ(kArchNop, instr->arch_opcode()); CHECK_EQ(kArchNop, instr->arch_opcode());
CHECK_EQ(0, static_cast<int>(instr->InputCount())); CHECK_EQ(0, static_cast<int>(instr->InputCount()));
CHECK_EQ(0, static_cast<int>(instr->OutputCount())); CHECK_EQ(0, static_cast<int>(instr->OutputCount()));
CHECK_EQ(0, static_cast<int>(instr->TempCount())); CHECK_EQ(0, static_cast<int>(instr->TempCount()));
} }
void CheckBranch(TestCode& code, // NOLINT(runtime/references) void CheckBranch(TestCode* code, int pos, int t1, int t2) {
int pos, int t1, int t2) { Instruction* instr = code->sequence_.InstructionAt(pos);
Instruction* instr = code.sequence_.InstructionAt(pos);
CHECK_EQ(2, static_cast<int>(instr->InputCount())); CHECK_EQ(2, static_cast<int>(instr->InputCount()));
CHECK_EQ(0, static_cast<int>(instr->OutputCount())); CHECK_EQ(0, static_cast<int>(instr->OutputCount()));
CHECK_EQ(0, static_cast<int>(instr->TempCount())); CHECK_EQ(0, static_cast<int>(instr->TempCount()));
CHECK_EQ(t1, code.sequence_.InputRpo(instr, 0).ToInt()); CHECK_EQ(t1, code->sequence_.InputRpo(instr, 0).ToInt());
CHECK_EQ(t2, code.sequence_.InputRpo(instr, 1).ToInt()); CHECK_EQ(t2, code->sequence_.InputRpo(instr, 1).ToInt());
} }
void CheckAssemblyOrder(TestCode& code, // NOLINT(runtime/references) void CheckAssemblyOrder(TestCode* code, int size, int* expected) {
int size, int* expected) {
int i = 0; 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()); CHECK_EQ(expected[i++], block->ao_number().ToInt());
} }
} }
@ -668,12 +662,12 @@ TEST(Rewire1) {
code.End(); code.End();
static int forward[] = {2, 2, 2}; static int forward[] = {2, 2, 2};
ApplyForwarding(code, 3, forward); ApplyForwarding(&code, 3, forward);
CheckJump(code, j1, 2); CheckJump(&code, j1, 2);
CheckNop(code, j2); CheckNop(&code, j2);
static int assembly[] = {0, 1, 1}; static int assembly[] = {0, 1, 1};
CheckAssemblyOrder(code, 3, assembly); CheckAssemblyOrder(&code, 3, assembly);
} }
@ -691,13 +685,13 @@ TEST(Rewire1_deferred) {
code.End(); code.End();
static int forward[] = {3, 3, 3, 3}; static int forward[] = {3, 3, 3, 3};
ApplyForwarding(code, 4, forward); ApplyForwarding(&code, 4, forward);
CheckJump(code, j1, 3); CheckJump(&code, j1, 3);
CheckNop(code, j2); CheckNop(&code, j2);
CheckNop(code, j3); CheckNop(&code, j3);
static int assembly[] = {0, 1, 2, 1}; static int assembly[] = {0, 1, 2, 1};
CheckAssemblyOrder(code, 4, assembly); CheckAssemblyOrder(&code, 4, assembly);
} }
@ -717,12 +711,12 @@ TEST(Rewire2_deferred) {
code.End(); code.End();
static int forward[] = {0, 1, 2, 3}; static int forward[] = {0, 1, 2, 3};
ApplyForwarding(code, 4, forward); ApplyForwarding(&code, 4, forward);
CheckJump(code, j1, 1); CheckJump(&code, j1, 1);
CheckJump(code, j2, 3); CheckJump(&code, j2, 3);
static int assembly[] = {0, 2, 3, 1}; static int assembly[] = {0, 2, 3, 1};
CheckAssemblyOrder(code, 4, assembly); CheckAssemblyOrder(&code, 4, assembly);
} }
@ -742,18 +736,18 @@ TEST(Rewire_diamond) {
code.End(); code.End();
int forward[] = {0, 1, i ? 4 : 2, j ? 4 : 3, 4}; int forward[] = {0, 1, i ? 4 : 2, j ? 4 : 3, 4};
ApplyForwarding(code, 5, forward); ApplyForwarding(&code, 5, forward);
CheckJump(code, j1, 1); CheckJump(&code, j1, 1);
CheckBranch(code, b1, i ? 4 : 2, j ? 4 : 3); CheckBranch(&code, b1, i ? 4 : 2, j ? 4 : 3);
if (i) { if (i) {
CheckNop(code, j2); CheckNop(&code, j2);
} else { } else {
CheckJump(code, j2, 4); CheckJump(&code, j2, 4);
} }
if (j) { if (j) {
CheckNop(code, j3); CheckNop(&code, j3);
} else { } else {
CheckJump(code, j3, 4); CheckJump(&code, j3, 4);
} }
int assembly[] = {0, 1, 2, 3, 4}; int assembly[] = {0, 1, 2, 3, 4};
@ -763,7 +757,7 @@ TEST(Rewire_diamond) {
if (j) { if (j) {
for (int k = 4; k < 5; k++) assembly[k]--; for (int k = 4; k < 5; k++) assembly[k]--;
} }
CheckAssemblyOrder(code, 5, assembly); CheckAssemblyOrder(&code, 5, assembly);
} }
} }
} }

View File

@ -201,9 +201,9 @@ struct While {
} }
void chain(Node* control) { loop->ReplaceInput(0, control); } void chain(Node* control) { loop->ReplaceInput(0, control); }
void nest(While& that) { // NOLINT(runtime/references) void nest(While* that) {
that.loop->ReplaceInput(1, exit); that->loop->ReplaceInput(1, exit);
this->loop->ReplaceInput(0, that.if_true); this->loop->ReplaceInput(0, that->if_true);
} }
}; };
@ -214,17 +214,17 @@ struct Counter {
Node* phi; Node* phi;
Node* add; Node* add;
Counter(While& w, // NOLINT(runtime/references) Counter(While* w, int32_t b, int32_t k)
int32_t b, int32_t k) : base(w->t.jsgraph.Int32Constant(b)),
: base(w.t.jsgraph.Int32Constant(b)), inc(w.t.jsgraph.Int32Constant(k)) { inc(w->t.jsgraph.Int32Constant(k)) {
Build(w); 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) { void Build(While* w) {
phi = w.t.graph.NewNode(w.t.op(2, false), base, base, w.loop); phi = w->t.graph.NewNode(w->t.op(2, false), base, base, w->loop);
add = w.t.graph.NewNode(&kIntAdd, phi, inc); add = w->t.graph.NewNode(&kIntAdd, phi, inc);
phi->ReplaceInput(1, add); phi->ReplaceInput(1, add);
} }
}; };
@ -236,16 +236,16 @@ struct StoreLoop {
Node* phi; Node* phi;
Node* store; Node* store;
explicit StoreLoop(While& w) // NOLINT(runtime/references) explicit StoreLoop(While* w)
: base(w.t.graph.start()), val(w.t.jsgraph.Int32Constant(13)) { : base(w->t.graph.start()), val(w->t.jsgraph.Int32Constant(13)) {
Build(w); 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) { void Build(While* w) {
phi = w.t.graph.NewNode(w.t.op(2, true), base, base, w.loop); phi = w->t.graph.NewNode(w->t.op(2, true), base, base, w->loop);
store = w.t.graph.NewNode(&kStore, val, phi, w.loop); store = w->t.graph.NewNode(&kStore, val, phi, w->loop);
phi->ReplaceInput(1, store); phi->ReplaceInput(1, store);
} }
}; };
@ -287,7 +287,7 @@ TEST(LaLoop1c) {
// One loop with a counter. // One loop with a counter.
LoopFinderTester t; LoopFinderTester t;
While w(t, t.p0); While w(t, t.p0);
Counter c(w, 0, 1); Counter c(&w, 0, 1);
t.Return(c.phi, t.start, w.exit); t.Return(c.phi, t.start, w.exit);
Node* chain[] = {w.loop}; Node* chain[] = {w.loop};
@ -303,7 +303,7 @@ TEST(LaLoop1e) {
// One loop with an effect phi. // One loop with an effect phi.
LoopFinderTester t; LoopFinderTester t;
While w(t, t.p0); While w(t, t.p0);
StoreLoop c(w); StoreLoop c(&w);
t.Return(t.p0, c.phi, w.exit); t.Return(t.p0, c.phi, w.exit);
Node* chain[] = {w.loop}; Node* chain[] = {w.loop};
@ -319,8 +319,8 @@ TEST(LaLoop1d) {
// One loop with two counters. // One loop with two counters.
LoopFinderTester t; LoopFinderTester t;
While w(t, t.p0); While w(t, t.p0);
Counter c1(w, 0, 1); Counter c1(&w, 0, 1);
Counter c2(w, 1, 1); Counter c2(&w, 1, 1);
t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w.exit); t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w.exit);
Node* chain[] = {w.loop}; Node* chain[] = {w.loop};
@ -365,8 +365,8 @@ TEST(LaLoop2c) {
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
While w2(t, t.p0); While w2(t, t.p0);
Counter c1(w1, 0, 1); Counter c1(&w1, 0, 1);
Counter c2(w2, 0, 1); Counter c2(&w2, 0, 1);
w2.chain(w1.exit); w2.chain(w1.exit);
t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w2.exit); t.Return(t.graph.NewNode(&kIntAdd, c1.phi, c2.phi), t.start, w2.exit);
@ -396,10 +396,10 @@ TEST(LaLoop2cc) {
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
While w2(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. // 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); if (i & 3) w2.branch->ReplaceInput(0, c1.phi);
w2.chain(w1.exit); w2.chain(w1.exit);
@ -431,7 +431,7 @@ TEST(LaNestedLoop1) {
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
While w2(t, t.p0); While w2(t, t.p0);
w2.nest(w1); w2.nest(&w1);
t.Return(t.p0, t.start, w1.exit); t.Return(t.p0, t.start, w1.exit);
Node* chain[] = {w1.loop, w2.loop}; Node* chain[] = {w1.loop, w2.loop};
@ -452,10 +452,10 @@ TEST(LaNestedLoop1c) {
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
While w2(t, t.p0); While w2(t, t.p0);
Counter c1(w1, 0, 1); Counter c1(&w1, 0, 1);
Counter c2(w2, 0, 1); Counter c2(&w2, 0, 1);
w2.branch->ReplaceInput(0, c2.phi); w2.branch->ReplaceInput(0, c2.phi);
w2.nest(w1); w2.nest(&w1);
t.Return(c1.phi, t.start, w1.exit); t.Return(c1.phi, t.start, w1.exit);
Node* chain[] = {w1.loop, w2.loop}; Node* chain[] = {w1.loop, w2.loop};
@ -477,7 +477,7 @@ TEST(LaNestedLoop1x) {
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
While w2(t, t.p0); While w2(t, t.p0);
w2.nest(w1); w2.nest(&w1);
const Operator* op = t.common.Phi(MachineRepresentation::kWord32, 2); const Operator* op = t.common.Phi(MachineRepresentation::kWord32, 2);
Node* p1a = t.graph.NewNode(op, t.p0, t.p0, w1.loop); Node* p1a = t.graph.NewNode(op, t.p0, t.p0, w1.loop);
@ -513,8 +513,8 @@ TEST(LaNestedLoop2) {
While w1(t, t.p0); While w1(t, t.p0);
While w2(t, t.p0); While w2(t, t.p0);
While w3(t, t.p0); While w3(t, t.p0);
w2.nest(w1); w2.nest(&w1);
w3.nest(w1); w3.nest(&w1);
w3.chain(w2.exit); w3.chain(w2.exit);
t.Return(t.p0, t.start, w1.exit); t.Return(t.p0, t.start, w1.exit);
@ -573,11 +573,11 @@ TEST(LaNestedLoop3c) {
// Three nested loops with counters. // Three nested loops with counters.
LoopFinderTester t; LoopFinderTester t;
While w1(t, t.p0); While w1(t, t.p0);
Counter c1(w1, 0, 1); Counter c1(&w1, 0, 1);
While w2(t, t.p0); While w2(t, t.p0);
Counter c2(w2, 0, 1); Counter c2(&w2, 0, 1);
While w3(t, t.p0); While w3(t, t.p0);
Counter c3(w3, 0, 1); Counter c3(&w3, 0, 1);
w2.loop->ReplaceInput(0, w1.if_true); w2.loop->ReplaceInput(0, w1.if_true);
w3.loop->ReplaceInput(0, w2.if_true); w3.loop->ReplaceInput(0, w2.if_true);
w2.loop->ReplaceInput(1, w3.exit); w2.loop->ReplaceInput(1, w3.exit);

View File

@ -43,81 +43,76 @@ CallDescriptor* CreateCallDescriptor(Zone* zone, int return_count,
return compiler::GetWasmCallDescriptor(zone, builder.Build()); return compiler::GetWasmCallDescriptor(zone, builder.Build());
} }
Node* MakeConstant(RawMachineAssembler& m, // NOLINT(runtime/references) Node* MakeConstant(RawMachineAssembler* m, MachineType type, int value) {
MachineType type, int value) {
switch (type.representation()) { switch (type.representation()) {
case MachineRepresentation::kWord32: case MachineRepresentation::kWord32:
return m.Int32Constant(static_cast<int32_t>(value)); return m->Int32Constant(static_cast<int32_t>(value));
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return m.Int64Constant(static_cast<int64_t>(value)); return m->Int64Constant(static_cast<int64_t>(value));
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
return m.Float32Constant(static_cast<float>(value)); return m->Float32Constant(static_cast<float>(value));
case MachineRepresentation::kFloat64: case MachineRepresentation::kFloat64:
return m.Float64Constant(static_cast<double>(value)); return m->Float64Constant(static_cast<double>(value));
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
Node* Add(RawMachineAssembler& m, // NOLINT(runtime/references) Node* Add(RawMachineAssembler* m, MachineType type, Node* a, Node* b) {
MachineType type, Node* a, Node* b) {
switch (type.representation()) { switch (type.representation()) {
case MachineRepresentation::kWord32: case MachineRepresentation::kWord32:
return m.Int32Add(a, b); return m->Int32Add(a, b);
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return m.Int64Add(a, b); return m->Int64Add(a, b);
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
return m.Float32Add(a, b); return m->Float32Add(a, b);
case MachineRepresentation::kFloat64: case MachineRepresentation::kFloat64:
return m.Float64Add(a, b); return m->Float64Add(a, b);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
Node* Sub(RawMachineAssembler& m, // NOLINT(runtime/references) Node* Sub(RawMachineAssembler* m, MachineType type, Node* a, Node* b) {
MachineType type, Node* a, Node* b) {
switch (type.representation()) { switch (type.representation()) {
case MachineRepresentation::kWord32: case MachineRepresentation::kWord32:
return m.Int32Sub(a, b); return m->Int32Sub(a, b);
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return m.Int64Sub(a, b); return m->Int64Sub(a, b);
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
return m.Float32Sub(a, b); return m->Float32Sub(a, b);
case MachineRepresentation::kFloat64: case MachineRepresentation::kFloat64:
return m.Float64Sub(a, b); return m->Float64Sub(a, b);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
Node* Mul(RawMachineAssembler& m, // NOLINT(runtime/references) Node* Mul(RawMachineAssembler* m, MachineType type, Node* a, Node* b) {
MachineType type, Node* a, Node* b) {
switch (type.representation()) { switch (type.representation()) {
case MachineRepresentation::kWord32: case MachineRepresentation::kWord32:
return m.Int32Mul(a, b); return m->Int32Mul(a, b);
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return m.Int64Mul(a, b); return m->Int64Mul(a, b);
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
return m.Float32Mul(a, b); return m->Float32Mul(a, b);
case MachineRepresentation::kFloat64: case MachineRepresentation::kFloat64:
return m.Float64Mul(a, b); return m->Float64Mul(a, b);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
Node* ToInt32(RawMachineAssembler& m, // NOLINT(runtime/references) Node* ToInt32(RawMachineAssembler* m, MachineType type, Node* a) {
MachineType type, Node* a) {
switch (type.representation()) { switch (type.representation()) {
case MachineRepresentation::kWord32: case MachineRepresentation::kWord32:
return a; return a;
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return m.TruncateInt64ToInt32(a); return m->TruncateInt64ToInt32(a);
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
return m.TruncateFloat32ToInt32(a); return m->TruncateFloat32ToInt32(a);
case MachineRepresentation::kFloat64: case MachineRepresentation::kFloat64:
return m.RoundFloat64ToInt32(a); return m->RoundFloat64ToInt32(a);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -159,9 +154,9 @@ void TestReturnMultipleValues(MachineType type) {
using Node_ptr = Node*; using Node_ptr = Node*;
std::unique_ptr<Node_ptr[]> returns(new Node_ptr[count]); std::unique_ptr<Node_ptr[]> returns(new Node_ptr[count]);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if (i % 3 == 0) returns[i] = Add(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 == 1) returns[i] = Sub(&m, type, p0, p1);
if (i % 3 == 2) returns[i] = Mul(m, type, p0, p1); if (i % 3 == 2) returns[i] = Mul(&m, type, p0, p1);
} }
m.Return(count, returns.get()); m.Return(count, returns.get());
@ -201,24 +196,24 @@ void TestReturnMultipleValues(MachineType type) {
// WasmContext dummy // WasmContext dummy
call_inputs[1] = mt.PointerConstant(nullptr); call_inputs[1] = mt.PointerConstant(nullptr);
// Special inputs for the test. // Special inputs for the test.
call_inputs[2] = MakeConstant(mt, type, a); call_inputs[2] = MakeConstant(&mt, type, a);
call_inputs[3] = MakeConstant(mt, type, b); call_inputs[3] = MakeConstant(&mt, type, b);
for (int i = 2; i < param_count; i++) { 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), Node* ret_multi = mt.AddNode(mt.common()->Call(desc),
input_count, call_inputs); input_count, call_inputs);
Node* ret = MakeConstant(mt, type, 0); Node* ret = MakeConstant(&mt, type, 0);
bool sign = false; bool sign = false;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
Node* x = (count == 1) Node* x = (count == 1)
? ret_multi ? ret_multi
: mt.AddNode(mt.common()->Projection(i), 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; if (i % 4 == 0) sign = !sign;
} }
mt.Return(ToInt32(mt, type, ret)); mt.Return(ToInt32(&mt, type, ret));
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
Handle<Code> code2 = mt.GetCode(); Handle<Code> code2 = mt.GetCode();
if (FLAG_print_code) { if (FLAG_print_code) {
@ -265,7 +260,7 @@ void ReturnLastValue(MachineType type) {
std::unique_ptr<Node* []> returns(new Node*[return_count]); std::unique_ptr<Node* []> returns(new Node*[return_count]);
for (int i = 0; i < return_count; ++i) { 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()); m.Return(return_count, returns.get());
@ -292,8 +287,9 @@ void ReturnLastValue(MachineType type) {
Node* call = mt.AddNode(mt.common()->Call(desc), 2, inputs); Node* call = mt.AddNode(mt.common()->Call(desc), 2, inputs);
mt.Return(ToInt32( mt.Return(
mt, type, mt.AddNode(mt.common()->Projection(return_count - 1), call))); ToInt32(&mt, type,
mt.AddNode(mt.common()->Projection(return_count - 1), call)));
CHECK_EQ(expect, mt.Call()); CHECK_EQ(expect, mt.Call());
} }
@ -327,7 +323,7 @@ void ReturnSumOfReturns(MachineType type) {
std::unique_ptr<Node* []> returns(new Node*[return_count]); std::unique_ptr<Node* []> returns(new Node*[return_count]);
for (int i = 0; i < return_count; ++i) { 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()); m.Return(return_count, returns.get());
@ -360,7 +356,7 @@ void ReturnSumOfReturns(MachineType type) {
expect += i; expect += i;
result = mt.Int32Add( result = mt.Int32Add(
result, result,
ToInt32(mt, type, mt.AddNode(mt.common()->Projection(i), call))); ToInt32(&mt, type, mt.AddNode(mt.common()->Projection(i), call)));
} }
mt.Return(result); mt.Return(result);

View File

@ -327,38 +327,32 @@ class ArgsBuffer {
return kTypes; return kTypes;
} }
Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* MakeConstant(RawMachineAssembler* raw, int32_t value) {
int32_t value) { return raw->Int32Constant(value);
return raw.Int32Constant(value);
} }
Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* MakeConstant(RawMachineAssembler* raw, int64_t value) {
int64_t value) { return raw->Int64Constant(value);
return raw.Int64Constant(value);
} }
Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* MakeConstant(RawMachineAssembler* raw, float32 value) {
float32 value) { return raw->Float32Constant(value);
return raw.Float32Constant(value);
} }
Node* MakeConstant(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* MakeConstant(RawMachineAssembler* raw, float64 value) {
float64 value) { return raw->Float64Constant(value);
return raw.Float64Constant(value);
} }
Node* LoadInput(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* LoadInput(RawMachineAssembler* raw, Node* base, int index) {
Node* base, int index) { Node* offset = raw->Int32Constant(index * sizeof(CType));
Node* offset = raw.Int32Constant(index * sizeof(CType)); return raw->Load(MachineTypeForC<CType>(), base, offset);
return raw.Load(MachineTypeForC<CType>(), base, offset);
} }
Node* StoreOutput(RawMachineAssembler& raw, // NOLINT(runtime/references) Node* StoreOutput(RawMachineAssembler* raw, Node* value) {
Node* value) { Node* base = raw->PointerConstant(&output);
Node* base = raw.PointerConstant(&output); Node* offset = raw->Int32Constant(0);
Node* offset = raw.Int32Constant(0); return raw->Store(MachineTypeForC<CType>().representation(), base, offset,
return raw.Store(MachineTypeForC<CType>().representation(), base, offset, value, kNoWriteBarrier);
value, kNoWriteBarrier);
} }
// Computes the next set of inputs by updating the {input} array. // Computes the next set of inputs by updating the {input} array.
@ -425,7 +419,7 @@ template <typename CType>
class Computer { class Computer {
public: public:
static void Run(CallDescriptor* desc, static void Run(CallDescriptor* desc,
void (*build)(CallDescriptor*, RawMachineAssembler&), void (*build)(CallDescriptor*, RawMachineAssembler*),
CType (*compute)(CallDescriptor*, CType* inputs), CType (*compute)(CallDescriptor*, CType* inputs),
int seed = 1) { int seed = 1) {
int num_params = ParamCount(desc); int num_params = ParamCount(desc);
@ -438,7 +432,7 @@ class Computer {
Zone zone(isolate->allocator(), ZONE_NAME); Zone zone(isolate->allocator(), ZONE_NAME);
Graph graph(&zone); Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc); RawMachineAssembler raw(isolate, &graph, desc);
build(desc, raw); build(desc, &raw);
inner = CompileGraph("Compute", desc, &graph, raw.ExportForTest()); inner = CompileGraph("Compute", desc, &graph, raw.ExportForTest());
} }
@ -459,11 +453,11 @@ class Computer {
int input_count = 0; int input_count = 0;
inputs[input_count++] = target; inputs[input_count++] = target;
for (int i = 0; i < num_params; i++) { 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* call = raw.CallN(desc, input_count, inputs);
Node* store = io.StoreOutput(raw, call); Node* store = io.StoreOutput(&raw, call);
USE(store); USE(store);
raw.Return(raw.Int32Constant(seed)); raw.Return(raw.Int32Constant(seed));
wrapper = CompileGraph("Compute-wrapper-const", cdesc, &graph, wrapper = CompileGraph("Compute-wrapper-const", cdesc, &graph,
@ -494,11 +488,11 @@ class Computer {
int input_count = 0; int input_count = 0;
inputs[input_count++] = target; inputs[input_count++] = target;
for (int i = 0; i < num_params; i++) { 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* call = raw.CallN(desc, input_count, inputs);
Node* store = io.StoreOutput(raw, call); Node* store = io.StoreOutput(&raw, call);
USE(store); USE(store);
raw.Return(raw.Int32Constant(seed)); raw.Return(raw.Int32Constant(seed));
wrapper = wrapper =
@ -704,28 +698,25 @@ TEST(Run_CopyTwentyInt32_all_allocatable_pairs) {
} }
} }
template <typename CType> template <typename CType>
static void Run_Computation( static void Run_Computation(
CallDescriptor* desc, void (*build)(CallDescriptor*, RawMachineAssembler&), CallDescriptor* desc, void (*build)(CallDescriptor*, RawMachineAssembler*),
CType (*compute)(CallDescriptor*, CType* inputs), int seed = 1) { CType (*compute)(CallDescriptor*, CType* inputs), int seed = 1) {
Computer<CType>::Run(desc, build, compute, seed); Computer<CType>::Run(desc, build, compute, seed);
} }
static uint32_t coeff[] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 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, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113}; 79, 83, 89, 97, 101, 103, 107, 109, 113};
static void Build_Int32_WeightedSum( static void Build_Int32_WeightedSum(CallDescriptor* desc,
CallDescriptor* desc, RawMachineAssembler* raw) {
RawMachineAssembler& raw) { // NOLINT(runtime/references) Node* result = raw->Int32Constant(0);
Node* result = raw.Int32Constant(0);
for (int i = 0; i < ParamCount(desc); i++) { for (int i = 0; i < ParamCount(desc); i++) {
Node* term = raw.Int32Mul(raw.Parameter(i), raw.Int32Constant(coeff[i])); Node* term = raw->Int32Mul(raw->Parameter(i), raw->Int32Constant(coeff[i]));
result = raw.Int32Add(result, term); result = raw->Int32Add(result, term);
} }
raw.Return(result); raw->Return(result);
} }
static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) { static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) {
@ -774,10 +765,8 @@ TEST_INT32_WEIGHTEDSUM(17)
TEST_INT32_WEIGHTEDSUM(19) TEST_INT32_WEIGHTEDSUM(19)
template <int which> template <int which>
static void Build_Select( static void Build_Select(CallDescriptor* desc, RawMachineAssembler* raw) {
CallDescriptor* desc, raw->Return(raw->Parameter(which));
RawMachineAssembler& raw) { // NOLINT(runtime/references)
raw.Return(raw.Parameter(which));
} }
template <typename CType, int which> template <typename CType, int which>
@ -950,9 +939,8 @@ TEST(Float64Select_stack_params_return_reg) {
} }
template <typename CType, int which> template <typename CType, int which>
static void Build_Select_With_Call( static void Build_Select_With_Call(CallDescriptor* desc,
CallDescriptor* desc, RawMachineAssembler* raw) {
RawMachineAssembler& raw) { // NOLINT(runtime/references)
Handle<Code> inner = Handle<Code>::null(); Handle<Code> inner = Handle<Code>::null();
int num_params = ParamCount(desc); int num_params = ParamCount(desc);
CHECK_LE(num_params, kMaxParamCount); 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. // Build a call to the function that does the select.
Node* target = raw.HeapConstant(inner); Node* target = raw->HeapConstant(inner);
Node** inputs = raw.zone()->NewArray<Node*>(num_params + 1); Node** inputs = raw->zone()->NewArray<Node*>(num_params + 1);
int input_count = 0; int input_count = 0;
inputs[input_count++] = target; inputs[input_count++] = target;
for (int i = 0; i < num_params; i++) { 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); Node* call = raw->CallN(desc, input_count, inputs);
raw.Return(call); raw->Return(call);
} }
} }

View File

@ -31,9 +31,8 @@ void CheckInvariantsOfAbortedPage(Page* page) {
CHECK(!page->IsFlagSet(Page::COMPACTION_WAS_ABORTED)); CHECK(!page->IsFlagSet(Page::COMPACTION_WAS_ABORTED));
} }
void CheckAllObjectsOnPage( void CheckAllObjectsOnPage(const std::vector<Handle<FixedArray>>& handles,
std::vector<Handle<FixedArray>>& handles, // NOLINT(runtime/references) Page* page) {
Page* page) {
for (Handle<FixedArray> fixed_array : handles) { for (Handle<FixedArray> fixed_array : handles) {
CHECK(Page::FromHeapObject(*fixed_array) == page); CHECK(Page::FromHeapObject(*fixed_array) == page);
} }

View File

@ -43,8 +43,7 @@ v8::Isolate* NewIsolateForPagePromotion(int min_semi_space_size = 8,
return isolate; return isolate;
} }
Page* FindLastPageInNewSpace( Page* FindLastPageInNewSpace(const std::vector<Handle<FixedArray>>& handles) {
std::vector<Handle<FixedArray>>& handles) { // NOLINT(runtime/references)
for (auto rit = handles.rbegin(); rit != handles.rend(); ++rit) { for (auto rit = handles.rbegin(); rit != handles.rend(); ++rit) {
// One deref gets the Handle, the second deref gets the FixedArray. // One deref gets the Handle, the second deref gets the FixedArray.
Page* candidate = Page::FromHeapObject(**rit); Page* candidate = Page::FromHeapObject(**rit);

View File

@ -132,24 +132,24 @@ BytecodeExpectationsPrinter::GetBytecodeArrayOfCallee(
} }
void BytecodeExpectationsPrinter::PrintEscapedString( void BytecodeExpectationsPrinter::PrintEscapedString(
std::ostream& stream, const std::string& string) const { std::ostream* stream, const std::string& string) const {
for (char c : string) { for (char c : string) {
switch (c) { switch (c) {
case '"': case '"':
stream << "\\\""; *stream << "\\\"";
break; break;
case '\\': case '\\':
stream << "\\\\"; *stream << "\\\\";
break; break;
default: default:
stream << c; *stream << c;
break; break;
} }
} }
} }
void BytecodeExpectationsPrinter::PrintBytecodeOperand( 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 { const Bytecode& bytecode, int op_index, int parameter_count) const {
OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index); OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index);
OperandSize op_size = Bytecodes::GetOperandSize( OperandSize op_size = Bytecodes::GetOperandSize(
@ -172,207 +172,207 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand(
if (Bytecodes::IsRegisterOperandType(op_type)) { if (Bytecodes::IsRegisterOperandType(op_type)) {
Register register_value = bytecode_iterator.GetRegisterOperand(op_index); Register register_value = bytecode_iterator.GetRegisterOperand(op_index);
stream << 'R'; *stream << 'R';
if (op_size != OperandSize::kByte) stream << size_tag; if (op_size != OperandSize::kByte) *stream << size_tag;
if (register_value.is_current_context()) { if (register_value.is_current_context()) {
stream << "(context)"; *stream << "(context)";
} else if (register_value.is_function_closure()) { } else if (register_value.is_function_closure()) {
stream << "(closure)"; *stream << "(closure)";
} else if (register_value.is_parameter()) { } else if (register_value.is_parameter()) {
int parameter_index = register_value.ToParameterIndex(parameter_count); int parameter_index = register_value.ToParameterIndex(parameter_count);
if (parameter_index == 0) { if (parameter_index == 0) {
stream << "(this)"; *stream << "(this)";
} else { } else {
stream << "(arg" << (parameter_index - 1) << ')'; *stream << "(arg" << (parameter_index - 1) << ')';
} }
} else { } else {
stream << '(' << register_value.index() << ')'; *stream << '(' << register_value.index() << ')';
} }
} else { } else {
switch (op_type) { switch (op_type) {
case OperandType::kFlag8: case OperandType::kFlag8:
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
stream << bytecode_iterator.GetFlagOperand(op_index); *stream << bytecode_iterator.GetFlagOperand(op_index);
break; break;
case OperandType::kIdx: { case OperandType::kIdx: {
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
stream << bytecode_iterator.GetIndexOperand(op_index); *stream << bytecode_iterator.GetIndexOperand(op_index);
break; break;
} }
case OperandType::kUImm: case OperandType::kUImm:
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
stream << bytecode_iterator.GetUnsignedImmediateOperand(op_index); *stream << bytecode_iterator.GetUnsignedImmediateOperand(op_index);
break; break;
case OperandType::kImm: case OperandType::kImm:
stream << 'I' << size_tag << '('; *stream << 'I' << size_tag << '(';
stream << bytecode_iterator.GetImmediateOperand(op_index); *stream << bytecode_iterator.GetImmediateOperand(op_index);
break; break;
case OperandType::kRegCount: case OperandType::kRegCount:
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
stream << bytecode_iterator.GetRegisterCountOperand(op_index); *stream << bytecode_iterator.GetRegisterCountOperand(op_index);
break; break;
case OperandType::kRuntimeId: { case OperandType::kRuntimeId: {
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
Runtime::FunctionId id = Runtime::FunctionId id =
bytecode_iterator.GetRuntimeIdOperand(op_index); bytecode_iterator.GetRuntimeIdOperand(op_index);
stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; *stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name;
break; break;
} }
case OperandType::kIntrinsicId: { case OperandType::kIntrinsicId: {
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
Runtime::FunctionId id = Runtime::FunctionId id =
bytecode_iterator.GetIntrinsicIdOperand(op_index); bytecode_iterator.GetIntrinsicIdOperand(op_index);
stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; *stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name;
break; break;
} }
case OperandType::kNativeContextIndex: { case OperandType::kNativeContextIndex: {
stream << 'U' << size_tag << '('; *stream << 'U' << size_tag << '(';
uint32_t idx = bytecode_iterator.GetNativeContextIndexOperand(op_index); uint32_t idx = bytecode_iterator.GetNativeContextIndexOperand(op_index);
stream << "%" << NameForNativeContextIntrinsicIndex(idx); *stream << "%" << NameForNativeContextIntrinsicIndex(idx);
break; break;
} }
default: default:
UNREACHABLE(); UNREACHABLE();
} }
stream << ')'; *stream << ')';
} }
} }
void BytecodeExpectationsPrinter::PrintBytecode( void BytecodeExpectationsPrinter::PrintBytecode(
std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, std::ostream* stream, const BytecodeArrayIterator& bytecode_iterator,
int parameter_count) const { int parameter_count) const {
Bytecode bytecode = bytecode_iterator.current_bytecode(); Bytecode bytecode = bytecode_iterator.current_bytecode();
OperandScale operand_scale = bytecode_iterator.current_operand_scale(); OperandScale operand_scale = bytecode_iterator.current_operand_scale();
if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale)) { if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale)) {
Bytecode prefix = Bytecodes::OperandScaleToPrefixBytecode(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); int operands_count = Bytecodes::NumberOfOperands(bytecode);
for (int op_index = 0; op_index < operands_count; ++op_index) { for (int op_index = 0; op_index < operands_count; ++op_index) {
stream << ", "; *stream << ", ";
PrintBytecodeOperand(stream, bytecode_iterator, bytecode, op_index, PrintBytecodeOperand(stream, bytecode_iterator, bytecode, op_index,
parameter_count); parameter_count);
} }
} }
void BytecodeExpectationsPrinter::PrintSourcePosition( void BytecodeExpectationsPrinter::PrintSourcePosition(
std::ostream& stream, SourcePositionTableIterator& source_iterator, std::ostream* stream, SourcePositionTableIterator* source_iterator,
int bytecode_offset) const { int bytecode_offset) const {
static const size_t kPositionWidth = 4; static const size_t kPositionWidth = 4;
if (!source_iterator.done() && if (!source_iterator->done() &&
source_iterator.code_offset() == bytecode_offset) { source_iterator->code_offset() == bytecode_offset) {
stream << "/* " << std::setw(kPositionWidth) *stream << "/* " << std::setw(kPositionWidth)
<< source_iterator.source_position().ScriptOffset(); << source_iterator->source_position().ScriptOffset();
if (source_iterator.is_statement()) { if (source_iterator->is_statement()) {
stream << " S> */ "; *stream << " S> */ ";
} else { } else {
stream << " E> */ "; *stream << " E> */ ";
} }
source_iterator.Advance(); source_iterator->Advance();
} else { } 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 { i::String string) const {
stream << '"'; *stream << '"';
for (int i = 0, length = string.length(); i < length; ++i) { 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( void BytecodeExpectationsPrinter::PrintConstant(
std::ostream& stream, i::Handle<i::Object> constant) const { std::ostream* stream, i::Handle<i::Object> constant) const {
if (constant->IsSmi()) { if (constant->IsSmi()) {
stream << "Smi ["; *stream << "Smi [";
i::Smi::cast(*constant).SmiPrint(stream); i::Smi::cast(*constant).SmiPrint(*stream);
stream << "]"; *stream << "]";
} else { } else {
stream << i::HeapObject::cast(*constant).map().instance_type(); *stream << i::HeapObject::cast(*constant).map().instance_type();
if (constant->IsHeapNumber()) { if (constant->IsHeapNumber()) {
stream << " ["; *stream << " [";
i::HeapNumber::cast(*constant).HeapNumberPrint(stream); i::HeapNumber::cast(*constant).HeapNumberPrint(*stream);
stream << "]"; *stream << "]";
} else if (constant->IsString()) { } else if (constant->IsString()) {
stream << " ["; *stream << " [";
PrintV8String(stream, i::String::cast(*constant)); PrintV8String(stream, i::String::cast(*constant));
stream << "]"; *stream << "]";
} }
} }
} }
void BytecodeExpectationsPrinter::PrintFrameSize( void BytecodeExpectationsPrinter::PrintFrameSize(
std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { std::ostream* stream, i::Handle<i::BytecodeArray> bytecode_array) const {
int32_t frame_size = bytecode_array->frame_size(); int32_t frame_size = bytecode_array->frame_size();
DCHECK(IsAligned(frame_size, kSystemPointerSize)); DCHECK(IsAligned(frame_size, kSystemPointerSize));
stream << "frame size: " << frame_size / kSystemPointerSize *stream << "frame size: " << frame_size / kSystemPointerSize
<< "\nparameter count: " << bytecode_array->parameter_count() << '\n'; << "\nparameter count: " << bytecode_array->parameter_count() << '\n';
} }
void BytecodeExpectationsPrinter::PrintBytecodeSequence( void BytecodeExpectationsPrinter::PrintBytecodeSequence(
std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { std::ostream* stream, i::Handle<i::BytecodeArray> bytecode_array) const {
stream << "bytecode array length: " << bytecode_array->length() *stream << "bytecode array length: " << bytecode_array->length()
<< "\nbytecodes: [\n"; << "\nbytecodes: [\n";
SourcePositionTableIterator source_iterator( SourcePositionTableIterator source_iterator(
bytecode_array->SourcePositionTable()); bytecode_array->SourcePositionTable());
BytecodeArrayIterator bytecode_iterator(bytecode_array); BytecodeArrayIterator bytecode_iterator(bytecode_array);
for (; !bytecode_iterator.done(); bytecode_iterator.Advance()) { for (; !bytecode_iterator.done(); bytecode_iterator.Advance()) {
stream << kIndent; *stream << kIndent;
PrintSourcePosition(stream, source_iterator, PrintSourcePosition(stream, &source_iterator,
bytecode_iterator.current_offset()); bytecode_iterator.current_offset());
PrintBytecode(stream, bytecode_iterator, bytecode_array->parameter_count()); PrintBytecode(stream, bytecode_iterator, bytecode_array->parameter_count());
stream << ",\n"; *stream << ",\n";
} }
stream << "]\n"; *stream << "]\n";
} }
void BytecodeExpectationsPrinter::PrintConstantPool( void BytecodeExpectationsPrinter::PrintConstantPool(
std::ostream& stream, i::FixedArray constant_pool) const { std::ostream* stream, i::FixedArray constant_pool) const {
stream << "constant pool: [\n"; *stream << "constant pool: [\n";
int num_constants = constant_pool.length(); int num_constants = constant_pool.length();
if (num_constants > 0) { if (num_constants > 0) {
for (int i = 0; i < num_constants; ++i) { for (int i = 0; i < num_constants; ++i) {
stream << kIndent; *stream << kIndent;
PrintConstant(stream, i::FixedArray::get(constant_pool, i, i_isolate())); PrintConstant(stream, i::FixedArray::get(constant_pool, i, i_isolate()));
stream << ",\n"; *stream << ",\n";
} }
} }
stream << "]\n"; *stream << "]\n";
} }
void BytecodeExpectationsPrinter::PrintCodeSnippet( void BytecodeExpectationsPrinter::PrintCodeSnippet(
std::ostream& stream, const std::string& body) const { std::ostream* stream, const std::string& body) const {
stream << "snippet: \"\n"; *stream << "snippet: \"\n";
std::stringstream body_stream(body); std::stringstream body_stream(body);
std::string body_line; std::string body_line;
while (std::getline(body_stream, body_line)) { while (std::getline(body_stream, body_line)) {
stream << kIndent; *stream << kIndent;
PrintEscapedString(stream, body_line); PrintEscapedString(stream, body_line);
stream << '\n'; *stream << '\n';
} }
stream << "\"\n"; *stream << "\"\n";
} }
void BytecodeExpectationsPrinter::PrintHandlers( void BytecodeExpectationsPrinter::PrintHandlers(
std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { std::ostream* stream, i::Handle<i::BytecodeArray> bytecode_array) const {
stream << "handlers: [\n"; *stream << "handlers: [\n";
HandlerTable table(*bytecode_array); HandlerTable table(*bytecode_array);
for (int i = 0, num_entries = table.NumberOfRangeEntries(); i < num_entries; for (int i = 0, num_entries = table.NumberOfRangeEntries(); i < num_entries;
++i) { ++i) {
stream << " [" << table.GetRangeStart(i) << ", " << table.GetRangeEnd(i) *stream << " [" << table.GetRangeStart(i) << ", " << table.GetRangeEnd(i)
<< ", " << table.GetRangeHandler(i) << "],\n"; << ", " << table.GetRangeHandler(i) << "],\n";
} }
stream << "]\n"; *stream << "]\n";
} }
void BytecodeExpectationsPrinter::PrintBytecodeArray( void BytecodeExpectationsPrinter::PrintBytecodeArray(
std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { std::ostream* stream, i::Handle<i::BytecodeArray> bytecode_array) const {
PrintFrameSize(stream, bytecode_array); PrintFrameSize(stream, bytecode_array);
PrintBytecodeSequence(stream, bytecode_array); PrintBytecodeSequence(stream, bytecode_array);
PrintConstantPool(stream, bytecode_array->constant_pool()); PrintConstantPool(stream, bytecode_array->constant_pool());
@ -380,7 +380,7 @@ void BytecodeExpectationsPrinter::PrintBytecodeArray(
} }
void BytecodeExpectationsPrinter::PrintExpectation( void BytecodeExpectationsPrinter::PrintExpectation(
std::ostream& stream, const std::string& snippet) const { std::ostream* stream, const std::string& snippet) const {
std::string source_code = std::string source_code =
wrap_ ? WrapCodeInFunction(test_function_name_.c_str(), snippet) wrap_ ? WrapCodeInFunction(test_function_name_.c_str(), snippet)
: snippet; : snippet;
@ -404,10 +404,10 @@ void BytecodeExpectationsPrinter::PrintExpectation(
} }
} }
stream << "---\n"; *stream << "---\n";
PrintCodeSnippet(stream, snippet); PrintCodeSnippet(stream, snippet);
PrintBytecodeArray(stream, bytecode_array); PrintBytecodeArray(stream, bytecode_array);
stream << '\n'; *stream << '\n';
} }
} // namespace interpreter } // namespace interpreter

View File

@ -36,8 +36,7 @@ class BytecodeExpectationsPrinter final {
oneshot_opt_(false), oneshot_opt_(false),
test_function_name_(kDefaultTopFunctionName) {} test_function_name_(kDefaultTopFunctionName) {}
void PrintExpectation(std::ostream& stream, // NOLINT void PrintExpectation(std::ostream* stream, const std::string& snippet) const;
const std::string& snippet) const;
void set_module(bool module) { module_ = module; } void set_module(bool module) { module_ = module; }
bool module() const { return module_; } bool module() const { return module_; }
@ -60,34 +59,30 @@ class BytecodeExpectationsPrinter final {
std::string test_function_name() const { return test_function_name_; } std::string test_function_name() const { return test_function_name_; }
private: private:
void PrintEscapedString(std::ostream& stream, // NOLINT void PrintEscapedString(std::ostream* stream,
const std::string& string) const; const std::string& string) const;
void PrintBytecodeOperand(std::ostream& stream, // NOLINT void PrintBytecodeOperand(std::ostream* stream,
const BytecodeArrayIterator& bytecode_iterator, const BytecodeArrayIterator& bytecode_iterator,
const Bytecode& bytecode, int op_index, const Bytecode& bytecode, int op_index,
int parameter_count) const; int parameter_count) const;
void PrintBytecode(std::ostream& stream, // NOLINT void PrintBytecode(std::ostream* stream,
const BytecodeArrayIterator& bytecode_iterator, const BytecodeArrayIterator& bytecode_iterator,
int parameter_count) const; int parameter_count) const;
void PrintSourcePosition(std::ostream& stream, // NOLINT void PrintSourcePosition(std::ostream* stream,
SourcePositionTableIterator& SourcePositionTableIterator* source_iterator,
source_iterator, // NOLINT(runtime/references)
int bytecode_offset) const; int bytecode_offset) const;
void PrintV8String(std::ostream& stream, // NOLINT void PrintV8String(std::ostream* stream, i::String string) const;
i::String string) const; void PrintConstant(std::ostream* stream, i::Handle<i::Object> constant) const;
void PrintConstant(std::ostream& stream, // NOLINT void PrintFrameSize(std::ostream* stream,
i::Handle<i::Object> constant) const;
void PrintFrameSize(std::ostream& stream, // NOLINT
i::Handle<i::BytecodeArray> bytecode_array) const; i::Handle<i::BytecodeArray> bytecode_array) const;
void PrintBytecodeSequence(std::ostream& stream, // NOLINT void PrintBytecodeSequence(std::ostream* stream,
i::Handle<i::BytecodeArray> bytecode_array) const; i::Handle<i::BytecodeArray> bytecode_array) const;
void PrintConstantPool(std::ostream& stream, // NOLINT void PrintConstantPool(std::ostream* stream,
i::FixedArray constant_pool) const; i::FixedArray constant_pool) const;
void PrintCodeSnippet(std::ostream& stream, // NOLINT void PrintCodeSnippet(std::ostream* stream, const std::string& body) const;
const std::string& body) const; void PrintBytecodeArray(std::ostream* stream,
void PrintBytecodeArray(std::ostream& stream, // NOLINT
i::Handle<i::BytecodeArray> bytecode_array) const; i::Handle<i::BytecodeArray> bytecode_array) const;
void PrintHandlers(std::ostream& stream, // NOLINT void PrintHandlers(std::ostream* stream,
i::Handle<i::BytecodeArray> bytecode_array) const; i::Handle<i::BytecodeArray> bytecode_array) const;
v8::Local<v8::String> V8StringFromUTF8(const char* data) const; v8::Local<v8::String> V8StringFromUTF8(const char* data) const;

View File

@ -50,8 +50,8 @@ class ProgramOptions final {
verbose_(false) {} verbose_(false) {}
bool Validate() const; bool Validate() const;
void UpdateFromHeader(std::istream& stream); // NOLINT void UpdateFromHeader(std::istream* stream);
void PrintHeader(std::ostream& stream) const; // NOLINT void PrintHeader(std::ostream* stream) const;
bool parsing_failed() const { return parsing_failed_; } bool parsing_failed() const { return parsing_failed_; }
bool print_help() const { return print_help_; } bool print_help() const { return print_help_; }
@ -291,17 +291,17 @@ bool ProgramOptions::Validate() const {
return true; return true;
} }
void ProgramOptions::UpdateFromHeader(std::istream& stream) { void ProgramOptions::UpdateFromHeader(std::istream* stream) {
std::string line; std::string line;
const char* kPrintCallee = "print callee: "; const char* kPrintCallee = "print callee: ";
const char* kOneshotOpt = "oneshot opt: "; const char* kOneshotOpt = "oneshot opt: ";
// Skip to the beginning of the options header // Skip to the beginning of the options header
while (std::getline(stream, line)) { while (std::getline(*stream, line)) {
if (line == "---") break; if (line == "---") break;
} }
while (std::getline(stream, line)) { while (std::getline(*stream, line)) {
if (line.compare(0, 8, "module: ") == 0) { if (line.compare(0, 8, "module: ") == 0) {
module_ = ParseBoolean(line.c_str() + 8); module_ = ParseBoolean(line.c_str() + 8);
} else if (line.compare(0, 6, "wrap: ") == 0) { } 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 void ProgramOptions::PrintHeader(std::ostream* stream) const {
stream << "---" *stream << "---"
<< "\nwrap: " << BooleanToString(wrap_); << "\nwrap: " << BooleanToString(wrap_);
if (!test_function_name_.empty()) { 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 (module_) *stream << "\nmodule: yes";
if (top_level_) stream << "\ntop level: yes"; if (top_level_) *stream << "\ntop level: yes";
if (print_callee_) stream << "\nprint callee: yes"; if (print_callee_) *stream << "\nprint callee: yes";
if (oneshot_opt_) stream << "\noneshot opt: yes"; if (oneshot_opt_) *stream << "\noneshot opt: yes";
if (async_iteration_) stream << "\nasync iteration: yes"; if (async_iteration_) *stream << "\nasync iteration: yes";
if (private_methods_) stream << "\nprivate methods: yes"; if (private_methods_) *stream << "\nprivate methods: yes";
stream << "\n\n"; *stream << "\n\n";
} }
V8InitializationScope::V8InitializationScope(const char* exec_path) V8InitializationScope::V8InitializationScope(const char* exec_path)
@ -370,17 +370,17 @@ V8InitializationScope::~V8InitializationScope() {
v8::V8::ShutdownPlatform(); v8::V8::ShutdownPlatform();
} }
std::string ReadRawJSSnippet(std::istream& stream) { // NOLINT std::string ReadRawJSSnippet(std::istream* stream) {
std::stringstream body_buffer; std::stringstream body_buffer;
CHECK(body_buffer << stream.rdbuf()); CHECK(body_buffer << stream->rdbuf());
return body_buffer.str(); 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; std::string line;
bool found_begin_snippet = false; bool found_begin_snippet = false;
string_out->clear(); string_out->clear();
while (std::getline(stream, line)) { while (std::getline(*stream, line)) {
if (line == "snippet: \"") { if (line == "snippet: \"") {
found_begin_snippet = true; found_begin_snippet = true;
continue; continue;
@ -420,8 +420,7 @@ std::string UnescapeString(const std::string& escaped_string) {
} }
void ExtractSnippets(std::vector<std::string>* snippet_list, void ExtractSnippets(std::vector<std::string>* snippet_list,
std::istream& body_stream, // NOLINT std::istream* body_stream, bool read_raw_js_snippet) {
bool read_raw_js_snippet) {
if (read_raw_js_snippet) { if (read_raw_js_snippet) {
snippet_list->push_back(ReadRawJSSnippet(body_stream)); snippet_list->push_back(ReadRawJSSnippet(body_stream));
} else { } else {
@ -432,7 +431,7 @@ void ExtractSnippets(std::vector<std::string>* snippet_list,
} }
} }
void GenerateExpectationsFile(std::ostream& stream, // NOLINT void GenerateExpectationsFile(std::ostream* stream,
const std::vector<std::string>& snippet_list, const std::vector<std::string>& snippet_list,
const V8InitializationScope& platform, const V8InitializationScope& platform,
const ProgramOptions& options) { const ProgramOptions& options) {
@ -453,7 +452,7 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT
if (options.private_methods()) i::FLAG_harmony_private_methods = true; 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); options.PrintHeader(stream);
for (const std::string& snippet : snippet_list) { for (const std::string& snippet : snippet_list) {
printer.PrintExpectation(stream, snippet); printer.PrintExpectation(stream, snippet);
@ -477,7 +476,7 @@ bool WriteExpectationsFile(const std::vector<std::string>& snippet_list,
std::ostream& output_stream = std::ostream& output_stream =
options.write_to_stdout() ? std::cout : output_file_handle; 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; return true;
} }
@ -487,7 +486,7 @@ std::string WriteExpectationsToString(
const V8InitializationScope& platform, const ProgramOptions& options) { const V8InitializationScope& platform, const ProgramOptions& options) {
std::stringstream output_string; std::stringstream output_string;
GenerateExpectationsFile(output_string, snippet_list, platform, options); GenerateExpectationsFile(&output_string, snippet_list, platform, options);
return output_string.str(); 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 // Rebaseline will never get here, so we will always take the
// GenerateExpectationsFile at the end of this function. // GenerateExpectationsFile at the end of this function.
DCHECK(!options.rebaseline() && !options.check_baseline()); 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 { } else {
bool check_failed = false; bool check_failed = false;
for (const std::string& input_filename : options.input_filenames()) { for (const std::string& input_filename : options.input_filenames()) {
@ -628,11 +627,11 @@ int main(int argc, char** argv) {
ProgramOptions updated_options = options; ProgramOptions updated_options = options;
if (options.baseline()) { if (options.baseline()) {
updated_options.UpdateFromHeader(input_stream); updated_options.UpdateFromHeader(&input_stream);
CHECK(updated_options.Validate()); CHECK(updated_options.Validate());
} }
ExtractSnippets(&snippet_list, input_stream, ExtractSnippets(&snippet_list, &input_stream,
options.read_raw_js_snippet()); options.read_raw_js_snippet());
input_stream.close(); input_stream.close();

View File

@ -95,10 +95,10 @@ class InitializedIgnitionHandleScope : public InitializedHandleScope {
} }
}; };
void SkipGoldenFileHeader(std::istream& stream) { // NOLINT void SkipGoldenFileHeader(std::istream* stream) {
std::string line; std::string line;
int separators_seen = 0; int separators_seen = 0;
while (std::getline(stream, line)) { while (std::getline(*stream, line)) {
if (line == "---") separators_seen += 1; if (line == "---") separators_seen += 1;
if (separators_seen == 2) return; if (separators_seen == 2) return;
} }
@ -107,7 +107,7 @@ void SkipGoldenFileHeader(std::istream& stream) { // NOLINT
std::string LoadGolden(const std::string& golden_filename) { std::string LoadGolden(const std::string& golden_filename) {
std::ifstream expected_file((kGoldenFileDirectory + golden_filename).c_str()); std::ifstream expected_file((kGoldenFileDirectory + golden_filename).c_str());
CHECK(expected_file.is_open()); CHECK(expected_file.is_open());
SkipGoldenFileHeader(expected_file); SkipGoldenFileHeader(&expected_file);
std::ostringstream expected_stream; std::ostringstream expected_stream;
// Restore the first separator, which was consumed by SkipGoldenFileHeader // Restore the first separator, which was consumed by SkipGoldenFileHeader
expected_stream << "---\n" << expected_file.rdbuf(); expected_stream << "---\n" << expected_file.rdbuf();
@ -125,31 +125,30 @@ std::string BuildActual(const BytecodeExpectationsPrinter& printer,
if (prologue) source_code += prologue; if (prologue) source_code += prologue;
source_code += snippet; source_code += snippet;
if (epilogue) source_code += epilogue; if (epilogue) source_code += epilogue;
printer.PrintExpectation(actual_stream, source_code); printer.PrintExpectation(&actual_stream, source_code);
} }
return actual_stream.str(); return actual_stream.str();
} }
// inplace left trim // inplace left trim
static inline void ltrim(std::string& str) { // NOLINT(runtime/references) static inline void ltrim(std::string* str) {
str.erase(str.begin(), str->erase(str->begin(),
std::find_if(str.begin(), str.end(), std::find_if(str->begin(), str->end(),
[](unsigned char ch) { return !std::isspace(ch); })); [](unsigned char ch) { return !std::isspace(ch); }));
} }
// inplace right trim // inplace right trim
static inline void rtrim(std::string& str) { // NOLINT(runtime/references) static inline void rtrim(std::string* str) {
str.erase(std::find_if(str.rbegin(), str.rend(), str->erase(std::find_if(str->rbegin(), str->rend(),
[](unsigned char ch) { return !std::isspace(ch); }) [](unsigned char ch) { return !std::isspace(ch); })
.base(), .base(),
str.end()); str->end());
} }
static inline std::string trim( static inline std::string trim(std::string* str) {
std::string& str) { // NOLINT(runtime/references)
ltrim(str); ltrim(str);
rtrim(str); rtrim(str);
return str; return *str;
} }
bool CompareTexts(const std::string& generated, const std::string& expected) { 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; 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 << "Inputs differ at line " << line_number << "\n";
std::cerr << " Generated: '" << generated_line << "'\n"; std::cerr << " Generated: '" << generated_line << "'\n";
std::cerr << " Expected: '" << expected_line << "'\n"; std::cerr << " Expected: '" << expected_line << "'\n";

View File

@ -1485,19 +1485,20 @@ TEST(InterpreterCall) {
} }
} }
static BytecodeArrayBuilder& SetRegister( static BytecodeArrayBuilder& SetRegister(BytecodeArrayBuilder* builder,
BytecodeArrayBuilder& builder, // NOLINT(runtime/references) Register reg, int value,
Register reg, int value, Register scratch) { Register scratch) {
return builder.StoreAccumulatorInRegister(scratch) return builder->StoreAccumulatorInRegister(scratch)
.LoadLiteral(Smi::FromInt(value)) .LoadLiteral(Smi::FromInt(value))
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadAccumulatorWithRegister(scratch); .LoadAccumulatorWithRegister(scratch);
} }
static BytecodeArrayBuilder& IncrementRegister( static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder* builder,
BytecodeArrayBuilder& builder, // NOLINT(runtime/references) Register reg, int value,
Register reg, int value, Register scratch, int slot_index) { Register scratch,
return builder.StoreAccumulatorInRegister(scratch) int slot_index) {
return builder->StoreAccumulatorInRegister(scratch)
.LoadLiteral(Smi::FromInt(value)) .LoadLiteral(Smi::FromInt(value))
.BinaryOperation(Token::Value::ADD, reg, slot_index) .BinaryOperation(Token::Value::ADD, reg, slot_index)
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
@ -1525,13 +1526,13 @@ TEST(InterpreterJumps) {
builder.LoadLiteral(Smi::zero()) builder.LoadLiteral(Smi::zero())
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.Jump(&label[0]); .Jump(&label[0]);
SetRegister(builder, reg, 1024, scratch).Bind(&loop_header); SetRegister(&builder, reg, 1024, scratch).Bind(&loop_header);
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot)).Jump(&label[1]); IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot)).Jump(&label[1]);
SetRegister(builder, reg, 2048, scratch).Bind(&label[0]); SetRegister(&builder, reg, 2048, scratch).Bind(&label[0]);
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot1)) IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot1))
.JumpLoop(&loop_header, 0); .JumpLoop(&loop_header, 0);
SetRegister(builder, reg, 4096, scratch).Bind(&label[1]); SetRegister(&builder, reg, 4096, scratch).Bind(&label[1]);
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot2)) IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot2))
.LoadAccumulatorWithRegister(reg) .LoadAccumulatorWithRegister(reg)
.Return(); .Return();
@ -1566,19 +1567,19 @@ TEST(InterpreterConditionalJumps) {
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadFalse() .LoadFalse()
.JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]); .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]);
IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot)) IncrementRegister(&builder, reg, 1024, scratch, GetIndex(slot))
.Bind(&label[0]) .Bind(&label[0])
.LoadTrue() .LoadTrue()
.JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done); .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done);
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1)) IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot1))
.LoadTrue() .LoadTrue()
.JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]); .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]);
IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2)) IncrementRegister(&builder, reg, 2048, scratch, GetIndex(slot2))
.Bind(&label[1]); .Bind(&label[1]);
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3)) IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot3))
.LoadFalse() .LoadFalse()
.JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1); .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1);
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4)) IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot4))
.LoadAccumulatorWithRegister(reg) .LoadAccumulatorWithRegister(reg)
.Bind(&done) .Bind(&done)
.Bind(&done1) .Bind(&done1)
@ -1616,19 +1617,19 @@ TEST(InterpreterConditionalJumps2) {
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadFalse() .LoadFalse()
.JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]); .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &label[0]);
IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot)) IncrementRegister(&builder, reg, 1024, scratch, GetIndex(slot))
.Bind(&label[0]) .Bind(&label[0])
.LoadTrue() .LoadTrue()
.JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done); .JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &done);
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1)) IncrementRegister(&builder, reg, 1, scratch, GetIndex(slot1))
.LoadTrue() .LoadTrue()
.JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]); .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &label[1]);
IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2)) IncrementRegister(&builder, reg, 2048, scratch, GetIndex(slot2))
.Bind(&label[1]); .Bind(&label[1]);
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3)) IncrementRegister(&builder, reg, 2, scratch, GetIndex(slot3))
.LoadFalse() .LoadFalse()
.JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1); .JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &done1);
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4)) IncrementRegister(&builder, reg, 4, scratch, GetIndex(slot4))
.LoadAccumulatorWithRegister(reg) .LoadAccumulatorWithRegister(reg)
.Bind(&done) .Bind(&done)
.Bind(&done1) .Bind(&done1)

View File

@ -3391,7 +3391,9 @@ TEST(ARMv8_vminmax_f32) {
template <typename T, typename Inputs, typename Results> template <typename T, typename Inputs, typename Results>
static GeneratedCode<F_ppiii> GenerateMacroFloatMinMax( static GeneratedCode<F_ppiii> GenerateMacroFloatMinMax(
MacroAssembler& assm) { // NOLINT(runtime/references) MacroAssembler* assm_ptr) {
MacroAssembler& assm = *assm_ptr;
T a = T::from_code(0); // d0/s0 T a = T::from_code(0); // d0/s0
T b = T::from_code(1); // d1/s1 T b = T::from_code(1); // d1/s1
T c = T::from_code(2); // d2/s2 T c = T::from_code(2); // d2/s2
@ -3509,7 +3511,7 @@ TEST(macro_float_minmax_f64) {
double max_aba_; double max_aba_;
}; };
auto f = GenerateMacroFloatMinMax<DwVfpRegister, Inputs, Results>(assm); auto f = GenerateMacroFloatMinMax<DwVfpRegister, Inputs, Results>(&assm);
#define CHECK_MINMAX(left, right, min, max) \ #define CHECK_MINMAX(left, right, min, max) \
do { \ do { \
@ -3574,7 +3576,7 @@ TEST(macro_float_minmax_f32) {
float max_aba_; float max_aba_;
}; };
auto f = GenerateMacroFloatMinMax<SwVfpRegister, Inputs, Results>(assm); auto f = GenerateMacroFloatMinMax<SwVfpRegister, Inputs, Results>(&assm);
#define CHECK_MINMAX(left, right, min, max) \ #define CHECK_MINMAX(left, right, min, max) \
do { \ do { \

View File

@ -4825,9 +4825,10 @@ TEST(r6_beqzc) {
} }
} }
void load_elements_of_vector( void load_elements_of_vector(MacroAssembler* assm_ptr,
MacroAssembler& assm, // NOLINT(runtime/references) const uint64_t elements[], MSARegister w,
const uint64_t elements[], MSARegister w, Register t0, Register t1) { Register t0, Register t1) {
MacroAssembler& assm = *assm_ptr;
__ li(t0, static_cast<uint32_t>(elements[0] & 0xFFFFFFFF)); __ li(t0, static_cast<uint32_t>(elements[0] & 0xFFFFFFFF));
__ li(t1, static_cast<uint32_t>((elements[0] >> 32) & 0xFFFFFFFF)); __ li(t1, static_cast<uint32_t>((elements[0] >> 32) & 0xFFFFFFFF));
__ insert_w(w, 0, t0); __ insert_w(w, 0, t0);
@ -4838,9 +4839,9 @@ void load_elements_of_vector(
__ insert_w(w, 3, t1); __ insert_w(w, 3, t1);
} }
inline void store_elements_of_vector( inline void store_elements_of_vector(MacroAssembler* assm_ptr, MSARegister w,
MacroAssembler& assm, // NOLINT(runtime/references) Register a) {
MSARegister w, Register a) { MacroAssembler& assm = *assm_ptr;
__ st_d(w, MemOperand(a, 0)); __ st_d(w, MemOperand(a, 0));
} }
@ -4876,15 +4877,15 @@ void run_bz_bnz(TestCaseMsaBranch* input, Branch GenerateBranch,
msa_reg_t res; msa_reg_t res;
Label do_not_move_w0_to_w2; Label do_not_move_w0_to_w2;
load_elements_of_vector(assm, &t.ws_lo, w0, 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, &t.wd_lo, w2, t0, t1);
load_elements_of_vector(assm, &input->wt_lo, w1, t0, t1); load_elements_of_vector(&assm, &input->wt_lo, w1, t0, t1);
GenerateBranch(assm, do_not_move_w0_to_w2); GenerateBranch(assm, do_not_move_w0_to_w2);
__ nop(); __ nop();
__ move_v(w2, w0); __ move_v(w2, w0);
__ bind(&do_not_move_w0_to_w2); __ bind(&do_not_move_w0_to_w2);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -5841,7 +5842,7 @@ void run_msa_insert(int32_t rs_value, int n, msa_reg_t* w) {
UNREACHABLE(); UNREACHABLE();
} }
store_elements_of_vector(assm, w0, a0); store_elements_of_vector(&assm, w0, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -5937,10 +5938,10 @@ TEST(MSA_move_v) {
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
load_elements_of_vector(assm, &t[i].ws_lo, w0, 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); load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1);
__ move_v(w2, w0); __ move_v(w2, w0);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -5981,10 +5982,10 @@ void run_msa_sldi(OperFunc GenerateOperation,
for (unsigned i = 0; i < arraysize(t); ++i) { for (unsigned i = 0; i < arraysize(t); ++i) {
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
load_elements_of_vector(assm, &t[i].ws_lo, w0, 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); load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1);
GenerateOperation(assm); GenerateOperation(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6175,7 +6176,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi,
UNREACHABLE(); UNREACHABLE();
} }
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6460,11 +6461,11 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext,
int32_t i5 = int32_t i5 =
i5_sign_ext ? static_cast<int32_t>(input->i5 << 27) >> 27 : input->i5; i5_sign_ext ? static_cast<int32_t>(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); GenerateI5InstructionFunc(assm, i5);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6880,10 +6881,10 @@ void run_msa_2r(const struct TestCaseMsa2R* input,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, reinterpret_cast<const uint64_t*>(input), w0, load_elements_of_vector(&assm, reinterpret_cast<const uint64_t*>(input), w0,
t0, t1); t0, t1);
Generate2RInstructionFunc(assm); Generate2RInstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -7926,13 +7927,13 @@ void run_msa_vector(struct TestCaseMsaVector* input,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->ws_lo), w0, 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->wt_lo), w2, t0, t1);
load_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); load_elements_of_vector(&assm, &(input->wd_lo), w4, t0, t1);
GenerateVectorInstructionFunc(assm); GenerateVectorInstructionFunc(assm);
store_elements_of_vector(assm, w4, a0); store_elements_of_vector(&assm, w4, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -8014,12 +8015,12 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); 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->wd_lo), w2, t0, t1);
GenerateInstructionFunc(assm, input->m); GenerateInstructionFunc(assm, input->m);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -8491,7 +8492,7 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc,
GenerateVectorInstructionFunc(assm, input); GenerateVectorInstructionFunc(assm, input);
store_elements_of_vector(assm, w0, a0); store_elements_of_vector(&assm, w0, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -8640,13 +8641,13 @@ void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->wt_lo), w0, 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->ws_lo), w1, t0, t1);
load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1);
GenerateI5InstructionFunc(assm); GenerateI5InstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -9645,13 +9646,13 @@ void run_msa_3rf(const struct TestCaseMsa3RF* input,
msa_reg_t res; msa_reg_t res;
load_elements_of_vector( load_elements_of_vector(
assm, reinterpret_cast<const uint64_t*>(&input->ws_lo), w0, t0, t1); &assm, reinterpret_cast<const uint64_t*>(&input->ws_lo), w0, t0, t1);
load_elements_of_vector( load_elements_of_vector(
assm, reinterpret_cast<const uint64_t*>(&input->wt_lo), w1, t0, t1); &assm, reinterpret_cast<const uint64_t*>(&input->wt_lo), w1, t0, t1);
load_elements_of_vector( load_elements_of_vector(
assm, reinterpret_cast<const uint64_t*>(&input->wd_lo), w2, t0, t1); &assm, reinterpret_cast<const uint64_t*>(&input->wd_lo), w2, t0, t1);
Generate2RInstructionFunc(assm); Generate2RInstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();

View File

@ -5430,9 +5430,10 @@ TEST(r6_beqzc) {
} }
} }
void load_elements_of_vector( void load_elements_of_vector(MacroAssembler* assm_ptr,
MacroAssembler& assm, // NOLINT(runtime/references) const uint64_t elements[], MSARegister w,
const uint64_t elements[], MSARegister w, Register t0, Register t1) { Register t0, Register t1) {
MacroAssembler& assm = *assm_ptr;
__ li(t0, static_cast<uint32_t>(elements[0] & 0xFFFFFFFF)); __ li(t0, static_cast<uint32_t>(elements[0] & 0xFFFFFFFF));
__ li(t1, static_cast<uint32_t>((elements[0] >> 32) & 0xFFFFFFFF)); __ li(t1, static_cast<uint32_t>((elements[0] >> 32) & 0xFFFFFFFF));
__ insert_w(w, 0, t0); __ insert_w(w, 0, t0);
@ -5443,9 +5444,9 @@ void load_elements_of_vector(
__ insert_w(w, 3, t1); __ insert_w(w, 3, t1);
} }
inline void store_elements_of_vector( inline void store_elements_of_vector(MacroAssembler* assm_ptr, MSARegister w,
MacroAssembler& assm, // NOLINT(runtime/references) Register a) {
MSARegister w, Register a) { MacroAssembler& assm = *assm_ptr;
__ st_d(w, MemOperand(a, 0)); __ st_d(w, MemOperand(a, 0));
} }
@ -5481,15 +5482,15 @@ void run_bz_bnz(TestCaseMsaBranch* input, Branch GenerateBranch,
msa_reg_t res; msa_reg_t res;
Label do_not_move_w0_to_w2; Label do_not_move_w0_to_w2;
load_elements_of_vector(assm, &t.ws_lo, w0, 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, &t.wd_lo, w2, t0, t1);
load_elements_of_vector(assm, &input->wt_lo, w1, t0, t1); load_elements_of_vector(&assm, &input->wt_lo, w1, t0, t1);
GenerateBranch(assm, do_not_move_w0_to_w2); GenerateBranch(assm, do_not_move_w0_to_w2);
__ nop(); __ nop();
__ move_v(w2, w0); __ move_v(w2, w0);
__ bind(&do_not_move_w0_to_w2); __ bind(&do_not_move_w0_to_w2);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6799,7 +6800,7 @@ void run_msa_insert(int64_t rs_value, int n, msa_reg_t* w) {
UNREACHABLE(); UNREACHABLE();
} }
store_elements_of_vector(assm, w0, a0); store_elements_of_vector(&assm, w0, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6953,10 +6954,10 @@ TEST(MSA_move_v) {
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
load_elements_of_vector(assm, &t[i].ws_lo, w0, 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); load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1);
__ move_v(w2, w0); __ move_v(w2, w0);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -6997,10 +6998,10 @@ void run_msa_sldi(OperFunc GenerateOperation,
for (unsigned i = 0; i < arraysize(t); ++i) { for (unsigned i = 0; i < arraysize(t); ++i) {
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes); MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
load_elements_of_vector(assm, &t[i].ws_lo, w0, 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); load_elements_of_vector(&assm, &t[i].wd_lo, w2, t0, t1);
GenerateOperation(assm); GenerateOperation(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -7157,7 +7158,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi,
UNREACHABLE(); UNREACHABLE();
} }
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -7358,11 +7359,11 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext,
int32_t i5 = int32_t i5 =
i5_sign_ext ? static_cast<int32_t>(input->i5 << 27) >> 27 : input->i5; i5_sign_ext ? static_cast<int32_t>(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); GenerateI5InstructionFunc(assm, i5);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -7784,10 +7785,10 @@ void run_msa_2r(const struct TestCaseMsa2R* input,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, reinterpret_cast<const uint64_t*>(input), w0, load_elements_of_vector(&assm, reinterpret_cast<const uint64_t*>(input), w0,
t0, t1); t0, t1);
Generate2RInstructionFunc(assm); Generate2RInstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -8830,13 +8831,13 @@ void run_msa_vector(struct TestCaseMsaVector* input,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->ws_lo), w0, 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->wt_lo), w2, t0, t1);
load_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); load_elements_of_vector(&assm, &(input->wd_lo), w4, t0, t1);
GenerateVectorInstructionFunc(assm); GenerateVectorInstructionFunc(assm);
store_elements_of_vector(assm, w4, a0); store_elements_of_vector(&assm, w4, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -8918,12 +8919,12 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); 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->wd_lo), w2, t0, t1);
GenerateInstructionFunc(assm, input->m); GenerateInstructionFunc(assm, input->m);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -9395,7 +9396,7 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc,
GenerateVectorInstructionFunc(assm, input); GenerateVectorInstructionFunc(assm, input);
store_elements_of_vector(assm, w0, a0); store_elements_of_vector(&assm, w0, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -9544,13 +9545,13 @@ void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc,
CpuFeatureScope fscope(&assm, MIPS_SIMD); CpuFeatureScope fscope(&assm, MIPS_SIMD);
msa_reg_t res; msa_reg_t res;
load_elements_of_vector(assm, &(input->wt_lo), w0, 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->ws_lo), w1, t0, t1);
load_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); load_elements_of_vector(&assm, &(input->wd_lo), w2, t0, t1);
GenerateI5InstructionFunc(assm); GenerateI5InstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();
@ -10554,7 +10555,7 @@ void run_msa_3rf(const struct TestCaseMsa3RF* input,
load_elements_of_vector( load_elements_of_vector(
assm, reinterpret_cast<const uint64_t*>(&input->wd_lo), w2, t0, t1); assm, reinterpret_cast<const uint64_t*>(&input->wd_lo), w2, t0, t1);
Generate2RInstructionFunc(assm); Generate2RInstructionFunc(assm);
store_elements_of_vector(assm, w2, a0); store_elements_of_vector(&assm, w2, a0);
__ jr(ra); __ jr(ra);
__ nop(); __ nop();

View File

@ -1438,8 +1438,7 @@ struct CheckNormalize {
// //
template <typename TestConfig, typename Checker> template <typename TestConfig, typename Checker>
static void TestReconfigureProperty_CustomPropertyAfterTargetMap( static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
TestConfig& config, // NOLINT(runtime/references) TestConfig* config, Checker* checker) {
Checker& checker) { // NOLINT(runtime/references)
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
@ -1471,7 +1470,7 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
map1 = expectations1.AddDataField(map1, NONE, constness, representation, map1 = expectations1.AddDataField(map1, NONE, constness, representation,
any_type); any_type);
} }
map1 = config.AddPropertyAtBranch(1, expectations1, map1); map1 = config->AddPropertyAtBranch(1, &expectations1, map1);
for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { for (int i = kCustomPropIndex + 1; i < kPropCount; i++) {
map1 = expectations1.AddDataField(map1, NONE, constness, representation, map1 = expectations1.AddDataField(map1, NONE, constness, representation,
any_type); any_type);
@ -1491,7 +1490,7 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
map2 = expectations2.AddDataField(map2, NONE, constness, representation, map2 = expectations2.AddDataField(map2, NONE, constness, representation,
any_type); any_type);
} }
map2 = config.AddPropertyAtBranch(2, expectations2, map2); map2 = config->AddPropertyAtBranch(2, &expectations2, map2);
for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { for (int i = kCustomPropIndex + 1; i < kPropCount; i++) {
map2 = expectations2.AddDataField(map2, NONE, constness, representation, map2 = expectations2.AddDataField(map2, NONE, constness, representation,
any_type); any_type);
@ -1512,8 +1511,8 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
CHECK_NE(*map2, *new_map); CHECK_NE(*map2, *new_map);
CHECK(expectations2.Check(*map2)); CHECK(expectations2.Check(*map2));
config.UpdateExpectations(kCustomPropIndex, expectations1); config->UpdateExpectations(kCustomPropIndex, &expectations1);
checker.Check(isolate, map1, new_map, expectations1); checker->Check(isolate, map1, new_map, expectations1);
} }
TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) {
@ -1528,18 +1527,14 @@ TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) {
js_func_ = factory->NewFunctionForTest(factory->empty_string()); js_func_ = factory->NewFunctionForTest(factory->empty_string());
} }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
// Add the same data constant property at both transition tree branches. // 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( void UpdateExpectations(int property_index, Expectations* expectations) {
int property_index,
Expectations& expectations) { // NOLINT(runtime/references)
// Expectations stay the same. // Expectations stay the same.
} }
}; };
@ -1547,7 +1542,7 @@ TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) {
TestConfig config; TestConfig config;
// Two branches are "compatible" so the |map1| should NOT be deprecated. // Two branches are "compatible" so the |map1| should NOT be deprecated.
CheckSameMap checker; 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()); factory->NewFunction(sloppy_map, info, isolate->native_context());
} }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; Handle<JSFunction> 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( void UpdateExpectations(int property_index, Expectations* expectations) {
int property_index, expectations->SetDataField(property_index, PropertyConstness::kConst,
Expectations& expectations) { // NOLINT(runtime/references) Representation::HeapObject(), function_type_);
expectations.SetDataField(property_index, PropertyConstness::kConst,
Representation::HeapObject(), function_type_);
} }
}; };
TestConfig config; TestConfig config;
CheckSameMap checker; CheckSameMap checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} }
@ -1614,28 +1605,23 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) {
pair_ = CreateAccessorPair(true, true); pair_ = CreateAccessorPair(true, true);
} }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
if (branch_id == 1) { if (branch_id == 1) {
return expectations.AddDataConstant(map, NONE, js_func_); return expectations->AddDataConstant(map, NONE, js_func_);
} else { } else {
return expectations.AddAccessorConstant(map, NONE, pair_); return expectations->AddAccessorConstant(map, NONE, pair_);
} }
} }
void UpdateExpectations( void UpdateExpectations(int property_index, Expectations* expectations) {}
int property_index,
Expectations& expectations // NOLINT(runtime/references)
) {}
}; };
TestConfig config; TestConfig config;
// These are completely separate branches in transition tree. // These are completely separate branches in transition tree.
CheckUnrelated checker; CheckUnrelated checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} }
@ -1647,26 +1633,22 @@ TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) {
Handle<AccessorPair> pair_; Handle<AccessorPair> pair_;
TestConfig() { pair_ = CreateAccessorPair(true, true); } TestConfig() { pair_ = CreateAccessorPair(true, true); }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
// Add the same accessor constant property at both transition tree // Add the same accessor constant property at both transition tree
// branches. // branches.
return expectations.AddAccessorConstant(map, NONE, pair_); return expectations->AddAccessorConstant(map, NONE, pair_);
} }
void UpdateExpectations( void UpdateExpectations(int property_index, Expectations* expectations) {
int property_index,
Expectations& expectations) { // NOLINT(runtime/references)
// Two branches are "compatible" so the |map1| should NOT be deprecated. // Two branches are "compatible" so the |map1| should NOT be deprecated.
} }
}; };
TestConfig config; TestConfig config;
CheckSameMap checker; CheckSameMap checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} }
@ -1682,24 +1664,20 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) {
pair2_ = CreateAccessorPair(true, true); pair2_ = CreateAccessorPair(true, true);
} }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
Handle<AccessorPair> pair = branch_id == 1 ? pair1_ : pair2_; Handle<AccessorPair> pair = branch_id == 1 ? pair1_ : pair2_;
return expectations.AddAccessorConstant(map, NONE, pair); return expectations->AddAccessorConstant(map, NONE, pair);
} }
void UpdateExpectations( void UpdateExpectations(int property_index, Expectations* expectations) {
int property_index,
Expectations& expectations) { // NOLINT(runtime/references)
if (IS_ACCESSOR_FIELD_SUPPORTED) { if (IS_ACCESSOR_FIELD_SUPPORTED) {
expectations.SetAccessorField(property_index); expectations->SetAccessorField(property_index);
} else { } else {
// Currently we have a normalize case and ACCESSOR property becomes // Currently we have a normalize case and ACCESSOR property becomes
// ACCESSOR_CONSTANT. // ACCESSOR_CONSTANT.
expectations.SetAccessorConstant(property_index, pair2_); expectations->SetAccessorConstant(property_index, pair2_);
} }
} }
}; };
@ -1707,11 +1685,11 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) {
TestConfig config; TestConfig config;
if (IS_ACCESSOR_FIELD_SUPPORTED) { if (IS_ACCESSOR_FIELD_SUPPORTED) {
CheckSameMap checker; CheckSameMap checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} else { } else {
// Currently we have a normalize case. // Currently we have a normalize case.
CheckNormalize checker; CheckNormalize checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} }
} }
@ -1724,31 +1702,26 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) {
Handle<AccessorPair> pair_; Handle<AccessorPair> pair_;
TestConfig() { pair_ = CreateAccessorPair(true, true); } TestConfig() { pair_ = CreateAccessorPair(true, true); }
Handle<Map> AddPropertyAtBranch( Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
int branch_id, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references)
Handle<Map> map) {
CHECK(branch_id == 1 || branch_id == 2); CHECK(branch_id == 1 || branch_id == 2);
if (branch_id == 1) { if (branch_id == 1) {
return expectations.AddAccessorConstant(map, NONE, pair_); return expectations->AddAccessorConstant(map, NONE, pair_);
} else { } else {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
return expectations.AddDataField(map, NONE, PropertyConstness::kConst, return expectations->AddDataField(map, NONE, PropertyConstness::kConst,
Representation::Smi(), any_type); Representation::Smi(), any_type);
} }
} }
void UpdateExpectations( void UpdateExpectations(int property_index, Expectations* expectations) {}
int property_index,
Expectations& expectations // NOLINT(runtime/references)
) {}
}; };
TestConfig config; TestConfig config;
// These are completely separate branches in transition tree. // These are completely separate branches in transition tree.
CheckUnrelated checker; CheckUnrelated checker;
TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); TestReconfigureProperty_CustomPropertyAfterTargetMap(&config, &checker);
} }
@ -2143,9 +2116,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
// fixed. // fixed.
template <typename TestConfig> template <typename TestConfig>
static void TestGeneralizeFieldWithSpecialTransition( static void TestGeneralizeFieldWithSpecialTransition(
TestConfig& config, // NOLINT(runtime/references) TestConfig* config, const CRFTData& from, const CRFTData& to,
const CRFTData& from, const CRFTData& to, const CRFTData& expected, const CRFTData& expected, bool expected_deprecation) {
bool expected_deprecation) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Expectations expectations(isolate); Expectations expectations(isolate);
@ -2165,13 +2137,13 @@ static void TestGeneralizeFieldWithSpecialTransition(
// Apply some special transition to |map|. // Apply some special transition to |map|.
CHECK(map->owns_descriptors()); CHECK(map->owns_descriptors());
Handle<Map> map2 = config.Transition(map, expectations2); Handle<Map> map2 = config->Transition(map, &expectations2);
// |map| should still match expectations. // |map| should still match expectations.
CHECK(!map->is_deprecated()); CHECK(!map->is_deprecated());
CHECK(expectations.Check(*map)); CHECK(expectations.Check(*map));
if (config.generalizes_representations()) { if (config->generalizes_representations()) {
for (int i = 0; i < kPropCount; i++) { for (int i = 0; i < kPropCount; i++) {
expectations2.GeneralizeField(i); expectations2.GeneralizeField(i);
} }
@ -2208,10 +2180,10 @@ static void TestGeneralizeFieldWithSpecialTransition(
CHECK_EQ(*new_map2, *tmp_map); CHECK_EQ(*new_map2, *tmp_map);
} else { } else {
// Equivalent transitions should always find the updated map. // 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 // In case of non-equivalent transition currently we generalize all
// representations. // representations.
for (int i = 0; i < kPropCount; i++) { for (int i = 0; i < kPropCount; i++) {
@ -2262,9 +2234,9 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) {
ElementsKind kind) ElementsKind kind)
: attributes(attributes), symbol(symbol), elements_kind(kind) {} : attributes(attributes), symbol(symbol), elements_kind(kind) {}
Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { Handle<Map> Transition(Handle<Map> map, Expectations* expectations) {
expectations.SetElementsKind(elements_kind); expectations->SetElementsKind(elements_kind);
expectations.ChangeAttributesForAllProperties(attributes); expectations->ChangeAttributesForAllProperties(attributes);
return Map::CopyForPreventExtensions(CcTest::i_isolate(), map, attributes, return Map::CopyForPreventExtensions(CcTest::i_isolate(), map, attributes,
symbol, "CopyForPreventExtensions"); symbol, "CopyForPreventExtensions");
} }
@ -2289,13 +2261,13 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) {
: DICTIONARY_ELEMENTS}}; : DICTIONARY_ELEMENTS}};
for (size_t i = 0; i < arraysize(configs); i++) { for (size_t i = 0; i < arraysize(configs); i++) {
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
configs[i], &configs[i],
{PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::Smi(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
!FLAG_modify_field_representation_inplace); !FLAG_modify_field_representation_inplace);
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
configs[i], &configs[i],
{PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::Double(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
@ -2318,7 +2290,7 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) {
ElementsKind kind) ElementsKind kind)
: attributes(attributes), symbol(symbol), elements_kind(kind) {} : attributes(attributes), symbol(symbol), elements_kind(kind) {}
Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { Handle<Map> Transition(Handle<Map> map, Expectations* expectations) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
@ -2331,8 +2303,8 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) {
.ToHandleChecked(); .ToHandleChecked();
CHECK(!map->owns_descriptors()); CHECK(!map->owns_descriptors());
expectations.SetElementsKind(elements_kind); expectations->SetElementsKind(elements_kind);
expectations.ChangeAttributesForAllProperties(attributes); expectations->ChangeAttributesForAllProperties(attributes);
return Map::CopyForPreventExtensions(isolate, map, attributes, symbol, return Map::CopyForPreventExtensions(isolate, map, attributes, symbol,
"CopyForPreventExtensions"); "CopyForPreventExtensions");
} }
@ -2357,13 +2329,13 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) {
: DICTIONARY_ELEMENTS}}; : DICTIONARY_ELEMENTS}};
for (size_t i = 0; i < arraysize(configs); i++) { for (size_t i = 0; i < arraysize(configs); i++) {
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
configs[i], &configs[i],
{PropertyConstness::kMutable, Representation::Smi(), any_type}, {PropertyConstness::kMutable, Representation::Smi(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
!FLAG_modify_field_representation_inplace); !FLAG_modify_field_representation_inplace);
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
configs[i], &configs[i],
{PropertyConstness::kMutable, Representation::Double(), any_type}, {PropertyConstness::kMutable, Representation::Double(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
@ -2390,9 +2362,7 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) {
prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0));
} }
Handle<Map> Transition( Handle<Map> Transition(Handle<Map> map, Expectations* expectations) {
Handle<Map> map,
Expectations& expectations) { // NOLINT(runtime/references)
return Map::TransitionToPrototype(CcTest::i_isolate(), map, prototype_); return Map::TransitionToPrototype(CcTest::i_isolate(), map, prototype_);
} }
// TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed.
@ -2403,12 +2373,13 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) {
}; };
TestConfig config; TestConfig config;
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, &config, {PropertyConstness::kMutable, Representation::Smi(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
!FLAG_modify_field_representation_inplace); !FLAG_modify_field_representation_inplace);
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {PropertyConstness::kMutable, Representation::Double(), any_type}, &config,
{PropertyConstness::kMutable, Representation::Double(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace); FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
@ -2432,9 +2403,7 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) {
prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0));
} }
Handle<Map> Transition( Handle<Map> Transition(Handle<Map> map, Expectations* expectations) {
Handle<Map> map,
Expectations& expectations) { // NOLINT(runtime/references)
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
@ -2457,12 +2426,13 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) {
}; };
TestConfig config; TestConfig config;
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {PropertyConstness::kMutable, Representation::Smi(), any_type}, &config, {PropertyConstness::kMutable, Representation::Smi(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
!FLAG_modify_field_representation_inplace); !FLAG_modify_field_representation_inplace);
TestGeneralizeFieldWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {PropertyConstness::kMutable, Representation::Double(), any_type}, &config,
{PropertyConstness::kMutable, Representation::Double(), any_type},
{PropertyConstness::kMutable, Representation::HeapObject(), value_type}, {PropertyConstness::kMutable, Representation::HeapObject(), value_type},
{PropertyConstness::kMutable, Representation::Tagged(), any_type}, {PropertyConstness::kMutable, Representation::Tagged(), any_type},
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace); FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
@ -2490,10 +2460,8 @@ struct TransitionToDataFieldOperator {
heap_type_(heap_type), heap_type_(heap_type),
value_(value) {} value_(value) {}
Handle<Map> DoTransition( Handle<Map> DoTransition(Expectations* expectations, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references) return expectations->TransitionToDataField(
Handle<Map> map) {
return expectations.TransitionToDataField(
map, attributes_, constness_, representation_, heap_type_, value_); map, attributes_, constness_, representation_, heap_type_, value_);
} }
}; };
@ -2507,8 +2475,8 @@ struct TransitionToDataConstantOperator {
PropertyAttributes attributes = NONE) PropertyAttributes attributes = NONE)
: attributes_(attributes), value_(value) {} : attributes_(attributes), value_(value) {}
Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { Handle<Map> DoTransition(Expectations* expectations, Handle<Map> map) {
return expectations.TransitionToDataConstant(map, attributes_, value_); return expectations->TransitionToDataConstant(map, attributes_, value_);
} }
}; };
@ -2521,8 +2489,8 @@ struct TransitionToAccessorConstantOperator {
PropertyAttributes attributes = NONE) PropertyAttributes attributes = NONE)
: attributes_(attributes), pair_(pair) {} : attributes_(attributes), pair_(pair) {}
Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { Handle<Map> DoTransition(Expectations* expectations, Handle<Map> map) {
return expectations.TransitionToAccessorConstant(map, attributes_, pair_); return expectations->TransitionToAccessorConstant(map, attributes_, pair_);
} }
}; };
@ -2542,12 +2510,10 @@ struct ReconfigureAsDataPropertyOperator {
attributes_(attributes), attributes_(attributes),
heap_type_(heap_type) {} heap_type_(heap_type) {}
Handle<Map> DoTransition( Handle<Map> DoTransition(Isolate* isolate, Expectations* expectations,
Isolate* isolate, Handle<Map> map) {
Expectations& expectations, // NOLINT(runtime/references) expectations->SetDataField(descriptor_, PropertyConstness::kMutable,
Handle<Map> map) { representation_, heap_type_);
expectations.SetDataField(descriptor_, PropertyConstness::kMutable,
representation_, heap_type_);
return Map::ReconfigureExistingProperty(isolate, map, descriptor_, kData, return Map::ReconfigureExistingProperty(isolate, map, descriptor_, kData,
attributes_, attributes_,
PropertyConstness::kConst); PropertyConstness::kConst);
@ -2563,9 +2529,9 @@ struct ReconfigureAsAccessorPropertyOperator {
PropertyAttributes attributes = NONE) PropertyAttributes attributes = NONE)
: descriptor_(descriptor), attributes_(attributes) {} : descriptor_(descriptor), attributes_(attributes) {}
Handle<Map> DoTransition(Isolate* isolate, Expectations& expectations, Handle<Map> DoTransition(Isolate* isolate, Expectations* expectations,
Handle<Map> map) { Handle<Map> map) {
expectations.SetAccessorField(descriptor_); expectations->SetAccessorField(descriptor_);
return Map::ReconfigureExistingProperty(isolate, map, descriptor_, return Map::ReconfigureExistingProperty(isolate, map, descriptor_,
kAccessor, attributes_, kAccessor, attributes_,
PropertyConstness::kConst); PropertyConstness::kConst);
@ -2590,9 +2556,8 @@ struct FieldGeneralizationChecker {
attributes_(attributes), attributes_(attributes),
heap_type_(heap_type) {} heap_type_(heap_type) {}
void Check(Isolate* isolate, void Check(Isolate* isolate, Expectations* expectations, Handle<Map> map1,
Expectations& expectations2, // NOLINT(runtime/references) Handle<Map> map2) {
Handle<Map> map1, Handle<Map> map2) {
CHECK(!map2->is_deprecated()); CHECK(!map2->is_deprecated());
CHECK(map1->is_deprecated()); CHECK(map1->is_deprecated());
@ -2601,21 +2566,20 @@ struct FieldGeneralizationChecker {
CHECK_EQ(*map2, *updated_map); CHECK_EQ(*map2, *updated_map);
CheckMigrationTarget(isolate, *map1, *updated_map); CheckMigrationTarget(isolate, *map1, *updated_map);
expectations2.SetDataField(descriptor_, attributes_, constness_, expectations->SetDataField(descriptor_, attributes_, constness_,
representation_, heap_type_); representation_, heap_type_);
CHECK(expectations2.Check(*map2)); CHECK(expectations->Check(*map2));
} }
}; };
// Checks that existing transition was taken as is. // Checks that existing transition was taken as is.
struct SameMapChecker { struct SameMapChecker {
void Check(Isolate* isolate, void Check(Isolate* isolate, Expectations* expectations, Handle<Map> map1,
Expectations& expectations, // NOLINT(runtime/references) Handle<Map> map2) {
Handle<Map> map1, Handle<Map> map2) {
CHECK(!map2->is_deprecated()); CHECK(!map2->is_deprecated());
CHECK_EQ(*map1, *map2); 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 // Checks that both |map1| and |map2| should stays non-deprecated, this is
// the case when property kind is change. // the case when property kind is change.
struct PropertyKindReconfigurationChecker { struct PropertyKindReconfigurationChecker {
void Check(Expectations& expectations, // NOLINT(runtime/references) void Check(Expectations* expectations, Handle<Map> map1, Handle<Map> map2) {
Handle<Map> map1, Handle<Map> map2) {
CHECK(!map1->is_deprecated()); CHECK(!map1->is_deprecated());
CHECK(!map2->is_deprecated()); CHECK(!map2->is_deprecated());
CHECK_NE(*map1, *map2); 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. // where "p4A" and "p4B" differ only in the attributes.
// //
template <typename TransitionOp1, typename TransitionOp2, typename Checker> template <typename TransitionOp1, typename TransitionOp2, typename Checker>
static void TestTransitionTo( static void TestTransitionTo(TransitionOp1* transition_op1,
TransitionOp1& transition_op1, // NOLINT(runtime/references) TransitionOp2* transition_op2, Checker* checker) {
TransitionOp2& transition_op2, // NOLINT(runtime/references)
Checker& checker) { // NOLINT(runtime/references)
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
@ -2668,14 +2629,14 @@ static void TestTransitionTo(
CHECK(expectations.Check(*map)); CHECK(expectations.Check(*map));
Expectations expectations1 = expectations; Expectations expectations1 = expectations;
Handle<Map> map1 = transition_op1.DoTransition(expectations1, map); Handle<Map> map1 = transition_op1->DoTransition(&expectations1, map);
CHECK(expectations1.Check(*map1)); CHECK(expectations1.Check(*map1));
Expectations expectations2 = expectations; Expectations expectations2 = expectations;
Handle<Map> map2 = transition_op2.DoTransition(expectations2, map); Handle<Map> map2 = transition_op2->DoTransition(&expectations2, map);
// Let the test customization do the check. // Let the test customization do the check.
checker.Check(isolate, expectations2, map1, map2); checker->Check(isolate, &expectations2, map1, map2);
} }
TEST(TransitionDataFieldToDataField) { TEST(TransitionDataFieldToDataField) {
@ -2696,7 +2657,7 @@ TEST(TransitionDataFieldToDataField) {
FieldGeneralizationChecker checker(kPropCount - 1, FieldGeneralizationChecker checker(kPropCount - 1,
PropertyConstness::kMutable, PropertyConstness::kMutable,
Representation::Double(), any_type); Representation::Double(), any_type);
TestTransitionTo(transition_op1, transition_op2, checker); TestTransitionTo(&transition_op1, &transition_op2, &checker);
} }
TEST(TransitionDataConstantToSameDataConstant) { TEST(TransitionDataConstantToSameDataConstant) {
@ -2710,7 +2671,7 @@ TEST(TransitionDataConstantToSameDataConstant) {
TransitionToDataConstantOperator transition_op(js_func); TransitionToDataConstantOperator transition_op(js_func);
SameMapChecker checker; 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); TransitionToDataConstantOperator transition_op2(js_func2);
SameMapChecker checker; 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) { if (FLAG_modify_field_representation_inplace) {
SameMapChecker checker; SameMapChecker checker;
TestTransitionTo(transition_op1, transition_op2, checker); TestTransitionTo(&transition_op1, &transition_op2, &checker);
} else { } else {
FieldGeneralizationChecker checker(kPropCount - 1, FieldGeneralizationChecker checker(kPropCount - 1,
PropertyConstness::kMutable, PropertyConstness::kMutable,
Representation::Tagged(), any_type); 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); TransitionToAccessorConstantOperator transition_op(pair);
SameMapChecker checker; 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. // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported.

View File

@ -3578,10 +3578,9 @@ TEST(AddressToTraceMap) {
} }
static const v8::AllocationProfile::Node* FindAllocationProfileNode( static const v8::AllocationProfile::Node* FindAllocationProfileNode(
v8::Isolate* isolate, v8::Isolate* isolate, v8::AllocationProfile* profile,
v8::AllocationProfile& profile, // NOLINT(runtime/references)
const Vector<const char*>& names) { const Vector<const char*>& names) {
v8::AllocationProfile::Node* node = profile.GetRootNode(); v8::AllocationProfile::Node* node = profile->GetRootNode();
for (int i = 0; node != nullptr && i < names.length(); ++i) { for (int i = 0; node != nullptr && i < names.length(); ++i) {
const char* name = names[i]; const char* name = names[i];
auto children = node->children; auto children = node->children;
@ -3651,7 +3650,7 @@ TEST(SamplingHeapProfiler) {
CHECK(profile); CHECK(profile);
const char* names[] = {"", "foo", "bar"}; const char* names[] = {"", "foo", "bar"};
auto node_bar = FindAllocationProfileNode(env->GetIsolate(), *profile, auto node_bar = FindAllocationProfileNode(env->GetIsolate(), profile.get(),
ArrayVector(names)); ArrayVector(names));
CHECK(node_bar); CHECK(node_bar);
@ -3675,12 +3674,12 @@ TEST(SamplingHeapProfiler) {
CHECK(profile); CHECK(profile);
const char* names1[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"}; 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)); ArrayVector(names1));
CHECK(node1); CHECK(node1);
const char* names2[] = {"", "generateFunctions"}; const char* names2[] = {"", "generateFunctions"};
auto node2 = FindAllocationProfileNode(env->GetIsolate(), *profile, auto node2 = FindAllocationProfileNode(env->GetIsolate(), profile.get(),
ArrayVector(names2)); ArrayVector(names2));
CHECK(node2); CHECK(node2);
@ -3738,11 +3737,11 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) {
CHECK(profile); CHECK(profile);
const char* path_to_foo[] = {"", "foo"}; 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)); ArrayVector(path_to_foo));
CHECK(node_foo); CHECK(node_foo);
const char* path_to_bar[] = {"", "foo", "bar"}; 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)); ArrayVector(path_to_bar));
CHECK(node_bar); CHECK(node_bar);
@ -3762,11 +3761,11 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) {
CHECK(profile); CHECK(profile);
const char* path_to_foo[] = {"", "foo"}; 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)); ArrayVector(path_to_foo));
CHECK(node_foo); CHECK(node_foo);
const char* path_to_bar[] = {"", "foo", "bar"}; 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)); ArrayVector(path_to_bar));
CHECK(node_bar); CHECK(node_bar);
@ -3805,7 +3804,7 @@ TEST(SamplingHeapProfilerApiAllocation) {
heap_profiler->GetAllocationProfile()); heap_profiler->GetAllocationProfile());
CHECK(profile); CHECK(profile);
const char* names[] = {"(V8 API)"}; const char* names[] = {"(V8 API)"};
auto node = FindAllocationProfileNode(env->GetIsolate(), *profile, auto node = FindAllocationProfileNode(env->GetIsolate(), profile.get(),
ArrayVector(names)); ArrayVector(names));
CHECK(node); CHECK(node);
@ -3945,7 +3944,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
heap_profiler->StopSamplingHeapProfiler(); heap_profiler->StopSamplingHeapProfiler();
const char* names[] = {"f"}; const char* names[] = {"f"};
auto node_f = FindAllocationProfileNode(env->GetIsolate(), *profile, auto node_f = FindAllocationProfileNode(env->GetIsolate(), profile.get(),
ArrayVector(names)); ArrayVector(names));
CHECK(node_f); CHECK(node_f);
@ -3975,7 +3974,7 @@ TEST(SamplingHeapProfilerLargeInterval) {
heap_profiler->GetAllocationProfile()); heap_profiler->GetAllocationProfile());
CHECK(profile); CHECK(profile);
const char* names[] = {"(EXTERNAL)"}; const char* names[] = {"(EXTERNAL)"};
auto node = FindAllocationProfileNode(env->GetIsolate(), *profile, auto node = FindAllocationProfileNode(env->GetIsolate(), profile.get(),
ArrayVector(names)); ArrayVector(names));
CHECK(node); CHECK(node);

View File

@ -674,13 +674,12 @@ static const char* line_number_test_source_profile_time_functions =
"bar_at_the_second_line();\n" "bar_at_the_second_line();\n"
"function lazy_func_at_6th_line() {}"; "function lazy_func_at_6th_line() {}";
int GetFunctionLineNumber(CpuProfiler& profiler, // NOLINT(runtime/references) int GetFunctionLineNumber(CpuProfiler* profiler, LocalContext* env,
LocalContext& env, // NOLINT(runtime/references)
const char* name) { const char* name) {
CodeMap* code_map = profiler.generator()->code_map(); CodeMap* code_map = profiler->generator()->code_map();
i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast( i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
env->Global()->Get(env.local(), v8_str(name)).ToLocalChecked()))); (*env)->Global()->Get(env->local(), v8_str(name)).ToLocalChecked())));
CodeEntry* func_entry = CodeEntry* func_entry =
code_map->FindEntry(func->abstract_code().InstructionStart()); code_map->FindEntry(func->abstract_code().InstructionStart());
if (!func_entry) FATAL("%s", name); if (!func_entry) FATAL("%s", name);
@ -705,12 +704,12 @@ TEST(LineNumber) {
profiler.processor()->StopSynchronously(); profiler.processor()->StopSynchronously();
bool is_lazy = i::FLAG_lazy; 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, CHECK_EQ(is_lazy ? 0 : 4,
GetFunctionLineNumber(profiler, env, "lazy_func_at_forth_line")); GetFunctionLineNumber(&profiler, &env, "lazy_func_at_forth_line"));
CHECK_EQ(2, GetFunctionLineNumber(profiler, env, "bar_at_the_second_line")); CHECK_EQ(2, GetFunctionLineNumber(&profiler, &env, "bar_at_the_second_line"));
CHECK_EQ(is_lazy ? 0 : 6, 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"); profiler.StopProfiling("LineNumber");
} }

View File

@ -98,8 +98,7 @@ class TestSerializer {
return v8_isolate; return v8_isolate;
} }
static v8::Isolate* NewIsolateFromBlob( static v8::Isolate* NewIsolateFromBlob(const StartupBlobs& blobs) {
StartupBlobs& blobs) { // NOLINT(runtime/references)
SnapshotData startup_snapshot(blobs.startup); SnapshotData startup_snapshot(blobs.startup);
SnapshotData read_only_snapshot(blobs.read_only); SnapshotData read_only_snapshot(blobs.read_only);
ReadOnlyDeserializer read_only_deserializer(&read_only_snapshot); ReadOnlyDeserializer read_only_deserializer(&read_only_snapshot);
@ -204,8 +203,7 @@ Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head,
source_length); source_length);
} }
static v8::Isolate* Deserialize( static v8::Isolate* Deserialize(const StartupBlobs& blobs) {
StartupBlobs& blobs) { // NOLINT(runtime/references)
v8::Isolate* isolate = TestSerializer::NewIsolateFromBlob(blobs); v8::Isolate* isolate = TestSerializer::NewIsolateFromBlob(blobs);
CHECK(isolate); CHECK(isolate);
return isolate; return isolate;

View File

@ -14,11 +14,11 @@ namespace internal {
namespace { namespace {
void AddSigned(std::set<Smi>& smis, int64_t x) { // NOLINT(runtime/references) void AddSigned(std::set<Smi>* smis, int64_t x) {
if (!Smi::IsValid(x)) return; if (!Smi::IsValid(x)) return;
smis.insert(Smi::FromInt(static_cast<int>(x))); smis->insert(Smi::FromInt(static_cast<int>(x)));
smis.insert(Smi::FromInt(static_cast<int>(-x))); smis->insert(Smi::FromInt(static_cast<int>(-x)));
} }
// Uses std::lexicographical_compare twice to convert the result to -1, 0 or 1. // 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 xb = 1; xb <= Smi::kMaxValue; xb *= 10) {
for (int64_t xf = 0; xf <= 9; ++xf) { for (int64_t xf = 0; xf <= 9; ++xf) {
for (int64_t xo = -1; xo <= 1; ++xo) { 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 yb = 1; yb <= Smi::kMaxValue; yb *= 2) {
for (int64_t yo = -2; yo <= 2; ++yo) { for (int64_t yo = -2; yo <= 2; ++yo) {
AddSigned(smis, yb + yo); AddSigned(&smis, yb + yo);
} }
} }

View File

@ -15,12 +15,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
void TestArrayBufferViewContents( void TestArrayBufferViewContents(LocalContext* env, bool should_use_buffer) {
LocalContext& env, // NOLINT(runtime/references)
bool should_use_buffer) {
v8::Local<v8::Object> obj_a = v8::Local<v8::Object>::Cast( v8::Local<v8::Object> obj_a = v8::Local<v8::Object>::Cast(
env->Global() (*env)
->Get(env->GetIsolate()->GetCurrentContext(), v8_str("a")) ->Global()
->Get((*env)->GetIsolate()->GetCurrentContext(), v8_str("a"))
.ToLocalChecked()); .ToLocalChecked());
CHECK(obj_a->IsArrayBufferView()); CHECK(obj_a->IsArrayBufferView());
v8::Local<v8::ArrayBufferView> array_buffer_view = v8::Local<v8::ArrayBufferView> array_buffer_view =
@ -44,7 +43,7 @@ TEST(CopyContentsTypedArray) {
"a[1] = 1;" "a[1] = 1;"
"a[2] = 2;" "a[2] = 2;"
"a[3] = 3;"); "a[3] = 3;");
TestArrayBufferViewContents(env, false); TestArrayBufferViewContents(&env, false);
} }
@ -52,7 +51,7 @@ TEST(CopyContentsArray) {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
CompileRun("var a = new Uint8Array([0, 1, 2, 3]);"); 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[4] = 2;"
"c[5] = 3;" "c[5] = 3;"
"var a = new DataView(b, 2);"); "var a = new DataView(b, 2);");
TestArrayBufferViewContents(env, true); TestArrayBufferViewContents(&env, true);
} }

View File

@ -13,11 +13,10 @@ namespace wasm {
namespace test_run_wasm_bulk_memory { namespace test_run_wasm_bulk_memory {
namespace { namespace {
void CheckMemoryEquals( void CheckMemoryEquals(TestingModuleBuilder* builder, size_t index,
TestingModuleBuilder& builder, // NOLINT(runtime/references) const std::vector<byte>& expected) {
size_t index, const std::vector<byte>& expected) { const byte* mem_start = builder->raw_mem_start<byte>();
const byte* mem_start = builder.raw_mem_start<byte>(); const byte* mem_end = builder->raw_mem_end<byte>();
const byte* mem_end = builder.raw_mem_end<byte>();
size_t mem_size = mem_end - mem_start; size_t mem_size = mem_end - mem_start;
CHECK_LE(index, mem_size); CHECK_LE(index, mem_size);
CHECK_LE(index + expected.size(), mem_size); CHECK_LE(index + expected.size(), mem_size);
@ -26,11 +25,10 @@ void CheckMemoryEquals(
} }
} }
void CheckMemoryEqualsZero( void CheckMemoryEqualsZero(TestingModuleBuilder* builder, size_t index,
TestingModuleBuilder& builder, // NOLINT(runtime/references) size_t length) {
size_t index, size_t length) { const byte* mem_start = builder->raw_mem_start<byte>();
const byte* mem_start = builder.raw_mem_start<byte>(); const byte* mem_end = builder->raw_mem_end<byte>();
const byte* mem_end = builder.raw_mem_end<byte>();
size_t mem_size = mem_end - mem_start; size_t mem_size = mem_end - mem_start;
CHECK_LE(index, mem_size); CHECK_LE(index, mem_size);
CHECK_LE(index + length, mem_size); CHECK_LE(index + length, mem_size);
@ -39,12 +37,11 @@ void CheckMemoryEqualsZero(
} }
} }
void CheckMemoryEqualsFollowedByZeroes( void CheckMemoryEqualsFollowedByZeroes(TestingModuleBuilder* builder,
TestingModuleBuilder& builder, // NOLINT(runtime/references) const std::vector<byte>& expected) {
const std::vector<byte>& expected) {
CheckMemoryEquals(builder, 0, expected); CheckMemoryEquals(builder, 0, expected);
CheckMemoryEqualsZero(builder, expected.size(), CheckMemoryEqualsZero(builder, expected.size(),
builder.mem_size() - expected.size()); builder->mem_size() - expected.size());
} }
} // namespace } // namespace
@ -60,24 +57,24 @@ WASM_EXEC_TEST(MemoryInit) {
kExprI32Const, 0); kExprI32Const, 0);
// All zeroes. // All zeroes.
CheckMemoryEqualsZero(r.builder(), 0, kWasmPageSize); CheckMemoryEqualsZero(&r.builder(), 0, kWasmPageSize);
// Copy all bytes from data segment 0, to memory at [10, 20). // Copy all bytes from data segment 0, to memory at [10, 20).
CHECK_EQ(0, r.Call(10, 0, 10)); CHECK_EQ(0, r.Call(10, 0, 10));
CheckMemoryEqualsFollowedByZeroes( 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}); {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). // Copy bytes in range [5, 10) from data segment 0, to memory at [0, 5).
CHECK_EQ(0, r.Call(0, 5, 5)); CHECK_EQ(0, r.Call(0, 5, 5));
CheckMemoryEqualsFollowedByZeroes( 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}); {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. // Copy 0 bytes does nothing.
CHECK_EQ(0, r.Call(10, 1, 0)); CHECK_EQ(0, r.Call(10, 1, 0));
CheckMemoryEqualsFollowedByZeroes( 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}); {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. // 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. // Write all values up to the out-of-bounds write.
CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, 0, 6)); 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. // Write all values up to the out-of-bounds read.
r.builder().BlankMemory(); r.builder().BlankMemory();
CHECK_EQ(0xDEADBEEF, r.Call(0, 5, 6)); 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) { WASM_EXEC_TEST(MemoryInitOutOfBounds) {
@ -155,13 +152,13 @@ WASM_EXEC_TEST(MemoryCopy) {
// Copy from [1, 8] to [10, 16]. // Copy from [1, 8] to [10, 16].
CHECK_EQ(0, r.Call(10, 1, 8)); CHECK_EQ(0, r.Call(10, 1, 8));
CheckMemoryEqualsFollowedByZeroes( CheckMemoryEqualsFollowedByZeroes(
r.builder(), &r.builder(),
{0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); {0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77});
// Copy 0 bytes does nothing. // Copy 0 bytes does nothing.
CHECK_EQ(0, r.Call(10, 2, 0)); CHECK_EQ(0, r.Call(10, 2, 0));
CheckMemoryEqualsFollowedByZeroes( CheckMemoryEqualsFollowedByZeroes(
r.builder(), &r.builder(),
{0, 11, 22, 33, 44, 55, 66, 77, 0, 0, 11, 22, 33, 44, 55, 66, 77}); {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. // 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 // Copy from [0, 3] -> [2, 5]. The copy must not overwrite 30 before copying
// it (i.e. cannot copy forward in this case). // it (i.e. cannot copy forward in this case).
CHECK_EQ(0, r.Call(2, 0, 3)); 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. // Copy from [2, 5] -> [0, 3]. The copy must not write the first 10 (i.e.
// cannot copy backward in this case). // cannot copy backward in this case).
CHECK_EQ(0, r.Call(0, 2, 3)); 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) { WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
@ -209,21 +206,21 @@ WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
// Copy with source < destination. Copy would happen backwards, // Copy with source < destination. Copy would happen backwards,
// but the first byte to copy is out-of-bounds, so no data should be written. // 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)); 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 // Copy overlapping with destination < source. Copy will happen forwards, up
// to the out-of-bounds access. // to the out-of-bounds access.
r.builder().BlankMemory(); r.builder().BlankMemory();
memcpy(mem + last_5_bytes, data, 5); memcpy(mem + last_5_bytes, data, 5);
CHECK_EQ(0xDEADBEEF, r.Call(0, last_5_bytes, kWasmPageSize)); 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, // 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. // but the first byte to copy is out-of-bounds, so no data should be written.
r.builder().BlankMemory(); r.builder().BlankMemory();
memcpy(mem, data, 5); memcpy(mem, data, 5);
CHECK_EQ(0xDEADBEEF, r.Call(last_5_bytes, 0, kWasmPageSize)); 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) { 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)), WASM_MEMORY_FILL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)),
kExprI32Const, 0); kExprI32Const, 0);
CHECK_EQ(0, r.Call(1, 33, 5)); 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)); CHECK_EQ(0, r.Call(4, 66, 4));
CheckMemoryEqualsFollowedByZeroes(r.builder(), CheckMemoryEqualsFollowedByZeroes(&r.builder(),
{0, 33, 33, 33, 66, 66, 66, 66}); {0, 33, 33, 33, 66, 66, 66, 66});
// Fill 0 bytes does nothing. // Fill 0 bytes does nothing.
CHECK_EQ(0, r.Call(4, 66, 0)); CHECK_EQ(0, r.Call(4, 66, 0));
CheckMemoryEqualsFollowedByZeroes(r.builder(), CheckMemoryEqualsFollowedByZeroes(&r.builder(),
{0, 33, 33, 33, 66, 66, 66, 66}); {0, 33, 33, 33, 66, 66, 66, 66});
// Fill 0 at end of memory region is OK. // Fill 0 at end of memory region is OK.
@ -290,7 +287,7 @@ WASM_EXEC_TEST(MemoryFillValueWrapsToByte) {
kExprI32Const, 0); kExprI32Const, 0);
CHECK_EQ(0, r.Call(0, 1000, 3)); CHECK_EQ(0, r.Call(0, 1000, 3));
const byte expected = 1000 & 255; const byte expected = 1000 & 255;
CheckMemoryEqualsFollowedByZeroes(r.builder(), CheckMemoryEqualsFollowedByZeroes(&r.builder(),
{expected, expected, expected}); {expected, expected, expected});
} }
@ -304,7 +301,7 @@ WASM_EXEC_TEST(MemoryFillOutOfBoundsData) {
kExprI32Const, 0); kExprI32Const, 0);
const byte v = 123; const byte v = 123;
CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, v, 999)); 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) { WASM_EXEC_TEST(MemoryFillOutOfBounds) {
@ -408,14 +405,13 @@ void CheckTable(Isolate* isolate, Handle<WasmTableObject> table, Args... args) {
template <typename WasmRunner, typename... Args> template <typename WasmRunner, typename... Args>
void CheckTableCall(Isolate* isolate, Handle<WasmTableObject> table, void CheckTableCall(Isolate* isolate, Handle<WasmTableObject> table,
WasmRunner& r, // NOLINT(runtime/references) WasmRunner* r, uint32_t function_index, Args... args) {
uint32_t function_index, Args... args) {
uint32_t args_length = static_cast<uint32_t>(sizeof...(args)); uint32_t args_length = static_cast<uint32_t>(sizeof...(args));
CHECK_EQ(table->current_length(), args_length); CHECK_EQ(table->current_length(), args_length);
double expected[] = {args...}; double expected[] = {args...};
for (uint32_t i = 0; i < args_length; ++i) { for (uint32_t i = 0; i < args_length; ++i) {
Handle<Object> buffer[] = {isolate->factory()->NewNumber(i)}; Handle<Object> buffer[] = {isolate->factory()->NewNumber(i)};
r.CheckCallApplyViaJS(expected[i], function_index, buffer, 1); r->CheckCallApplyViaJS(expected[i], function_index, buffer, 1);
} }
} }
} // namespace } // namespace
@ -462,7 +458,7 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) {
isolate); isolate);
const double null = 0xDEADBEEF; 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. // 0 count is ok in bounds, and at end of regions.
r.CheckCallViaJS(0, 0, 0, 0); r.CheckCallViaJS(0, 0, 0, 0);
@ -471,19 +467,19 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) {
// Test actual writes. // Test actual writes.
r.CheckCallViaJS(0, 0, 0, 1); 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); 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); 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); 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); 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); 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); 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); } WASM_EXEC_TEST(TableInitElems0) { TestTableInitElems(execution_tier, 0); }
@ -534,15 +530,15 @@ void TestTableInitOob(ExecutionTier execution_tier, int table_index) {
isolate); isolate);
const double null = 0xDEADBEEF; 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. // Write all values up to the out-of-bounds write.
r.CheckCallViaJS(0xDEADBEEF, 3, 0, 3); 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. // Write all values up to the out-of-bounds read.
r.CheckCallViaJS(0xDEADBEEF, 0, 3, 3); 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. // 0-count is never oob.
r.CheckCallViaJS(0, kTableSize + 1, 0, 0); r.CheckCallViaJS(0, kTableSize + 1, 0, 0);
@ -696,21 +692,21 @@ void TestTableCopyCalls(ExecutionTier execution_tier, int table_dst,
isolate); isolate);
if (table_dst == table_src) { 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); 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); 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); 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 { } 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); 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); 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); 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);
} }
} }

View File

@ -2487,7 +2487,7 @@ void AppendShuffle(const Shuffle& shuffle, std::vector<byte>* buffer) {
for (size_t i = 0; i < kSimd128Size; ++i) buffer->push_back((shuffle[i])); for (size_t i = 0; i < kSimd128Size; ++i) buffer->push_back((shuffle[i]));
} }
void BuildShuffle(std::vector<Shuffle>& shuffles, // NOLINT(runtime/references) void BuildShuffle(const std::vector<Shuffle>& shuffles,
std::vector<byte>* buffer) { std::vector<byte>* buffer) {
// Perform the leaf shuffles on globals 0 and 1. // Perform the leaf shuffles on globals 0 and 1.
size_t row_index = (shuffles.size() - 1) / 2; size_t row_index = (shuffles.size() - 1) / 2;

View File

@ -112,20 +112,19 @@ class BreakHandler : public debug::DebugDelegate {
} }
}; };
void SetBreakpoint(WasmRunnerBase& runner, // NOLINT(runtime/references) void SetBreakpoint(WasmRunnerBase* runner, int function_index, int byte_offset,
int function_index, int byte_offset,
int expected_set_byte_offset = -1) { int expected_set_byte_offset = -1) {
int func_offset = int func_offset =
runner.builder().GetFunctionAt(function_index)->code.offset(); runner->builder().GetFunctionAt(function_index)->code.offset();
int code_offset = func_offset + byte_offset; int code_offset = func_offset + byte_offset;
if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset; if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset;
Handle<WasmInstanceObject> instance = runner.builder().instance_object(); Handle<WasmInstanceObject> instance = runner->builder().instance_object();
Handle<WasmModuleObject> module_object(instance->module_object(), Handle<WasmModuleObject> module_object(instance->module_object(),
runner.main_isolate()); runner->main_isolate());
static int break_index = 0; static int break_index = 0;
Handle<BreakPoint> break_point = Handle<BreakPoint> break_point =
runner.main_isolate()->factory()->NewBreakPoint( runner->main_isolate()->factory()->NewBreakPoint(
break_index++, runner.main_isolate()->factory()->empty_string()); break_index++, runner->main_isolate()->factory()->empty_string());
CHECK(WasmModuleObject::SetBreakPoint(module_object, &code_offset, CHECK(WasmModuleObject::SetBreakPoint(module_object, &code_offset,
break_point)); break_point));
int set_byte_offset = code_offset - func_offset; int set_byte_offset = code_offset - func_offset;
@ -276,7 +275,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) {
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index()); 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}}); BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}});
@ -298,7 +297,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) {
runner.builder().WrapCode(runner.function_index()); runner.builder().WrapCode(runner.function_index());
// Set breakpoint at the first I32Const. // Set breakpoint at the first I32Const.
SetBreakpoint(runner, runner.function_index(), 1, 1); SetBreakpoint(&runner, runner.function_index(), 1, 1);
BreakHandler count_breaks(isolate, BreakHandler count_breaks(isolate,
{ {
@ -341,7 +340,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
runner.builder().WrapCode(f2.function_index()); runner.builder().WrapCode(f2.function_index());
// Set first breakpoint on the GetLocal (offset 19) before the Call. // 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, 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 // Set breakpoint at the first instruction (7 bytes for local decls: num
// entries + 3x<count, type>). // entries + 3x<count, type>).
SetBreakpoint(runner, runner.function_index(), 7, 7); SetBreakpoint(&runner, runner.function_index(), 7, 7);
CollectValuesBreakHandler break_handler( CollectValuesBreakHandler break_handler(
isolate, isolate,

View File

@ -32,28 +32,27 @@ namespace {
template <typename T> template <typename T>
class ArgPassingHelper { class ArgPassingHelper {
public: public:
ArgPassingHelper( ArgPassingHelper(WasmRunnerBase* runner, WasmFunctionCompiler* inner_compiler,
WasmRunnerBase& runner, // NOLINT(runtime/references) std::initializer_list<uint8_t> bytes_inner_function,
WasmFunctionCompiler& inner_compiler, // NOLINT(runtime/references) std::initializer_list<uint8_t> bytes_outer_function,
std::initializer_list<uint8_t> bytes_inner_function, const T& expected_lambda)
std::initializer_list<uint8_t> bytes_outer_function, : isolate_(runner->main_isolate()),
const T& expected_lambda)
: isolate_(runner.main_isolate()),
expected_lambda_(expected_lambda), expected_lambda_(expected_lambda),
debug_info_(WasmInstanceObject::GetOrCreateDebugInfo( debug_info_(WasmInstanceObject::GetOrCreateDebugInfo(
runner.builder().instance_object())) { runner->builder().instance_object())) {
std::vector<uint8_t> inner_code{bytes_inner_function}; std::vector<uint8_t> inner_code{bytes_inner_function};
inner_compiler.Build(inner_code.data(), inner_compiler->Build(inner_code.data(),
inner_code.data() + inner_code.size()); inner_code.data() + inner_code.size());
std::vector<uint8_t> outer_code{bytes_outer_function}; std::vector<uint8_t> 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<int>(inner_compiler.function_index())}; int funcs_to_redict[] = {
runner.builder().SetExecutable(); static_cast<int>(inner_compiler->function_index())};
runner->builder().SetExecutable();
WasmDebugInfo::RedirectToInterpreter(debug_info_, WasmDebugInfo::RedirectToInterpreter(debug_info_,
ArrayVector(funcs_to_redict)); ArrayVector(funcs_to_redict));
main_fun_wrapper_ = runner.builder().WrapCode(runner.function_index()); main_fun_wrapper_ = runner->builder().WrapCode(runner->function_index());
} }
template <typename... Args> template <typename... Args>
@ -82,8 +81,7 @@ class ArgPassingHelper {
template <typename T> template <typename T>
static ArgPassingHelper<T> GetHelper( static ArgPassingHelper<T> GetHelper(
WasmRunnerBase& runner, // NOLINT(runtime/references) WasmRunnerBase* runner, WasmFunctionCompiler* inner_compiler,
WasmFunctionCompiler& inner_compiler, // NOLINT(runtime/references)
std::initializer_list<uint8_t> bytes_inner_function, std::initializer_list<uint8_t> bytes_inner_function,
std::initializer_list<uint8_t> bytes_outer_function, std::initializer_list<uint8_t> bytes_outer_function,
const T& expected_lambda) { const T& expected_lambda) {
@ -99,7 +97,7 @@ TEST(TestArgumentPassing_int32) {
WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>(); WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>();
auto helper = GetHelper( auto helper = GetHelper(
runner, f2, &runner, &f2,
{// Return 2*<0> + 1. {// Return 2*<0> + 1.
WASM_I32_ADD(WASM_I32_MUL(WASM_I32V_1(2), WASM_GET_LOCAL(0)), WASM_ONE)}, WASM_I32_ADD(WASM_I32_MUL(WASM_I32V_1(2), WASM_GET_LOCAL(0)), WASM_ONE)},
{// Call f2 with param <0>. {// Call f2 with param <0>.
@ -117,7 +115,7 @@ TEST(TestArgumentPassing_double_int64) {
WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>(); WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>();
auto helper = GetHelper( auto helper = GetHelper(
runner, f2, &runner, &f2,
{// Return (double)<0>. {// Return (double)<0>.
WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))}, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))},
{// Call f2 with param (<0> | (<1> << 32)). {// Call f2 with param (<0> | (<1> << 32)).
@ -150,7 +148,7 @@ TEST(TestArgumentPassing_int64_double) {
WasmFunctionCompiler& f2 = runner.NewFunction<int64_t, double>(); WasmFunctionCompiler& f2 = runner.NewFunction<int64_t, double>();
auto helper = GetHelper( auto helper = GetHelper(
runner, f2, &runner, &f2,
{// Return (int64_t)<0>. {// Return (int64_t)<0>.
WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))}, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))},
{// Call f2 with param <0>, convert returned value back to double. {// Call f2 with param <0>, convert returned value back to double.
@ -169,7 +167,7 @@ TEST(TestArgumentPassing_float_double) {
WasmFunctionCompiler& f2 = runner.NewFunction<double, float>(); WasmFunctionCompiler& f2 = runner.NewFunction<double, float>();
auto helper = GetHelper( auto helper = GetHelper(
runner, f2, &runner, &f2,
{// Return 2*(double)<0> + 1. {// Return 2*(double)<0> + 1.
WASM_F64_ADD( WASM_F64_ADD(
WASM_F64_MUL(WASM_F64(2), WASM_F64_CONVERT_F32(WASM_GET_LOCAL(0))), WASM_F64_MUL(WASM_F64(2), WASM_F64_CONVERT_F32(WASM_GET_LOCAL(0))),
@ -186,7 +184,7 @@ TEST(TestArgumentPassing_double_double) {
WasmRunner<double, double, double> runner(ExecutionTier::kTurbofan); WasmRunner<double, double, double> runner(ExecutionTier::kTurbofan);
WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>(); WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>();
auto helper = GetHelper(runner, f2, auto helper = GetHelper(&runner, &f2,
{// Return <0> + <1>. {// Return <0> + <1>.
WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))},
{// Call f2 with params <0>, <1>. {// Call f2 with params <0>, <1>.
@ -208,7 +206,7 @@ TEST(TestArgumentPassing_AllTypes) {
runner.NewFunction<double, int32_t, int64_t, float, double>(); runner.NewFunction<double, int32_t, int64_t, float, double>();
auto helper = GetHelper( auto helper = GetHelper(
runner, f2, &runner, &f2,
{ {
// Convert all arguments to double, add them and return the sum. // Convert all arguments to double, add them and return the sum.
WASM_F64_ADD( // <0+1+2> + <3> WASM_F64_ADD( // <0+1+2> + <3>

View File

@ -112,19 +112,19 @@ class SharedEngineIsolate {
class SharedEngineThread : public v8::base::Thread { class SharedEngineThread : public v8::base::Thread {
public: public:
SharedEngineThread(SharedEngine* engine, SharedEngineThread(SharedEngine* engine,
std::function<void(SharedEngineIsolate&)> callback) std::function<void(SharedEngineIsolate*)> callback)
: Thread(Options("SharedEngineThread")), : Thread(Options("SharedEngineThread")),
engine_(engine), engine_(engine),
callback_(callback) {} callback_(callback) {}
void Run() override { void Run() override {
SharedEngineIsolate isolate(engine_); SharedEngineIsolate isolate(engine_);
callback_(isolate); callback_(&isolate);
} }
private: private:
SharedEngine* engine_; SharedEngine* engine_;
std::function<void(SharedEngineIsolate&)> callback_; std::function<void(SharedEngineIsolate*)> callback_;
}; };
namespace { namespace {
@ -159,13 +159,12 @@ class MockInstantiationResolver : public InstantiationResultResolver {
class MockCompilationResolver : public CompilationResultResolver { class MockCompilationResolver : public CompilationResultResolver {
public: public:
MockCompilationResolver( MockCompilationResolver(SharedEngineIsolate* isolate,
SharedEngineIsolate& isolate, // NOLINT(runtime/references) Handle<Object>* out_instance)
Handle<Object>* out_instance)
: isolate_(isolate), out_instance_(out_instance) {} : isolate_(isolate), out_instance_(out_instance) {}
void OnCompilationSucceeded(Handle<WasmModuleObject> result) override { void OnCompilationSucceeded(Handle<WasmModuleObject> result) override {
isolate_.isolate()->wasm_engine()->AsyncInstantiate( isolate_->isolate()->wasm_engine()->AsyncInstantiate(
isolate_.isolate(), isolate_->isolate(),
base::make_unique<MockInstantiationResolver>(out_instance_), result, base::make_unique<MockInstantiationResolver>(out_instance_), result,
{}); {});
} }
@ -174,27 +173,25 @@ class MockCompilationResolver : public CompilationResultResolver {
} }
private: private:
SharedEngineIsolate& isolate_; SharedEngineIsolate* isolate_;
Handle<Object>* out_instance_; Handle<Object>* out_instance_;
}; };
void PumpMessageLoop( void PumpMessageLoop(SharedEngineIsolate* isolate) {
SharedEngineIsolate& isolate) { // NOLINT(runtime/references)
v8::platform::PumpMessageLoop(i::V8::GetCurrentPlatform(), v8::platform::PumpMessageLoop(i::V8::GetCurrentPlatform(),
isolate.v8_isolate(), isolate->v8_isolate(),
platform::MessageLoopBehavior::kWaitForWork); platform::MessageLoopBehavior::kWaitForWork);
isolate.isolate()->default_microtask_queue()->RunMicrotasks( isolate->isolate()->default_microtask_queue()->RunMicrotasks(
isolate.isolate()); isolate->isolate());
} }
Handle<WasmInstanceObject> CompileAndInstantiateAsync( Handle<WasmInstanceObject> CompileAndInstantiateAsync(
SharedEngineIsolate& isolate, // NOLINT(runtime/references) SharedEngineIsolate* isolate, ZoneBuffer* buffer) {
ZoneBuffer* buffer) { Handle<Object> maybe_instance = handle(Smi::kZero, isolate->isolate());
Handle<Object> maybe_instance = handle(Smi::kZero, isolate.isolate()); auto enabled_features = WasmFeaturesFromIsolate(isolate->isolate());
auto enabled_features = WasmFeaturesFromIsolate(isolate.isolate());
constexpr const char* kAPIMethodName = "Test.CompileAndInstantiateAsync"; constexpr const char* kAPIMethodName = "Test.CompileAndInstantiateAsync";
isolate.isolate()->wasm_engine()->AsyncCompile( isolate->isolate()->wasm_engine()->AsyncCompile(
isolate.isolate(), enabled_features, isolate->isolate(), enabled_features,
base::make_unique<MockCompilationResolver>(isolate, &maybe_instance), base::make_unique<MockCompilationResolver>(isolate, &maybe_instance),
ModuleWireBytes(buffer->begin(), buffer->end()), true, kAPIMethodName); ModuleWireBytes(buffer->begin(), buffer->end()), true, kAPIMethodName);
while (!maybe_instance->IsWasmInstanceObject()) PumpMessageLoop(isolate); while (!maybe_instance->IsWasmInstanceObject()) PumpMessageLoop(isolate);
@ -261,17 +258,19 @@ TEST(SharedEngineRunImported) {
TEST(SharedEngineRunThreadedBuildingSync) { TEST(SharedEngineRunThreadedBuildingSync) {
SharedEngine engine; SharedEngine engine;
SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { SharedEngineThread thread1(&engine, [](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 23);
Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); Handle<WasmInstanceObject> instance =
CHECK_EQ(23, isolate.Run(instance)); isolate->CompileAndInstantiate(buffer);
CHECK_EQ(23, isolate->Run(instance));
}); });
SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { SharedEngineThread thread2(&engine, [](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 42);
Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); Handle<WasmInstanceObject> instance =
CHECK_EQ(42, isolate.Run(instance)); isolate->CompileAndInstantiate(buffer);
CHECK_EQ(42, isolate->Run(instance));
}); });
CHECK(thread1.Start()); CHECK(thread1.Start());
CHECK(thread2.Start()); CHECK(thread2.Start());
@ -281,19 +280,19 @@ TEST(SharedEngineRunThreadedBuildingSync) {
TEST(SharedEngineRunThreadedBuildingAsync) { TEST(SharedEngineRunThreadedBuildingAsync) {
SharedEngine engine; SharedEngine engine;
SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { SharedEngineThread thread1(&engine, [](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 23);
Handle<WasmInstanceObject> instance = Handle<WasmInstanceObject> instance =
CompileAndInstantiateAsync(isolate, buffer); CompileAndInstantiateAsync(isolate, buffer);
CHECK_EQ(23, isolate.Run(instance)); CHECK_EQ(23, isolate->Run(instance));
}); });
SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { SharedEngineThread thread2(&engine, [](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); ZoneBuffer* buffer = BuildReturnConstantModule(isolate->zone(), 42);
Handle<WasmInstanceObject> instance = Handle<WasmInstanceObject> instance =
CompileAndInstantiateAsync(isolate, buffer); CompileAndInstantiateAsync(isolate, buffer);
CHECK_EQ(42, isolate.Run(instance)); CHECK_EQ(42, isolate->Run(instance));
}); });
CHECK(thread1.Start()); CHECK(thread1.Start());
CHECK(thread2.Start()); CHECK(thread2.Start());
@ -311,15 +310,15 @@ TEST(SharedEngineRunThreadedExecution) {
Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer);
module = isolate.ExportInstance(instance); module = isolate.ExportInstance(instance);
} }
SharedEngineThread thread1(&engine, [module](SharedEngineIsolate& isolate) { SharedEngineThread thread1(&engine, [module](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); Handle<WasmInstanceObject> instance = isolate->ImportInstance(module);
CHECK_EQ(23, isolate.Run(instance)); CHECK_EQ(23, isolate->Run(instance));
}); });
SharedEngineThread thread2(&engine, [module](SharedEngineIsolate& isolate) { SharedEngineThread thread2(&engine, [module](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); Handle<WasmInstanceObject> instance = isolate->ImportInstance(module);
CHECK_EQ(23, isolate.Run(instance)); CHECK_EQ(23, isolate->Run(instance));
}); });
CHECK(thread1.Start()); CHECK(thread1.Start());
CHECK(thread2.Start()); CHECK(thread2.Start());
@ -340,23 +339,23 @@ TEST(SharedEngineRunThreadedTierUp) {
constexpr int kNumberOfThreads = 5; constexpr int kNumberOfThreads = 5;
std::list<SharedEngineThread> threads; std::list<SharedEngineThread> threads;
for (int i = 0; i < kNumberOfThreads; ++i) { 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; constexpr int kNumberOfIterations = 100;
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); Handle<WasmInstanceObject> instance = isolate->ImportInstance(module);
for (int j = 0; j < kNumberOfIterations; ++j) { 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) { threads.emplace_back(&engine, [module](SharedEngineIsolate* isolate) {
HandleScope scope(isolate.isolate()); HandleScope scope(isolate->isolate());
Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); Handle<WasmInstanceObject> instance = isolate->ImportInstance(module);
WasmFeatures detected = kNoWasmFeatures; WasmFeatures detected = kNoWasmFeatures;
WasmCompilationUnit::CompileWasmFunction( WasmCompilationUnit::CompileWasmFunction(
isolate.isolate(), module.get(), &detected, isolate->isolate(), module.get(), &detected,
&module->module()->functions[0], ExecutionTier::kTurbofan); &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) CHECK(thread.Start());
for (auto& thread : threads) thread.Join(); for (auto& thread : threads) thread.Join();