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

Unified Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1524803003: [Interpreter] Add support for Load / Store to Lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@init_eval_impl
Patch Set: Fixed nits. Created 5 years 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 9e8ee1e2d8bb0118beada53d1d2635cb9736f194..02f6c59480a2c4c89b29d8dac40210c4161c7b0b 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -3093,6 +3093,42 @@ TEST(InterpreterToName) {
}
}
+
+TEST(InterpreterLookupSlot) {
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+ i::Factory* factory = isolate->factory();
+
+ // TODO(mythria): Add more tests when we have support for eval/with.
+ const char* function_prologue = "var f;"
+ "var x = 1;"
+ "function f1() {"
+ " eval(\"function t() {";
+ const char* function_epilogue = " }; f = t;\");"
+ "}"
+ "f1();";
+
+
+ std::pair<const char*, Handle<Object>> lookup_slot[] = {
+ {"return x;", handle(Smi::FromInt(1), isolate)},
+ {"return typeof x;", factory->NewStringFromStaticChars("number")},
+ {"x = 10; return x;", handle(Smi::FromInt(10), isolate)},
+ {"'use strict'; x = 20; return x;", handle(Smi::FromInt(20), isolate)},
+ };
+
+ for (size_t i = 0; i < arraysize(lookup_slot); i++) {
+ std::string script = std::string(function_prologue) +
+ std::string(lookup_slot[i].first) +
+ std::string(function_epilogue);
+
+ InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*lookup_slot[i].second));
+ }
+}
+
} // 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