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

Unified Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1546683002: [Interpreter] Add support for jumps using constants with wide operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweak constant-array-builder-unittest.cc. 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
Index: test/cctest/compiler/test-run-bytecode-graph-builder.cc
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
index be1fefeee52e9a338489251acd607680c3e76473..31977e524ec2fa6faeb3c9c49dce4e0f3aac0126 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -4,6 +4,7 @@
#include <utility>
+#include "src/base/utils/random-number-generator.h"
#include "src/compiler/pipeline.h"
#include "src/execution.h"
#include "src/handles.h"
@@ -2106,6 +2107,45 @@ TEST(BytecodeGraphBuilderForIn) {
}
+TEST(JumpWithConstantsAndWideConstants) {
+ HandleAndZoneScope scope;
+ auto isolate = scope.main_isolate();
+ const int kStep = 19;
+ int start = isolate->random_number_generator()->NextInt(kStep);
rmcilroy 2016/01/05 13:46:10 Do you really need this random number generator? I
oth 2016/01/05 18:31:59 Done. The hope was the bots ran different seeds an
+ for (int constants = start; constants < 256 + 3 * kStep; constants += kStep) {
+ std::stringstream os;
+ // Generate a string that consumes constant pool entries and
+ // spread out branch distances in script below.
+ for (int i = 0; i < constants; i++) {
+ os << "var x_ = 'x_" << i << "';\n";
+ }
+ std::string filler(os.str());
+ os.str("");
rmcilroy 2016/01/05 13:46:10 Please use a different std::stringstream rather t
oth 2016/01/05 18:31:59 Done.
+ os << "function " << kFunctionName << "(a) {\n";
+ os << " " << filler;
+ os << " for (var i = a; i < 2; i++) {\n";
+ os << " " << filler;
+ os << " if (i == 0) { " << filler << "i = 10; continue; }\n";
+ os << " else if (i == a) { " << filler << "i = 12; break; }\n";
+ os << " else { " << filler << " }\n";
+ os << " }\n";
+ os << " return i;\n";
+ os << "}\n";
+ os << kFunctionName << "(0);\n";
+ std::string script(os.str());
+ auto factory = isolate->factory();
+ auto zone = scope.main_zone();
+ for (int a = 0; a < 3; a++) {
+ BytecodeGraphTester tester(isolate, zone, script.c_str());
+ auto callable = tester.GetCallable<Handle<Object>>();
+ Handle<Object> return_val =
+ callable(factory->NewNumberFromInt(a)).ToHandleChecked();
+ static const int results[] = {11, 12, 2};
+ CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]);
+ }
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698