Commit a29516bc authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[cleanup] Add templatized FunctionTester::CallChecked(...) helpers

- use asm_tester instead of data variable name
- directly expose Variable and Label for convenience

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