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

Unified Diff: test/cctest/interpreter/test-interpreter.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: Incorporate comments on patchset 13. 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/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 5e7764348db2e65ddfae7adf29d68ff872f40033..6a4b7bdebda5cab1f45c1c680ec940bf12e87505 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -3305,6 +3305,43 @@ TEST(InterpreterDeleteLookupSlot) {
}
}
+
+TEST(JumpWithConstantsAndWideConstants) {
+ HandleAndZoneScope handles;
+ auto isolate = handles.main_isolate();
+ auto factory = isolate->factory();
+ const int kStep = 13;
+ for (int constants = 3; constants < 256 + 3 * kStep; constants += kStep) {
+ std::ostringstream 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::ostringstream script_os;
+ script_os << "function " << InterpreterTester::function_name() << "(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";
+ std::string script(script_os.str());
+ for (int a = 0; a < 3; a++) {
+ InterpreterTester tester(handles.main_isolate(), 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 interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698