[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: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#46738}
This commit is contained in:
parent
beb4037aed
commit
a29516bcce
@ -42,38 +42,13 @@ FunctionTester::FunctionTester(Handle<Code> 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> 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) {
|
||||
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
|
||||
MaybeHandle<Object> no_result = Call(a);
|
||||
|
@ -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<JSFunction> function;
|
||||
|
||||
MaybeHandle<Object> Call();
|
||||
MaybeHandle<Object> Call(Handle<Object> a);
|
||||
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b);
|
||||
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b,
|
||||
Handle<Object> c);
|
||||
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c,
|
||||
Handle<Object> d);
|
||||
MaybeHandle<Object> Call() {
|
||||
return Execution::Call(isolate, function, undefined(), 0, nullptr);
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
MaybeHandle<Object> Call(Arg1 arg1, Args... args) {
|
||||
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, Handle<Object> b);
|
||||
|
@ -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> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(37, Handle<Smi>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(37, ft.CallChecked<Smi>()->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<intptr_t>(&test))));
|
||||
Handle<Code> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(reinterpret_cast<intptr_t>(&test),
|
||||
reinterpret_cast<intptr_t>(*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> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(0.5, Handle<HeapNumber>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(0.5, ft.CallChecked<HeapNumber>()->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<Context>(isolate->native_context()));
|
||||
Node* b = SmiTag(m, m.Int32Constant(0));
|
||||
m.Return(m.CallRuntime(Runtime::kNumberToSmi, context, b));
|
||||
Handle<Code> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(0, ft.CallChecked<Smi>()->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<Context>(isolate->native_context()));
|
||||
Node* b = SmiTag(m, m.Int32Constant(0));
|
||||
m.TailCallRuntime(Runtime::kNumberToSmi, context, b);
|
||||
Handle<Code> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(0, ft.CallChecked<Smi>()->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<Context>(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> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(6, Handle<Smi>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(6, ft.CallChecked<Smi>()->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<Context>(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> code = data.GenerateCode();
|
||||
FunctionTester ft(code);
|
||||
MaybeHandle<Object> result = ft.Call();
|
||||
CHECK_EQ(6, Handle<Smi>::cast(result.ToHandleChecked())->value());
|
||||
FunctionTester ft(asm_tester.GenerateCode());
|
||||
CHECK_EQ(6, ft.CallChecked<Smi>()->value());
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -154,8 +144,8 @@ Handle<JSFunction> 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> code = data.GenerateCode();
|
||||
FunctionTester ft(code, kNumParams);
|
||||
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
||||
|
||||
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft);
|
||||
MaybeHandle<Object> 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> code = data.GenerateCode();
|
||||
FunctionTester ft(code, kNumParams);
|
||||
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
||||
|
||||
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft);
|
||||
MaybeHandle<Object> 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> code = data.GenerateCode();
|
||||
FunctionTester ft(code, kNumParams);
|
||||
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
||||
|
||||
Handle<JSFunction> sum = CreateSumAllArgumentsFunction(ft);
|
||||
MaybeHandle<Object> 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<Context>(isolate->native_context()));
|
||||
Node* to_string_tag =
|
||||
@ -469,10 +450,7 @@ TEST(GotoIfException) {
|
||||
m.Bind(&exception_handler);
|
||||
m.Return(exception.value());
|
||||
|
||||
Handle<Code> code = data.GenerateCode();
|
||||
CHECK(!code.is_null());
|
||||
|
||||
FunctionTester ft(code, kNumParams);
|
||||
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
||||
Handle<Object> 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<Context>(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> code = data.GenerateCode();
|
||||
CHECK(!code.is_null());
|
||||
|
||||
FunctionTester ft(code, kNumParams);
|
||||
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
||||
|
||||
Handle<Object> result;
|
||||
// First handler does not throw, returns result of first value.
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user