Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1514)

Unified Diff: test/cctest/compiler/test-code-stub-assembler.cc

Issue 1649723002: [compiler] Extend the functionality of CodeStubAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix release build Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/raw-machine-assembler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-code-stub-assembler.cc
diff --git a/test/cctest/compiler/test-code-stub-assembler.cc b/test/cctest/compiler/test-code-stub-assembler.cc
index 6a002771baf2ef75ab3c3bf94dbe2688a5a32cea..0306561020abe41e5342f9cc209062f67bd9d208 100644
--- a/test/cctest/compiler/test-code-stub-assembler.cc
+++ b/test/cctest/compiler/test-code-stub-assembler.cc
@@ -120,6 +120,133 @@ TEST(SimpleTailCallRuntime2Arg) {
CHECK_EQ(16, Handle<Smi>::cast(result.ToHandleChecked())->value());
}
+TEST(VariableMerge1) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Variable var1(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::Label l1(&m), l2(&m), merge(&m);
+ Node* temp = m.Int32Constant(0);
+ var1.Bind(temp);
+ m.Branch(m.Int32Constant(1), &l1, &l2);
+ m.Bind(&l1);
+ CHECK_EQ(var1.value(), temp);
+ m.Goto(&merge);
+ m.Bind(&l2);
+ CHECK_EQ(var1.value(), temp);
+ m.Goto(&merge);
+ m.Bind(&merge);
+ CHECK_EQ(var1.value(), temp);
+}
+
+TEST(VariableMerge2) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Variable var1(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::Label l1(&m), l2(&m), merge(&m);
+ Node* temp = m.Int32Constant(0);
+ var1.Bind(temp);
+ m.Branch(m.Int32Constant(1), &l1, &l2);
+ m.Bind(&l1);
+ CHECK_EQ(var1.value(), temp);
+ m.Goto(&merge);
+ m.Bind(&l2);
+ Node* temp2 = m.Int32Constant(2);
+ var1.Bind(temp2);
+ CHECK_EQ(var1.value(), temp2);
+ m.Goto(&merge);
+ m.Bind(&merge);
+ CHECK_NE(var1.value(), temp);
+}
+
+TEST(VariableMerge3) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Variable var1(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::Variable var2(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::Label l1(&m), l2(&m), merge(&m);
+ Node* temp = m.Int32Constant(0);
+ var1.Bind(temp);
+ var2.Bind(temp);
+ m.Branch(m.Int32Constant(1), &l1, &l2);
+ m.Bind(&l1);
+ CHECK_EQ(var1.value(), temp);
+ m.Goto(&merge);
+ m.Bind(&l2);
+ Node* temp2 = m.Int32Constant(2);
+ var1.Bind(temp2);
+ CHECK_EQ(var1.value(), temp2);
+ m.Goto(&merge);
+ m.Bind(&merge);
+ CHECK_NE(var1.value(), temp);
+ CHECK_NE(var1.value(), temp2);
+ CHECK_EQ(var2.value(), temp);
+}
+
+TEST(VariableMergeBindFirst) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Variable var1(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::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);
+ m.Bind(&l1);
+ CHECK_EQ(var1.value(), temp);
+ m.Goto(&merge);
+ m.Bind(&merge);
+ CHECK(var1.value() != temp);
+ CHECK(var1.value() != nullptr);
+ m.Goto(&end);
+ m.Bind(&l2);
+ Node* temp2 = m.Int32Constant(2);
+ var1.Bind(temp2);
+ CHECK_EQ(var1.value(), temp2);
+ m.Goto(&merge);
+ m.Bind(&end);
+ CHECK(var1.value() != temp);
+ CHECK(var1.value() != nullptr);
+}
+
+TEST(VariableMergeSwitch) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Variable var1(&m, MachineRepresentation::kTagged);
+ CodeStubAssembler::Label l1(&m), l2(&m), default_label(&m);
+ CodeStubAssembler::Label* labels[] = {&l1, &l2};
+ int32_t values[] = {1, 2};
+ Node* temp = m.Int32Constant(0);
+ var1.Bind(temp);
+ m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
+ m.Bind(&l1);
+ DCHECK_EQ(temp, var1.value());
+ m.Return(temp);
+ m.Bind(&l2);
+ DCHECK_EQ(temp, var1.value());
+ m.Return(temp);
+ m.Bind(&default_label);
+ DCHECK_EQ(temp, var1.value());
+ m.Return(temp);
+}
+
+TEST(FixedArrayAccessSmiIndex) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(5);
+ array->set(4, Smi::FromInt(733));
+ m.Return(m.LoadFixedArrayElementSmiIndex(m.HeapConstant(array),
+ m.SmiTag(m.Int32Constant(4))));
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(descriptor, code);
+ MaybeHandle<Object> result = ft.Call();
+ CHECK_EQ(733, Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler/raw-machine-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698