diff --git a/test/cctest/compiler/function-tester.cc b/test/cctest/compiler/function-tester.cc index 18d868fae2..94086c1eac 100644 --- a/test/cctest/compiler/function-tester.cc +++ b/test/cctest/compiler/function-tester.cc @@ -42,38 +42,13 @@ FunctionTester::FunctionTester(Handle code, int param_count) function((FLAG_allow_natives_syntax = true, NewFunction(BuildFunction(param_count).c_str()))), flags_(0) { + CHECK(!code.is_null()); Compile(function); function->ReplaceCode(*code); } FunctionTester::FunctionTester(Handle code) : FunctionTester(code, 0) {} -MaybeHandle FunctionTester::Call() { - return Execution::Call(isolate, function, undefined(), 0, nullptr); -} - -MaybeHandle FunctionTester::Call(Handle a) { - Handle args[] = {a}; - return Execution::Call(isolate, function, undefined(), 1, args); -} - -MaybeHandle FunctionTester::Call(Handle a, Handle b) { - Handle args[] = {a, b}; - return Execution::Call(isolate, function, undefined(), 2, args); -} - -MaybeHandle FunctionTester::Call(Handle a, Handle b, - Handle c) { - Handle args[] = {a, b, c}; - return Execution::Call(isolate, function, undefined(), 3, args); -} - -MaybeHandle FunctionTester::Call(Handle a, Handle b, - Handle c, Handle d) { - Handle args[] = {a, b, c, d}; - return Execution::Call(isolate, function, undefined(), 4, args); -} - void FunctionTester::CheckThrows(Handle a) { TryCatch try_catch(reinterpret_cast(isolate)); MaybeHandle no_result = Call(a); diff --git a/test/cctest/compiler/function-tester.h b/test/cctest/compiler/function-tester.h index 2cbd00a0e7..abcb924cec 100644 --- a/test/cctest/compiler/function-tester.h +++ b/test/cctest/compiler/function-tester.h @@ -5,6 +5,7 @@ #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ +#include "src/execution.h" #include "src/handles.h" #include "test/cctest/cctest.h" @@ -32,13 +33,22 @@ class FunctionTester : public InitializedHandleScope { Isolate* isolate; Handle function; - MaybeHandle Call(); - MaybeHandle Call(Handle a); - MaybeHandle Call(Handle a, Handle b); - MaybeHandle Call(Handle a, Handle b, - Handle c); - MaybeHandle Call(Handle a, Handle b, Handle c, - Handle d); + MaybeHandle Call() { + return Execution::Call(isolate, function, undefined(), 0, nullptr); + } + + template + MaybeHandle Call(Arg1 arg1, Args... args) { + const int nof_args = sizeof...(Args) + 1; + Handle call_args[] = {arg1, args...}; + return Execution::Call(isolate, function, undefined(), nof_args, call_args); + } + + template + Handle CallChecked(Args... args) { + Handle result = Call(args...).ToHandleChecked(); + return Handle::cast(result); + } void CheckThrows(Handle a); void CheckThrows(Handle a, Handle b); diff --git a/test/cctest/compiler/test-code-assembler.cc b/test/cctest/compiler/test-code-assembler.cc index 4ca4456f8d..b3067a71ab 100644 --- a/test/cctest/compiler/test-code-assembler.cc +++ b/test/cctest/compiler/test-code-assembler.cc @@ -15,6 +15,9 @@ namespace compiler { namespace { +typedef CodeAssemblerLabel Label; +typedef CodeAssemblerVariable Variable; + Node* SmiTag(CodeAssembler& m, Node* value) { int32_t constant_value; if (m.ToInt32Constant(value, constant_value) && @@ -47,24 +50,21 @@ Node* LoadMap(CodeAssembler& m, Node* object) { TEST(SimpleSmiReturn) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); m.Return(SmiTag(m, m.Int32Constant(37))); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(37, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(37, ft.CallChecked()->value()); } TEST(SimpleIntPtrReturn) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); int test; m.Return(m.BitcastWordToTagged( m.IntPtrConstant(reinterpret_cast(&test)))); - Handle code = data.GenerateCode(); - FunctionTester ft(code); + FunctionTester ft(asm_tester.GenerateCode()); MaybeHandle result = ft.Call(); CHECK_EQ(reinterpret_cast(&test), reinterpret_cast(*result.ToHandleChecked())); @@ -72,67 +72,57 @@ TEST(SimpleIntPtrReturn) { TEST(SimpleDoubleReturn) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); m.Return(m.NumberConstant(0.5)); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(0.5, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(0.5, ft.CallChecked()->value()); } TEST(SimpleCallRuntime1Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* b = SmiTag(m, m.Int32Constant(0)); m.Return(m.CallRuntime(Runtime::kNumberToSmi, context, b)); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(0, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(0, ft.CallChecked()->value()); } TEST(SimpleTailCallRuntime1Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* b = SmiTag(m, m.Int32Constant(0)); m.TailCallRuntime(Runtime::kNumberToSmi, context, b); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(0, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(0, ft.CallChecked()->value()); } TEST(SimpleCallRuntime2Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* a = SmiTag(m, m.Int32Constant(2)); Node* b = SmiTag(m, m.Int32Constant(4)); m.Return(m.CallRuntime(Runtime::kAdd, context, a, b)); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(6, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(6, ft.CallChecked()->value()); } TEST(SimpleTailCallRuntime2Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* a = SmiTag(m, m.Int32Constant(2)); Node* b = SmiTag(m, m.Int32Constant(4)); m.TailCallRuntime(Runtime::kAdd, context, a, b); - Handle code = data.GenerateCode(); - FunctionTester ft(code); - MaybeHandle result = ft.Call(); - CHECK_EQ(6, Handle::cast(result.ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode()); + CHECK_EQ(6, ft.CallChecked()->value()); } namespace { @@ -154,8 +144,8 @@ Handle CreateSumAllArgumentsFunction(FunctionTester& ft) { TEST(SimpleCallJSFunction0Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeAssembler m(asm_tester.state()); { Node* function = m.Parameter(0); Node* context = m.Parameter(kNumParams + 2); @@ -166,8 +156,7 @@ TEST(SimpleCallJSFunction0Arg) { Node* result = m.CallJS(callable, context, function, receiver); m.Return(result); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle sum = CreateSumAllArgumentsFunction(ft); MaybeHandle result = ft.Call(sum); @@ -177,8 +166,8 @@ TEST(SimpleCallJSFunction0Arg) { TEST(SimpleCallJSFunction1Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeAssembler m(asm_tester.state()); { Node* function = m.Parameter(0); Node* context = m.Parameter(1); @@ -190,8 +179,7 @@ TEST(SimpleCallJSFunction1Arg) { Node* result = m.CallJS(callable, context, function, receiver, a); m.Return(result); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle sum = CreateSumAllArgumentsFunction(ft); MaybeHandle result = ft.Call(sum); @@ -201,8 +189,8 @@ TEST(SimpleCallJSFunction1Arg) { TEST(SimpleCallJSFunction2Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeAssembler m(asm_tester.state()); { Node* function = m.Parameter(0); Node* context = m.Parameter(1); @@ -215,8 +203,7 @@ TEST(SimpleCallJSFunction2Arg) { Node* result = m.CallJS(callable, context, function, receiver, a, b); m.Return(result); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle sum = CreateSumAllArgumentsFunction(ft); MaybeHandle result = ft.Call(sum); @@ -225,10 +212,10 @@ TEST(SimpleCallJSFunction2Arg) { TEST(VariableMerge1) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerVariable var1(&m, MachineRepresentation::kTagged); - CodeAssemblerLabel l1(&m), l2(&m), merge(&m); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Variable var1(&m, MachineRepresentation::kTagged); + Label l1(&m), l2(&m), merge(&m); Node* temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); @@ -244,10 +231,10 @@ TEST(VariableMerge1) { TEST(VariableMerge2) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerVariable var1(&m, MachineRepresentation::kTagged); - CodeAssemblerLabel l1(&m), l2(&m), merge(&m); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Variable var1(&m, MachineRepresentation::kTagged); + Label l1(&m), l2(&m), merge(&m); Node* temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); @@ -265,11 +252,11 @@ TEST(VariableMerge2) { TEST(VariableMerge3) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerVariable var1(&m, MachineRepresentation::kTagged); - CodeAssemblerVariable var2(&m, MachineRepresentation::kTagged); - CodeAssemblerLabel l1(&m), l2(&m), merge(&m); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Variable var1(&m, MachineRepresentation::kTagged); + Variable var2(&m, MachineRepresentation::kTagged); + Label l1(&m), l2(&m), merge(&m); Node* temp = m.Int32Constant(0); var1.Bind(temp); var2.Bind(temp); @@ -290,10 +277,10 @@ TEST(VariableMerge3) { TEST(VariableMergeBindFirst) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerVariable var1(&m, MachineRepresentation::kTagged); - CodeAssemblerLabel l1(&m), l2(&m), merge(&m, &var1), end(&m); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Variable var1(&m, MachineRepresentation::kTagged); + Label l1(&m), l2(&m), merge(&m, &var1), end(&m); Node* temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); @@ -316,11 +303,11 @@ TEST(VariableMergeBindFirst) { TEST(VariableMergeSwitch) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerVariable var1(&m, MachineRepresentation::kTagged); - CodeAssemblerLabel l1(&m), l2(&m), default_label(&m); - CodeAssemblerLabel* labels[] = {&l1, &l2}; + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Variable var1(&m, MachineRepresentation::kTagged); + Label l1(&m), l2(&m), default_label(&m); + Label* labels[] = {&l1, &l2}; int32_t values[] = {1, 2}; Node* temp = m.Int32Constant(0); var1.Bind(temp); @@ -338,22 +325,22 @@ TEST(VariableMergeSwitch) { TEST(SplitEdgeBranchMerge) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerLabel l1(&m), merge(&m); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Label l1(&m), merge(&m); m.Branch(m.Int32Constant(1), &l1, &merge); m.Bind(&l1); m.Goto(&merge); m.Bind(&merge); - USE(data.GenerateCode()); + USE(asm_tester.GenerateCode()); } TEST(SplitEdgeSwitchMerge) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); - CodeAssemblerLabel l1(&m), l2(&m), l3(&m), default_label(&m); - CodeAssemblerLabel* labels[] = {&l1, &l2}; + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); + Label l1(&m), l2(&m), l3(&m), default_label(&m); + Label* labels[] = {&l1, &l2}; int32_t values[] = {1, 2}; m.Branch(m.Int32Constant(1), &l3, &l1); m.Bind(&l3); @@ -363,13 +350,13 @@ TEST(SplitEdgeSwitchMerge) { m.Bind(&l2); m.Goto(&default_label); m.Bind(&default_label); - USE(data.GenerateCode()); + USE(asm_tester.GenerateCode()); } TEST(TestToConstant) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); int32_t value32; int64_t value64; Node* a = m.Int32Constant(5); @@ -394,11 +381,9 @@ TEST(TestToConstant) { } TEST(DeferredCodePhiHints) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Label block1(&m, Label::kDeferred); m.Goto(&block1); m.Bind(&block1); @@ -414,15 +399,13 @@ TEST(DeferredCodePhiHints) { m.Goto(&loop); } } - CHECK(!data.GenerateCode().is_null()); + CHECK(!asm_tester.GenerateCode().is_null()); } TEST(TestOutOfScopeVariable) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeAssembler m(asm_tester.state()); Label block1(&m); Label block2(&m); Label block3(&m); @@ -443,17 +426,15 @@ TEST(TestOutOfScopeVariable) { m.Goto(&block1); } m.Bind(&block1); - CHECK(!data.GenerateCode().is_null()); + CHECK(!asm_tester.GenerateCode().is_null()); } TEST(GotoIfException) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* to_string_tag = @@ -469,10 +450,7 @@ TEST(GotoIfException) { m.Bind(&exception_handler); m.Return(exception.value()); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call().ToHandleChecked(); // Should be a TypeError. @@ -486,13 +464,11 @@ TEST(GotoIfException) { } TEST(GotoIfExceptionMultiple) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; // receiver, first, second, third - CodeAssemblerTester data(isolate, kNumParams); - CodeAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeAssembler m(asm_tester.state()); Node* context = m.HeapConstant(Handle(isolate->native_context())); Node* first_value = m.Parameter(0); @@ -534,10 +510,7 @@ TEST(GotoIfExceptionMultiple) { m.Bind(&exception_handler3); m.Return(error.value()); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result; // First handler does not throw, returns result of first value. diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc index 9f0edd9ce6..e83dd27435 100644 --- a/test/cctest/test-code-stub-assembler.cc +++ b/test/cctest/test-code-stub-assembler.cc @@ -18,16 +18,13 @@ namespace v8 { namespace internal { - -using compiler::CodeAssemblerTester; -using compiler::FunctionTester; -using compiler::Node; -using compiler::CodeAssemblerLabel; -using compiler::CodeAssemblerVariable; -using compiler::CodeAssemblerVariableList; +namespace compiler { namespace { +typedef CodeAssemblerLabel Label; +typedef CodeAssemblerVariable Variable; + int sum9(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; @@ -39,8 +36,8 @@ TEST(CallCFunction9) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 0; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); { Node* const fun_constant = m.ExternalConstant( @@ -58,8 +55,7 @@ TEST(CallCFunction9) { m.Return(m.SmiTag(result)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call().ToHandleChecked(); CHECK_EQ(36, Handle::cast(result)->value()); @@ -94,16 +90,15 @@ TEST(ToUint32) { Factory* factory = isolate->factory(); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); const int kContextOffset = 2; Node* const context = m.Parameter(kNumParams + kContextOffset); Node* const input = m.Parameter(0); m.Return(m.ToUint32(context, input)); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); // clang-format off double inputs[] = { @@ -170,40 +165,37 @@ TEST(ToUint32) { TEST(FixedArrayAccessSmiIndex) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeStubAssembler m(asm_tester.state()); Handle array = isolate->factory()->NewFixedArray(5); array->set(4, Smi::FromInt(733)); m.Return(m.LoadFixedArrayElement(m.HeapConstant(array), m.SmiTag(m.Int32Constant(4)), 0, CodeStubAssembler::SMI_PARAMETERS)); - Handle code = data.GenerateCode(); - FunctionTester ft(code); + FunctionTester ft(asm_tester.GenerateCode()); MaybeHandle result = ft.Call(); CHECK_EQ(733, Handle::cast(result.ToHandleChecked())->value()); } TEST(LoadHeapNumberValue) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeStubAssembler m(asm_tester.state()); Handle number = isolate->factory()->NewHeapNumber(1234); m.Return(m.SmiFromWord32( m.ChangeFloat64ToUint32(m.LoadHeapNumberValue(m.HeapConstant(number))))); - Handle code = data.GenerateCode(); - FunctionTester ft(code); + FunctionTester ft(asm_tester.GenerateCode()); MaybeHandle result = ft.Call(); CHECK_EQ(1234, Handle::cast(result.ToHandleChecked())->value()); } TEST(LoadInstanceType) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeStubAssembler m(asm_tester.state()); Handle undefined = isolate->factory()->undefined_value(); m.Return(m.SmiFromWord32(m.LoadInstanceType(m.HeapConstant(undefined)))); - Handle code = data.GenerateCode(); - FunctionTester ft(code); + FunctionTester ft(asm_tester.GenerateCode()); MaybeHandle result = ft.Call(); CHECK_EQ(InstanceType::ODDBALL_TYPE, Handle::cast(result.ToHandleChecked())->value()); @@ -211,14 +203,13 @@ TEST(LoadInstanceType) { TEST(DecodeWordFromWord32) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate); + CodeStubAssembler m(asm_tester.state()); class TestBitField : public BitField {}; m.Return( m.SmiTag(m.DecodeWordFromWord32(m.Int32Constant(0x2f)))); - Handle code = data.GenerateCode(); - FunctionTester ft(code); + FunctionTester ft(asm_tester.GenerateCode()); MaybeHandle result = ft.Call(); // value = 00101111 // mask = 00111000 @@ -229,13 +220,12 @@ TEST(DecodeWordFromWord32) { TEST(JSFunction) { const int kNumParams = 3; // Receiver, left, right. Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.Return(m.SmiFromWord32(m.Int32Add(m.SmiToWord32(m.Parameter(1)), m.SmiToWord32(m.Parameter(2))))); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); MaybeHandle result = ft.Call(isolate->factory()->undefined_value(), handle(Smi::FromInt(23), isolate), @@ -246,13 +236,12 @@ TEST(JSFunction) { TEST(ComputeIntegerHash) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.Return(m.SmiFromWord32(m.ComputeIntegerHash( m.SmiUntag(m.Parameter(0)), m.SmiToWord32(m.Parameter(1))))); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle hash_seed = isolate->factory()->hash_seed(); @@ -273,12 +262,11 @@ TEST(ComputeIntegerHash) { TEST(ToString) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.Return(m.ToString(m.Parameter(kNumParams + 2), m.Parameter(0))); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle test_cases = isolate->factory()->NewFixedArray(5); Handle smi_test = isolate->factory()->NewFixedArray(2); @@ -328,13 +316,11 @@ TEST(ToString) { } TEST(TryToName) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 3; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); enum Result { kKeyIsIndex, kKeyIsUnique, kBailout }; { @@ -377,8 +363,7 @@ TEST(TryToName) { m.Return(m.BooleanConstant(false)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle expect_index(Smi::FromInt(kKeyIsIndex), isolate); Handle expect_unique(Smi::FromInt(kKeyIsUnique), isolate); @@ -485,16 +470,15 @@ void TestEntryToIndex() { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); { Node* entry = m.SmiUntag(m.Parameter(0)); Node* result = m.EntryToIndex(entry); m.Return(m.SmiTag(result)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); // Test a wide range of entries but staying linear in the first 100 entries. for (int entry = 0; entry < Dictionary::kMaxCapacity; @@ -514,13 +498,11 @@ namespace { template void TestNameDictionaryLookup() { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); enum Result { kFound, kNotFound }; { @@ -554,8 +536,7 @@ void TestNameDictionaryLookup() { m.Return(m.BooleanConstant(false)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle expect_found(Smi::FromInt(kFound), isolate); Handle expect_not_found(Smi::FromInt(kNotFound), isolate); @@ -621,13 +602,11 @@ namespace { template void TestNumberDictionaryLookup() { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); enum Result { kFound, kNotFound }; { @@ -661,8 +640,7 @@ void TestNumberDictionaryLookup() { m.Return(m.BooleanConstant(false)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle expect_found(Smi::FromInt(kFound), isolate); Handle expect_not_found(Smi::FromInt(kNotFound), isolate); @@ -760,12 +738,11 @@ void AddProperties(Handle object, Handle names[], } // namespace TEST(TryHasOwnProperty) { - typedef CodeAssemblerLabel Label; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); enum Result { kFound, kNotFound, kBailout }; { @@ -803,8 +780,7 @@ TEST(TryHasOwnProperty) { m.Return(m.BooleanConstant(false)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle expect_found(Smi::FromInt(kFound), isolate); Handle expect_not_found(Smi::FromInt(kNotFound), isolate); @@ -945,14 +921,12 @@ TEST(TryHasOwnProperty) { } TEST(TryGetOwnProperty) { - typedef CodeAssemblerLabel Label; - typedef CodeAssemblerVariable Variable; Isolate* isolate(CcTest::InitIsolateOnce()); Factory* factory = isolate->factory(); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); Handle not_found_symbol = factory->NewSymbol(); Handle bailout_symbol = factory->NewSymbol(); @@ -981,8 +955,7 @@ TEST(TryGetOwnProperty) { m.Return(m.HeapConstant(bailout_symbol)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle deleted_property_name = factory->InternalizeUtf8String("deleted"); @@ -1164,12 +1137,11 @@ void AddElement(Handle object, uint32_t index, Handle value, } // namespace TEST(TryLookupElement) { - typedef CodeAssemblerLabel Label; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 3; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); enum Result { kFound, kAbsent, kNotFound, kBailout }; { @@ -1211,8 +1183,7 @@ TEST(TryLookupElement) { m.Return(m.BooleanConstant(false)); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Factory* factory = isolate->factory(); Handle smi0(Smi::kZero, isolate); @@ -1395,8 +1366,8 @@ TEST(AllocateJSObjectFromMap) { Factory* factory = isolate->factory(); const int kNumParams = 3; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); { Node* map = m.Parameter(0); @@ -1408,8 +1379,7 @@ TEST(AllocateJSObjectFromMap) { m.Return(result); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle maps[] = { handle(isolate->object_function()->initial_map(), isolate), @@ -1460,8 +1430,8 @@ TEST(AllocateNameDictionary) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); { Node* capacity = m.Parameter(0); @@ -1469,8 +1439,7 @@ TEST(AllocateNameDictionary) { m.Return(result); } - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); { for (int i = 0; i < 256; i = i * 1.1 + 1) { @@ -1490,8 +1459,8 @@ TEST(PopAndReturnConstant) { const int kNumParams = 4; const int kNumProgrammaticParams = 2; - CodeAssemblerTester data(isolate, kNumParams - kNumProgrammaticParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams - kNumProgrammaticParams); + CodeStubAssembler m(asm_tester.state()); // Call a function that return |kNumProgramaticParams| parameters in addition // to those specified by the static descriptor. |kNumProgramaticParams| is @@ -1499,10 +1468,7 @@ TEST(PopAndReturnConstant) { m.PopAndReturn(m.Int32Constant(kNumProgrammaticParams), m.SmiConstant(Smi::FromInt(1234))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result; for (int test_count = 0; test_count < 100; ++test_count) { result = ft.Call(isolate->factory()->undefined_value(), @@ -1519,8 +1485,8 @@ TEST(PopAndReturnVariable) { const int kNumParams = 4; const int kNumProgrammaticParams = 2; - CodeAssemblerTester data(isolate, kNumParams - kNumProgrammaticParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams - kNumProgrammaticParams); + CodeStubAssembler m(asm_tester.state()); // Call a function that return |kNumProgramaticParams| parameters in addition // to those specified by the static descriptor. |kNumProgramaticParams| is @@ -1528,10 +1494,7 @@ TEST(PopAndReturnVariable) { // a constant. m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result; for (int test_count = 0; test_count < 100; ++test_count) { result = ft.Call(isolate->factory()->undefined_value(), @@ -1547,8 +1510,8 @@ TEST(OneToTwoByteStringCopy) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.CopyStringCharacters( m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)), @@ -1557,15 +1520,12 @@ TEST(OneToTwoByteStringCopy) { CodeStubAssembler::SMI_PARAMETERS); m.Return(m.SmiConstant(Smi::FromInt(0))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - Handle string1 = isolate->factory()->InternalizeUtf8String("abcde"); uc16 array[] = {1000, 1001, 1002, 1003, 1004}; Vector str(array); Handle string2 = isolate->factory()->NewStringFromTwoByte(str).ToHandleChecked(); - FunctionTester ft(code, 2); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); CHECK_EQ(Handle::cast(string1)->GetChars()[0], Handle::cast(string2)->GetChars()[0]); @@ -1583,8 +1543,8 @@ TEST(OneToOneByteStringCopy) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.CopyStringCharacters( m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)), @@ -1593,15 +1553,12 @@ TEST(OneToOneByteStringCopy) { CodeStubAssembler::SMI_PARAMETERS); m.Return(m.SmiConstant(Smi::FromInt(0))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - Handle string1 = isolate->factory()->InternalizeUtf8String("abcde"); uint8_t array[] = {100, 101, 102, 103, 104}; Vector str(array); Handle string2 = isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); - FunctionTester ft(code, 2); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); CHECK_EQ(Handle::cast(string1)->GetChars()[0], Handle::cast(string2)->GetChars()[0]); @@ -1619,8 +1576,8 @@ TEST(OneToOneByteStringCopyNonZeroStart) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.CopyStringCharacters( m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)), @@ -1629,15 +1586,12 @@ TEST(OneToOneByteStringCopyNonZeroStart) { CodeStubAssembler::SMI_PARAMETERS); m.Return(m.SmiConstant(Smi::FromInt(0))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - Handle string1 = isolate->factory()->InternalizeUtf8String("abcde"); uint8_t array[] = {100, 101, 102, 103, 104}; Vector str(array); Handle string2 = isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); - FunctionTester ft(code, 2); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); CHECK_EQ(Handle::cast(string1)->GetChars()[0], Handle::cast(string2)->GetChars()[3]); @@ -1652,8 +1606,8 @@ TEST(TwoToTwoByteStringCopy) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.CopyStringCharacters( m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)), @@ -1662,9 +1616,6 @@ TEST(TwoToTwoByteStringCopy) { CodeStubAssembler::SMI_PARAMETERS); m.Return(m.SmiConstant(Smi::FromInt(0))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - uc16 array1[] = {2000, 2001, 2002, 2003, 2004}; Vector str1(array1); Handle string1 = @@ -1673,7 +1624,7 @@ TEST(TwoToTwoByteStringCopy) { Vector str2(array2); Handle string2 = isolate->factory()->NewStringFromTwoByte(str2).ToHandleChecked(); - FunctionTester ft(code, 2); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); CHECK_EQ(Handle::cast(string1)->GetChars()[0], Handle::cast(string2)->GetChars()[0]); @@ -1691,8 +1642,8 @@ TEST(Arguments) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); CodeStubArguments arguments(&m, m.IntPtrConstant(3)); @@ -1705,10 +1656,7 @@ TEST(Arguments) { m.Return(arguments.GetReceiver()); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value(), Handle(Smi::FromInt(12), isolate), Handle(Smi::FromInt(13), isolate), @@ -1721,12 +1669,12 @@ TEST(ArgumentsForEach) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 4; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); CodeStubArguments arguments(&m, m.IntPtrConstant(3)); - CodeAssemblerVariable sum(&m, MachineRepresentation::kTagged); + Variable sum(&m, MachineRepresentation::kTagged); CodeAssemblerVariableList list({&sum}, m.zone()); sum.Bind(m.SmiConstant(0)); @@ -1736,10 +1684,7 @@ TEST(ArgumentsForEach) { m.Return(sum.value()); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value(), Handle(Smi::FromInt(12), isolate), Handle(Smi::FromInt(13), isolate), @@ -1752,10 +1697,10 @@ TEST(IsDebugActive) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); - CodeAssemblerLabel if_active(&m), if_not_active(&m); + Label if_active(&m), if_not_active(&m); m.Branch(m.IsDebugActive(), &if_active, &if_not_active); m.BIND(&if_active); @@ -1763,10 +1708,7 @@ TEST(IsDebugActive) { m.BIND(&if_not_active); m.Return(m.FalseConstant()); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); CHECK(!isolate->debug()->is_active()); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); @@ -1791,11 +1733,9 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { ElementsKind kind) : CodeStubAssembler(state), kind_(kind) {} - void TestAppendJSArrayImpl(Isolate* isolate, CodeAssemblerTester* tester, + void TestAppendJSArrayImpl(Isolate* isolate, CodeAssemblerTester* csa_tester, Object* o1, Object* o2, Object* o3, Object* o4, int initial_size, int result_size) { - typedef CodeAssemblerVariable Variable; - typedef CodeAssemblerLabel Label; Handle array = isolate->factory()->NewJSArray( kind_, 2, initial_size, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); JSObject::SetElement(isolate, array, 0, @@ -1815,10 +1755,7 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { BIND(&bailout); Return(SmiTag(IntPtrAdd(arg_index.value(), IntPtrConstant(2)))); - Handle code = tester->GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(csa_tester->GenerateCode(), kNumParams); Handle result = ft.Call(Handle(o1, isolate), Handle(o2, isolate), @@ -1841,9 +1778,9 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { static void TestAppendJSArray(Isolate* isolate, ElementsKind kind, Object* o1, Object* o2, Object* o3, Object* o4, int initial_size, int result_size) { - CodeAssemblerTester data(isolate, kNumParams); - AppendJSArrayCodeStubAssembler m(data.state(), kind); - m.TestAppendJSArrayImpl(isolate, &data, o1, o2, o3, o4, initial_size, + CodeAssemblerTester asm_tester(isolate, kNumParams); + AppendJSArrayCodeStubAssembler m(asm_tester.state(), kind); + m.TestAppendJSArrayImpl(isolate, &asm_tester, o1, o2, o3, o4, initial_size, result_size); } @@ -1933,15 +1870,12 @@ TEST(IsPromiseHookEnabled) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabledOrDebugIsActive())); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK_EQ(isolate->heap()->false_value(), *result); @@ -1959,17 +1893,14 @@ TEST(AllocateAndInitJSPromise) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const promise = m.AllocateAndInitJSPromise(context); m.Return(promise); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result->IsJSPromise()); @@ -1979,18 +1910,15 @@ TEST(AllocateAndSetJSPromise) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const promise = m.AllocateAndSetJSPromise( context, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1)); m.Return(promise); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result->IsJSPromise()); @@ -2004,9 +1932,9 @@ TEST(AllocatePromiseReactionJobInfo) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); - PromiseBuiltinsAssembler p(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); + PromiseBuiltinsAssembler p(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const tasks = @@ -2020,10 +1948,7 @@ TEST(AllocatePromiseReactionJobInfo) { m.UndefinedConstant(), context); m.Return(info); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result->IsPromiseReactionJobInfo()); @@ -2041,8 +1966,8 @@ TEST(AllocatePromiseResolveThenableJobInfo) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler p(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler p(asm_tester.state()); Node* const context = p.Parameter(kNumParams + 2); Node* const native_context = p.LoadNativeContext(context); @@ -2058,10 +1983,7 @@ TEST(AllocatePromiseResolveThenableJobInfo) { thenable, then, resolve, reject, context); p.Return(info); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result->IsPromiseResolveThenableJobInfo()); @@ -2078,16 +2000,13 @@ TEST(IsSymbol) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); Node* const symbol = m.Parameter(0); m.Return(m.SelectBooleanConstant(m.IsSymbol(symbol))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->NewSymbol()).ToHandleChecked(); CHECK_EQ(isolate->heap()->true_value(), *result); @@ -2100,16 +2019,13 @@ TEST(IsPrivateSymbol) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); Node* const symbol = m.Parameter(0); m.Return(m.SelectBooleanConstant(m.IsPrivateSymbol(symbol))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->NewSymbol()).ToHandleChecked(); CHECK_EQ(isolate->heap()->false_value(), *result); @@ -2125,18 +2041,15 @@ TEST(PromiseHasHandler) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const promise = m.AllocateAndInitJSPromise(context, m.UndefinedConstant()); m.Return(m.SelectBooleanConstant(m.PromiseHasHandler(promise))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK_EQ(isolate->heap()->false_value(), *result); @@ -2146,8 +2059,8 @@ TEST(CreatePromiseResolvingFunctionsContext) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); @@ -2157,10 +2070,7 @@ TEST(CreatePromiseResolvingFunctionsContext) { promise, m.BooleanConstant(false), native_context); m.Return(promise_context); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result->IsContext()); @@ -2179,8 +2089,8 @@ TEST(CreatePromiseResolvingFunctions) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); @@ -2195,10 +2105,7 @@ TEST(CreatePromiseResolvingFunctions) { m.StoreFixedArrayElement(arr, 1, reject); m.Return(arr); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result_obj = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result_obj->IsFixedArray()); @@ -2209,31 +2116,29 @@ TEST(CreatePromiseResolvingFunctions) { TEST(NewElementsCapacity) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate, 1); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, 1); + CodeStubAssembler m(asm_tester.state()); m.Return(m.SmiTag(m.CalculateNewElementsCapacity( m.SmiUntag(m.Parameter(0)), CodeStubAssembler::INTPTR_PARAMETERS))); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, 1); + + FunctionTester ft(asm_tester.GenerateCode(), 1); Handle test_value = Handle(Smi::FromInt(0), isolate); - Handle result_obj = - Handle::cast(ft.Call(test_value).ToHandleChecked()); + Handle result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(1), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(2), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(1025), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); @@ -2241,31 +2146,29 @@ TEST(NewElementsCapacity) { TEST(NewElementsCapacitySmi) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate, 1); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, 1); + CodeStubAssembler m(asm_tester.state()); m.Return(m.CalculateNewElementsCapacity(m.Parameter(0), CodeStubAssembler::SMI_PARAMETERS)); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, 1); + + FunctionTester ft(asm_tester.GenerateCode(), 1); Handle test_value = Handle(Smi::FromInt(0), isolate); - Handle result_obj = - Handle::cast(ft.Call(test_value).ToHandleChecked()); + Handle result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(1), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(2), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); test_value = Handle(Smi::FromInt(1025), isolate); - result_obj = Handle::cast(ft.Call(test_value).ToHandleChecked()); + result_obj = ft.CallChecked(test_value); CHECK_EQ( result_obj->value(), static_cast(JSObject::NewElementsCapacity(test_value->value()))); @@ -2275,8 +2178,8 @@ TEST(AllocateFunctionWithMapAndContext) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); @@ -2292,10 +2195,7 @@ TEST(AllocateFunctionWithMapAndContext) { m.AllocateFunctionWithMapAndContext(map, resolve_info, promise_context); m.Return(resolve); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result_obj = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result_obj->IsJSFunction()); @@ -2313,8 +2213,8 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); @@ -2331,10 +2231,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { m.CreatePromiseGetCapabilitiesExecutorContext(capability, native_context); m.Return(executor_context); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result_obj = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result_obj->IsContext()); @@ -2353,8 +2250,8 @@ TEST(NewPromiseCapability) { { // Builtin Promise const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); @@ -2365,8 +2262,7 @@ TEST(NewPromiseCapability) { m.NewPromiseCapability(context, promise_constructor); m.Return(capability); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle result_obj = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); @@ -2400,8 +2296,8 @@ TEST(NewPromiseCapability) { { // Custom Promise const int kNumParams = 2; - CodeAssemblerTester data(isolate, kNumParams); - PromiseBuiltinsAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); @@ -2409,8 +2305,7 @@ TEST(NewPromiseCapability) { Node* const capability = m.NewPromiseCapability(context, constructor); m.Return(capability); - Handle code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle constructor_fn = Handle::cast(v8::Utils::OpenHandle(*CompileRun( @@ -2463,11 +2358,10 @@ TEST(NewPromiseCapability) { TEST(DirectMemoryTest8BitWord32Immediate) { Isolate* isolate(CcTest::InitIsolateOnce()); - typedef CodeAssemblerLabel Label; const int kNumParams = 0; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); int8_t buffer[] = {1, 2, 4, 8, 17, 33, 65, 127}; const int element_count = 8; Label bad(&m); @@ -2491,19 +2385,15 @@ TEST(DirectMemoryTest8BitWord32Immediate) { m.BIND(&bad); m.Return(m.SmiConstant(0)); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, kNumParams); - CHECK_EQ(1, Handle::cast(ft.Call().ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + CHECK_EQ(1, ft.CallChecked()->value()); } TEST(DirectMemoryTest16BitWord32Immediate) { Isolate* isolate(CcTest::InitIsolateOnce()); - typedef CodeAssemblerLabel Label; - const int kNumParams = 0; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); int16_t buffer[] = {156, 2234, 4544, 8444, 1723, 3888, 658, 1278}; const int element_count = 8; Label bad(&m); @@ -2528,19 +2418,15 @@ TEST(DirectMemoryTest16BitWord32Immediate) { m.BIND(&bad); m.Return(m.SmiConstant(0)); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, kNumParams); - CHECK_EQ(1, Handle::cast(ft.Call().ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + CHECK_EQ(1, ft.CallChecked()->value()); } TEST(DirectMemoryTest8BitWord32) { Isolate* isolate(CcTest::InitIsolateOnce()); - typedef CodeAssemblerLabel Label; - const int kNumParams = 0; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); int8_t buffer[] = {1, 2, 4, 8, 17, 33, 65, 127, 67, 38}; const int element_count = 10; Label bad(&m); @@ -2577,19 +2463,15 @@ TEST(DirectMemoryTest8BitWord32) { m.BIND(&bad); m.Return(m.SmiConstant(0)); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, kNumParams); - CHECK_EQ(1, Handle::cast(ft.Call().ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + CHECK_EQ(1, ft.CallChecked()->value()); } TEST(DirectMemoryTest16BitWord32) { Isolate* isolate(CcTest::InitIsolateOnce()); - typedef CodeAssemblerLabel Label; - const int kNumParams = 0; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); int16_t buffer[] = {1, 2, 4, 8, 12345, 33, 65, 255, 67, 3823}; const int element_count = 10; Label bad(&m); @@ -2640,11 +2522,10 @@ TEST(DirectMemoryTest16BitWord32) { m.BIND(&bad); m.Return(m.SmiConstant(0)); - Handle code = data.GenerateCode(); - CHECK(!code.is_null()); - FunctionTester ft(code, kNumParams); - CHECK_EQ(1, Handle::cast(ft.Call().ToHandleChecked())->value()); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + CHECK_EQ(1, ft.CallChecked()->value()); } +} // namespace compiler } // namespace internal } // namespace v8