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

Unified Diff: test/cctest/compiler/test-run-machops.cc

Issue 892513003: [turbofan] Initial support for Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Wuschelstudio build. Created 5 years, 10 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/disassembler.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-machops.cc
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc
index 2d205758aa9026d8e98885d5241ec4ac8e25cf07..1511a01033a69b33f4063efb8de589f33703c50d 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -447,6 +447,56 @@ TEST(RunLoopIncrementFloat64) {
}
+TEST(RunSwitch1) {
+ RawMachineAssemblerTester<int32_t> m;
+
+ int constant = 11223344;
+
+ MLabel block0, block1, end;
+ MLabel* cases[] = {&block0, &block1};
+ m.Switch(m.IntPtrConstant(0), cases, arraysize(cases));
+ m.Bind(&block0);
+ m.Goto(&end);
+ m.Bind(&block1);
+ m.Goto(&end);
+ m.Bind(&end);
+ m.Return(m.Int32Constant(constant));
+
+ CHECK_EQ(constant, m.Call());
+}
+
+
+TEST(RunSwitch2) {
+ RawMachineAssemblerTester<int32_t> m(kMachInt32);
+
+ const size_t kNumCases = 255;
+ int32_t values[kNumCases];
+ m.main_isolate()->random_number_generator()->NextBytes(values,
+ sizeof(values));
+ MLabel end;
+ MLabel* cases[kNumCases];
+ Node* results[kNumCases];
+ for (size_t i = 0; i < kNumCases; ++i) {
+ cases[i] = new (m.main_zone()->New(sizeof(MLabel))) MLabel;
+ }
+ m.Switch(m.ConvertInt32ToIntPtr(m.Parameter(0)), cases, arraysize(cases));
+ for (size_t i = 0; i < kNumCases; ++i) {
+ m.Bind(cases[i]);
+ results[i] = m.Int32Constant(values[i]);
+ m.Goto(&end);
+ }
+ m.Bind(&end);
+ const int num_results = static_cast<int>(arraysize(results));
+ Node* phi =
+ m.NewNode(m.common()->Phi(kMachInt32, num_results), num_results, results);
+ m.Return(phi);
+
+ for (size_t i = 0; i < kNumCases; ++i) {
+ CHECK_EQ(values[i], m.Call(static_cast<int>(i)));
+ }
+}
+
+
TEST(RunLoadInt32) {
RawMachineAssemblerTester<int32_t> m;
« no previous file with comments | « src/disassembler.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698