Index: test/cctest/interpreter/test-interpreter.cc |
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc |
index 9e8ee1e2d8bb0118beada53d1d2635cb9736f194..2962cc9fa74289c5d17db159dab6814976b24940 100644 |
--- a/test/cctest/interpreter/test-interpreter.cc |
+++ b/test/cctest/interpreter/test-interpreter.cc |
@@ -3093,6 +3093,40 @@ TEST(InterpreterToName) { |
} |
} |
+ |
+TEST(TemporaryRegisterAllocation) { |
+ HandleAndZoneScope handles; |
+ i::Isolate* isolate = handles.main_isolate(); |
+ i::Factory* factory = isolate->factory(); |
+ |
+ std::pair<const char*, Handle<Object>> reg_tests[] = { |
+ {"function add(a, b, c) {" |
+ " return a + b + c;" |
+ "}" |
+ "function f() {" |
+ " var a = 10, b = 10;" |
+ " return add(a, b++, b);" |
+ "}", |
+ factory->NewNumberFromInt(31)}, |
+ {"function add(a, b, c, d) {" |
+ " return a + b + c + d;" |
+ "}" |
+ "function f() {" |
+ " var x = 10, y = 20, z = 30;" |
+ " return x + add(x, (y= x++), x, z);" |
+ "}", |
+ factory->NewNumberFromInt(71)}, |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(reg_tests); i++) { |
+ InterpreterTester tester(handles.main_isolate(), reg_tests[i].first); |
+ auto callable = tester.GetCallable<>(); |
+ |
+ Handle<i::Object> return_value = callable().ToHandleChecked(); |
+ CHECK(return_value->SameValue(*reg_tests[i].second)); |
+ } |
+} |
+ |
} // namespace interpreter |
} // namespace internal |
} // namespace v8 |