| 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 cef27098be69b89b0e7d4194f638bfd3eb35b13c..322a3eb7025bac170aafc8a2d1e0756b6af385d8 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"
|
| @@ -2028,6 +2029,45 @@ TEST(BytecodeGraphBuilderForIn) {
|
| }
|
|
|
|
|
| +TEST(JumpWithConstantsAndWideConstants) {
|
| + HandleAndZoneScope scope;
|
| + auto isolate = scope.main_isolate();
|
| + const int kStep = 19;
|
| + int start = isolate->random_number_generator()->NextInt(kStep);
|
| + 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("");
|
| + 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
|
|
|