| 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..2f5c4ff57b626c8ab87b7178ebe581d86c9c23cc 100644
|
| --- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
|
| +++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
|
| @@ -2106,6 +2106,46 @@ TEST(BytecodeGraphBuilderForIn) {
|
| }
|
|
|
|
|
| +TEST(JumpWithConstantsAndWideConstants) {
|
| + HandleAndZoneScope scope;
|
| + auto isolate = scope.main_isolate();
|
| + const int kStep = 19;
|
| + int start = 7;
|
| + for (int constants = start; constants < 256 + 3 * kStep; constants += kStep) {
|
| + std::stringstream filler_os;
|
| + // Generate a string that consumes constant pool entries and
|
| + // spread out branch distances in script below.
|
| + for (int i = 0; i < constants; i++) {
|
| + filler_os << "var x_ = 'x_" << i << "';\n";
|
| + }
|
| + std::string filler(filler_os.str());
|
| +
|
| + std::stringstream script_os;
|
| + script_os << "function " << kFunctionName << "(a) {\n";
|
| + script_os << " " << filler;
|
| + script_os << " for (var i = a; i < 2; i++) {\n";
|
| + script_os << " " << filler;
|
| + script_os << " if (i == 0) { " << filler << "i = 10; continue; }\n";
|
| + script_os << " else if (i == a) { " << filler << "i = 12; break; }\n";
|
| + script_os << " else { " << filler << " }\n";
|
| + script_os << " }\n";
|
| + script_os << " return i;\n";
|
| + script_os << "}\n";
|
| + script_os << kFunctionName << "(0);\n";
|
| + std::string script(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
|
|
|