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

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

Issue 2347143002: [interpreter] Add fast path for dynamic global lookups (Closed)
Patch Set: Fix bytecode operand documentation Created 4 years, 3 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 99b99734ae280bc770f3ae0922fd6cbc8eb07ffc..09b6ac24c4caaba906108523445ff445f0fa850a 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -3906,6 +3906,47 @@ TEST(InterpreterLookupContextSlot) {
}
}
+TEST(InterpreterLookupGlobalSlot) {
+ HandleAndZoneScope handles;
+ Isolate* isolate = handles.main_isolate();
+
+ const char* inner_function_prologue = "function inner() {";
+ const char* inner_function_epilogue = "};";
+ const char* outer_function_epilogue = "return inner();";
+
+ std::tuple<const char*, const char*, Handle<Object>> lookup_slot[] = {
+ // Eval in inner context.
+ std::make_tuple("x = 0;", "eval(''); return x;",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("x = 0;", "eval('var x = 1'); return x;",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("x = 0;", "'use strict'; eval('var x = 1'); return x;",
+ handle(Smi::FromInt(0), isolate)),
+ // Eval in outer context.
+ std::make_tuple("x = 0; eval('');", "return x;",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("x = 0; eval('var x = 1');", "return x;",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("'use strict'; x = 0; eval('var x = 1');", "return x;",
+ handle(Smi::FromInt(0), isolate)),
+ };
+
+ for (size_t i = 0; i < arraysize(lookup_slot); i++) {
+ std::string body = std::string(std::get<0>(lookup_slot[i])) +
+ std::string(inner_function_prologue) +
+ std::string(std::get<1>(lookup_slot[i])) +
+ std::string(inner_function_epilogue) +
+ std::string(outer_function_epilogue);
+ std::string script = InterpreterTester::SourceForBody(body.c_str());
+
+ InterpreterTester tester(isolate, script.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*std::get<2>(lookup_slot[i])));
+ }
+}
+
TEST(InterpreterCallLookupSlot) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
« 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